PDA

View Full Version : Assembly, programming interrupt service routines


uniquity
11-04-2009, 11:28 PM
i'm trying to write a program which involves two user programs, one trap routine and a interrupt service routine

the first user program simply calls trap routine x26 which waits for input, then enables the interrupt bit on KBSR. once a key is pressed, the second user program is supposed to start while program waits for more input. all the second user program does is output asterisks. its supposed to keep outputting asterisks while user program 1 is waiting for input...once 5 keys are pressed the program is halted

right now, my program only takes in 5 keys and outputs them but the 2nd user program is never called upon and no asterisks are outputted.

below is the code for the trap routine, can anyone help me out and let me know why the 2nd user program is never called? p.s. x3400 is the starting address of the 2nd user program

.ORIG x3300

START LD R4, BIT ; load bit to enable KBSR
STI R7, ADDR ; save PC/R7 to x32FF
WAIT LDI R5, KBSR ; load KBSR to R5
BRzp WAIT ; wait for input
LDI R0, KBDR ; load input to R0
ADD R5, R5, R4 ; enable interrupt bit
STI R5, KBSR ; set KBSR
LD R7, UP2 ; load starting address of UP2
JMP R7 ; return to UP2

ADDR .FILL x32FF ; address to store PC
UP2 .FILL x3400 ; starting address of UP2
KBSR .FILL xFE00 ; address of KBSR
KBDR .FILL xFE02 ; address of KBDR
BIT .FILL #16384 ; bit to enable ready/interrupt

.END

oracleguy
11-05-2009, 12:05 AM
What architecture is this for?

drhowarddrfine
11-05-2009, 12:30 AM
It looks like ARM.

The only thing I can tell is it looks like the only chance to break out of this loop is if it receives keyboard input. So the obvious question is, are you sure you're getting keyboard data?

uniquity
11-05-2009, 01:45 AM
i am using an lc-3 simulator for these programs.

drhowarddrfine - yes, its getting keyboard data, everything works fine in my program until you hit the JMP R7 line, which is supposed to jump it to address x3400, but it jumps instead to the interrupt service routine (x3500) without ever going to x3400 (2nd user program)

drhowarddrfine
11-05-2009, 04:47 AM
Never heard of this simulator before. This is something you'll have a hard time finding an answer for outside your class.