All questions except #17 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. How does assembly language differ from machine language?
2. Code written in a high-level language (C/Java/Python) can, in theory,
be ported to a different architecture without modifying the source. An
assembly language program, on the other hand, is specific to a certain
architecture; i.e., a MIPS assembly program will only assemble on
a MIPS architecture, x86 assembly is for Intel architectures, etc. Why is
assembly not portable unless you use a cross-assembler?
3. Define the terms assembler, macro, and object file.
4. What is the difference between a compiler and an assembler? Compare GNU C
compiler and GNU gas assembler under Linux as a specific example.
5. What are the disadvantages to writing in assembly language versus
writing in a high-level language?
6. Define the terms external label, local label,
and forward reference in the context of assembly language. How
do these concepts differ from a high-level language context?
7. How does an assembler handle forward references?
8. List two important differences between assembly language
and a high-level language such as C in terms of code writability.
9. List the primary sections of an object file under Unix.
10. What is an assembler directive? Give an example of one and explain what
it does.
11. What is a pseudoinstruction?
12. List the duties of a linker. What is the name of the Unix linker?
13. Describe the steps by which an executable is loaded into memory
under Unix? (This is also typical of most OSs.)
14. 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.
15. Where does the MIPS global pointer register ($gp) point and what is $gp
used for?
16. Why is the maximum size of a program's stack and the size of each stack
frame not necessarily known at compile time?
17. 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.
18. 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.
19. 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.
20. How do each of these commands modify the program counter?