Assignment 3, due Sep 12Solutions
Part of
the homework for CS:2630, Fall 2019
|
STRING1:ASCII "this is an example string",0 ENDMARK: LENGTH: H ENDMARK-STRING STRING2:ASCII "this is another example string",0 POINT1: W STRING1 POINT2: W STRING2
Rewrite the above code with ALIGN directives insterted where they should be to assure that all halfwords and words are properly aligned. (1 point, 0.2 point penalty for each missing or extra align)
STRING1:ASCII "this is an example string",0 ENDMARK: ALIGN 2 LENGTH: H ENDMARK-STRING STRING2:ASCII "this is another example string",0 ALIGN 4 POINT1: W STRING1 POINT2: W STRING2
113201D1 C213F2F3 000662F4 000010E5
a) Disassemble these words into a sequence of hawk instructions, and give those instructions in SMAL Hawk notation. (1.0 points, 0.1 points penalty per error in opcode, register or field.)
Hint: All the instructions are found in Chapter 4, Appendix B of the Hawk Manual is the primary resource for this kind of problem, in general, the Hawk emulator can solve this problem for you, but you will be expected to be able to disassemble code by hand using Appendix B on exams.
LIS R1,1 ADD R2,R1,R1 MOVE R3,R2 ADDSI R3,2 ADDI R4,R2,6 ; alternately, LEACC R4,R2,6 LIL R5,#10
b) What registers does the above code change, and what values does it leave in those registers, when it is done. (0.5 points, 0.1 point penalty per error)
Hint: Again, you will be expected to be able to solve this with pencil, paper and the Hawk manual, but you can check your work using the Hawk emulator.
It sets
R1 = 1
R2 = 2
R3 = 4
R4 = 8
R5 = 16
LOADA rd,address
Here, rd is the destination register, address is a 32-bit literal memory address, and the instruction loads the word from that memory address into the destination register.
A problem: Write a SMAL Hawk macro that implements this. (0.5 points, 0.1 per missing or confused element)
MACRO LOADA rd,address LIW rd,address LOADS rd,rd ENDMAC
Note: The first line can be MACRO LOADA =rd.=address (with equals signs added). If you do this, the error messages will change, for example, if you pass something that isn't a register for the rd parameter. By default, the text of each parameter is passed without interpretation. If a formal parameter in the macro header is preceeded with an equals sign, it asks the assembler to evaluate the parameter first, then pass its value (as a decimal number, possibly with an added relocation base) instead of the text.