%r15
)Byte | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 |
---|---|---|---|---|---|---|---|---|---|---|
halt |
0:0 | |||||||||
nop |
1:0 | |||||||||
cmovXX rA, rB |
2:n | rA:rB | ||||||||
irmovq V, rB |
3:0 | F:rB | V | V | V | V | V | V | V | V |
rmmovq rA, D(rB) |
4:0 | rA:rB | D | D | D | D | D | D | D | D |
mrmovq D(rB), rA |
5:0 | rA:rB | D | D | D | D | D | D | D | D |
OPq rA, rB |
6:n | rA:rB | ||||||||
jXX L |
7:n | L | L | L | L | L | L | L | L | |
call L |
8:0 | L | L | L | L | L | L | L | L | |
ret |
9:0 | |||||||||
pushq rA |
A:0 | A:F | ||||||||
popq rA |
B:0 | A:F |
Format
cmovXX
InstructionsByte | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 |
---|---|---|---|---|---|---|---|---|---|---|
rrmovq rA, rB |
2:0 | rA:rB | ||||||||
cmovle rA, rB |
2:1 | rA:rB | ||||||||
cmovl rA, rB |
2:2 | rA:rB | ||||||||
cmove rA, rB |
2:3 | rA:rB | ||||||||
cmovne rA, rB |
2:4 | rA:rB | ||||||||
cmovge rA, rB |
2:5 | rA:rB | ||||||||
cmovg rA, rB |
2:6 | rA:rB |
OPq
InstructionsByte | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 |
---|---|---|---|---|---|---|---|---|---|---|
addq rA, rB |
6:0 | rA:rB | ||||||||
subq rA, rB |
6:1 | rA:rB | ||||||||
andq rA, rB |
6:2 | rA:rB | ||||||||
xorq rA, rB |
6:3 | rA:rB |
jXX
InstructionsByte | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 |
---|---|---|---|---|---|---|---|---|---|---|
jmp L |
7 | 0 | L | L | L | L | L | L | L | |
jle L |
7 | 1 | L | L | L | L | L | L | L | |
jl L |
7 | 2 | L | L | L | L | L | L | L | |
je L |
7 | 3 | L | L | L | L | L | L | L | |
jne L |
7 | 4 | L | L | L | L | L | L | L | |
jge L |
7 | 5 | L | L | L | L | L | L | L | |
jg L |
7 | 6 | L | L | L | L | L | L | L |
Each register has 4-bit ID
%rax |
0 | %r8 |
8 |
%rcx |
1 | %r9 |
9 |
%rdx |
2 | %r10 |
A |
%rbx |
3 | %r11 |
B |
%rsp |
4 | %r12 |
C |
%rbp |
5 | %r13 |
D |
%rsi |
6 | %r14 |
E |
%rdi |
7 | F |
addq rA, rB
60 rA rB
Set condition codes based on result
Example: addq %rax, %rsi
, encoding: 60 06
Referred to generically as “OPq”
Set condition codes as side effect
Instruction | Source | Destination |
---|---|---|
rrmovq rA, rB |
Register | Register |
irmovq V, rB |
Immediate | Register |
rmmovq rA, D(rB) |
Register | Memory |
mrmovq D(rA), rB |
Memory | Register |
movq
instructionx86-64 | Y86-64 | Encoding |
---|---|---|
movq $0xabcd, %rdx |
irmovq $0xabcd, %rdx |
30 82 cd ab 00 00 00 00 00 00 |
movq %rsp, %rbx% |
rrmovq %rsp, %rbx |
20 43 |
movq -12(%rbp), %rcx |
mrmovq -12(%rbp), %rcx |
50 15 f4 ff ff ff ff ff ff ff |
movq %rsi, 0x41c(%rsp) |
rmmovq %rsi, 0x41c(%rsp) |
40 64 1c 04 00 00 00 00 00 00 |
Referred to generically as “cmovXX”
Encodings differ only by “function code”
Based on values of condition codes
rrmovq
instruction
%rsp
pushq rA
: A 0 rA F
%rsp
by 8popq rA
: B 0 rA F
%rsp
%rsp
by 8call Dest
ret
nop
: 1 0
halt
: 0 0
Mnemonic | Code | Comment |
---|---|---|
AOK |
1 | Normal operation |
HLT |
2 | Halt instruction encountered |
ADR |
3 | Bad address (either instruction or data) encountered |
INS |
4 | Invalid instruction encountered |
AOK
keep goinginit: # Initialization
...
call Main
halt
.align 8 # Program data
array:
...
Main: # Main function
...
call len
len:
....
.pos 0x100 # Placement of stack
Stack:
Program starts at address 0
Must initialize data
init:
# Set up stack pointer
irmovq Stack, %rsp
# Execute main program
call Main
# Terminate
halt
# Array of 4 elements + terminating 0
.align 8
Array:
.quad 0x000d000d000d000d
.quad 0x00c000c000c000c0
.quad 0x0b000b000b000b00
.quad 0xa000a000a000a000
.quad 0
Complex Instruction Set Computer
Arithmetic instructions can access memory
Reduced Instruction Set Computer
Only load and store instructions can access memory