| Instruction | Operands | Description |
|---|---|---|
| MOV | dist, source | Copy the data from the source to the distnation register or memory |
| INC | dist | Increment the distnation register or memory by one |
| DEC | dist | Decrement the distnation register or memory by one |
| JNZ | dist(label) | Tests the value of Zero Flag and jump to the distnation if its not set(a.k.a. set o 0) |
| JMP | dist | Always jump to its operand |
| ADD | dist, source | Add the source value to the distnation |
| NOP | n/a | No operation, it takes some time to execute |
| NEG | dist | Take a positive value and make it nigative |
| MOVSX | dist, source | Move with sign extension |
The MOV instruction is used to move copy a byte(1-bit), word(116-bit), double word(32-bit), or quad word(64-bit} from the source to the distnation.
Copy the data from register into anouther register with the same size
mov <dist>, <source reg>
Copy the data from memory to a register
mov <dist>, [<source mem>]
Copy the data with the specified size from the source to the distnation memory
mov <size> [<dist mem>], <source>
Copy 73 hex immediate value to RAX register
mov rax, 73hCopy data from RAX register to RCX register
mov rcx, raxCopy the memory address to RSI register
mov rsi, myloveCopy the actual data from the memory address to RAX register
mov rax, [mylove]Copy one-byte from the memory to AL register
mov al, [mylove]Copy one byte to the last place in memory location
mov byte [mylove], 'd'Note
You can't use the MOV instruction to copy data directly from one address in memory to different address in memory.
To do that you need to two separate MOV instructions: the first is to move data from memory to some register, and the second is to move data from that register to the distenitaon memory.
The INC instruction is used to increment the distenation value by one.
inc <dist>
mov ebx, 15h
inc ebx ; 16h mov eax, 0ffff_ffffh
inc eax ; 0Note
Notice that in the second example the OF didn't set, and this because the the INC instruction work with unsigned numbers and OF is for signed numbers.
The DEC instruction is used to decrement the distenation value by one.
dec <dist>
mov ebx, 15h
dec ebx ; 14h mov eax, 0h
dec eax ; 0xffff_ffffhNote
Notice that in the second example the OF didn't set, and this because the the DEC instruction work with unsigned numbers and OF is for signed numbers.
The JNZ instruction is used to change the flow of machine instructions in your programs based on the ZF value.
If the ZF is set(a.k.a. equal 1) this instructions doesn't do anything and your program excuation continue as nomal. If the ZF isn't set(a.k.a. is equal to 0) this instruction will change your excuation to a new distenation in your program.
jnz <dist>
mov rax, 5
do_more:
dec rax
jnz do_moreThe JMP instruction dose not look at the flags. When executed, it always jump to its operand.
jmp <dist>
xor rax, rax
work:
inc rax
jmp workThe ADD instruction is used to add a value to the distenation.
add <dist>, <source>
add <size> [<mem dist>], <source>
mov rax, 3
add rax, 3 ; 6 mov rbx, mylove
add byte [rbx], 32The NEG instructoin take a positive value and negate that value, i.e. make it negative. It does so by generating the two's complement from of the positive value.
neg <dist>
mov rax, 8
neg rax ; -8MOVSX means "Move with Sign Extension," and it was introduced with i386 family of CPUs, and because Linux will not run on anything older than 386 you can assume that the MOVSX is always available.
Note
MOVSX is significantly different from MOV in that its operands may be of different sizes.
movsx <dist>, <source>
mov ax, -32
movsx rbx, ax