Hi everyone, I am trying to make a timer in assembly.
The user has to type the timer value (in seconds) and a beep occurs when the time is elapsed.
I think i'm not far from the end but i got an error i can't seem to find :/
the program should work like this :
I encode timer value in TIMER
i get actual second from bios and keep it in BH
In a loop i get second from bios and compare it with the value in BH, when the values differ -> i increment a VAR
When var = TIMER i emit a beep
heres where I am
it seems i can't get out of the GETSEC loop, but i dont understand why isnt the JNE working right , i should get out of it every time a second change , right ?
Thanks for all the help u can give me :)
and sorry for the lame french names :( -> french coder here
.MODEL SMALL ;
.STACK 256 ;
.DATA
RetourLigne DB "",13,10,"$"
Chaine1 DB "enter timer value :","$"
Chaine2 DB "timer is :","$"
Chaine3 DB "test 3",13,10,"$"
Chaine4 DB "test 4",13,10,"$"
TIMER DB 0
VAR DB 0
.CODE
;*****************************************************;
; Instruction debut de programme ;
;*****************************************************;
mov ax,@data
mov ds,ax
;*****************************************************;
; Calcul taille fichier ;
;*****************************************************;
call VALEURTIMER
call GETSECONDE
call BEEP
call FIN
;--------------------------------PROCEDURES---------------------------
GETSECONDE proc
TOP:
MOV AH,2Ch
INT 21
MOV BH,DH
GETSEC:
MOV AH,2Ch
INT 21
CMP DH,BH
JNE PRINTA
LEA DX,Chaine3
MOV AH,09H
INT 21H
JMP GETSEC
PRINTA:
LEA DX,Chaine4
MOV AH,09H
INT 21H
ADD VAR,1d
MOV AH,VAR
CMP AH,TIMER
JE SORTIR
JMP TOP
SORTIR:
ret
ENDP
VALEURTIMER proc
LEA DX,Chaine1
MOV AH,09H
INT 21H
MOV Ah, 01h
INT 21h
MOV TIMER, AL
LEA DX,RetourLigne
MOV AH,09H
INT 21H
LEA DX,Chaine2
MOV AH,09H
INT 21H
LEA DX,TIMER
MOV AH,09H
INT 21H
MOV Ah, TIMER
SUB Ah,30h ; Converti l'ascii en numérique
MOV TIMER,Ah
ret
ENDP
BEEP proc
mov ah,02h
mov dl,07h
int 21h
ret
ENDP
;fin du programme
FIN proc
mov ax,4C00h
int 21h
ret
ENDP
END