Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- STACKSG SEGMENT PARA STACK 'Stack'
- DW 32 DUP(?)
- STACKSG ENDS
- ;############ DATA SEGMENT ##########
- DATASG SEGMENT PARA 'Data'
- NAMEPAR LABEL BYTE
- DATASG ENDS
- ;############ CODE SEGMENT ##########
- CODESG SEGMENT PARA 'Code'
- BEGIN PROC FAR
- ASSUME CS:CODESG, DS:DATASG, SS:STACKSG
- PUSH DS
- SUB AX, AX
- PUSH AX
- MOV AX, DATASG
- MOV DS, AX
- MOV DX,2000 ; Number of times to repeat whole routine.
- MOV BX,1 ; Frequency value.
- MOV AL, 10110110B ; The Magic Number (use this binary number only)
- OUT 43H, AL ; Send it to the initializing port 43H Timer 2.
- NEXT_FREQUENCY: ; This is were we will jump back to 2000 times.
- MOV AX, BX ; Move our Frequency value into AX.
- OUT 42H, AL ; Send LSB to port 42H.
- MOV AL, AH ; Move MSB into AL
- OUT 42H, AL ; Send MSB to port 42H.
- IN AL, 61H ; Get current value of port 61H.
- OR AL, 00000011B ; OR AL to this value, forcing first two bits high.
- OUT 61H, AL ; Copy it to port 61H of the PPI Chip
- ; to turn ON the speaker.
- MOV CX, 100 ; Repeat loop 100 times
- DELAY_LOOP: ; Here is where we loop back too.
- LOOP DELAY_LOOP ; Jump repeatedly to DELAY_LOOP until CX = 0
- INC BX ; Incrementing the value of BX lowers
- ; the frequency each time we repeat the
- ; whole routine
- DEC DX ; Decrement repeat routine count
- CMP DX, 0 ; Is DX (repeat count) = to 0
- JNZ NEXT_FREQUENCY ; If not jump to NEXT_FREQUENCY
- ; and do whole routine again.
- ; Else DX = 0 time to turn speaker OFF
- IN AL,61H ; Get current value of port 61H.
- AND AL,11111100B ; AND AL to this value, forcing first two bits low.
- OUT 61H,AL ; Copy it to port 61H of the PPI Chip
- ; to turn OFF the speaker
- MOV AH,00
- MOV AL, 2
- INT 10h
- ret
- BEGIN ENDP
- CODESG ENDS
- END BEGIN
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement