Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
data segment
zero:
db " 000000000 ",10
db " 00:::::::::00 ",10
db " 00:::::::::::::00 ",10
db "0:::::::000:::::::0 ",10
db "0::::::0 0::::::0 ",10
db "0:::::0 0:::::0 ",10
db "0:::::0 0:::::0 ",10
db "0:::::0 000 0:::::0 ",10
db "0:::::0 000 0:::::0 ",10
db "0:::::0 0:::::0 ",10
db "0:::::0 0:::::0 ",10
db "0::::::0 0::::::0 ",10
db "0:::::::000:::::::0 ",10
db " 00:::::::::::::00 ",10
db " 00:::::::::00 ",10
db " 000000000 ",0
um:
db " 1111111 ",10
db " 1::::::1 ",10
db " 1:::::::1 ",10
db " 111:::::1 ",10
db " 1::::1 ",10
db " 1::::1 ",10
db " 1::::1 ",10
db " 1::::l ",10
db " 1::::l ",10
db " 1::::l ",10
db " 1::::l ",10
db " 1::::l ",10
db " 111111::::::111111 ",10
db " 1::::::::::::::::1 ",10
db " 1::::::::::::::::1 ",10
db " 111111111111111111 ",0
dois:
db " 222222222222222 ",10
db "2:::::::::::::::22 ",10
db "2::::::222222:::::2 ",10
db "2222222 2:::::2 ",10
db " 2:::::2 ",10
db " 2:::::2 ",10
db " 2222::::2 ",10
db " 22222::::::22 ",10
db " 22::::::::222 ",10
db " 2:::::22222 ",10
db "2:::::2 ",10
db "2:::::2 ",10
db "2:::::2 22222 ",10
db "2::::::2222222::::2 ",10
db "2:::::::::::::::::2 ",10
db "2222222222222222222 ",0
tres:
db " 333333333333333 ",10
db "3:::::::::::::::33 ",10
db "3::::::33333::::::3 ",10
db "3333333 3:::::3 ",10
db " 3:::::3 ",10
db " 3:::::3 ",10
db " 33333333:::::3 ",10
db " 3:::::::::::3 ",10
db " 33333333:::::3 ",10
db " 3:::::3 ",10
db " 3:::::3 ",10
db " 3:::::3 ",10
db "3333333 3:::::3 ",10
db "3::::::33333::::::3 ",10
db "3:::::::::::::::33 ",10
db " 333333333333333 ",0
quatro:
db " 444444444 ",10
db " 4::::::::4 ",10
db " 4:::::::::4 ",10
db " 4::::44::::4 ",10
db " 4::::4 4::::4 ",10
db " 4::::4 4::::4 ",10
db " 4::::4 4::::4 ",10
db " 4::::444444::::444 ",10
db " 4::::::::::::::::4 ",10
db " 4444444444:::::444 ",10
db " 4::::4 ",10
db " 4::::4 ",10
db " 4::::4 ",10
db " 44::::::44 ",10
db " 4::::::::4 ",10
db " 4444444444 ",0
cinco:
db "555555555555555555 ",10
db "5::::::::::::::::5 ",10
db "5::::::::::::::::5 ",10
db "5:::::555555555555 ",10
db "5:::::5 ",10
db "5:::::5 ",10
db "5:::::5555555555 ",10
db "5:::::::::::::::5 ",10
db "555555555555:::::5 ",10
db " 5:::::5 ",10
db " 5:::::5 ",10
db "5555555 5:::::5 ",10
db "5::::::55555::::::5 ",10
db " 55:::::::::::::55 ",10
db " 55:::::::::55 ",10
db " 555555555 ",0
seis:
db " 66666666 ",10
db " 6::::::6 ",10
db " 6::::::6 ",10
db " 6::::::6 ",10
db " 6::::::6 ",10
db " 6::::::6 ",10
db " 6::::::6 ",10
db " 6::::::::66666 ",10
db "6::::::::::::::66 ",10
db "6::::::66666:::::6 ",10
db "6:::::6 6:::::6 ",10
db "6:::::6 6:::::6 ",10
db "6::::::66666::::::6 ",10
db " 66:::::::::::::66 ",10
db " 66:::::::::66 ",10
db " 666666666 ",0
sete:
db "77777777777777777777",10
db "7::::::::::::::::::7",10
db "7::::::::::::::::::7",10
db "777777777777:::::::7",10
db " 7::::::7 ",10
db " 7::::::7 ",10
db " 7::::::7 ",10
db " 7::::::7 ",10
db " 7::::::7 ",10
db " 7::::::7 ",10
db " 7::::::7 ",10
db " 7::::::7 ",10
db " 7::::::7 ",10
db " 7::::::7 ",10
db " 7::::::7 ",10
db "77777777 ",0
oito:
db " 888888888 ",10
db " 88:::::::::88 ",10
db " 88:::::::::::::88 ",10
db "8::::::88888::::::8 ",10
db "8:::::8 8:::::8 ",10
db "8:::::8 8:::::8 ",10
db " 8:::::88888:::::8 ",10
db " 8:::::::::::::8 ",10
db " 8:::::88888:::::8 ",10
db "8:::::8 8:::::8 ",10
db "8:::::8 8:::::8 ",10
db "8:::::8 8:::::8 ",10
db "8::::::88888::::::8 ",10
db " 88:::::::::::::88 ",10
db " 88:::::::::88 ",10
db " 888888888 ",0
nove:
db " 999999999 ",10
db " 99:::::::::99 ",10
db " 99:::::::::::::99 ",10
db "9::::::99999::::::9 ",10
db "9:::::9 9:::::9 ",10
db "9:::::9 9:::::9 ",10
db " 9:::::99999::::::9 ",10
db " 99::::::::::::::9 ",10
db " 99999::::::::9 ",10
db " 9::::::9 ",10
db " 9::::::9 ",10
db " 9::::::9 ",10
db " 9::::::9 ",10
db " 9::::::9 ",10
db " 9::::::9 ",10
db " 99999999 ",0
linha db ?
coluna db ?
digito db ?
digito_uni db ?
digito_dez db ?
minutos db ?
segundos db ?
dig_aux db ?
ask_minutos db "informe os minutos:",13,10,"$"
ask_segundos db "informe os segundos:",13,10,"$"
new_line db "",13,10,"$"
ends
stack segment
dw 128 dup(0)
ends
code segment
start:
mov ax, data
mov ds, ax
mov ax, 0b800h
mov es, ax
mov ah,1
mov ch,20h
int 10h
;desliga cursor
lea dx, ask_minutos
call le_valor_inteiro
mov minutos, al
lea dx,new_line
mov ah, 09h
int 21h
lea dx, ask_segundos
call le_valor_inteiro
mov segundos, al
call cls
jmp mostrando
terminar:
mov ax, 4c00h
int 21h
le_valor_inteiro: ; imprime offset dx e retorna valor em al
pushf
push dx
mov ah, 09h
int 21h ; output string at ds:dx
mov ah, 01h
int 21h
sub al, '0'
mov ah, 0
mov bl, 10
mul bl
mov dig_aux, al
mov ah, 01h
int 21h
sub al, '0'
mov ah, 0
add al, dig_aux
mov dig_aux, 0
pop dx
popf
ret
mostrando:
;imprime segundos
mov ah,0
mov al,segundos
mov bl,10
div bl
mov digito_dez, al
mov digito_uni, ah
; imprime dez ss
mov al,digito_dez
mov digito,al
mov linha, 5
mov coluna, 40
call imprime_digito
; imprime unid ss
mov al,digito_uni
mov digito,al
mov linha, 5
mov coluna, 60
call imprime_digito
;imprime minutos
mov ah,0
mov al,minutos
mov bl,10
div bl
mov digito_dez, al
mov digito_uni, ah
; imprime dez mm
mov al,digito_dez
mov digito,al
mov linha, 5
mov coluna, 0
call imprime_digito
; imprime unid mm
mov al,digito_uni
mov digito,al
mov linha, 5
mov coluna, 20
call imprime_digito
call atualiza_horario
;cmp segundos, 21
;je terminar
call wait_clock
jmp mostrando
atualiza_horario:
pushf
inc segundos
cmp segundos, 60
jge inc_minutos
jmp fim_atualiza_horario
inc_minutos:
mov segundos, 0
inc minutos
cmp minutos, 60
jge zera_minutos
jmp fim_atualiza_horario
zera_minutos:
mov minutos, 0
fim_atualiza_horario:
popf
ret
imprime_digito:
cmp digito,0
je imp_zero
cmp digito,1
je imp_um
cmp digito,2
je imp_dois
cmp digito,3
je imp_tres
cmp digito,4
je imp_quatro
cmp digito,5
je imp_cinco
cmp digito,6
je imp_seis
cmp digito,7
je imp_sete
cmp digito,8
je imp_oito
cmp digito,9
je imp_nove
imp_zero:
lea si, zero
jmp imprimindo
imp_um:
lea si, um
jmp imprimindo
imp_dois:
lea si, dois
jmp imprimindo
imp_tres:
lea si, tres
jmp imprimindo
imp_quatro:
lea si, quatro
jmp imprimindo
imp_cinco:
lea si, cinco
jmp imprimindo
imp_seis:
lea si, seis
jmp imprimindo
imp_sete:
lea si, sete
jmp imprimindo
imp_oito:
lea si, oito
jmp imprimindo
imp_nove:
lea si, nove
jmp imprimindo
imprimindo:
; posiciona cursor
mov ah,2
mov bh,0
mov dh, linha
mov dl, coluna
int 10h
procura_fim:
mov dl,ds:[si]
cmp dl,0
je fim_impressao
cmp dl,10
je pula_linha
mov ah,2
int 21h
inc si
jmp procura_fim
pula_linha:
inc byte ptr linha
inc si
jmp imprimindo
fim_impressao:
ret
cls:
pushf
push ax
push bx
push dx
mov si, 0
cls_apagando:
mov es:[si]," "
mov es:[si + 1],0fh
add si, 2
cmp si, 25*160
je fim_cls
jmp cls_apagando
fim_cls:
mov ah, 2
mov bh, 0
mov dh, 0 ;linha
mov dl, 0 ;coluna
int 10h
pop dx
pop bx
pop ax
popf
ret
wait_clock:
pushf
push cx
push dx
push ax
mov cx, 0fh
mov dx, 4240h
mov ah, 86h
int 15h
pop ax
pop dx
pop cx
popf
ret
ends
end start
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment