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 / PROGRAMS / CLOCKK / NO-SLOT.LBR / DT.Z80 < prev    next >
Text File  |  2000-06-30  |  3KB  |  149 lines

  1. ;
  2. ; This program is meant to display the no-slot clock time
  3. ; information in a simple but understandable format. (v1.1)
  4. ;                Andrew Sopchak 5/22/87
  5. ;
  6.     .hd64
  7. ;
  8.     .xlist
  9.     maclib    ports.lib
  10.     .list
  11. ;
  12. cr    equ    13
  13. lf    equ    10
  14.  
  15. highram    equ    02000h    ; RAM address for execution of access segment
  16.  
  17.     ext    eprint,cout    ; link with SYSLIB 3.x
  18.  
  19.     jp    start
  20.     org    highram        ; put rest of code in safe RAM area
  21. start:
  22.     ld    (stack),sp    ; save ccp stack
  23.     ld    sp,stack    ; set up local stack
  24.  
  25.     call    eprint
  26.     db    cr,lf,'DT v1.1 AMS 5/22/87',cr,lf,0
  27.     
  28.     ld    hl,(1)        ; get base bios address
  29.     ld    bc,60        ; offset to setlatch routine
  30.     add    hl,bc        ; address now in hl
  31.     ld    (setlatch+1),hl    ; store address for readclk
  32.  
  33.     call    readclk        ; get clock info
  34.     call    dumpclk        ; print out clock data
  35.  
  36.     ld    sp,(stack)    ; restore ccp stack
  37.     ret
  38.  
  39. dumpclk:
  40.     ld    a,(buf+6)    ; month
  41.     ld    c,'/'
  42.     call    dobyte
  43.     ld    a,(buf+5)    ; date
  44.     call    dobyte
  45.     ld    a,(buf+7)    ; year
  46.     ld    c,' '
  47.     call    dobyte
  48.     ld    a,(buf+3)    ; hours (24 hour format)
  49.     ld    c,':'
  50.     call    dobyte
  51.     ld    a,(buf+2)    ; minutes
  52.     call    dobyte
  53.     ld    a,(buf+1)    ; seconds
  54.     ld    c,'.'
  55.     call    dobyte
  56.     ld    a,(buf)        ; fractional seconds (just for fun)
  57.     ld    c,'|'
  58.     call    dobyte
  59.     ld    a,(buf+4)    ; day of week (also for fun)
  60.     ld    c,' '
  61.     call    dobyte
  62.     ret            ; and we're done
  63.     
  64. dobyte:
  65.     ld    b,a
  66.     and    11110000b
  67.     srl    a        ; move to lower nibble
  68.     srl    a
  69.     srl    a
  70.     srl    a
  71.     add    a,'0'        ; convert to ascii
  72.     call    cout
  73.     ld    a,b
  74.     and    00001111b
  75.     add    a,'0'
  76.     call    cout
  77.     ld    a,c        ; get separator character
  78.     call    cout
  79.     ret
  80.  
  81. readclk:
  82.     di            ; don't bother me
  83.     in0    a,(cbar)    ; save old value
  84.     ld    (oldcbar),a
  85.     ld    a,0
  86.     call    setlatch
  87.     ld    (oldlatch),bc    ; save old value
  88.     ld    a,b        ; load latch1 to a
  89.     res    3,a        ; point to ROM
  90.     ld    b,a
  91.     ld    a,0ffh        ; set values for latch
  92.     call    setlatch    ; now we are pointing to ROM
  93.     ld    a,081h        ; set MMU for 4k common area 0
  94.     out0    (cbar),a
  95.     
  96. ; This section turns on the clock by writing the 8 bytes
  97. ; in the comparison register of the clock
  98.     ld    a,(4)        ; reset clock comparator
  99.     ld    hl,compreg    ; point to bit stream
  100.     ld    a,(hl)        ; get first byte
  101. nxtbyt    ld    b,a        ; b contains byte
  102.     ld    c,8        ; do this for 8 bits
  103. nxtbit    srl    b        ; 0->b7...b0->cy
  104.     jr    c,wr1bit
  105. wr0bit    ld    a,(0)        ; write a 0 bit
  106.     jr    skip
  107. wr1bit    ld    a,(1)        ; write a 1 bit
  108. skip    dec    c
  109.     jr    nz,nxtbit    ; do all 8 bits
  110.     inc    hl        ; point to next byte
  111.     ld    a,(hl)        ; get next byte
  112.     or    a        ; set zero flag
  113.     jr    nz,nxtbyt    ; go do next byte
  114.     
  115. ; This section will read in all 8 bytes of the clock
  116.     ld    hl,buf        ; set up buffer
  117.     ld    e,8        ; do 8 bytes
  118. rdbyt    ld    d,8        ; do 8 bits
  119. rdbit    ld    a,(4)        ; get bit in b0
  120.     srl    a        ; shift bit into cy
  121.     rr    (hl)        ; shift bit into (hl)
  122.     dec    d        ; dec bit counter
  123.     jr    nz,rdbit    ; read next bit
  124.     inc    hl        ; point to next buf location
  125.     dec    e        ; dec byte counter
  126.     jr    nz,rdbyt    ; read next byte
  127.  
  128. ; We are all done reading, so restore values and return
  129.     ld    bc,(oldlatch)    ; restore old latch values
  130.     ld    a,0ffh
  131.     call    setlatch
  132.     ld    a,(oldcbar)    ; restore old CBAR values
  133.     out0    (cbar),a
  134.     ei            ; I can be bothered now
  135.     ret
  136.  
  137. ; data storage and values
  138. compreg        db    0c5h,3ah,0a3h,5ch    ; comparison reg
  139.         db    0c5h,3ah,0a3h,5ch,0    ; definition
  140. buf        ds    8    ; place to store data
  141. oldcbar        ds    1    ; old CBAR
  142. oldlatch    ds    2    ; temp save of current latch settings
  143. setlatch    jp    0000h    ; address of BIOS setlatch routine
  144.  
  145.     ds    64        ; local stack
  146. stack    ds    2
  147.  
  148.     end
  149.