.MODEL SMALL 
.STACK 1000H
.DATA
COUNT EQU 238   ; COUNT=Fin/Fout =1.19MH/5KH =238
TIME  EQU 20000 ;THIS IS UESED FOR THE DELAY

.CODE 
START:

MOV AL,0B6H    ;SEND THE CONTROL WORD TO THE CONTROL REGISTER 
OUT 43H,AL     ;THE ADDRESS OF THE CONTROL REGISTER

MOV AX,COUNT   ;SEND THE COUNT VALUE TO AX
OUT 42H,AL     ;SEND FIRST THE LSB OF THE COUNT VALUE TO COUNTER2

MOV AL,AH      ;SEND THE MSB OF THE COUNT VALUE TO COUNTER2
OUT 42H,AL

IN AL,61H     ;READ PORT B
OR AL,00000011B
OUT 61H,AL    ; ENABLE TIMER2 GATE TO SPEAKER BY SENDING 03H TO PORT B

MOV CX,TIME   ; DELAY INSTRUCTIONS 
DELAY1:
PUSH CX
MOV CX,30000
DELAY2:
LOOP DELAY2
POP CX
LOOP DELAY1

IN AL,61H  
AND AL,11111100B
OUT 61H,AL  ;DISENABLE TIMER2 GATE TO SPEAKER BY SENDING FCH TO PORT B 

MOV AX,4CH
INT 21H

END START

