$\require{cancel}$
| 64 Bit | Lowest 32 Bit | Lowest 16 bit | Lowest 8 Bit |
|---|---|---|---|
| rax | eax | ax | al |
| rbx | ebx | bx | bl |
| rcx | ecx | cx | cl |
| rdx | edx | dx | dl |
| rsi | esi | si | sil |
| rdi | edi | di | dil |
| rbp | ebp | bp | bpl |
| rsp | esp | sp | spl |
| r8 | r8d | r8w | r8b |
| r9 | r9d | r9w | r9b |
| r10 | r10d | r10w | r10b |
| r11 | r11d | r11w | r11b |
| r12 | r12d | r12w | r12b |
| r13 | r13d | r13w | r13b |
| r14 | r14d | r14w | r14b |
| r15 | r15d | r15w | r15b |
(From the book)
*h (ie ah) which is the second lowest 8-bits in the register.
ah.
global _start
section .text
_start:
; store a big number in the entire register
mov rax, 01111111111111111h
; store a smaller number in the lower 1/2
mov eax, 022222222h
; store a smaller number in the lower 1/4
mov ax, 03333h
; store a small number in the lower 1/8
mov al, 044h
mov al, -1
mov rax, -1
; exit the program properly
mov rax, 60 ; system call for exit
xor rdi, rdi ; exit code 0
syscall ; invoke operating system to exit
label: instruction operands ;comment
int main() {
rax = 0x1111111111111111;
eax =0x22222222;
ax = 0x3333;
al = 0x44;
al = -1
rax = -1
return 0;
}
move command
mov dest, src
nasm -f elf64 -g regDemo.asm -o regDemo.o ld -g regDemo.o -o regDemo
gdb to examine the registers.
gdb regDemo
list will list the next few lines of code.
l will list the next few lines of code.
l start,end Will list from start to end.
help list
break 7 will set a breakpoint at line 7
b 7 will set a breakpoint at line 7
run will run the program
step or s will step to the next instruction.
print or p will print.
regname prints the value of a register.
p \x $rax
info registers prints the registers
i r
quit