home *** CD-ROM | disk | FTP | other *** search
/ Oakland CPM Archive / oakcpm.iso / sigm / vol130 / tmodsci.mac < prev    next >
Encoding:
Text File  |  1984-04-29  |  4.5 KB  |  236 lines

  1.     name    ('tmod')
  2. ;    version 2.1    
  3. ;    ss1    dick lieber    rcl
  4.  
  5. ;    modified for scitronics clock board 7/9/82
  6. ;    by Jim Mills
  7. ;    ---->set "scip0" (below) to scitronics base address
  8.  
  9. ;
  10. ;    to assemble, type:    M80 TMOD,TMOD=TMOD
  11. ;    to link, type:        L80 TMODTEST,TMOD,TMODTEST/N/E
  12. ;    to run, type:        TMODTEST
  13. ;    it is self-prompting
  14. ;
  15.  
  16. bdos    equ    5
  17. wrcon    equ    2
  18. wrbuf    equ    9
  19.  
  20. entry    timemd,datemd,daymd
  21.  
  22. timemd:    jmp    gettime
  23. datemd:    jmp    getdate
  24. daymd:    jmp    getdow
  25.  
  26. gettime:
  27.     call    readclk        ;do actual read and store it
  28.     call    findstring    ;point to where calling prog wants data
  29.     lxi    d,tbuffer    ;point to our data
  30.     call    move        ;and move the data
  31.     call    endstring    ;and send a '$'
  32.     ret
  33. getdate:
  34.     call    readclk        ;do actual read and store it
  35.     call    findstring    ;point to where calling prog wants data
  36.     lxi    d,dbuffer    ;point to our data
  37.     call    move        ;and move the data
  38.     call    endstring
  39.     ret
  40. ;
  41. ; get day of week: 1. read dow from clock
  42. ;           2. point to appropriate section of table & send it
  43. ;
  44. getdow:
  45.     call    cinit        ;stop clock
  46.     mvi    a,6        ;day of week function
  47.     out    scip0        ;ask for it
  48.  
  49.     nop            ;delay for clock to settle
  50.     nop
  51.     nop
  52.     nop
  53.  
  54.     in    scip0        ;get dow
  55.     rar            ;rotate..
  56.     rar            ;..to swap..
  57.     rar            ;..the nibbles..
  58.     rar            ;..to get our DOW
  59. passb:    ani    0fh        ;strip off high bits
  60.     sta    dow        ;store it
  61.     call    ccont        ;start clock
  62. ;
  63. ; now point to table and send text to caller
  64. ;
  65.     call    findstring    ;target string area
  66.     push    h        ;save addr
  67.      xra    a        ;zero
  68.      mov    b,a        ;'B' must be zero
  69.      lxi    h,dowtable    ;point to address lookup table
  70.      lda    dow        ;offset
  71.      mov    c,a        ;put dow in BC..
  72.      dad    b        ;..and add to HL to get offset..
  73.      dad    b        ;..into table of DW's
  74.      mov    e,m        ;get lo byte of addr into DE
  75.      inx    h        ;bump pointer
  76.      mov    d,m        ;get hi byte of addr into DE
  77.     pop    h        ;target data addr into HL
  78.     jmp    move        ;move (DE) --> (HL)
  79. ;
  80. ;    process passed parameter    (passed to us from caller)
  81. ;    makes hl point to passed string (in caller's area)
  82. ;
  83. findstring:
  84.     inx    h    ;past length - assumed to be 9
  85.     mov    e,m
  86.     inx    h    ;get address of passed string into de
  87.     mov    d,m
  88.     xchg        ;now in HL
  89.     ret
  90. ;
  91. ;    move data from (de) to (hl)
  92. ;
  93. move:    ldax    d    ;get a byte from our table
  94.     ora    a    ;set flags, is it end-of-table mark?
  95.     rz        ;done, return
  96.     mov    m,a    ;else store byte to caller prog data area, then..
  97.     inx    d    ;..bump..
  98.     inx    h    ;..pointers..
  99.     jmp    move    ;..and loop
  100. ;
  101. ; send a '$' to the address specified by HL
  102. ;
  103. endstring:
  104.     mvi    a,'$'    ;string terminator..
  105.     mov    m,a    ;..to caller's string space
  106.     ret
  107. ;
  108. ;TIME READ FOR SCITRONICS CLOCK
  109. ;02/18/81 BY WARD CHRISTENSEN
  110. ;
  111. scip0    equ    018h
  112. SCIP1    EQU    SCIP0+1
  113. SCIP2    EQU    SCIP1+2
  114. SCIP3    EQU    SCIP0+3
  115. ;
  116. READCLK:
  117.     PUSH    B
  118.     PUSH    D
  119.     PUSH    H
  120.     LXI    H,BUFFER    ;POINT TO BUFFER
  121.     SHLD    BUFPTR        ;POINT TO FIRST CHAR
  122.     CALL    CINIT        ;INIT THE CLOCK
  123.     CALL    CREAD        ;READ THE CLOCK
  124.     CALL    CCONT        ;TELL THE CLOCK TO CONTINUE
  125.     POP    H
  126.     POP    D
  127.     POP    B
  128.     ret            ;with data in buffers
  129.  
  130. ;
  131. ;====>    CINIT    INITIALIZES THE CLOCK:
  132. ;        1.    INIT THE P.I.A.
  133. ;        2.    HOLD THE CLOCK
  134. ;
  135. CINIT:
  136.     MVI    A,0F0H
  137.     OUT    SCIP1
  138.     MVI    A,0FH
  139.     OUT    SCIP0
  140.     MVI    A,0FCH
  141.     OUT    SCIP3
  142.     MVI    A,0F4H
  143.     OUT    SCIP1
  144.     RET
  145. ;
  146. ;====>    CREAD    CLOCK READ ROUTINE, INTO M(HL)
  147. ;        SETS (D) TO THE DIGIT SELECT,
  148. ;        AND (E) WITH THE DELIMITER (/ OR :)
  149. ;
  150. CREAD:
  151.     LXI    D,256*10+'/'
  152.     CALL    CLOCK        ;'MM/'
  153.     CALL    CLOCK        ;'DD/'
  154.     LXI    D,256*12+' '
  155.     mvi    e,0        ;maintain 'db 0'
  156.     CALL    CLOCK        ;'YY '
  157.     LXI    D,256*5+':'
  158.     CALL    CLOCK        ;'HH:'
  159.     CALL    CLOCK        ;'MM:'
  160.     MVI    E,0
  161.     JMP    CLOCK        ;'SS',0
  162. ;
  163. ;====>    CLOCK:    READS 2 DIGITS, STORES IN MEMORY
  164. ;        INITIAL DIGIT IS IN D, DELIM IN E.
  165. ;
  166. CLOCK:
  167.     CALL    DIGIT        ;READ, STORE 1 DIGIT
  168.     CALL    DIGIT        ;READ, STORE 2ND DIGIT
  169.     MOV    M,E        ;STORE DELIM (/ OR :)
  170.     INX    H        ;SKIP DELIM
  171.     RET
  172. ;
  173. ;====>    DIGIT:    GETS A SINGLE DIGIT FROM THE CLOCK TO MEMORY
  174. ;        BASED ON THE SELECT VALUE IN (D)
  175. ;
  176. DIGIT:
  177.     MOV    A,D    ;GET DIGIT SELECT
  178.     DCR    D    ;SETUP FOR NEXT DIGIT
  179.     OUT    SCIP0    ;ASK FOR IT
  180.     CPI    5    ;HOURS (HAVE TO MASK)?
  181.     IN    SCIP0    ;READ IT (PRESERVES CPI 5 TEST)
  182.     JNZ    DIGNH    ;    NOT DIGIT 5, SKIP MASKING
  183.     ANI    70H    ;    KILL HI DIGIT
  184. DIGNH:
  185.     RAR
  186.     RAR
  187.     RAR
  188.     RAR    ;SHIFT THE DIGIT RIGHT 4
  189.     ANI    0FH    ;ISOLATE NUMERIC VALUE
  190.     ADI    '0'    ;MAKE PRINTABLE
  191.     MOV    M,A    ;STORE I
  192.     INX    H    ;BUMP TO NEXT
  193.     RET        ;    AND RETURN
  194. ;
  195. ;====>    CCONT    CONTINUE CLOCK, DISABLE P.I.A.
  196. ;
  197. CCONT:
  198.     MVI    A,0F8H
  199.     OUT    SCIP1
  200.     MVI    A,0FH
  201.     OUT    SCIP0
  202.     MVI    A,0F8H
  203.     OUT    SCIP3
  204.     MVI    A,0FCH
  205.     OUT    SCIP1
  206.     MVI    A,0FH
  207.     OUT    SCIP0
  208.     RET        ;END OF CLOCK ROUTINES
  209. BUFPTR:
  210.     DW    0
  211. BUFFER:
  212. DBUFFER:    ;date buffer
  213.     DB    'MM/DD/YY',0
  214. TBUFFER:    ;time buffer
  215.     DB    'HH:MM:SS',0
  216. DOW:    DB    0        ;used for day of week index
  217. ;
  218. ;    day of week table
  219. ;
  220. dowtable:
  221.     dw    sun
  222.     dw    mon
  223.     dw    tues
  224.     dw    wed
  225.     dw    thurs
  226.     dw    fri
  227.     dw    sat
  228. sun:    db    'Sunday$',0
  229. mon:    db    'Monday$',0
  230. tues:    db    'Tuesday$',0
  231. wed:    db    'Wednesday$',0
  232. thurs:    db    'Thursday$',0
  233. fri:    db    'Friday$',0
  234. sat:    db    'Saturday$',0
  235.     end
  236.