home *** CD-ROM | disk | FTP | other *** search
- ;Battery clock program for the GATEWAY HANDBOOK ONLY!
- ;DO NOT USE ON ANOTHER MACHINE! I am NOT responsible if you trash
- ;your setup information!
- ;YOU HAVE BEEN WARNED!
-
- codeseg segment
- assume cs:codeseg, ds:codeseg
- org 100h
- hbc proc far
- start:
- jmp gotsr ; go set ourselves up as TSR
- count dw 0 ; used to store ticks within a minute
- istart: ; here on each int 08 in TSR mode
- push ax
- push bx
- push cx
- push dx
- push ds
- mov ds,cs ; be sure we are in our own segment
- mov cx,[count] ; get last tick count
- add cx,0001 ; increment by 1
- mov [count],cx ; 18.20664 ticks/second 1092.398 ticks/min
- cmp cx,1093 ; is a minute up yet
- je dosome ; yes do some work
- nuttin: ; now prepare to leave
- pop ds
- pop dx
- pop cx
- pop bx
- pop ax
- bozo:
- jmp 0000:0000 ; go back up interrupt chain
- dosome:
- xor cx,cx ; yes minute is up
- mov [count],cx ; clear the tick count for last minute
- mov al,3eh ; where we keep hour in cmos
- out 70h,al ; send address to port
- in al,71h ; pick up the hour
- mov dl,al ; load up hour since we need it anyhow
- mov al,3fh ; where we keep minutes in cmos
- out 70h,al ; send address to port
- in al,71h ; pick up minutes
- mov cl,al ; get the count of minutes elapsed
- push ds ; save data segment
- mov ds,0F000 ; point to BIOS
- mov al,[0160ah] ; pick up power pointer
- pop ds ; gimme back my segment
- cmp al,80h ; is it AC power
- je acpower ; yup, different strokes
- inc cl ; battery power so increment by one
- cmp cl,60 ; hour up yet?
- jne nohour ; nope
- inc dl ; increment the hour
- xor cl,cl ; zero register for minutes
- jmp short sendhour ; go send it out
- acpower:
- dec cl ; deduct a minute
- cmp cl,0ff ; gone negative?
- jne nohour ; nah
- mov cl,59 ; roll to 59 minutes
- dec dl ; down an hour
- cmp dl,0ff ; gone negative hours?
- jne sendhour ; no problem dude
- jmp short nuttin ; yes, don't display any longer!
- sendhour: ;
- mov al,3eh ; set up port address
- out 70h,al ; send it out
- mov al,dl ; the hour
- out 71h,al ; tuck away in cmos
- nohour:
- mov al,3fh ; where we keep minutes in cmos
- out 70h,al ; send address to port
- mov al,cl ; prepare minutes
- out 71h,al ; save in cmos
- ; Here is the display stuff. It does direct writes to the b8 video segment.
- mov ds,0b800h ; set up b8 segment
- aam ; unpack minutes (already there) to bcd
- or ax,3030h ; mask it to ascii digits
- mov bl,ah ; move to proper register
- mov bh,74h ; character attribute, light color
- mov [009ch],bx ; move to video buffer
- mov bl,al ; move the other character
- mov [009eh],bx ; send to buffer
- mov al,dl ; pick up hours
- aam ; unpack binary to bcd
- or ax,3030h ; mask bcd to ascii digits
- mov bl,al ; to output register
- mov [0098h],bx ; and put in screen buffer
- mov bl,0f9h ; how about a bizarre separator
- mov [009ah],bx ; put it on screen
- jmp short nuttin ; get outta heah
- gotsr: ;on dos invocation we set up int 8 and go resident
- push ds ; save the good stuff
- xor ax,ax ; zero register
- mov ds,ax ; set segment to 0
- mov ax,ds:20h ; pick up current int 08
- mov dx,ds:22h
- pop ds ; back to our own segment
- mov ds:bozo+1,ax ; chain old interrupt
- mov ds:bozo+3,dx
- lea dx,istart ; set up our own handler
- mov ax,2508h
- int 21h
- mov dx,gotsr
- int 27h ; terminate and stay resident
- hbc endp
- codeseg ends
- end start
-