我竟然用汇编让计算机唱出了《大鱼》!!!

⬇⬇⬇最终成果在这,跪求三连!!!⬇⬇⬇

→→→→→→给个三连吧孩子不容易

assume cs:codesg,ds:datasg,ss:stacksg
datasg segment 
mus_frep dw 659,587,659,880,659,587,659,988
         dw 659,587,659,1046,988,784
	 dw 659,587,659,880,659,587,659,988
	 dw 784,523,494,494
	 dw 659,587,659,880,659,587,659,988
	 dw 659,587,659,1046,988,784
	 dw 587,659,440,587,659,440,392
	 dw 440,440,440,440

	 dw 440,523,523,587,587,659,659,880
	 dw 784,659,587,587
	 dw 440,523,523,587,587,659,659
	 dw 440,392,392,392,392
	 dw 440,523,523,587,587,659,659,880
	 dw 784,659,587,587
	 dw 587,659,440,587,659,440,392
	 dw 440,440,440,440,262
	 dw 587,523,440,440,523
	 dw 587,523,659,659,784
	 dw 880,880,784,659,587,523
	 dw 587,659,659,659,440,523
	 dw 587,523,440,440,440,523
	 dw 587,523,659,659
	 dw 587,659,440,587,659,440,392
	 dw 440,440,440,659,784
	 dw 1046,988,659,659,587
	 dw 523,523,587,659,659,587
	 dw 523,880,1046,988,880,784,587
	 dw 659,659,659,659,784
	 dw 1046,988,659,659,587
	 dw 523,523,587,659,659
	 dw 587,659,440,587,659,440,392
	 dw 440,440,440,440

	 dw 440,523,523,587,587,659,659,880
	 dw 784,659,587,587
	 dw 440,523,523,587,587,659,659
	 dw 440,392,392,392,392
	 dw 440,523,523,587,587,659,659,880
	 dw 784,659,587,587
	 dw 587,659,440,587,659,440,392
	 dw 440,440,440,440,262
	 dw 587,523,440,440,523
	 dw 587,523,659,659,784
	 dw 880,880,784,659,587,523
	 dw 587,659,659,659,440,523
	 dw 587,523,440,440,440,523
	 dw 587,523,659,659
	 dw 587,659,440,587,659,440,392
	 dw 440,440,440,659,784
	 dw 1046,988,659,659,587
	 dw 523,523,587,659,659,587
	 dw 523,880,1046,988,880,784,880
	 dw 659,659,659,659,784
	 dw 1046,988,659,659,587
	 dw 523,523,587,659,659
	 dw 587,659,440,587,659,440,392
	 dw 440,440,440,440,-1
mus_time dw 8 dup(25)
         dw 4 dup(25),2 dup(50)
	 dw 8 dup(25)
	 dw 4 dup(50)
	 dw 8 dup(25)
	 dw 4 dup(25),2 dup(50)
	 dw 2 dup(50),25,2 dup(50),2 dup(50)
	 dw 4 dup(50)

	 dw 8 dup(25)
	 dw 75,25,2 dup(50)
	 dw 6 dup(25),50
	 dw 37,13,3 dup(50)
	 dw 8 dup(25)
	 dw 75,25,2 dup(50)
	 dw 2 dup(25),50,4 dup(25)
	 dw 3 dup(50),2 dup(25)
	 dw 75,25,50,2 dup(25)
	 dw 50,4 dup(25),50
	 dw 37,13,2 dup(50),2 dup(25)
	 dw 75,12,13,50,2 dup(25)
	 dw 4 dup(50)
	 dw 2 dup(25),50,4 dup(25)
	 dw 3 dup(50),2 dup(25)
	 dw 75,25,50,2 dup(25)
	 dw 50,2 dup(25),50,2 dup(25)
	 dw 50,6 dup(25)
	 dw 3 dup(50),2 dup(25)
	 dw 75,25,50,2 dup(25)
	 dw 50,2 dup(25),2 dup(50)
	 dw 2 dup(25),50,2 dup(25),2 dup(25)
	 dw 4 dup(50)

	 dw 8 dup(25)
	 dw 75,25,2 dup(50)
	 dw 6 dup(25),50
	 dw 37,13,3 dup(50)
	 dw 8 dup(25)
	 dw 75,25,2 dup(50)
	 dw 2 dup(25),50,4 dup(25)
	 dw 3 dup(50),2 dup(25)
	 dw 75,25,50,2 dup(25)
	 dw 50,4 dup(25),50
	 dw 37,13,2 dup(50),2 dup(25)
	 dw 75,12,13,50,2 dup(25)
	 dw 4 dup(50)
	 dw 2 dup(25),50,4 dup(25)
	 dw 3 dup(50),2 dup(25)
	 dw 75,25,50,2 dup(25)
	 dw 50,2 dup(25),50,2 dup(25)
	 dw 50,6 dup(25)
	 dw 3 dup(50),2 dup(25)
	 dw 75,25,50,2 dup(25)
	 dw 50,2 dup(25),2 dup(50)
	 dw 2 dup(25),50,2 dup(25),2 dup(25)
	 dw 4 dup(50)
datasg ends
stacksg segment
  db 100h dup(0)
stacksg ends
codesg segment
start: 
       mov ax,stacksg
       mov ss,ax
       mov sp,100h
       mov ax,datasg
       mov ds,ax
       lea si,mus_frep
       lea di,mus_time
play:
       mov dx,[si]
       cmp dx,-1
       je end_play
       call sound
       add si,2
       add bp,2
       jmp play
end_play:
       mov ax,4c00h
       int 21h
sound:
       push ax
       push dx
       push cx

       mov al,0b6h       ;8253 chip initialization settings.
       out 43h,al        ;Port address 43h.
       mov dx,12h        
       mov ax,34dch
       div word ptr [si] ;Find the frequency address of the note.
       out 42h,al        ;First send the lower 8 bits to the counter, 42h is the port address of channel 2 of the 8253 chip.
       mov al,ah
       out 42h,al        ;Then send the high 8-bit counter.

       ;Set 8255 chip to control speaker switch.
       in al,61h
       mov ah,al  ;Save the original value read from the port.
       or al,3    ;Low 2 position 1, turn on the switch.
       out 61h,al  

       ;Delay for a certain amount of time.
       mov dx,[di]
wait1:
       mov cx,28000
delay:
       nop
       loop delay
       dec dx
       jnz wait1

       ;Restore the original value of the speaker port.
       mov al,ah
       out 61h,al

       pop cx
       pop dx
       pop ax
       ret
codesg ends
end start

 

  • 3
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值