The following program executes, generating an interrupt for DECI: 0000 040005 BR
ID: 3657487 • Letter: T
Question
The following program executes, generating an interrupt for DECI:
0000 040005 BR main ;Branch around data
0003 0000 num: .BLOCK 2 ;Global variable
;
0005 310003 main: DECI num,d ;Input decimal value
0008 390003 DECO num,d ;Output decimal value
000B 50000A CHARO ' ',i
000E 410012 STRO msg,d ;Output message
0011 00 STOP
0012 546861 msg: .ASCII "That's all. "
742773
20616C
6C2E0A
00
001F .END
The entry to and exit from the trap handler, state the values in the following registers as four hexadecimal digits:
(c)X after SUBX at FCBA
Explanation / Answer
You can simply run this along with the second part
;******* Trap handl er
oldIR: .EQUATE 9 ;Stack address of IR on trap
;
FC9B C80000 trap: LDX 0,i ;Cl ear X for a byte compare
FC9E DB0009 LDBYTEX ol dIR,s ;X := trapped IR
FCA1 B80028 CPX 0x0028,i ;If X >= first nonunary trap opcode
FCA4 0EFCB7 BRGE nonUnary ;trap opcode is nonunary
;
FCA7 980003 unary: ANDX 0x0003,i ;Mask out al l but rightmost two bits
FCAA 1D ASLX ;An address is two bytes
FCAB 17FCAF CALL unaryJT,x ;Cal l unary trap routine
FCAE 01 RETTR ;Return from trap
;
FCAF FDB6 unaryJT: .ADDRSS opcode24 ;Address of NOP0 subroutine
FCB1 FDB7 .ADDRSS opcode25 ;Address of NOP1 subroutine
FCB3 FDB8 .ADDRSS opcode26 ;Address of NOP2 subroutine
FCB5 FDB9 .ADDRSS opcode27 ;Address of NOP3 subroutine
;
FCB7 1F nonUnary:ASRX ;Trap opcode is nonunary
FCB8 1F ASRX ;Discard addressing mode bits
FCB9 1F ASRX
FCBA 880005 SUBX 5,i ;Adjust so that NOP opcode = 0
FCBD 1D ASLX ;An address is two bytes
FCBE 17FCC2 CALL nonUnJT,x ;Cal l nonunary trap routine
FCC1 01 return: RETTR ;Return from trap
;
FCC2 FDBA nonUnJT: .ADDRSS opcode28 ;Address of NOP subroutine
FCC4 FDC4 .ADDRSS opcode30 ;Address of DECI subroutine
FCC6 FF3B .ADDRSS opcode38 ;Address of DECO subroutine
FCC8 FFC6 .ADDRSS opcode40 ;Address of STRO subroutine
And step through the code until you get to the part at FCBA which gives you 0001 for your index register
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.