.model small
.stack 1000h
.data
t equ 4000 

.code 

tone macro div,dur
    mov al,0b6h
    out 43h , al  
    
    mov ax ,div
    out 42h,al 
    
    mov al,ah
    out 42h,al
    
    mov al,03h
    out 61h ,al 
    
    mov cx,dur
    call delay1 
    
    mov ax,0h
    out 61h,al 
    
    call delay2
endm 

.startup
start: 

mov ah,01h
int 21h  

cmp al,'a'
je A
jmp l1  

A:
    tone 2705,t
    jmp start
l1:
    cmp al,'b'
    je B
    jmp l2  

B:
    tone 2554,t
    jmp start  

l2:
    cmp al,'c'
    je C
    jmp l3 

C:
    tone 4542,t
    jmp start
    
l3:
    cmp al,'d'
    je D
    jmp l4 

D:
    tone 4048,t
    jmp start  
    
l4:
    cmp al,'e'
    je E
    jmp l5 

E:
    tone 3606,t
    jmp start 
    
l5:
    cmp al,'f'
    je F
    jmp l6  

F:
    tone 3410,t
    jmp start 
    
l6:
    cmp al,'g'
    je G
    jmp l7  

G:
    tone 3036,t
    jmp start 
    
l7:
    cmp al,'h'
    je H
    jmp l8  

H:
    tone 2275,t
    jmp start
l8:
    cmp al,'q'
    je done
    jmp start 

done:
    mov ax ,4c00h
    int 21h 

delay1 proc near
    d1:
        push cx
        mov cx,38000
    d2:
    loop d2 
    
    pop cx
    loop d1 
    
    ret 
delay1 endp  

delay2 proc near
    mov cx,65000
    d3:
        loop d3
    ret 
delay2 endp   

end