home *** CD-ROM | disk | FTP | other *** search
/ High Voltage Shareware / high1.zip / high1 / DIR3 / LAPCLOCK.ZIP / HBC.ASM < prev    next >
Assembly Source File  |  1993-07-21  |  5KB  |  109 lines

  1. ;Battery clock program for the GATEWAY HANDBOOK ONLY!
  2. ;DO NOT USE ON ANOTHER MACHINE!  I am NOT responsible if you trash
  3. ;your setup information!
  4. ;YOU HAVE BEEN WARNED!
  5.  
  6.          codeseg     segment
  7.          assume      cs:codeseg, ds:codeseg
  8.          org    100h
  9. hbc      proc   far
  10. start:
  11.          jmp    gotsr           ; go set ourselves up as TSR
  12. count    dw     0               ; used to store ticks within a minute
  13. istart:                         ; here on each int 08 in TSR mode
  14.          push   ax
  15.          push   bx
  16.          push   cx
  17.          push   dx
  18.          push   ds
  19.          mov    ds,cs           ; be sure we are in our own segment
  20.          mov    cx,[count]      ; get last tick count
  21.          add    cx,0001         ; increment by 1
  22.          mov    [count],cx      ; 18.20664 ticks/second  1092.398 ticks/min
  23.          cmp    cx,1093         ; is a minute up yet
  24.          je     dosome          ; yes do some work
  25. nuttin:                         ; now prepare to leave
  26.          pop    ds
  27.          pop    dx
  28.          pop    cx
  29.          pop    bx
  30.          pop    ax
  31. bozo:
  32.          jmp    0000:0000       ; go back up interrupt chain
  33. dosome:
  34.          xor    cx,cx           ; yes minute is up
  35.          mov    [count],cx      ; clear the tick count for last minute
  36.          mov    al,3eh          ; where we keep hour in cmos
  37.          out    70h,al          ; send address to port
  38.          in     al,71h          ; pick up the hour
  39.          mov    dl,al           ; load up hour since we need it anyhow
  40.          mov    al,3fh          ; where we keep minutes in cmos
  41.          out    70h,al          ; send address to port
  42.          in     al,71h          ; pick up minutes
  43.          mov    cl,al           ; get the count of minutes elapsed
  44.          push   ds              ; save data segment
  45.          mov    ds,0F000        ; point to BIOS
  46.          mov    al,[0160ah]     ; pick up power pointer
  47.          pop    ds              ; gimme back my segment
  48.          cmp    al,80h          ; is it AC power
  49.          je     acpower         ; yup, different strokes
  50.          inc    cl              ; battery power so increment by one
  51.          cmp    cl,60           ; hour up yet?
  52.          jne    nohour          ; nope
  53.          inc    dl              ; increment the hour
  54.          xor    cl,cl           ; zero register for minutes
  55.          jmp    short sendhour  ; go send it out
  56. acpower:
  57.          dec    cl              ; deduct a minute
  58.          cmp    cl,0ff          ; gone negative?
  59.          jne    nohour          ; nah
  60.          mov    cl,59           ; roll to 59 minutes
  61.          dec    dl              ; down an hour
  62.          cmp    dl,0ff          ; gone negative hours?
  63.          jne    sendhour        ; no problem dude
  64.          jmp    short nuttin    ; yes, don't display any longer!
  65. sendhour:                       ;
  66.          mov    al,3eh          ; set up port address
  67.          out    70h,al          ; send it out
  68.          mov    al,dl           ; the hour
  69.          out    71h,al          ; tuck away in cmos
  70. nohour:
  71.          mov    al,3fh          ; where we keep minutes in cmos
  72.          out    70h,al          ; send address to port
  73.          mov    al,cl           ; prepare minutes
  74.          out    71h,al          ; save in cmos
  75. ; Here is the display stuff.  It does direct writes to the b8 video segment.
  76.          mov    ds,0b800h       ; set up b8 segment
  77.          aam                    ; unpack minutes (already there) to bcd
  78.          or     ax,3030h        ; mask it to ascii digits
  79.          mov    bl,ah           ; move to proper register
  80.          mov    bh,74h          ; character attribute, light color
  81.          mov    [009ch],bx      ; move to video buffer
  82.          mov    bl,al           ; move the other character
  83.          mov    [009eh],bx      ; send to buffer
  84.          mov    al,dl           ; pick up hours
  85.          aam                    ; unpack binary to bcd
  86.          or     ax,3030h        ; mask bcd to ascii digits
  87.          mov    bl,al           ; to output register
  88.          mov    [0098h],bx      ; and put in screen buffer
  89.          mov    bl,0f9h         ; how about a bizarre separator
  90.          mov    [009ah],bx      ; put it on screen
  91.          jmp    short nuttin    ; get outta heah
  92. gotsr:                  ;on dos invocation we set up int 8 and go resident
  93.          push   ds              ; save the good stuff
  94.          xor    ax,ax           ; zero register
  95.          mov    ds,ax           ; set segment to 0
  96.          mov    ax,ds:20h       ; pick up current int 08
  97.          mov    dx,ds:22h
  98.          pop    ds              ; back to our own segment
  99.          mov    ds:bozo+1,ax    ; chain old interrupt
  100.          mov    ds:bozo+3,dx
  101.          lea    dx,istart       ; set up our own handler
  102.          mov    ax,2508h
  103.          int    21h
  104.          mov    dx,gotsr
  105.          int    27h             ; terminate and stay resident
  106. hbc      endp
  107.          codeseg     ends
  108.          end start
  109.