HW09 Assembly Language ================================================================================ Refer to Chapter 7 in your textbook for material and questions. 1. For a certain program, 2% of the code accounts for 50% of the execution time. Compare the following three strategies with respect to programming time and execution time. Assume that it would take 100 man-months to write it in C, and that assembly code is 10 times slower to write and four times more efficient. a. Entire program in C. b. Entire program in assembler. c. First all in C, then the key 2% rewritten in assembler. 2. Do the considerations that hold for two-pass assemblers also hold for compilers? a. Assume that the compilers produce object modules, not assembly code. b. Assume that the compilers produce symbolic assembly language. 3. Most assemblers for the x86 have the destination address as the first operand and the source address as the second operand. What problems would have to be solved to do it the other way? 4. Can the following program be assembled in two passes? EQU is a pseudoinstruction that equates the label to the expression in the operand field. P EQU Q Q EQU R R EQU S S EQU 4 6. What is the difference between an instruction and a pseudoinstruction? 7. What is the difference between the instruction location counter and the program counter, if any? After all, both keep track of the next instruction in a program. 12. Compute the hash code for each of the following symbols by adding up the letters (A = 1, B = 2, etc.) and taking the result modulo the hash table size. The hash table has 19 slots, numbered 0 to 18. els, jan, jelle, maaike Does each symbol generate a unique hash value? If not, how can the collision problem be dealt with? 16. Programs often link to multiple DLLs. Would it not be more efficient just to put all the procedures in one big DLL and then link to it? 17. Can a DLL be mapped into two process’ virtual address spaces at different virtual addresses? If so, what problems arise? Can they be solved? If not, what can be done to eliminate them? 18. One way to do (static) linking is as follows. Before scanning the library, the linker builds a list of procedures needed, that is, names defined as EXTERN in the modules being linked. Then the linker goes through the library linearly, extracting every procedure that is in the list of names needed. Does this scheme work? If not, why not and how can it be remedied?