home *** CD-ROM | disk | FTP | other *** search
/ High Voltage Shareware / high1.zip / high1 / DIR3 / LAPCLOCK.ZIP / BCLOCK.ASM next >
Assembly Source File  |  1993-07-20  |  4KB  |  79 lines

  1. ; Generic battery clock progam
  2. ;
  3.          codeseg     segment
  4.          assume      cs:codeseg, ds:codeseg
  5.          org    100h
  6. hbc      proc   far
  7. start:
  8.          jmp    short gotsr     ; go set ourselves up as TSR
  9. hour     dw     0               ; used to store total hours, yowza!
  10. minut    dw     0               ; used to store total minutes
  11. count    dw     0               ; used to store ticks within a minute
  12. istart:                         ; here on each int 08 in TSR mode
  13.          push   ax
  14.          push   bx
  15.          push   cx
  16.          push   dx
  17.          push   ds
  18.          mov    ds,cs           ; be sure we are in our own segment
  19.          mov    cx,[count]      ; get last tick count
  20.          add    cx,0001         ; increment by 1
  21.          mov    [count],cx      ; 18.20664 ticks/second  1092.398 ticks/min
  22.          cmp    cx,1093         ; is a minute up yet
  23.          jne    nuttin          ; no, so just get out of here
  24.          mov    cx,0            ; yes minute is up
  25.          mov    [count],cx      ; clear the tick count for last minute
  26.          mov    dx,[hour]       ; load up hour since we need it anyhow
  27.          mov    cx,[minut]      ; get the count of minutes elapsed
  28.          inc    cx              ; increment by one
  29.          cmp    cx,60           ; hour up yet?
  30.          jne    nohour          ; nope
  31.          inc    dx              ; increment the hour
  32.          mov    [hour],dx       ; save it
  33.          xor    cx,cx           ; zero register
  34. nohour:
  35.          mov    [minut],cx      ; save it
  36. ; Here is the display stuff.  It does direct writes to the b8 video segment.
  37.          mov    ax,0b800h       ; set up b8 segment
  38.          mov    ds,ax           ; put in data segment register
  39.          mov    ax,cx           ; pick up minute count
  40.          aam                    ; unpack to bcd
  41.          or     ax,3030h        ; mask it to ascii digits
  42.          mov    bl,ah           ; move to proper register
  43.          mov    bh,74h          ; character attribute, light color
  44.          mov    [009ch],bx      ; move to video buffer
  45.          mov    bl,al           ; move the other character
  46.          mov    [009eh],bx      ; send to buffer
  47.          mov    ax,dx           ; pick up hours
  48.          aam                    ; unpack binary to bcd
  49.          or     ax,3030h        ; mask bcd to ascii digits
  50.          mov    bl,al           ; to output register
  51.          mov    [0098h],bx      ; and put in screen buffer
  52.          mov    bl,0f9h         ; how about a bizarre separator
  53.          mov    [009ah],bx      ; put it on screen
  54. nuttin:                         ; now prepare to leave
  55.          pop    ds
  56.          pop    dx
  57.          pop    cx
  58.          pop    bx
  59.          pop    ax
  60. bozo:
  61.          jmp    0000:0000       ; go back up interrupt chain
  62. gotsr:                  ;on dos invocation we set up int 8 and go resident
  63.          push   ds              ; save the good stuff
  64.          xor    ax,ax           ; zero register
  65.          mov    ds,ax           ; set segment to 0
  66.          mov    ax,ds:20h       ; pick up current int 08
  67.          mov    dx,ds:22h
  68.          pop    ds              ; back to our own segment
  69.          mov    ds:bozo+1,ax    ; chain old interrupt
  70.          mov    ds:bozo+3,dx
  71.          lea    dx,istart       ; set up our own handler
  72.          mov    ax,2508h
  73.          int    21h
  74.          mov    dx,gotsr
  75.          int    27h             ; terminate and stay resident
  76. hbc      endp
  77.          codeseg     ends
  78.          end start
  79.