home *** CD-ROM | disk | FTP | other *** search
/ Amiga Elysian Archive / AmigaElysianArchive.iso / emulate / z80emula.lzh / Interrupts.ASM next >
Assembly Source File  |  1992-06-23  |  2KB  |  54 lines

  1. ; Program to show clock interrupts of Z80 System
  2. ; Written for Z80 Emulator
  3.  
  4. ; interrupt handling routine must reside at address 0008
  5. ; to correspond with RST 8 instruction for a clock interrupt in
  6. ; the Z80 system
  7.  
  8. ; this interrupt service routine shows some typical aspects of
  9. ; Z80 interrupt programming:
  10. ; - the use of EXX to quickly make available an alternate register set
  11. ;   without the overheads of stacking to main store
  12. ; - the use of B as a counter for a looping instruction
  13. ; - the use of C (the unused half of BC) to store the port address
  14.  
  15. INTERRUPT EQU 1000            ; define the start for the main routine
  16.  
  17.           ORG #8
  18. SERV_INT: EXX                 ; exchange register sets
  19.           LD HL,INT_MESS      ; point to interrupt message
  20.           LD B,25             ; message length
  21.           LD C,1              ; port for output (console screen)
  22.           OTIR                ; output the message
  23.           EXX                 ; get back our first set of registers
  24.           EI                  ; re-enable interrupts that were disabled
  25.           RETI                ; return from interrupt service routine
  26.  
  27. ; this following routine is a simple loop to continuously display a message
  28. ; we'll use an alternate format of the OUT instruction just to be different
  29.  
  30.           ORG INTERRUPT
  31. DISP_MESS:LD HL,STD_MESS      ; point to standard message
  32.           LD B,20             ; message length
  33. LOOP:     LD A,(HL)           ; get next character
  34.           OUT (1),A           ; output character to console screen
  35.           INC HL              ; point to next character
  36.           DJNZ LOOP           ; repeat until all have been printed
  37.           LD A,R              ; get value of refresh register
  38.           ADD A,32            ; offset to get normal ASCII character
  39.           OUT (1),A           ; display this value
  40.           LD A,13             ; now define a carriage return
  41.           OUT (1),A           ; and display it
  42.           JR DISP_MESS        ; just continue forever
  43.  
  44. INT_MESS: DEFM **
  45.           DEFB 32
  46.           DEFM Servicing
  47.           DEFB 32
  48.           DEFM interrupt
  49.           DEFB 32
  50.           DEFM **
  51. STD_MESS: DEFM Normal
  52.           DEFB 32
  53.           DEFM processing...
  54.