Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Code Help!

Status
Not open for further replies.

Cuso

MIS
Jul 11, 2005
8
US
I have this code but when i excecute it the computer keep beeping and the application freeze. What am I doing wrong?

.model small
.stack 100h
.data
memTeclado label byte
longBuffer db 20
totalCaract db ?
contenido db 20 dup('$')


caracter db ?
mensaje db "This program work", 0dh,0ah,'$'
mensaje2 db "Enter a character:$ "
mensaje3 db "The character is [$"
mensaje4 db 0dh,0ah,"Enter a string: ",0dh,0ah,'$'
mensaje5 db 0dh,0ah,"The string is: ",0dh,0ah,'$'

.code
main proc
mov ax,@data
mov ds,ax


mov ah,2
mov dl,'*'
int 21h


mov ah,6
mov dl,'@'
int 21h


mov dx,offset mensaje
mov ah,9
int 21h



mov dx,offset mensaje2
mov ah,9
int 21h


mov ah,1
int 21h
mov caracter,al

mov dx,offset mensaje3
mov ah,9
int 21h

mov ah,2
mov dl,caracter
int 21h
mov ah,2
mov dl,']'
int 21h

mov SI,3
next:
mov ah,2
mov dl,7
int 21h

;Ej INT21-06
mov ah,6
mov dl,0ffh
int 21h

jz next
dec si
cmp SI,0
je stopBeep
jmp next
stopBeep:

mov dx,offset mensaje4
mov ah,9
int 21h

;Ej INT21-0A
mov ah,0ah
mov dx,offset memTeclado
int 21h

mov dx,offset mensaje5
mov ah,9
int 21h

mov dx,offset contenido
mov ah,9
int 21h

mov ax,4c00h
int 21h
main endp
end main
 
the reason for your problem is the following loop:

Code:
    mov SI,3
next:
    mov ah,2
    mov dl,7   
    int 21h
;Ej INT21-06   
    mov ah,6
    mov dl,0ffh
    int 21h

    jz next
    dec si
    cmp SI,0
    je stopBeep
    jmp next
stopBeep:

it beeps, it outputs char 0xFFh (which actually has no effect with function 6),
int21h sets the zero flag upon return, and you test for the zero flag to iterate
a loop.
An infinite loop because SI never gets tested!

if you want to let the speaker beep three times i'd recommend this code:

mov ah,2
mov dl,7
int 21h
int 21h
int 21h
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top