Addition
Objectives
We would like to :
- Investigate addition instructions.
Notes
- This is Jorgensen chapter 7.5
- The add instruction is
add dest, src
- This performs the action
dest = dest + src
- The operands must be the same size.
- The destination can not be an immediate
- Both source and destination can not be memory, one or the other
- An immediate can not be 64 bits.
- And remember, you need a q modifier in printf, (%qd, %qx)
- There is an increment instruction as well
- This is
inc dest
- This adds one to the destination
- The destination can not be an immediate.
- sub, dec
- Just like add, inc
- But be careful, you might not get the sign extended as you need.
- See adder.asm
- "It is the programmer's responsibility to ensure that the data types and sizes are appropriate for the operations being performed.", Jorgensen P 88.