Scanf
Objectives
We would like to :
- Be able to write programs that employ
scanf.
Notes
- scanf, like printf, takes
- A format string, much like printf, but be careful
- Addresses where data will be stored
- Like printf we need to
- Save the base pointer, and set the stack pointer to be the base pointer.
- Make sure that the stack is word aligned
- Since I only push on 8 bit number, I need to subtract 8
- Make sure that rdi holds the format string
- Make sure that addresses are in rsi, rdx, rc, r8, r9, on the stack in reverse order
- Call scanf
- Unaligned the stack pointer if needed.
- restore the base pointer
- return
- Take a look at readExamp.asm
- Scanf will
- Attempt to match the format string.
- Literals must match exactly
- Format variables will match like cin
- Strings will be null terminated.
- Read is probably better for strings, avoids buffer overflow, but we will work on that later.
- It will return the number of input items matched