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 / TURBODSG / CBTOD.ASM < prev    next >
Assembly Source File  |  2000-06-30  |  3KB  |  188 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. ; get the time and convert it to HHMMSS
  31. ;
  32. ?time:    call    p0093
  33.     lxi    b,3003h        ;b='0', c=byte counter
  34.     mvi    d,0fh        ;mask
  35.     lxi    h,d0002        ;.data
  36. p000b:    mov    a,m        ;get byte
  37.     xthl            ;save .data, get .destination
  38.     mov    e,a        ;save data byte
  39.     rrc            ;get high nybble...
  40.     rrc            ;...into low nybble
  41.     rrc
  42.     rrc
  43.     ana    d        ;mask out low nybble
  44.     ora    b        ;make ASCII
  45.     mov    m,a        ;store ASCII character
  46.     inx    h        ;point to next .dest
  47.     mov    a,e        ;get byte
  48.     ana    d        ;isolate low nybble
  49.     ora    b        ;make ASCII
  50.     mov    m,a        ;save it too
  51.     inx    h        ;increment .dest
  52.     xthl            ;save .dest, get .data
  53.     inx    h        ;point to next data byte
  54.     dcr    c        ;all 3 done?
  55.     jnz    p000b        ;no, repeat
  56.     pop    h        ;munch up parameters
  57.     pop    h
  58.     ret
  59. ;
  60. ; get the date and convert it to YYMMDD
  61. ;
  62. ?date:    call    p0093
  63.     mvi    a,44h
  64.     push    psw
  65.     mvi    h,4dh
  66.     push    h
  67. p002d:    pop    d
  68.     pop    psw
  69.     rrc
  70.     push    psw
  71.     mvi    a,1ch
  72.     aci    0
  73.     sta    p0087+1
  74.     inr    d
  75.     push    d
  76.     mvi    c,0ch
  77.     lxi    d,p0087
  78.     lhld    d0000
  79. p0042:    xchg
  80.     mov    a,e
  81.     sub    m
  82.     mov    e,a
  83.     mov    a,d
  84.     sbi    0
  85.     jm    p005d
  86.     mov    d,a
  87.     ora    e
  88.     jz    p005d
  89.     inx    h
  90.     xchg
  91.     shld    d0000
  92.     dcr    c
  93.     jnz    p0042
  94.     jmp    p002d
  95. ;
  96. p005d:    pop    d
  97.     pop    psw
  98.     pop    h
  99.     lda    d0000
  100.     push    psw
  101.     mvi    a,13
  102.     sub    c
  103.     push    psw
  104.     push    d
  105.     mvi    b,10
  106.     mvi    c,3
  107. p006d:    pop    psw
  108.     mvi    d,-1
  109. p0070:    sub    b
  110.     inr    d
  111.     jnc    p0070
  112.     add    b
  113.     mov    e,a
  114.     mov    a,d
  115.     ori    '0'
  116.     mov    m,a
  117.     inx    h
  118.     mov    a,e
  119.     ori    '0'
  120.     mov    m,a
  121.     inx    h
  122.     dcr    c
  123.     jnz    p006d
  124.     pop    h
  125.     ret
  126. ;
  127. ; This is the days table for the year. each entry is one month,
  128. ; with february being computed by the program.
  129. ;
  130. p0087:    db    1fh
  131.     ds    1
  132.     db    1fh,1eh,1fh,1eh,1fh
  133.     db    1fh,1eh,1fh,1eh,1fh
  134. ;
  135. p0093:    lxi    h,8
  136.     call    ?gets        ;get buffer pointer in string fmt in HL
  137.     pop    d
  138.     push    h
  139.     mvi    m,80h
  140.     inx    h
  141.     mvi    m,6
  142.     inx    h
  143.     push    h
  144.     push    d
  145.     mvi    c,12
  146.     call    5
  147.     mov    a,h
  148.     ani    5
  149.     jnz    dotim
  150.     mov    a,l
  151.     cpi    30h        ;cp/m plus?
  152.     jc    p00b6        ;no, skip
  153. dotim:    mvi    c,69h        ;mp/m time/date call
  154.     lxi    d,d0000
  155.     call    5
  156.     sta    d0004
  157.     ret
  158. ;
  159. p00b6:    pop    psw
  160.     pop    d
  161.     mvi    c,6
  162.     mvi    a,' '        ;filler for no time call
  163. p00bc:    stax    d
  164.     inx    d
  165.     dcr    c
  166.     jnz    p00bc
  167.     pop    h
  168.     ret
  169. ;
  170.     dseg
  171. ;
  172. d0000:    ds    2
  173. d0002:    ds    1
  174. d0003:    ds    1
  175. d0004:    ds    1
  176.     end
  177. pop    d
  178.     pop    psw
  179.     pop    h
  180.     lda    d0000
  181.     push    psw
  182.     mvi    a,13
  183.     sub    c
  184.     push    psw
  185.     push    d
  186.     mvi    b,10
  187.     mvi    c,3
  188. p006d:    po