Mean = 14 X X X Median = 13.9 X X X X X X X X X X X X X X X X X X X X X X X X X X X __________X_____X___X_X_X_X_X_X_X_X_X_X_X___X_X________ 0 . 2 . 4 . 6 . 8 . 10. 12. 14. 16. 18. 20. 22. 24
Procedure calls have an explicit reference to the called routine; with traps and interrupts, the routine is implicit (implied by the cause). Traps and procedure calls are both caused by actions of the executing program, interrupts are caused by external conditions. Traps and interrupts transfer control to system or monitor service routines, procedure calls transfer control to procedures in the same program or sphere of protection.
The above answer addresses 3 issues, cause (or initiation), mechanism (how the routine is determined) and use. Nobody addressed all of these issues; most got roughly half credit for full coverage of traps and interrupts with regard to use and initiation while largely ignoring procedure calls.
; -------------------------- ; activation record format ;RA = 0 ; return address T = 4 ; save location for parameter SZ = 8 ; size of AR ; expects R3 = parameter t REVERSE: TEST R3 ; test t BZS QUIT ; go return if t null STORES R1,R2 ; save RA if t not null STORE R3,R2,T ; save t also LOAD R3,R3,LEFT ADDI R2,SZ JSR R1,REVERSE ; reverse( t->left ) LOAD R3,R2,T-SZ LOAD R3,R3,RIGHT JSR R1,REVERSE ; reverse( t->right ) ADDI R2,-SZ LOAD R3,R2,T LOAD R4,R3,LEFT ; exchange LOAD R5,R3,RIGHT ; t->left and t->right STORE R4,R3,RIGHT STORE R5,R3,LEFT LOADS R1,R2 ; restore return address QUIT: JUMPS R1This was close to being the "perfect exam question," in that the distribution of grades on this question alone was very similar to the distribution for the whole exam and the whole course. The answer above is perhaps the most compact translation possible for the Hawk architecture, and a fair number gave either this or a slightly less optimal and more straightforward solution. At the other extreme, some students clearly failed to understand the recursion and failed to effectively exchange the left and right pointers.
; assume R4 holds i, R5 holds j (this was given!) ADDSL R4,R4,3 ; multiply i by 9 ADD R4,R4,R5 ; make 9i + j (1 dimensional offset) LOAD R5,APOINT ; get base address of array ADDSL R4,R5,2 ; addr of A[i,j] = A + 4*(9i + j) LOADS R3,R4 ; fetch array elementThis was another "perfect exam question." Many forgot to multiply by 4 (the number of bytes per word) or worse yet, attempted to treat A as an array of bytes. Many forgot the order of array indices in C and Pascal (in both languages, A is an array of 5 sub-arrays, each of which holds 9 integers.) A few students managed to present answers with loops or other mysterious control structures that suggest a complete misunderstanding of the question.
This problem wasn't particularly difficult, but perhaps a third of the class managed to either read the question carelessly or study the material poorly. The hardest sub question involved the time to read the whole disk. Some had very strange answers, while some had answers that assumed that all tracks in one cylinder could be read in parallel.
MACRO MOVE =A,=B H B H A ENDMAC MACRO BR =A MOVE #FFFF,A ENDMAC MACRO ADD =A MOVE #FFFB,A ENDMAC MACRO BPOS =A MOVE #FFFE,#FFFA BR A ENDMACMany students gave fairly good answers. The most common error was to permute the parameters to the MOVE macro so source and destination were interchanged. Many who completely wrecked the MOVE macro managed to give good definitions for BR, ADD and BPOS in terms of it. Some students interpreted the question oddly, giving Hawk instructions instead of instructions in the strange machine language of the proposed machine. Some students were obviously confused and attempted to use conditional assembly in the BPOS instruction.