home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / jsage / znode3 / uploads / myz80clk.lbr / MYZ80CLK.MAC < prev    next >
Encoding:
Text File  |  1992-08-09  |  3.3 KB  |  204 lines

  1. ;
  2. ;    MYZ80CLK.MAC
  3. ;
  4. ;    ZSDOS clock interface for use with MYZ80 emulator 
  5. ;    
  6. ;    Version 0.1 - 8/9/92 by Steven Hirsch
  7. ;
  8. ;    This is a quick hack to enable ZSDOS access to system time
  9. ;    and date under MYZ80 emulation.  Simeon Cran did a great job
  10. ;    on MYZ80 but is not forthcoming with technical information.  
  11. ;    Consider this code a quick "hack" only!  In particular, 
  12. ;    no validation checks are made to ensure that we are running 
  13. ;    in the MYZ80 environment.  Be careful!
  14. ;
  15. ;    Revisions:
  16. ;
  17. ;
  18. ;
  19. VER    EQU    1
  20. ;
  21. GETTIM    EQU    0fff9h        ;fixed entry-point for MYZ80 time and
  22.                 ;date call  
  23. ;
  24.     .Z80
  25. ;
  26.     COMMON    /_CLKID_/
  27. ;
  28.     DW      0        ;static year if needed
  29. CLKNAM:    DB    'MYZ80CLK'    
  30.                 ;name of clock driver
  31.     DS    CLKNAM+24-$,' '
  32.     DB    VER/10+'0', '.', VER MOD 10+'0'
  33.     DB    0
  34.     DEFB    'MYZ80 Clock Driver',0
  35. ;
  36. ;
  37.     COMMON    /_PARM_/
  38. ;
  39.     DW    0        ;no parms
  40.     DW    0
  41. ;
  42. ;
  43.     CSEG
  44. ;
  45. READ:    
  46.     PUSH    HL        ; save pointer to caller's buffer
  47.     LD    BC,buff3    ; grab pointer to our buffer
  48.     PUSH    BC        ; save it, too
  49.     CALL    GETTIM        ; read system date/time to buffer in
  50.                 ; CPM3/P2DOS format
  51. ;
  52.     POP    HL        ; our local buffer is source
  53.     POP    DE        ; system buffer is dest
  54.     CALL    P2UTIM        ; convert to ZS format in system buffer
  55.                 ; except for seconds
  56. ;
  57.     LD    A,(DE)        ; which we will save aside for the moment
  58.     LDI            ; now move new seconds to dest
  59.      DEC    DE        ; roll pointer back to caller buff+5
  60.     EX    DE,HL        ; and point HL to it per ZS docs
  61.     LD    E,A        ; old seconds in E per docs
  62. ;
  63.     LD    A,1        ; say we're ok
  64.     RET            
  65. ;
  66. buff3:    defb    0,0,0,0,0    ; receives CP/M-3 time/date
  67. ;
  68. ;
  69. ;    Apologies to Carson Wilson, et al, for my disassembly
  70. ;    of DSLIB.  The SETUPZST loader will not resolve library
  71. ;    references, so I needed to hard-code this.  A venerable
  72. ;    utility called ZRELMAC.COM was used to "decompile" the 
  73. ;    .REL image back to source code... 
  74. ;     
  75. P2UTIM:
  76.     PUSH    DE        
  77.     LD    E,(HL)        
  78.     INC    HL        
  79.     LD    D,(HL)        
  80.     INC    HL        
  81.     PUSH    HL        
  82.     LD    A,D        
  83.     OR    E        
  84.     LD    BC,00H
  85.     JR    Z,P2UTIM+065H
  86.     LD    HL,08EADH
  87.     SBC    HL,DE
  88.     JR    C,P2UTIM+065H
  89.     LD    BC,07BAH
  90.     EX    DE,HL        
  91.     LD    DE,016DH
  92.     CALL    @L0
  93.     JR    NZ,P2UTIM+021H
  94.     INC    DE        
  95.     OR    A        
  96.     SBC    HL,DE
  97.     JR    C,P2UTIM+02BH
  98.     JR    Z,P2UTIM+02BH
  99.     INC    BC        
  100.     JR    P2UTIM+018H
  101.     ADD    HL,DE        
  102.     LD    A,01H
  103.     LD    D,00H
  104.     PUSH    HL        
  105.     LD    HL,mtable
  106.     LD    E,(HL)        
  107.     CP    02H
  108.     CALL    Z,@L0
  109.     JR    NZ,P2UTIM+03DH
  110.     INC    E        
  111.     EX    (SP),HL        
  112.     OR    A        
  113.     SBC    HL,DE
  114.     JR    C,P2UTIM+04AH
  115.     JR    Z,P2UTIM+04AH
  116.     EX    (SP),HL        
  117.     INC    HL        
  118.     INC    A        
  119.     JR    P2UTIM+034H
  120.     ADD    HL,DE        
  121.     EX    (SP),HL        
  122.     POP    HL        
  123.     CALL    BIN2BC
  124.     LD    H,B        
  125.     LD    B,A        
  126.     LD    A,L        
  127.     LD    L,C        
  128.     CALL    BIN2BC
  129.     LD    C,A        
  130.     LD    DE,064H
  131.     OR    A        
  132.     SBC    HL,DE
  133.     JR    NC,P2UTIM+05BH
  134.     ADD    HL,DE        
  135.     LD    A,L        
  136.     CALL    BIN2BC
  137.     POP    DE        
  138.     POP    HL        
  139.     LD    (HL),A        
  140.     INC    HL        
  141.     LD    (HL),B        
  142.     INC    HL        
  143.     LD    (HL),C        
  144.     INC    HL        
  145.     EX    DE,HL        
  146.     LDI    
  147.     LDI    
  148.     XOR    A        
  149.     RET            
  150. @L0:
  151.     BIT    0,C
  152.     RET    NZ        
  153.     BIT    1,C
  154.     RET            
  155. mtable:
  156.     db    31
  157.     db    28
  158.     db    31
  159.     db    30
  160.     db    31
  161.     db    30
  162.     db    31
  163.     db    31
  164.     db    30
  165.     db    31
  166.     db    30
  167.     db    31
  168. ;
  169. ;
  170. BIN2BC:
  171.     PUSH    BC        
  172.     LD    B,0FFH
  173.     INC    B        
  174.     SUB    0AH
  175.     JR    NC,BIN2BC+03H
  176.     ADD    A,0AH
  177.     LD    C,A        
  178.     LD    A,B        
  179.     ADD    A,A        
  180.     ADD    A,A        
  181.     ADD    A,A        
  182.     ADD    A,A        
  183.     ADD    A,C        
  184.     POP    BC        
  185.     RET            
  186. ;
  187. ;
  188. ;
  189.     COMMON    /_POST_/
  190. ;
  191.     RET
  192. ;
  193. ;
  194.     COMMON    /_PRE_/
  195. ;
  196. PRETST:    JR    PRETST1
  197.     DW    PRETST
  198. PRETST1:
  199.     SCF                ; indicate ok
  200.     RET
  201. ;
  202. ;
  203.     END
  204.