Digital Clock Codigo 1
Digital Clock Codigo 1
.model small
local l1
inc cx ;next
column
cmp cx, _col2 ;compare
jle l1 ;not
done yet
endm
local l2
jle l2 ;not
done yet
endm
.stack 100h
.data
colshft dw 0 ;shift
amount for column
rowshft dw 0 ;shift
amount for row
tmpcol1 dw 0
;temporary column value
tmpcol2 dw 0
;temporary column value
tmpcol3 dw 0
;temporary column value
tmprow1 dw 0
;temporary row value
tmprow2 dw 0
;temporary row value
tmprow3 dw 0
;temporary row value
fontcolor db 31 ;color of the
font
amflag db 0 ;flag to check
am or pm
time_buf db '00:00:00$' ;time buffer hr:min:sec
new_vec dw ?, ?
old_vec dw ?, ?
.code
convert proc
;converts to ascii
;input al = number
;output ax = ascii digits, al = high digit, ah = low digit
ret
convert endp
get_time proc
jng l5
jnl l5
jg l4
jne l6
mov al, 12
ret
get_time endp
time_int proc
push ds ;save ds
mov rowshft, 65
mov colshft, 30
call print_black
cmp [bx], al
jne h11
call print0
jmp h1d
h11: inc al
cmp [bx], al
jne h12
call print1
jmp h1d
h12: inc al
cmp [bx], al
jne h13
call print2
jmp h1d
h13: inc al
cmp [bx], al
jne h14
call print3
jmp h1d
h14: inc al
cmp [bx], al
jne h15
call print4
jmp h1d
h15: inc al
cmp [bx], al
jne h16
call print5
jmp h1d
h16: inc al
cmp [bx], al
jne h17
call print6
jmp h1d
h17: inc al
cmp [bx], al
jne h18
call print7
jmp h1d
h18: inc al
cmp [bx], al
jne h19
call print8
jmp h1d
h1d:
mov rowshft, 65
mov colshft, 70
call print_black
cmp [bx+1], al
jne h21
call print0
jmp h2d
h21: inc al
cmp [bx+1], al
jne h22
call print1
jmp h2d
h22: inc al
cmp [bx+1], al
jne h23
call print2
jmp h2d
h23: inc al
cmp [bx+1], al
jne h24
call print3
jmp h2d
h24: inc al
cmp [bx+1], al
jne h25
call print4
jmp h2d
h25: inc al
cmp [bx+1], al
jne h26
call print5
jmp h2d
h26: inc al
cmp [bx+1], al
jne h27
call print6
jmp h2d
h27: inc al
cmp [bx+1], al
jne h28
call print7
jmp h2d
h28: inc al
cmp [bx+1], al
jne h29
call print8
jmp h2d
h2d:
;print a colon
mov rowshft, 65
call print_colon
mov rowshft, 65
call print_black
cmp [bx+3], al
jne m11
call print0
jmp m1d
m11: inc al
cmp [bx+3], al
jne m12
call print1
jmp m1d
m12: inc al
cmp [bx+3], al
jne m13
call print2
jmp m1d
m13: inc al
cmp [bx+3], al
jne m14
call print3
jmp m1d
m14: inc al
cmp [bx+3], al
jne m15
call print4
jmp m1d
m15: inc al
cmp [bx+3], al
jne m16
call print5
jmp m1d
m16: inc al
cmp [bx+3], al
jne m17
call print6
jmp m1d
m17: inc al
cmp [bx+3], al
jne m18
call print7
jmp m1d
m18: inc al
cmp [bx+3], al
jne m19
call print8
jmp m1d
m1d:
mov rowshft, 65
call print_black
cmp [bx+4], al
jne m21
call print0
jmp m2d
m21: inc al
cmp [bx+4], al
jne m22
call print1
jmp m2d
m22: inc al
cmp [bx+4], al
jne m23
call print2
jmp m2d
m23: inc al
cmp [bx+4], al
jne m24
call print3
jmp m2d
m24: inc al
cmp [bx+4], al
jne m25
call print4
jmp m2d
m25: inc al
cmp [bx+4], al
jne m26
call print5
jmp m2d
m26: inc al
cmp [bx+4], al
jne m27
call print6
jmp m2d
m27: inc al
cmp [bx+4], al
jne m28
call print7
jmp m2d
m28: inc al
cmp [bx+4], al
jne m29
call print8
jmp m2d
m2d:
;print a colon
mov rowshft, 65
call print_colon
mov rowshft, 65
call print_black
cmp [bx+6], al
jne s11
call print0
jmp s1d
s11: inc al
cmp [bx+6], al
jne s12
call print1
jmp s1d
s12: inc al
cmp [bx+6], al
jne s13
call print2
jmp s1d
s13: inc al
cmp [bx+6], al
jne s14
call print3
jmp s1d
s14: inc al
cmp [bx+6], al
jne s15
call print4
jmp s1d
s15: inc al
cmp [bx+6], al
jne s16
call print5
jmp s1d
s16: inc al
cmp [bx+6], al
jne s17
call print6
jmp s1d
s17: inc al
cmp [bx+6], al
jne s18
call print7
jmp s1d
s18: inc al
cmp [bx+6], al
jne s19
call print8
jmp s1d
s1d:
mov rowshft, 65
call print_black
cmp [bx+7], al
jne s21
call print0
jmp s2d
s21: inc al
cmp [bx+7], al
jne s22
call print1
jmp s2d
s22: inc al
cmp [bx+7], al
jne s23
call print2
jmp s2d
s23: inc al
cmp [bx+7], al
jne s24
call print3
jmp s2d
s24: inc al
cmp [bx+7], al
jne s25
call print4
jmp s2d
s25: inc al
cmp [bx+7], al
jne s26
call print5
jmp s2d
s26: inc al
cmp [bx+7], al
jne s27
call print6
jmp s2d
s27: inc al
cmp [bx+7], al
jne s28
call print7
jmp s2d
s28: inc al
cmp [bx+7], al
jne s29
call print8
jmp s2d
s2d:
;print am/pm
call printA
jmp mp
call printA
call printP
call printM
pop ds
iret
time_int endp
setup_int proc
push ds ;save ds
ret
setup_int endp
main proc
mov ah, 0
int 16h
mov ah, 0
mov al, 3
int 10h
;exit
main endp
print0 proc
mov tmpcol1, 0
add tmpcol1, ax
mov tmpcol2, 30
add tmpcol2, ax
mov tmprow1, 0
add tmprow1, ax
mov tmprow2, 20
add tmprow2, ax
mov tmprow3, 50
add tmprow3, ax
ret
print0 endp
print1 proc
mov tmpcol1, 20
add tmpcol1, ax
mov tmpcol2, 30
add tmpcol2, ax
mov tmprow1, 0
add tmprow1, ax
mov tmprow2, 20
add tmprow2, ax
mov tmprow3, 50
add tmprow3, ax
ret
print1 endp
print2 proc
mov tmpcol1, 0
add tmpcol1, ax
mov tmpcol2, 30
add tmpcol2, ax
mov tmprow1, 0
add tmprow1, ax
mov tmprow2, 20
add tmprow2, ax
mov tmprow3, 50
add tmprow3, ax
ret
print2 endp
print3 proc
mov tmpcol1, 0
add tmpcol1, ax
mov tmpcol2, 30
add tmpcol2, ax
mov tmprow1, 0
add tmprow1, ax
mov tmprow2, 20
add tmprow2, ax
mov tmprow3, 50
add tmprow3, ax
print3 endp
print4 proc
mov tmpcol1, 0
add tmpcol1, ax
mov tmpcol2, 30
add tmpcol2, ax
mov tmprow1, 0
add tmprow1, ax
mov tmprow2, 20
add tmprow2, ax
mov tmprow3, 50
add tmprow3, ax
ret
print4 endp
print5 proc
mov tmpcol1, 0
add tmpcol1, ax
mov tmpcol2, 30
add tmpcol2, ax
mov tmprow1, 0
add tmprow1, ax
mov tmprow2, 20
add tmprow2, ax
mov tmprow3, 50
add tmprow3, ax
ret
print5 endp
print6 proc
mov tmpcol1, 0
add tmpcol1, ax
mov tmpcol2, 30
add tmpcol2, ax
mov tmprow1, 0
add tmprow1, ax
mov tmprow2, 20
add tmprow2, ax
mov tmprow3, 50
add tmprow3, ax
ret
print6 endp
print7 proc
mov tmpcol1, 0
add tmpcol1, ax
mov tmpcol2, 30
add tmpcol2, ax
mov tmprow1, 0
add tmprow1, ax
mov tmprow2, 20
add tmprow2, ax
mov tmprow3, 50
add tmprow3, ax
ret
print7 endp
print8 proc
mov tmpcol1, 0
add tmpcol1, ax
mov tmpcol2, 30
add tmpcol2, ax
mov tmprow1, 0
add tmprow1, ax
mov tmprow2, 20
add tmprow2, ax
mov tmprow3, 50
add tmprow3, ax
ret
print8 endp
print9 proc
mov tmpcol1, 0
add tmpcol1, ax
mov tmpcol2, 30
add tmpcol2, ax
mov tmprow1, 0
add tmprow1, ax
mov tmprow2, 20
add tmprow2, ax
mov tmprow3, 50
add tmprow3, ax
ret
print9 endp
print_colon proc
mov tmpcol1, 8
add tmpcol1, ax
mov tmpcol2, 12
add tmpcol2, ax
mov tmprow1, 16
add tmprow1, ax
mov tmprow2, 20
add tmprow2, ax
mov tmpcol1, 8
add tmpcol1, ax
mov tmpcol2, 12
add tmpcol2, ax
mov tmprow1, 30
add tmprow1, ax
mov tmprow2, 34
add tmprow2, ax
ret
print_colon endp
print_black proc
mov tmpcol1, 0
add tmpcol1, ax
mov tmpcol2, 30
add tmpcol2, ax
mov tmprow1, 0
add tmprow1, ax
mov tmprow2, 20
add tmprow2, ax
mov tmprow3, 50
add tmprow3, ax
ret
print_black endp
printA proc
mov tmpcol1, 0
add tmpcol1, ax
mov tmpcol2, 10
add tmpcol2, ax
mov tmprow1, 0
add tmprow1, ax
mov tmprow2, 7
add tmprow2, ax
mov tmprow3, 20
add tmprow3, ax
ret
printA endp
printP proc
mov tmpcol1, 0
add tmpcol1, ax
mov tmpcol2, 10
add tmpcol2, ax
mov tmprow1, 0
add tmprow1, ax
mov tmprow2, 7
add tmprow2, ax
mov tmprow3, 20
add tmprow3, ax
ret
printP endp
printM proc
mov tmpcol1, 0
add tmpcol1, ax
mov tmpcol2, 7
add tmpcol2, ax
mov tmpcol3, 20
add tmpcol3, ax
mov tmprow1, 0
add tmprow1, ax
mov tmprow3, 20
add tmprow3, ax
ret
printM endp
end main