home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / enterprs / c128 / text / examples.arc / TIME.A < prev    next >
Text File  |  1989-12-01  |  6KB  |  154 lines

  1. ; time.asm
  2. ;================================================================
  3. ; Display/Set time for CS-DOS                       12feb88 - CS
  4. ;================================================================
  5. ; Uses time of day clock at $DC08
  6.                                   
  7. hours       = $dc0b               ; latch
  8. mins        = $dc0a               
  9. secs        = $dc09               
  10. tenths      = $dc08               ; start
  11.                                   
  12. int04       = $1704               
  13. int05       = $1705               
  14. int0e       = $170e               
  15.                                   
  16. primm       = $ff7d               
  17. chrout      = $ffd2               
  18.                                   
  19. star        = $0b00               
  20.             .wor  star            
  21.             * = star
  22.  
  23.             jmp start
  24.             dw  Date
  25.                                   
  26. start       lda #0
  27.             sta $ff00             
  28. time        ldx #1                ; check for %1
  29.             jsr int04             
  30.             bcc stime             ; its there. Set time
  31. pt          jsr ptime             ; Else display time
  32.             lda #13               
  33.             jsr chrout            
  34. exit0       lda #0                
  35.             jmp int0e             
  36.                                   
  37. ptime       lda hours             ; Display hh:mm:ss.t
  38.             lda hours             
  39.             sta h                 
  40.             and #$7f              
  41.             jsr p0                
  42.             lda mins              
  43.             jsr p0                
  44.             lda secs              
  45.             jsr p1                
  46.             lda #"."              
  47.             jsr chrout            
  48.             lda tenths            
  49.             jsr p2                
  50.             bit h                 
  51.             bmi pm                
  52.             lda #"a"              
  53.             .byt $2c              
  54. pm          lda #"p"              
  55.             jsr chrout            
  56.             lda #"m"              
  57.             jmp chrout            
  58.                                   
  59. p1          pha                   
  60.             and #$f0              
  61.             lsr a                 
  62.             lsr a                 
  63.             lsr a                 
  64.             lsr a                 
  65.             ora #$30              
  66.             jsr chrout            
  67.             pla                   
  68. p2          and #$0f              
  69.             ora #$30              
  70.             jmp chrout            
  71.                                   
  72. p0          jsr p1                
  73.             lda #":"              
  74.             jmp chrout            
  75.                                   
  76. jpt         jmp pt                
  77.                                   
  78. ;----------------------------
  79. ; Set time from command line
  80. ;----------------------------
  81. ; time hh:mm:ss
  82. ; time hhmmss
  83. ; time hh-mm-ss
  84.                                   
  85. stime       pha                   ; save 1st char
  86.             lda #0                ; Reset time
  87.             sta h                 
  88.             sta m                 
  89.             sta s                 
  90.             sta t                 
  91.             pla                   
  92.             ldx #3                ; assume hours
  93.             ldy #1                ; two digits max
  94. sd          cmp #"."              ; Tenths?
  95.             beq st                
  96.             cmp #":"              
  97.             beq skip              
  98.             cmp #"-"              
  99.             beq skip              
  100. mp          cmp #"p"              
  101.             beq spm               
  102.             cmp #"0"              ; Error, ignore
  103.             bcc jpt               
  104.             cmp #"9"+1            
  105.             bcs jpt               
  106.             and #$0f              
  107.             asl a                 
  108.             asl a                 
  109.             asl a                 
  110.             asl a                 
  111.             asl a                 
  112.             rol t,x               
  113.             asl a                 
  114.             rol t,x               
  115.             asl a                 
  116.             rol t,x               
  117.             asl a                 
  118.             rol t,x               
  119.             .byt $2c              
  120. st          ldx #0                
  121.             dey                   
  122.             bmi skip              
  123. more        jsr int05             
  124.             bcc sd                
  125. stt         ldy #3                
  126. sl          lda t,y               
  127.             sta tenths,y          
  128.             dey                   
  129.             bpl sl                
  130.             jmp pt                
  131.                                   
  132. skip        ldy #1                
  133.             dex                   
  134.             bmi stt               
  135.             jsr int05             
  136.             bcs stt               
  137.             cmp #"0"              
  138.             bcs mp                
  139.             cmp #"."              
  140.             beq st                
  141.             bne more              
  142.                                   
  143. t           .byt 0                
  144. s           .byt 0                
  145. m           .byt 0                
  146. h           .byt 0                
  147.                                   
  148. spm         lda h                 
  149.             ora #$80              
  150.             sta h                 
  151.             jmp stt               
  152.                                   
  153.             .end                  
  154.