home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / cpm / cb80 / cbtod.aqm / CBTOD.ASM
Encoding:
Assembly Source File  |  1985-02-09  |  2.6 KB  |  184 lines

  1. ; CB80 CBTOD routine, fixed for seconds and for CP/M plus
  2. ;
  3. ; The original CBTOD routine in CB80 version 2.0 has a number of
  4. ; bugs:
  5. ; 1. BDOS function 155 is used instead of 105. 155 does not exist.
  6. ; 2. The routine, after changing to BDOS call 105, will only work
  7. ;    with MP/M, not with CP/M plus.
  8. ; 3. the TIME$ function returns HHMM00 instead of HHMMSS.
  9. ;
  10. ; This file CBTOD.ASM fixes all of the above problems. It has not been
  11. ; officially blessed by DRI and application of this file to your copy
  12. ; of CB80 is at your own risk!
  13. ;
  14. ; HOW TO:
  15. ; 1. Use RMAC or M80 to assemble CBTOD.ASM into CBTOD.REL
  16. ; 2. rename your existing CB80.IRL library to something different,
  17. ;    such as OLIB.IRL (preserve the .IRL type)
  18. ; 3. Use LIB as follows: LIB CB80[I]=OLIB.IRL<CBTOD>
  19. ; 4. Enjoy the DATE$ and TIME$ functions in CP/M plus.
  20. ;
  21. ; NOTE NOTE NOTE
  22. ; TO STRESS AGAIN, THIS CODE HAS NOT BEEN AUTHORIZED BY DRI AND WILL
  23. ; WORK WITH CB80 VERSION 2.0 ONLY!!!
  24. ;
  25. ; The original code below has been reconstructed with LIB.COM
  26. ;
  27.     public    ?time,?date
  28.     extrn    ?gets
  29. ;
  30. ?time:    call    p0093
  31.     lxi    b,3003h
  32.     mvi    d,0fh
  33.     lxi    h,d0002
  34. p000b:    mov    a,m
  35.     xthl
  36.     mov    e,a
  37.     rrc
  38.     rrc
  39.     rrc
  40.     rrc
  41.     ana    d
  42.     ora    b
  43.     mov    m,a
  44.     inx    h
  45.     mov    a,e
  46.     ana    d
  47.     ora    b
  48.     mov    m,a
  49.     inx    h
  50.     xthl
  51.     inx    h
  52.     dcr    c
  53.     jnz    p000b
  54.     pop    h
  55.     pop    h
  56.     ret
  57. ;
  58. ?date:    call    p0093
  59.     mvi    a,44h
  60.     push    psw
  61.     mvi    h,4dh
  62.     push    h
  63. p002d:    pop    d
  64.     pop    psw
  65.     rrc
  66.     push    psw
  67.     mvi    a,1ch
  68.     aci    0
  69.     sta    p0087+1
  70.     inr    d
  71.     push    d
  72.     mvi    c,0ch
  73.     lxi    d,p0087
  74.     lhld    d0000
  75. p0042:    xchg
  76.     mov    a,e
  77.     sub    m
  78.     mov    e,a
  79.     mov    a,d
  80.     sbi    0
  81.     jm    p005d
  82.     mov    d,a
  83.     ora    e
  84.     jz    p005d
  85.     inx    h
  86.     xchg
  87.     shld    d0000
  88.     dcr    c
  89.     jnz    p0042
  90.     jmp    p002d
  91. ;
  92. p005d:    pop    d
  93.     pop    psw
  94.     pop    h
  95.     lda    d0000
  96.     push    psw
  97.     mvi    a,13
  98.     sub    c
  99.     push    psw
  100.     push    d
  101.     mvi    b,10
  102.     mvi    c,3
  103. p006d:    pop    psw
  104.     mvi    d,-1
  105. p0070:    sub    b
  106.     inr    d
  107.     jnc    p0070
  108.     add    b
  109.     mov    e,a
  110.     mov    a,d
  111.     ori    '0'
  112.     mov    m,a
  113.     inx    h
  114.     mov    a,e
  115.     ori    '0'
  116.     mov    m,a
  117.     inx    h
  118.     dcr    c
  119.     jnz    p006d
  120.     pop    h
  121.     ret
  122. ;
  123. p0087:    db    1fh
  124.     ds    1
  125. ;
  126.     db    1fh,1eh,1fh,1eh,1fh
  127.     db    1fh,1eh,1fh,1eh,1fh
  128. ;
  129. p0093:    lxi    h,8
  130.     call    ?gets
  131.     pop    d
  132.     push    h
  133.     mvi    m,80h
  134.     inx    h
  135.     mvi    m,6
  136.     inx    h
  137.     push    h
  138.     push    d
  139.     mvi    c,12
  140.     call    5
  141.     mov    a,h
  142.     ani    5
  143.     jnz    dotim
  144.     mov    a,l
  145.     cpi    30h        ;cp/m plus?
  146.     jc    p00b6        ;no, skip
  147. dotim:    mvi    c,69h        ;mp/m time/date call
  148.     lxi    d,d0000
  149.     call    5
  150.     sta    d0004
  151.     ret
  152. ;
  153. p00b6:    pop    psw
  154.     pop    d
  155.     mvi    c,6
  156.     mvi    a,' '        ;filler for no time call
  157. p00bc:    stax    d
  158.     inx    d
  159.     dcr    c
  160.     jnz    p00bc
  161.     pop    h
  162.     ret
  163. ;
  164.     dseg
  165. ;
  166. d0000:    ds    2
  167. d0002:    ds    1
  168. d0003:    ds    1
  169. d0004:    ds    1
  170.     end
  171. ov    a,e
  172.     sub    m
  173.     mov    e,a
  174.     mov    a,d
  175.     sbi    0
  176.     jm    p005d
  177.     mov    d,a
  178.     ora    e
  179.     jz    p005d
  180.     inx    h
  181.     xchg
  182.     shld    d0000
  183.     dcr    c
  184.