*============================================================== * testint.asm - Demonstrates the interrupt function of the HC11. * * Usage: In THRSIM, connect a switch to the IRQ pin, and bring * up the I/O box. Set up the memory map and run the program. * The register D lights will count continuously. * The register B lights will count from 0-255 whenever * the switch first goes low. *=============================================================== #include "registers.asm" ; Declares the HC11 control registers. #include "vectors.asm" ; Declares interrupt & reset vectors. org $2000 ; Locate our program at address $2000, in external RAM. main: * Set IRQ for falling-edge-detect mode. (This must be done in the 1st 64 cycles out of reset.) ldx #OPTION ; Point X at the OPTION register bset 0,X IRQE ; Set the IRQE bit in the OPTION register * Turn on bits DDRD0-DDRD5 in data direction register D to make PD0-PD5 outputs. ldx #DDRD bset 0,X DDRD5|DDRD4|DDRD3|DDRD2|DDRD1|DDRD0 cli ; Clear I interrupt mask (enable IRQ interrupts) loop1: inc PORTD ; Increment port D contents. bra loop1 ; Just keep doing this forever. myISR: inc PORTB ; Increment port B contents. bne myISR ; Keep going till it gets back to 0. rti ; Return from interrupt. * Establish our interrupt and reset vectors in ROM. org VIRQ ; Point the IRQ interrupt vector... fdb myISR ; ...at my Interrupt Service Routine. org VRST ; Point the RESET vector... fdb main ; ...at my main routine.