Memory and Integer Arithmetic due Thu 06 Sep 14:45

In this assignment you will learn/practice several significant ...
...el assembly documentation
\item addressing modes

Preparation for Lab Day

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.
                section .data
int:            dd      68,-9
floaty:         dd      -68.125
char:           db      "Greetings!",10,0
bighex:         dq      10h
mediumbin:      dw      10b

                section .bss
somememory:     resd    2

                ; you can actually have multiple of these sections interleaved if you want to
                ; but generally that would just be confusing!

                section .data
nightnight:     db      "ZZZZZZZZ"

Bring your hand-written solution to lab day.

Lab Day

  1. At the beginning of the period show your prep work to the instructor.

  2. Create a new directory called labday01 and do your work in that directory.

  3. 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

  4. 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 %include directive to include dumpregs.asm. Move the number 10 to r8 and then call dump_regs and inspect the output.

  5. Now modify your program so that it encodes the NASM declarations above. Observe the output of these commands:
    	mov r8,int
    	mov r9,float
    	mov r10,[int]
    	mov r11,[float]

    If you subtract r8 from r9 (by hand) what do you get? Why? Ponder the output until you understand it.

  6. Move the memory starting at label int into registers. Do not use rbp or rsp. After you've copied the memory into the registers, call dump_regs to show the memory contents. Compare the output of the program with your hand-written solution and reconcile any differences.

  7. What happens if you continue to print memory past the end of your memory declarations? Try it.

  8. 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?

  9. Show your work to the instructor and describe any mistakes you may have made when creating your hand-written memory map.

  10. If you finish early, work on your homework assignment until the end of the lab period.

Quick Links