;-------------------- ; testAllInstrRTI.asm ; Try all LC3 instructions, including TRAP and RTI. ; Sets the TVT x25 (HALT) vector, then exercises all instructions. ; Does not set KBSR[14] to enable keyboard interrupts. Combine this with an ; explicit assignment to KBSR[14] in a verilog testbench to test interrupt ; handling. (Remembering to initialize kbHS.txt and kbData.txt so that the ; keyboard device will produce an interrupt.) This code sets the ; x0180 IVT vector (keyboard interrupt vector) to x0200. ; If interrupts are enabled (KBSR[14] = 1) and the keyboard file interface ; is set ("kbHS.txt" and kbData.txt" have appropriate values) keyboard interrupts ; will be generated. This will cause the code to restart at x0200. ; Otherwise, all instructions are executed. ; Load this at x0200. ;-------------------- .ORIG x0200 ld r0, k ;-- x0200: R0 <== x0025 = HALT vector slot ld r1, l ;-- x0201: R1 <== x0200 = OS start, vector for x25 str r1, r0, 0 ;-- x0202: Load TVT x25 vector w/ x0200 add r2, r1, r1 ;-- x0203: R2 <== x0400 add r3, r2, r1 ;-- x0204: R3 <== x0600 add r4, r3, r1 ;-- x0205: R4 <== x0800 and r4, r3, r2 ;-- x0206: r4 <== x0400 not r7, r0 ;-- x0207: r7 <== xffda br A ;-- x0208: goto x020a k: .FILL x0025 ;-- x0209: address of HALT vector A: lea r6, B ;-- x020a: R6 <== &B = x020d jmp r6 ;-- x020b: goto x020d l: .FILL x0200 ;-- x020c: HALT vector's new content B: jsr f ;-- x020d: goto 0211, R7 <== x020e lea r6, f ;-- x020e: R6 <== &f = x0211 h: jsrr r6 ;-- x020f: goto x0211 i: br C ;-- x0210: goto x0212 f: ret ;-- x0211: goto x020e C: ld r5, D ;-- x0212: r5 <== D = x4444. lea r0, D ;-- x0213: r0 <== &D = x0223 st r0, E ;-- x0214: E <== &D = x0223 sti r2, E ;-- x0215: D = (*E) <== r2 = x0400. ldi r1, E ;-- x0216: r1 <== (*E) = D = x0400. str r3, r0, 2 ;-- x0217: [ *(r0+2) = *(&D+2) = G ] <== r3 = x0600. ldr r6, r0, 2 ;-- x0218: r6 <== [ *(r0+2) = *(&D+2) = G ] = x0600. LEZ: BRnz LEZ ;-- x0219: should not loop. add r6, r6, r6 ;-- x021a: left shift r6 BRp LEZ ;-- x021b: 1st-4th: goto x0219; 5th: goto x021c add r6, r7, 0 ;-- x021c: set SP for RTI, SP = r6 <== x0210 st r1, f ;-- x021d: Mem[SP-1] <== PSR: x0211 <== r1 = x0002 lea r1, j ;-- x021e: get PC for RTI, r1 <== j = x0222 st r1, i ;-- x021f: Mem[SP] <== PC: x0210 <== r1 = x0222 rti ;-- x0220: goto x0222, R6 <== x0210+2 = x0212 .FILL x7777 ;-- x0221: something to jump over j: halt ;-- x0222: land here from RTI, then TRAP x25: goto x0200 D: .FILL x4444 ;-- x0223: E: .FILL x5555 ;-- x0224: G: .FILL x6666 ;-- x0225: .END