Added test for interrupt bits
This commit is contained in:
53
src/test/check_int.asm
Normal file
53
src/test/check_int.asm
Normal file
@@ -0,0 +1,53 @@
|
||||
;;Checks, which interrupts are allowed
|
||||
ORG 100H ;Tell the assembler to start at address 0x100
|
||||
CALL CLS ;Clear screen
|
||||
LD HL,BANNER ;Load the banner text
|
||||
LD B,0CH ;Set the length of the banner text
|
||||
LD DE,0H ;Start output in the top left corner
|
||||
CALL 84CDH ;Call str_out
|
||||
IN A,(17H) ;Read the interrupt sources
|
||||
LD HL,BUF ;Load the buffer address
|
||||
CALL BTOHEX ;Convert the register A to hexstr.
|
||||
LD B,02H ;Set the output length to 2
|
||||
LD DE,0DH ;Place the output cursor to row 0, col 13
|
||||
CALL 84CDH ;Call str_out
|
||||
LD HL,IREG ;Load the banner line
|
||||
LD B,0CH ;Load the length of the banner text
|
||||
LD DE,100H ;Start output at the second row
|
||||
CALL 84CDH ;Call str_out
|
||||
LD A,I ;Load the value of I into A
|
||||
LD HL,BUF ;Use the buffer
|
||||
CALL BTOHEX ;Convert the register A to hexstr
|
||||
LD B,02H ;Set the length to 2
|
||||
LD DE,10DH ;Place the cursor to row 1, col 13
|
||||
CALL 84CDH ;Call str_out
|
||||
RET ;Return from program call
|
||||
;;Clear the screen
|
||||
CLS: LD A,20H ;Use a space as output
|
||||
LD B,60H ;Repeat for entire screen (96 places)
|
||||
LD DE,0H ;Start in top left corner
|
||||
CALL 0BFEEH ;Call the str_repeat function
|
||||
RET
|
||||
;;Convert the contents of A into a hex-string and stores the result in the buffer pointed in HL
|
||||
BTOHEX: PUSH AF ;Store A onto the stack for later use
|
||||
LD B,4 ;Init a loop for shifting the register
|
||||
LP1: SRL A ;Shift the MSN down to the least significant Nibble
|
||||
DJNZ LP1 ;Shift again, until all 4 bits where shifted.
|
||||
CALL HEXDGT ;Converts the LSN to hex
|
||||
INC HL ;Point HL to the next byte in buffer
|
||||
POP AF ;Retrieve the original A
|
||||
AND 0FH ;Cut the first digit of the hex no.
|
||||
CALL HEXDGT ;Call HEXDIGIT again for the second digit.
|
||||
LD HL,BUF ;Restore the buffer address
|
||||
RET
|
||||
;;Converts the least significant nibble in A into a ASCII hex-digit and stores the result
|
||||
HEXDGT: CP 0AH ;Check if the number is smaller than 10
|
||||
JR C,SKIP ;Skip the next instruction, if it is
|
||||
ADD A,07H ;If the value is >10, we need to skip the chars between '9' and 'A'
|
||||
SKIP: ADD A,30H ;Converts the number into its ASCII digit
|
||||
LD (HL),A ;Store the digit in the correct location.
|
||||
RET
|
||||
BANNER: DB 'Interrupts: '
|
||||
IREG: DB 'I-Register: '
|
||||
BUF: DS 2 ;Define a 2 byte buffer.
|
||||
END ;End assembly
|
||||
@@ -5,91 +5,11 @@ START: IM 2 ;Set interrupt mode 2
|
||||
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
|
||||
LD A,INTTBL/256;Load the vectors for the interrupt table
|
||||
LD I,A ;Load the interrupt table to I
|
||||
EI ;Make sure interrupt are allowed
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user