CMPS-2240 Homework 3: Assemblers, Linkers & Loaders - Creating the Process Image


Refer to as needed:


All questions except #7 are taken from Appendix A.1 - A.5. Read A.1-A.5 completely before starting homework. Do not worry about references in the Appendix to chapters in the text, we will cover that material as needed.



1. What is a pseudoinstruction?

2. List the duties of a linker. What is the name of the Unix linker?

3. Describe the steps by which an executable is loaded into memory under Unix? (This is also typical of most OSs.)

4. Draw a picture of how a program is loaded in memory (AppenA shows MIPS which is fairly typical). Include the stack, the heap, the text segment and the data segment.

5. Where does the MIPS global pointer register ($gp) point and what is $gp used for?

6. Why is the maximum size of a program's stack and the size of each stack frame not necessarily known at compile time?

7. Little-endian (little-end in first) and big-endian (big-end in first) refer to the order in which chunks (one byte or two bytes) of a word are loaded into memory. Little refers to the "little end" (smallest value) of a number; i.e., the "little end" of 347 decimal is 7. The "big end" of 342 decimal is 3 (since the value of that digit is 300). In little-endian the least significant chunk is loaded into lowest memory address. Consider a 2-byte unsigned integer with binary and hex representations shown here:
           1100_0111 1111_0101  0xB7_F5
Assuming a machine with an 8-bit data bus (memory is loaded one byte at a time), the little end is the least significant btye (F5) and the big end is the most significant btye (B7). Show the order of bytes in both little-endian and big-endian.

8. Write MIPS code for a subroutine get_int that reads an integer from the keyboard and echos it to the display and stores the result into $v0.

9. Write MIPS code for a subroutine to_neg that takes the value in $a0 and converts it to negative, two's compliment. Assume that the value in $a0 is positive (don't do any input error checking). Store the result into $v0.

10. How do each of these commands modify the program counter?
          a. jr
          b. jal
          c. j