Question: Modify the TONE.ASM program so that the 0.25-second 1 KHz tones plays five times, once each second. Hint: Use DOS INT 21H Function 2CH (Get
Modify the TONE.ASM program so that the 0.25-second 1 KHz tones plays five times, once each second. Hint: Use DOS INT 21H Function 2CH (Get Time)
I need help getting the following code to work. I can get it to beep once, but once I added the code between the ********************** sections it wont beep five times.
Can someone correct the following code?
;Program TONE.ASM: Generate a tone through the PC speaker for 1/4 second once every 5 seconds. ; .MODEL SMALL .DATA OUTER DW 125 ;outer loop count INNER DW 1000 ;inner loop count NOW DB 00 .CODE .STARTUP CALL SPKRON ;turn speaker on MOV CX,1190 ;divisor for 1 KHz tone CALL LDTIMER ;set speaker frequency CALL DELAY ;wait for chosen duration CALL SPKROFF ;turn speaker off .EXIT
SPKRON PROC NEAR IN AL,61H ;read current state of port 61h OR AL,3 ;set speaker control bits OUT 61H,AL ;output new state RET SPKRON ENDP
SPKROFF PROC NEAR IN AL,61H ;read current state of port 61h AND AL,0FCH ;clear speaker control bits OUT 61H,AL ;output new state RET SPKROFF ENDP
DELAY PROC NEAR MOV DX,OUTER WAIT1: MOV CX,INNER WAIT2: NOP NOP NOP NOP LOOP WAIT2 DEC DX JNZ WAIT1 ;***************************************** MOV AH,2CH INT 21H MOV NOW,DH WAIT3: MOV AH,2CH INT 21H CMP NOW,DH JZ WAIT3 ;***************************************** RET DELAY ENDP
;Note: Output frequency equals 1,190,000 divided by CX
LDTIMER PROC NEAR MOV AL,0B6H ;timer 2 control word OUT 43H,AL MOV AL,CL ;output lower byte of count OUT 42H,AL MOV AL,CH ;output upper byte of count OUT 42H,AL RET LDTIMER ENDP
END
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
