Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Alarm
- cseg segment para public 'code'
- org 100h
- alarm proc far
- intaddr equ 1ch*4
- segaddr equ 62h*4
- mfactor equ 17478
- whozat equ 1234h
- color equ 14h
- assume cs:cseg,ds:cseg,ss:nothing,es:nothing
- jmp p150
- jumpval dd 0
- signature dw whozat
- state db 0
- wait dw 18
- hour dw 0
- atime dw 0ffffh
- acount dw 0
- atone db 5
- aleng dw 8080h
- dhours dw 0
- db ':'
- dmins dw 0
- db ':'
- dsecs dw 0
- db '-'
- ampm db 0
- db 'm'
- tstack db 16 dup('stack ')
- estack db 0
- holdsp dw 0
- holdss dw 0
- p000:
- push ax
- push ds
- pushf
- push cs
- pop ds
- mov ax,wait
- dec ax
- jz p010
- mov wait,ax
- jmp p080
- p010: cli
- mov ax,ss
- mov holdss,ax
- mov holdsp,sp
- mov ax,ds
- mov ss,ax
- mov sp,offset estack
- sti
- push bx
- push cx
- push dx
- push es
- push si
- push di
- push bp
- mov ax,18
- mov wait,ax
- mov al,state
- cmp al,'-'
- jnz p015
- jmp p070
- p015: mov ah,0
- int 1ah
- mov ax,dx
- mov dx,cx
- mov cl,4
- shl dx,cl
- mov bx,ax
- mov cl,12
- shr bx,cl
- add dx,bx
- mov cl,4
- shl ax,cl
- mov bx,mfactor
- div bx
- cmp ax,atime
- jnz p020
- call p100
- push ax
- mov ax,acount
- dec ax
- mov acount,ax
- cmp ax,0
- jnz p018
- mov ax,0ffffh
- mov atime,ax
- p018: pop ax
- p020: mov dsecs,dx
- mov bx,60
- xor dx,dx
- div bx
- mov dmins,dx
- cmp ax,0
- jnz p030
- mov ax,12
- jmp p040a
- p030: cmp ax,12
- jb p040a
- jz p040p
- sub ax,12
- p040p: mov bl,'p'
- jmp p040x
- p040a: mov bl,'a'
- p040x: mov ampm,bl
- aam
- cmp ax,hour
- jz p060
- mov hour,ax
- call p120
- p060: add ax,3030h
- xchg ah,al
- mov dhours,ax
- mov ax,dmins
- aam
- add ax,3030h
- xchg ah,al
- mov dmins,ax
- mov ax,dsecs
- xor dx,dx
- mov bx,60
- mul bx
- mov bx,mfactor
- div bx
- aam
- add ax,3030h
- xchg ah,al
- mov dsecs,ax
- xor ax,ax
- mov es,ax
- mov ax,es:[410h]
- and al,30h
- cmp al,30h
- mov ax,0b000h
- jz p061
- mov ax,0b800h
- p061: mov dx,es:[463h]
- add dx,6
- mov es,ax
- mov bh,color
- mov si,offset dhours
- mov di,138
- cld
- mov cx,11
- p062: mov bl,[si]
- p063: in al,dx
- test al,1
- jnz p063
- cli
- p064: in al,dx
- test al,1
- jz p064
- mov ax,bx
- stosw
- sti
- inc si
- loop p062
- p070: pop bp
- pop di
- pop si
- pop es
- pop dx
- pop cx
- pop bx
- cli
- mov ax,holdss
- mov ss,ax
- mov sp,holdsp
- sti
- p080: popf
- pop ds
- pop ax
- jmp cs:[jumpval]
- p100 proc near
- call p120
- push cx
- mov cx,20000
- p105: loop p105
- pop cx
- call p120
- push cx
- mov cx,20000
- p106: loop p106
- pop cx
- call p120
- ret
- p100 endp
- p120 proc near
- push ax
- push cx
- mov al,182
- out 43h,al
- mov al,0
- out 42h,al
- mov al,atone
- out 42h,al
- in al,61h
- push ax
- or al,3
- out 61h,al
- mov cx,aleng
- p125: loop p125
- pop ax
- out 61h,al
- pop cx
- pop ax
- ret
- p120 endp
- p150:
- mov dx,offset copyr
- call p220
- mov ax,0
- mov es,ax
- mov di,segaddr+2
- mov ax,es:[di]
- mov es,ax
- mov di,offset signature
- mov cx,es:[di]
- cmp cx,whozat
- jnz p160
- call p200
- int 20h
- p160: mov di,segaddr+2
- mov ax,0
- mov es,ax
- mov ax,ds
- mov es:[di],ax
- mov si,offset jumpval
- mov di,intaddr
- mov bx,es:[di]
- mov ax,es:[di+2]
- mov [si],bx
- mov [si+2],ax
- mov bx,offset p000
- mov ax,ds
- cli
- mov es:[di],bx
- mov es:[di+2],ax
- sti
- push ds
- pop es
- call p200
- mov dx,offset p150
- inc dx
- int 27h
- p200 proc near
- mov si,80h
- mov ax,0
- mov di,0ffffh
- mov bh,0
- mov ch,0
- mov dh,0
- mov es:[state],bh
- mov cl,[si]
- jcxz p210
- p203: inc si
- mov bl,[si]
- cmp bl,'-'
- jnz p204
- mov es:[state],bl
- push dx
- mov dx,offset msg3
- call p220
- pop dx
- jmp p206
- p204: cmp dh,2
- jz p206
- cmp bl,':'
- jnz p205
- inc dh
- cmp dh,2
- jz p206
- push cx
- push dx
- mov cx,60
- mul cx
- pop dx
- pop cx
- mov di,ax
- mov ax,0
- jmp p206
- p205: cmp bl,'0'
- jb p206
- cmp bl,'9'
- ja p206
- sub bl,'0'
- push cx
- push dx
- mov cx,10
- mul cx
- add ax,bx
- pop dx
- pop cx
- p206: loop p203
- cmp di,0ffffh
- jz p210
- add ax,di
- cmp ax,24*60
- jb p209
- mov dx,offset msg1
- call p220
- jmp p210
- p209: mov es:[atime],ax
- mov ax,5
- mov es:[acount],ax
- mov dx,offset msg2
- call p220
- p210: ret
- p200 endp
- p220 proc near
- push ax
- mov ah,9
- int 21h
- pop ax
- ret
- p220 endp
- copyr db 'Alarm - Clock',10,13,'$'
- msg1 db 'Invalid time - must be from 00:00 to 23:59',10,13,'$'
- msg2 db 'Resetting alarm time',10,13,'$'
- msg3 db 'Turning clock display off',10,13,'$'
- alarm endp
- cseg ends
- end alarm
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement