03 instruction set overview Flashcards
Refers to where the data is coming from and/or where the result is to be placed
Operands
What is the general form of the move instruction?
mov < dest>, < src>
____ operand is copied into the destination operand
Source
Conditions in using move instruction
Destination and source operand must be of the same size
Operands cannot be both memory variables
What are the basic addressing modes?
Register, Immediate, Memory
The operand is a CPU register. (kind of mode addressing)
Register Mode Addressing
ex:
move eax, ebx
(both eax and ebx are in register mode addressing)
The operand is an immediate value. (kind of mode addressing)
Immediate Mode Addressing
ex:
move eax, 130
(eax is in register mode, 130 is in immediate mode)
The operand is a location in memory (accessed via an address) referred to as indirection or dereferencing. (kind of mode addressing)
Brackets [ ] are used to access the values of memory variables.
Omitting the brackets will not access the value and instead obtain the address of the variable.
Memory Mode Addressing
ex:
mov rax, qword[var1]
(value of var1 in rax)
mov rax, var1
(address of var1 in rax)
What is the general form of integer addition instruction?
add < dest>, < src>
which performs:
< dest> = < dest> + < src>
What are the conditions in using addition instruction?
The destination and source operand must be of the same size
operands cannot be both memory variables
Convert to Assembly:
num1 db 42
num2 db 73
ans db 0
ans = num1 + num2
num1 db 42
num2 db 73
ans db 0
mov al, byte[num1]
add al, byte[num2]
mov byte[ans], al
What is the general form of increment instruction?
inc <operand></operand>
which performs:
<operand> = <operand> + 1
</operand></operand>
Convert to Assembly:
num dw 4200
num = num + 1
num dw 4200
inc word[num]
What is the general form of integer subtraction instruction?
sub <dest>, <src></src></dest>
which performs:
<dest> = <dest> - <src>
</src></dest></dest>
What are the conditions in using subtraction instruction?
The destination and source operand must be of the same size.
Operands cannot be both memory variables.
Convert to Assembly:
num1 db 73
num2 db 42
ans db 0
ans = num1 - num2
num1 db 73
num2 db 42
ans db 0
mov al, byte[num1]
sub al, byte[num2]
mov byte[ans], al
What is the general form of decrement instruction?
dec <operand></operand>
which performs:
<operand> = <operand> - 1
</operand></operand>
Convert to Assembly:
num dw 4200
num = num - 1
num dw 4200
dec word[num]
What is the general form of unsigned multiplication instruction?
mul <src></src>
where the source operand must be a register or memory location
What register must be used for one of the operands in unsigned multiplication?
A register (al/ax/eax/rax)
The result will be placed in the ___ and possibly ____ registers, based based on the sizes being multiplied.
A, D
Convert to Assembly:
num1 db 42
num2 db 73
ans dw 0
ans = num1*num2
num1 db 42
num2 db 73
ans dw 0
mov al, byte[num1]
mul byte[num2]
mov word[ans], ax
What is the general form of unsigned division instruction?
div <src></src>
where the source operand must be a register or memory location
The ___ and possibly the ___ register, must be used in combination for the dividend.
The result will be placed in the A register (al/ax/eax/rax)
A, D