Suppose the following declarations start at address 01B0h. As we did in
class write in hex on a byte-by-byte basis the address and value of each byte
generated by these NASM instructions. Also include the labels.
int: dd 68,-9
floaty: dd -68.125
char: db "Greetings!",10,0
bighex: dq 10h
mediumbin: dw 10b
somememory: resd 2
; you can actually have multiple of these sections interleaved if you want to
; but generally that would just be confusing!
nightnight: db "ZZZZZZZZ"
Bring your hand-written solution to lab day.
- At the beginning of the period show your prep work to the instructor.
- Create a new directory called labday01 and do your work in that
- From the course website download the dumpregs.asm source file
from the course website. If you want to do the download from the
command-line like a nerd you can use this command: wget
- dumpregs.asm contains macros that will be very helpful in
debugging programs this semester. It contains a command called
dump_regs that will show (in hex) the values of the registers.
Write an assembly program that uses the
to include dumpregs.asm. Move the number 10 to r8 and then
dump_regs and inspect the output.
- Now modify your program so that it encodes the NASM declarations above.
Observe the output of these commands:
If you subtract r8 from r9 (by hand) what do you get? Why?
Ponder the output until you understand it.
- Move the memory starting at label int into registers. Do not use
rbp or rsp. After you've copied the memory into the registers,
dump_regs to show the memory contents. Compare the output of
the program with your hand-written solution and reconcile any differences.
- What happens if you continue to print memory past the end of your memory
declarations? Try it.
- Prior to moving memory contents into registers issue this command so you will be
able to see where the label somememory starts:
mov qword [somememory],0x33333333
After you see the effect of this command, remove the word qword from it
and re-compile. Why is qword required for this mov command but not
for any of the other mov commands in this program?
- Show your work to the instructor and describe any mistakes you may have
made when creating your hand-written memory map.
- If you finish early, work on your homework assignment until the end of
the lab period.