Advertisement
Guest User

Untitled

a guest
May 22nd, 2019
195
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. STACKSG SEGMENT PARA STACK 'Stack'
  2.                 DW 32 DUP(?)
  3. STACKSG ENDS
  4. ;############    DATA SEGMENT    ##########
  5. DATASG SEGMENT PARA 'Data'
  6. NAMEPAR LABEL   BYTE
  7.  
  8. DATASG ENDS
  9. ;############    CODE SEGMENT    ##########
  10. CODESG SEGMENT PARA 'Code'
  11. BEGIN PROC FAR
  12. ASSUME CS:CODESG, DS:DATASG, SS:STACKSG
  13.        PUSH   DS
  14.        SUB    AX, AX
  15.        PUSH   AX
  16.        MOV    AX, DATASG
  17.        MOV    DS, AX
  18.        
  19.        
  20. MOV     DX,2000          ; Number of times to repeat whole routine.
  21.  
  22. MOV     BX,1             ; Frequency value.
  23.  
  24. MOV     AL, 10110110B    ; The Magic Number (use this binary number only)
  25. OUT     43H, AL          ; Send it to the initializing port 43H Timer 2.
  26.  
  27. NEXT_FREQUENCY:          ; This is were we will jump back to 2000 times.
  28.  
  29. MOV     AX, BX           ; Move our Frequency value into AX.
  30.  
  31. OUT     42H, AL          ; Send LSB to port 42H.
  32. MOV     AL, AH           ; Move MSB into AL  
  33. OUT     42H, AL          ; Send MSB to port 42H.
  34.  
  35. IN      AL, 61H          ; Get current value of port 61H.
  36. OR      AL, 00000011B    ; OR AL to this value, forcing first two bits high.
  37. OUT     61H, AL          ; Copy it to port 61H of the PPI Chip
  38.                          ; to turn ON the speaker.
  39.  
  40. MOV     CX, 100          ; Repeat loop 100 times
  41. DELAY_LOOP:              ; Here is where we loop back too.
  42. LOOP    DELAY_LOOP       ; Jump repeatedly to DELAY_LOOP until CX = 0
  43.  
  44.  
  45. INC     BX               ; Incrementing the value of BX lowers
  46.                          ; the frequency each time we repeat the
  47.                          ; whole routine
  48.  
  49. DEC     DX               ; Decrement repeat routine count
  50.  
  51. CMP     DX, 0            ; Is DX (repeat count) = to 0
  52. JNZ     NEXT_FREQUENCY   ; If not jump to NEXT_FREQUENCY
  53.                          ; and do whole routine again.
  54.  
  55.                          ; Else DX = 0 time to turn speaker OFF
  56.  
  57. IN      AL,61H           ; Get current value of port 61H.
  58. AND     AL,11111100B     ; AND AL to this value, forcing first two bits low.
  59. OUT     61H,AL           ; Copy it to port 61H of the PPI Chip
  60.                          ; to turn OFF the speaker
  61.  
  62.  
  63.   MOV AH,00
  64.   MOV AL, 2
  65.   INT 10h  
  66.  
  67. ret
  68.  
  69. BEGIN ENDP
  70.  
  71. CODESG        ENDS
  72. END           BEGIN
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement