diff --git a/src/example/char_int.asm b/src/example/char_int.asm index 0c9e771..baa8fbd 100644 --- a/src/example/char_int.asm +++ b/src/example/char_int.asm @@ -1,20 +1,11 @@ ;;Query the keyboard in an interrupt routine. - ORG 38H ;Assemble into the interrupt routine - DI ;Disable interrupts - EX AF,AF' ;Save the state of the AF register - EXX ;Save the state of any other registers - CALL INTR ;Call the interrupt handler - EXX ;Restore the state of each register - EX AF,AF' ;Restore the accumulator - EI ;Enable the interrupts - RET ;Return to caller ORG 100H ;Tell the assembler to start at addr 0x100 START: IM 1 ;Set interrupt mode 1 LD HL,GREET ;Load the start address of the banner LD B,15H ;Set the length of the banner text LD DE,0H ;Start output in the top left corner CALL 84CDH ;Call str_out -;; TODO: Add code + HALT ;Halts the CPU to save batteries. RET ;End the program INTR: IN A,(16H) ;Read the interrupt register AND 1H ;Check if this is a keyboard interrupt diff --git a/src/test/int_tab.asm b/src/test/int_tab.asm new file mode 100644 index 0000000..103a43d --- /dev/null +++ b/src/test/int_tab.asm @@ -0,0 +1,95 @@ +;;Tests all interrupt vectors to find which interrupt value is used querying the Keyboard in IM2 + ORG 100H ;Tell the assembler to start at addr 0x100 +START: IM 2 ;Set interrupt mode 2 + LD HL,GREET ;Load the start addr. of the banner + LD B,16H ;Set the length of the banner text + LD DE,0H ;Place curser in the top left + CALL 84CDH ;Call system str_out +LOOP: HALT ;Halt the CPU and wait for interrupts + JR LOOP ;Stay in the loop + RET ;Return to original caller +INTTBL: DW INTHD0 ;Define the address of the first interrupt handler + DW INTHD1 ;Define the address of the second interrupt handler + DW INTHD2 ;Define the address of the third interrupt handler + DW INTHD3 ;Define the address of the fourth interrupt handler + DW INTHD4 ;Define the address of the fifths interrupt handler + DW INTHD5 ;Define the address of the sixths interrupt handler + DW INTHD6 ;Define the address of the seventh interrupt handler + DW INTHD7 ;Define the address of the eighth interrupt handler +INTHD0: DI ;Disable interrupts + EX AF,AF' ;Push AF to the shadow register + EXX ;Push all other registers to the shadow register + LD A,30H ;Load handler id to A + CALL INTHDL ;Call the interrupt handler method. + EXX ;Restore the registers + EX AF,AF' ;Retore AF + EI ;Reenable interrupts + RETI ;Return from interrupt +INTHD1: DI ;Disable interrupts + EX AF,AF' ;Push AF to the shadow register + EXX ;Push all other registers to the shadow register + LD A,31H ;Load handler id to A + CALL INTHDL ;Call the interrupt handler method. + EXX ;Restore the registers + EX AF,AF' ;Retore AF + EI ;Reenable interrupts + RETI ;Return from interrupt +INTHD2: DI ;Disable interrupts + EX AF,AF' ;Push AF to the shadow register + EXX ;Push all other registers to the shadow register + LD A,32H ;Load handler id to A + CALL INTHDL ;Call the interrupt handler method. + EXX ;Restore the registers + EX AF,AF' ;Retore AF + EI ;Reenable interrupts + RETI ;Return from interrupt +INTHD3: DI ;Disable interrupts + EX AF,AF' ;Push AF to the shadow register + EXX ;Push all other registers to the shadow register + LD A,33H ;Load handler id to A + CALL INTHDL ;Call the interrupt handler method. + EXX ;Restore the registers + EX AF,AF' ;Retore AF + EI ;Reenable interrupts + RETI ;Return from interrupt +INTHD4: DI ;Disable interrupts + EX AF,AF' ;Push AF to the shadow register + EXX ;Push all other registers to the shadow register + LD A,34H ;Load handler id to A + CALL INTHDL ;Call the interrupt handler method. + EXX ;Restore the registers + EX AF,AF' ;Retore AF + EI ;Reenable interrupts + RETI ;Return from interrupt +INTHD5: DI ;Disable interrupts + EX AF,AF' ;Push AF to the shadow register + EXX ;Push all other registers to the shadow register + LD A,35H ;Load handler id to A + CALL INTHDL ;Call the interrupt handler method. + EXX ;Restore the registers + EX AF,AF' ;Retore AF + EI ;Reenable interrupts + RETI ;Return from interrupt +INTHD6: DI ;Disable interrupts + EX AF,AF' ;Push AF to the shadow register + EXX ;Push all other registers to the shadow register + LD A,36H ;Load handler id to A + CALL INTHDL ;Call the interrupt handler method. + EXX ;Restore the registers + EX AF,AF' ;Retore AF + EI ;Reenable interrupts + RETI ;Return from interrupt +INTHD7: DI ;Disable interrupts + EX AF,AF' ;Push AF to the shadow register + EXX ;Push all other registers to the shadow register + LD A,37H ;Load handler id to A + CALL INTHDL ;Call the interrupt handler method. + EXX ;Restore the registers + EX AF,AF' ;Retore AF + EI ;Reenable interrupts + RETI ;Return from interrupt +INTHDL: LD DE,100H ;Put char in row 2 col. 1 + CALL 8468H ;Calls the char_out function + RET ;Return to the interrupt handler +GREET: DB 'Test for keyboard int.' + END