Enlarge the instruction set #62
Labels
codegen
I guess the object files generated are buggy
design
Something that influences the language's design
enhancement
New feature or request
parsing
Is the syntax parsed well enough ?
type-checking
Anything about the typechecking process
Milestone
Currently, there are too few instructions included in N*.
Here's an exhaustive list:
jmp
unconditionnally jumps to the given label;call
is a restricted form ofjmp
which accounts for a "return address"ret
jumps to the address in the continuation spacesld
loads a value from the stack into a registersst
stores the value inside a register into the stack at the given indexsalloc
allocates some space on top of the stack (similarly toalloca
in C, though the size is restricted by the type instead of being a literal integer)sfree
removes the top-most stack cellsref
allows fetching a reference (pointer) to a given stack cellld
loads a value from a memory address into a registerst
writes a value inside a register at a memory addressmv
moves a register or immediate value into a registernop
is useless and does absolutely nothing more than take space in the resulting objectHowever, there are quite a lot more useful instructions to have in order to make N⋆ usable as both a programming assembly language and a compiler backend for Zilch.
Here are some examples:
add
,sub
,mul
, etc. with floating point counterparts (addf
,subf
,mulf
, etc. where thef
suffix stands for “floating”)jz
,jnz
,je
,jne
,jl
,jle
,jg
,jge
, etc. which act as simple jumps (e.g.jz %r0, then, else
jumps to thethen
label if the content of%r0
is0
, else jumps to theelse
label)and
,or
,xor
,not
, etc. Boolean logic operators may also be of great use as specific instructions, in order not to fall into traps such asnot 5 != 0
(we could havenotb 5 = 0
, orandb 1 2 = 1
, where every non-zero value is considered the truth value)Of course this list is absolutely not exhaustive (although it should be sufficient in the beginning). Many more instructions could be added (even for specific things such as SIMD), as long as they can be typed properly inside N⋆.
All the above instructions will need to have types, but this can be done while adding them to the language/compiler.
Roadmap
and
: bitwise logical ANDor
: bitwise logical ORxor
: bitwise logical XORnot
: bitwise logical NOTshiftl
: bitwise logical LEFT SHIFTshiftr
: bitwise logical RIGHT SHIFTcmvz
: conditionally move if zerocmvnz
: conditionally move if not zerocmvl
: conditionally move if less thancmvle
: conditionally move if less than or equalcmvg
: conditionally move if greater thancmvge
: conditionally move if greater than or equalcmve
: conditionally move if equalcmvne
: conditionally move if not equalcjz
: jump if zerocjnz
: jump if not zerocjl
: jump if less thancjle
: jump if less than or equalcjg
: jump if greater thancjge
: jump if greater than or equalcje
: jump if equalcjne
: jump if not equaladd
: add two integerssub
: subtract one integer from anothermul
: multiply two integers togetherdiv
: divide one integer by anotherThe text was updated successfully, but these errors were encountered: