Registers in Intel
Objectives
We would like to :
- Begin to Explore the x86 registers
Notes
- This is Jorgensen chapter 2.
- Intel supports the following data sizes
- byte - 8 bits
- word - 16 bits
- double word 32 bits
- quad word 64 bits.
- Intel has the following registers
- *ax - frequently used for return values
- *bx
- *cx - used to pass argument 4 to functions
- *dx - used to pass argument 3 to functions
- *si - used to pass argument 2 to functions
- *di - used to pass argument 1 to functions.
- rN - where n is 8 through 15
- *bp - the base of the stack
- *sp - the top of the stack.
- For the *
- It can be replaced with r, e, nothing, or followed by h or l
- rax is a 64 bit register
- eax is a 32 bit register
- ax is a 16 bit register
- al is a 8 bit register
- ah is a second 8 bit reister
-
- For r8 - r15
- r# is the 64 bit register
- r#d is the 32 bit register
- r#w is the 16 bit register
- r#b is the 8 bit register.
- the
mov instruction
- There are many forms.
- Each will generate a different op code.
- They depend on the arguments
- For now we will do a move immediate
- mov register, immediate value
- the immediate value, if followed by an h is hex.
-
mov rax, 1111111h
- A move to rax changes the entire register
- A move to eax changes the entire register
- A move to ax only changes the lower 16 bits
- A move to al only changes the lowest 8 bit
- A move to ah only changes the second lowest 8 bits.
- Negative numbers
- Note a move of a negative number is not what you think.
- Only a move to rax will fully set the negative number.
- Look at regDemo.cpp.
- Some GDB notes
-
list or l n will list the code
-
break # or b # for break
- # can be a line number
- Or it can be a label
-
run will restart the program.
-
print or p will print
- registers start with a $
- You can change the output type with /?
- o - octal
- x - hexadecimal
- u - unsigned decimal
- t - binary
- f - floating point
- a - address
- c - char
- s - string
-
p /x $rax
-
step n or s n
- Without an argument steps a single line
- This will step into function call
-
next n will step at the code level.