- Código: Selecionar todos
include 'emu8086.inc'
; multi-segment executable file template.
data segment
; add your data here!
pkey db "press any key...$"
linha db 0
coluna db 0
zero db "*****",0
db "* *",0
db "* *",0
db "* *",0
db "*****","$"
um db " *",0
db " *",0
db " *",0
db " *",0
db " *","$"
dois db "*****",0
db " *",0
db "*****",0
db "* ",0
db "*****","$"
tres db "*****",0
db " *",0
db "*****",0
db " *",0
db "*****","$"
quat db "* *",0
db "* *",0
db "*****",0
db " *",0
db " *","$"
cinc db "*****",0
db "* ",0
db "*****",0
db " *",0
db "*****","$"
seis db "*****",0
db "* ",0
db "*****",0
db "* *",0
db "*****","$"
sete db "*****",0
db " *",0
db " *",0
db " *",0
db " *","$"
oito db "*****",0
db "* *",0
db "*****",0
db "* *",0
db "*****","$"
nove db "*****",0
db "* *",0
db "*****",0
db " *",0
db "*****","$"
ends
stack segment
dw 128 dup(0)
ends
code segment
start:
; set segment registers:
mov ax, data
mov ds, ax
mov es, ax
; add your code here
; POE VIDEO 25X80
MOV AH,0
MOV AL,3
INT 10H
PEGA_HORA:
call obtem_hora
PUSH CX ; CONTEM HORA/MINUTO
PUSH DX ; CONTEM SEGUNDOS DH
CALL IMPRIME_TELA
JMP PEGA_HORA
lea dx, pkey
mov ah, 9
int 21h ; output string at ds:dx
; wait for any key....
mov ah, 1
int 21h
mov ax, 4c00h ; exit to operating system.
int 21h
obtem_hora:
; CH = HORA
; CL = MINUTO
; DH = SEGUNDOS
MOV AH,2CH
INT 21H
RET
IMPRIME_TELA:
PUSH BP
MOV BP,SP
; POSICIONA CURSOR
mov al,10
mov byte ptr linha,al
mov al,70
mov byte ptr coluna,al
MOV AX,[BP+4] ; SEGUNDOS
;AH SEGUNDOS
;SEPARE SEGUNDOS
XCHG AH,AL
MOV AH,0
; begin
mov bx, 10 ; divide segundos por 10...
xor dx, dx ; dx = 0
div bx ; ax = cociente dx = resto al=cociente dl=resto
mov ah,dl
CALL PEGA_OFFSET_TEXTO
CALL IMPRIME_DIGITO
; POSICIONA CURSOR
mov al,10
mov byte ptr linha,al
mov al,60
mov byte ptr coluna,al
MOV AX,[BP+4] ; SEGUNDOS
;AH SEGUNDOS
;SEPARE SEGUNDOS
XCHG AH,AL
MOV AH,0
; begin
mov bx, 10 ; divide segundos por 10...
xor dx, dx ; dx = 0
div bx ; ax = cociente dx = resto al=cociente dl=resto
mov ah,al
CALL PEGA_OFFSET_TEXTO
CALL IMPRIME_DIGITO
; POSICIONA CURSOR
mov al,10
mov byte ptr linha,al
mov al,50
mov byte ptr coluna,al
MOV AX,[BP+6] ; MINUTOS
;AL MINUTOS
;SEPARE MINUTOS
MOV AH,0
; begin
mov bx, 10 ; divide segundos por 10...
xor dx, dx ; dx = 0
div bx ; ax = cociente dx = resto al=cociente dl=resto
mov ah,dl
CALL PEGA_OFFSET_TEXTO
CALL IMPRIME_DIGITO
; POSICIONA CURSOR
mov al,10
mov byte ptr linha,al
mov al,40
mov byte ptr coluna,al
MOV AX,[BP+6] ; MINUTOS
;AL MINUTOS
;SEPARE MINUTOS
MOV AH,0
; begin
mov bx, 10 ; divide segundos por 10...
xor dx, dx ; dx = 0
div bx ; ax = cociente dx = resto al=cociente dl=resto
mov ah,al
CALL PEGA_OFFSET_TEXTO
CALL IMPRIME_DIGITO
; POSICIONA CURSOR
mov al,10
mov byte ptr linha,al
mov al,30
mov byte ptr coluna,al
MOV AX,[BP+6] ; HORAS
;AH HORA
;SEPARE HORAS
XCHG AH,AL
MOV AH,0
; begin
mov bx, 10 ; divide segundos por 10...
xor dx, dx ; dx = 0
div bx ; ax = cociente dx = resto al=cociente dl=resto
mov ah,dl
CALL PEGA_OFFSET_TEXTO
CALL IMPRIME_DIGITO
; POSICIONA CURSOR
mov al,10
mov byte ptr linha,al
mov al,20
mov byte ptr coluna,al
MOV AX,[BP+6] ; HORAS
;AL SEGUNDOS
;SEPARE SEGUNDOS
XCHG AH,AL
MOV AH,0
; begin
mov bx, 10 ; divide segundos por 10...
xor dx, dx ; dx = 0
div bx ; ax = cociente dx = resto al=cociente dl=resto
mov ah,al
CALL PEGA_OFFSET_TEXTO
CALL IMPRIME_DIGITO
POP BP
RET 4
PEGA_OFFSET_TEXTO:
DIG_0:
CMP AH,0
JNE DIG_1
MOV SI, OFFSET ZERO
DIG_1:
CMP AH,1
JNE DIG_2
MOV SI, OFFSET UM
DIG_2:
CMP AH,2
JNE DIG_3
MOV SI, OFFSET DOIS
DIG_3:
CMP AH,3
JNE DIG_4
MOV SI, OFFSET TRES
DIG_4:
CMP AH,4
JNE DIG_5
MOV SI, OFFSET QUAT
DIG_5:
CMP AH,5
JNE DIG_6
MOV SI, OFFSET CINC
DIG_6:
CMP AH,6
JNE DIG_7
MOV SI, OFFSET SEIS
DIG_7:
CMP AH,7
JNE DIG_8
MOV SI, OFFSET SETE
DIG_8:
CMP AH,8
JNE DIG_9
MOV SI, OFFSET OITO
DIG_9:
CMP AH,9
JNE ERRO_DIGITO
MOV SI, OFFSET NOVE
ERRO_DIGITO:
RET
IMPRIME_DIGITO:
; SI APONTA PARA INICIO TEXTO
mov dl, byte ptr coluna ; coluna
IMPRIME_LINHA:
mov dh, byte ptr linha ; linha
mov bh, 0
mov ah, 2
int 10h
MOV CL,[SI]
CMP CL,"$"
JE SAI_IMPRIME
CMP CL,0
JE PULA_LINHA
MOV AH,2
PUSH DX ; SALVE DL QUE CONTEM COLUNA
MOV DL,CL
INT 21H
POP DX ; RESTAURE DX QUE CONTEM DL
INC SI
INC DL ; AVANCA COLUNA
JMP IMPRIME_LINHA
PULA_LINHA:
INC SI
INC BYTE PTR LINHA
JMP IMPRIME_DIGITO ; RESTAURANDO COLUNA
SAI_IMPRIME:
RET
ends
end start ; set entry point and stop the assembler.