Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Q3. Lets assume that a main program writes three Address pointers saved in what

ID: 3691870 • Letter: Q

Question

Q3. Lets assume that a main program writes three Address pointers saved in what a0 points to, then write a subroutine to branch to those three addresses in sequence (one by one) and when finished return control back to the main. Do not forget to bring back back all the used registers before returning to main?

Q4. When the address of the of the interrupt handler routine of Undefined Instruction is starting in memory at address 0x280, then where and what should be written in that exception vector address designated for this type of interrupt?

Explanation / Answer

1)

arr1 DC16 1,2,3
main:

register a0
MOV #arr1, a0
MOV #3 R10
JMP Access

Access: MOV @a0+, a1 ;printing each value by address
INT 21h ;printing that value   
DEC R10 ; decrementing index
JNZ RET

-------------------------------------------------------------------------------------------------------------------------------------------------

2)

in
@TRY_EXCEPt ... handler if we get exception in 0x280 then it means there was a problem with
clearing pending registers.
Then we have to write in Handler section these lines ..

mov esp, [esp+8] ;if exception occurs get previus offset esp value
pop dword ptr fs:[0] ;restoring old exception
add esp,4 ;setting esp value
popad ;old state restoring