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 / CPM / BYE5 / B5C-DS.LBR / DSTOBYE.ZZ0 / DSTOBYE.Z80
Text File  |  2000-06-30  |  3KB  |  91 lines

  1. ;Program: DSTOBYE
  2. ;Author: Bruce Morgen
  3. ;Date: May 11, 1988
  4.  
  5. ;Purpose: Establishes an RST vector to the running DateStamper
  6. ;clock, if detected.  A default address of 0008h is assumed if
  7. ;none is specified.  An address may be specified in decimal,
  8. ;hex, binary or octal.  The warm boot (RST 0) and debugger
  9. ;trap (RST 7/RST 38h) vectors are disallowed, as are addresses
  10. ;not reachable via 8080/Z80 RST instructions.  Numeric input
  11. ;lower than 0008h is assumed to correspond to Intel-convention
  12. ;RST arguments, therefore 1 is equivalent to 0008h, 2 to 0010h,
  13. ;5 to 0028h, etc.  Illegal input results in a help screen, as
  14. ;does the Z3-style "//" help query syntax.
  15.  
  16. ;ASCII constants
  17. CR    EQU    13
  18. LF    EQU    10
  19. BEL    EQU    7
  20.  
  21. ;DSLIB & SYSLIB external references
  22.     EXTRN    FINDCK,EPRINT,PHL4HC,MULHD,EVAL
  23.  
  24. ;We begin...
  25.     LD    A,(5DH)        ; Get character from FCB #1
  26.     CP    '/'        ; Help query?
  27.     JP    Z,HELP        ; Comply if so
  28.     LD    DE,8        ; Load default RST vector addr.
  29.     CP    ' '        ; No other specified?
  30.     JR    Z,DFAULT    ; Then go use it
  31.     LD    HL,82H        ; Point to command tail
  32.     CALL    EVAL        ; Evaluate it to binary
  33.     INC    D        ; Can't be 16-bit value
  34.     DEC    D
  35.     JP    NZ,HELP        ; So give help if it is
  36.     OR    A        ; RST 0 is not available
  37.     JP    Z,HELP        ; Give help if required
  38.     CP    7        ; 0038h (RST 7) no good either
  39.     JP    Z,HELP        ; So give help if required
  40.     LD    HL,8        ; Intel must be multiplied by 8
  41.     CP    L        ; See if Zilog
  42.     JR    NC,DFAULT    ; Branch ahead if so
  43.     CALL    MULHD        ; Result into HL
  44.     EX    DE,HL        ; Swap into DE
  45.  
  46. DFAULT:
  47.     LD    A,E        ; Check range
  48.     CP    30H+1        ; 30h is highest legal address
  49.     JR    NC,HELP        ; Give help if needed
  50. LEGAL:
  51.     SUB    8        ; Subtract constant
  52.     JR    C,HELP        ; Oops, any remainder is n/g...
  53.     JR    NZ,LEGAL    ; Loop until done
  54.     PUSH    DE        ; Save address
  55.     CALL    FINDCK        ; Find The DateStamper
  56.     POP    DE        ; Restore address
  57.     JR    Z,DSFAIL    ; Barf if no DS
  58.     CALL    EPRINT        ; EPRINT & PHL4DC preserve regs
  59.     DB    CR,LF,'DateStamper vector to ',0
  60.     CALL    PHL4HC        ; Print DS clock address
  61.     CALL    EPRINT
  62.     DB    'h established at ',0
  63.     EX    DE,HL        ; Swap registers
  64.     CALL    PHL4HC        ; Print vector location
  65.     CALL    EPRINT
  66.     DB    'h for BYE',CR,LF,0
  67.     LD    (HL),0C3H    ; Poke JP instruction first
  68.     INC    HL        ; Point to address LSB
  69.     LD    (HL),E        ; Poke LSB
  70.     INC    HL        ; Point to address MSB
  71.     LD    (HL),D        ; Poke MSB
  72.     RET            ; All done
  73.  
  74. DSFAIL:    CALL    EPRINT        ; The usual bitch 'n barf
  75.     DB    BEL,CR,LF,'Can''t find The DateStamper',CR,LF,0
  76.     RET
  77.  
  78. HELP:    CALL    EPRINT
  79.     DB    CR,LF,'DSTOBYE, Version 1.0',CR,LF
  80.     DB    'Builds a vector to DateStamper for BYE',CR,LF
  81.     DB    'Syntax:',CR,LF
  82.     DB    ' DSTOBYE [rst addr.]',CR,LF
  83.     DB    'If the rst addr. is omitted, 0008h is assumed.',CR,LF
  84.     DB    'Either Zilog (address) or Intel (level)',CR,LF
  85.     DB    'RST nn conventions are accepted, RST 0 and',CR,LF
  86.     DB    'RST 38h (RST 7 in Intel) are disallowed,',CR,LF
  87.     DB    'as are addresses not reachable via RSTs.',CR,LF,0
  88.     RET
  89.  
  90.     END
  91.