;---------------------------------------------------------------------- ; LD263.ASM This program uses the DECE Timer and Interrupt Controller ; to generate periodic interrupts. Each interrupt request branches ; control to an interrupt handler where a register variable, N, is ; incremented and displayed at port-3. The main program displays the ; Timer Count value at port-2. C.P. Diduch, October 10, 2004. ;---------------------------------------------------------------------- .EQU Tmp R0 ; #define Tmp R0 .EQU N R1 ; #define N R1 .EQU Wrk R2 ; #define Wrk R2 ; .ORG 0x0000 ; RAM .DS 1 ; "interrupt vector 0" ; ; MAIN PROGRAM ; void main(void) { ; .ORG 0x8000 ; ROM ; ADD N, NULL, NULL ; N = 0 ; ADDL Tmp, NULL, IH ; "initialize interrupt vector" STOREM 0, Tmp ; ADDL Tmp, NULL, 0xF4 ; "write Interrupt Controller STOREP 0x001A, Tmp ; Control Word to clear all ; Irq's and unmask Timer LOADP Tmp, 0 ; "write Timer maximum count value" STOREP 0x0014, Tmp ; ADDL Tmp, NULL, 0x07 ; "write Timer Control Word : STOREP 0x0015, Tmp ; interrupt enabled & unmasked, ; continuous" ORL# FL, FL, 0x0040 ; "set DECE IF" ; do { M0: LOADP Tmp, 0x0014 ; "read timer count and STOREP 0x0002, Tmp ; write to port-2" JMP M0 ; } ; } ;---------------------------------------------------------------------- ; void interrupt IH(void) ; ; Each time the interrupt handler, IH, is invoked it increments the ; vale of N and writes the new value to port-3. ; IH: ; void interrupt IH(void) { ; ADDL N, N, 1 ; N = N + 1; STOREP 0x0003, N ; outport(3, N); ; LOADP Wrk, 0x0015 ; "read Timer Status to clear ; interrupt at Timer" ADDL Wrk, NULL, 0x44 ; "write Interrupt Controller STOREP 0x001A, Wrk ; Control Word to clear ; interrupt at Interrupt ; Controller Timer interrupts ; unmasked" RETI ; } ;----------------------------------------------------------------------