//=Reposted from others. .
SPEAKER EQU P2.0; Define the speaker driver port
ORG 0000H; Pseudo address
LJMP MAIN; Long jump, execute Main function
ORG 000BH
LJMP DSQT0
MAIN: MOV SP,#50H ;Write 50 to SP
MOV TMOD,#01H ;Timer setting
MOV TH0,#0F8H ;Bass 1-261HZ;Load the high initial value of the timer
MOV TL0,#39H ;Load the low initial value of the timer
< p>SETB EA ;Allow interruptsSETB ET0 ;Enable T0 timer interrupt if EA is open
CLR TR0 ;Do not enable T0 counter/timer LOOP: NOP ; Start looping. The program is incomplete
; ----------------------------------
; 1-|6. 5 3 5 | ;The first paragraph
LCALL DY6 ;Long jump to the bass 6 label, the program is incomplete and has not been written out.
The same applies to the following
SETB TR0; Start enabling T0 counter/timer
LCALL DEL11
LCALL DEL12
LCALL ZY5
LCALL DEL12
LCALL ZY3
LCALL DEL11
LCALL ZY5
LCALL DEL11
; -----------------------
; 2-|1 6 5 6- | ;Second paragraph
LCALL GY1
SETB TR0
LCALL DEL11
LCALL ZY6
LCALL DEL12
LCALL ZY5 p>
LCALL DEL12
LCALL ZY6
LCALL DEL11
LCALL DEL11
; -------- ---------------
; 3-|3 5 6 5 3 |
LCALL ZY3
SETB TR0
LCALL DEL11
LCALL ZY5
LCALL DEL12
LCALL ZY6
LCALL DEL12
< p>LCALL ZY5LCALL DEL11
LCALL ZY3
LCALL DEL11
; ----------- ------------
; 4-|1 6 5 3 2- |
LCALL ZY1
SETB TR0 p>
LCALL DEL12
LCALL DY6
LCALL DEL12
LCALL ZY5
LCALL DEL12
LCALL ZY3
LCALL DEL12
LCALL ZY2
LCALL DEL11
LCALL DEL11
; ---- ------------------
; 5-|2. 3 5 5 6 |
LCALL ZY2
SETB TR0
LCALL DEL11
LCALL DEL12
LCALL ZY3
LCALL DEL12
LCALL ZY5
LCALL DEL11
LCALL ZY5
LCALL DEL12
LCALL ZY6
LCALL DEL12
< p>; -----------------------; 6-|3 2 1 -|
LCALL ZY3
SETB TR0
LCALL DEL11
LCALL ZY2
LCALL DEL11
LCALL ZY1
LCALL DEL11
LCALL DEL11
; -----------------------
< p>; 7-|5. 3 2 1 6 1 |LCALL ZY5
SETB TR0
LCALL DEL11
LCALL ZY3
LCALL DEL12
LCALL ZY2
LCALL DEL12
LCALL ZY1
LCALL DEL12
< p>LCALL DY6LCALL DEL12
LCALL ZY1
LCALL DEL12
; ----------- ------------
; 8-|5 - - - |
LCALL DY5
SETB TR0
LCALL DEL11
LCALL DEL11
LCALL DEL11
LCALL DEL11
LJMP LOOP jump to loop and play again
p>; ===========================================< /p>
; The bass note frequency corresponds to the 16-bit timer initial value device subroutine
DY1: MOV 30H, #0F8H; Bass 1-262HZ Put F8 in the address of 30
MOV 40H,#89H
NOP
RET
DY2: MOV 30H,#0F9H; Bass 2-294HZ
MOV 40H,#59H
RET
NOP