Register Usage
Objectives
We would like to :
- Discuss register usage in x86 code.
Notes
- We continue with chapter 2 in Jorgensen
- I like This quick reference.
- Note, he provides a description of the use of some registers.
- Some you should not touch
- Scratch means you are probably safe to use it.
- The main thing you need to be aware of is usage when calling functions
- As we saw here
- rax is used to pass the system call number for a system call
- rdi, rsi, rdx are used for parameters
- In the chart r10, r8 and r9 are also sometimes used.
- This will be different in different situations.
- In addition, functions may use the registers for other things.
- So we may need to preserve values
- More on this when we get to function calls (soon)
- regDemo.asm makes a system call and rax is changed.
- For an output system call, it holds the number of bytes printed.
- rsp is the stack pointer.
- This points to the top of the stack.
- We will change this with function calls.
- But don't mess with it.
- rbp is the base pointer
- This is used in managing the stack as well.
- But don't mess with it.
- rip is the instruction pointer
- eflags (in gdb) is the flags register
- This is set by instructions.
- We will discuss these soon.
- The xmm registers
- xmm#, 0 through 15
- for floating point operations
- Also for SIMD instructions.