home *** CD-ROM | disk | FTP | other *** search
/ ftp.barnyard.co.uk / 2015.02.ftp.barnyard.co.uk.tar / ftp.barnyard.co.uk / cpm / walnut-creek-CDROM / JSAGE / ZSUS / PROGPACK / TYP3HDR1.Z80 < prev    next >
Text File  |  2000-06-30  |  2KB  |  49 lines

  1. ; TYP3HDR.Z80, Version 1.1
  2.  
  3. ; This code has been modified as suggested by Charles Irvine so that it will
  4. ; function correctly with interrupts enabled.
  5.  
  6. ; This is header code that can be used at the beginning of a type-3-environment
  7. ; program so that it will abort with an error message when not loaded to the
  8. ; correct address (such as when a user tries to run it under CP/M or Z30).
  9.  
  10. entry:
  11.     jr    start0        ; Must use relative jump
  12.     defb    0        ; Filler
  13.     db    'Z3ENV',3    ; Type-3 environment
  14. z3env:    dw    0        ; Filled in by Z33
  15.     dw    entry        ; Intended load address
  16.  
  17. start0:
  18.     ld    hl,0        ; Point to warmboot entry
  19.     ld    a,(hl)        ; Save the byte there
  20.     di            ; Protect against interrupts
  21.     ld    (hl),0c9h    ; Replace warmboot with a return opcode
  22.     rst    0        ; Call address 0, pushing RETADDR onto stack
  23. retaddr:
  24.     ld    (hl),a        ; Restore byte at 0
  25.     dec    sp        ; Get stack pointer to point
  26.     dec    sp        ; ..to the value of RETADDR
  27.     pop    hl        ; Get it into HL and restore stack
  28.     ei            ; We can allow interrupts again
  29.     ld    de,retaddr    ; This is where we should be
  30.     xor    a        ; Clear carry flag
  31.     push    hl        ; Save address again
  32.     sbc    hl,de        ; Subtract -- we should have 0 now
  33.     pop    hl        ; Restore value of RETADDR
  34.     jr    z,start        ; If addresses matched, begin real code
  35.  
  36.     ld    de,notz33msg-retaddr ; Offset to message
  37.     add    hl,de
  38.     ex    de,hl        ; Switch pointer to message into DE
  39.     ld    c,9
  40.     jp    0005h        ; Return via BDOS print string function
  41.  
  42. notz33msg:
  43.     defb    'Not Z33+$'    ; Abort message if not Z33-compatible
  44.  
  45. start:
  46.     ret            ; Replace with real code
  47.  
  48.     end
  49.