Search code examples
assemblyemu8086beep

8086 - Beep until get input


I am new to assembly language and i want to create a program with 8086 assembly. (emu8086) So the program is supposed to continuously beep until key E is pressed. now the first way is to use a simple jump to check input each time and this is the code that i came up with :

    macro beep
    mov dl,7h
    mov ah,2
    int 21h
endm

.model small
.stack 64

.code :  

lp:

beep

mov ah,1
int 21h

cmp al,'e'
je end

jmp lp

end:
mov ah,4ch
int 21h

Now what i want to achieve is that beeping must be continuous and i dont want the user to do input in each cycle. Something like multi threading in C which beeping is done in another thread.

is that even possible in 8086 ?


Solution

  • BIOS function 01h checks if a key is pending.

    • If not, you immediately re-beep.
    • If a key is present, you fetch it with BIOS function 00h, and if it's not 'e', you continue to re-beep.

    This is probably the simplest solution to get a continuous beep until the character 'e' is pressed.

    lp:
     beep
     mov ah, 01h
     int 16h      ;Gives ZF
     jz  lp       ;No key waiting
     mov ah, 00h
     int 16h      ;Gives AX
     cmp al, 'e'
     jne lp
     mov ax, 4C00h
     int 21h