×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Code Help!

Code Help!

Code Help!

(OP)
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

RE: Code Help!

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

RE: Code Help!

(OP)
Thank You for your help!

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login


Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close