Instructions (identical to x86)
|
| Mnemonic |
Purpose |
Examples |
| mov dest,src |
Move data between registers, load immediate data into registers, move data between registers and memory. |
mov rax,4 ; Load constant
into rax mov rdx,rax ; Copy rax into rdx mov rdx,[123] ; Copy rdx to memory address 123 |
| push src |
Insert a value onto the stack. Useful for passing arguments, saving registers, etc. |
push rbp |
| pop dest |
Remove topmost value from the stack. Equivalent to "mov dest, [esp]; add 4,esp" |
pop rbp |
| call func |
Push the address of the next instruction and start executing func. |
call print_int |
| ret |
Pop the return program counter, and jump there. Ends a subroutine. |
ret |
| add dest,src |
dest=dest+src |
add rax,rdx ; Add rbx to rax |
| mul src |
Multiply eax and src as unsigned integers, and put the result in eax. High 32 bits of product go into eax. |
mul rdx ; Multiply rax by rdx |
| jmp label | Goto the instruction label:. Skips anything else in the way. | jmp post_mem mov [0],rax ; Write to NULL! post_mem: ; OK here... |
| cmp a,b |
Compare two values. Sets
flags that are used by the conditional jumps (below). WARNING:
compare is relative to *last* argument, so "jl" jumps if b<a! |
cmp rax,10 |
| jl label | Goto label if previous comparison came out as less-than. Other conditionals available are: jle (<=), jeq (==), jge (>=), jg (>), jne (!=), and many others. | jl loop_start ; Jump if eax<10 |