回 帖 发 新 帖 刷新版面

主题:[原创]汇编版张雨生《大海》

自学两个月汇编了,用MASM5.0编译。

data segment
freq dw 196,220
     dw 262,262,262,262,262,220,196
     dw 262,262,262,262,294,262,220,262
     dw 294,294,294,294,294,262,220
     dw 294,294,294,294,330,294,330,392
     dw 440,440,392,440,392,330
     dw 294,294,330,294,262,220,196,220
     dw 262,262,262,262,262,220
     dw 262,196,220
     dw 440,440,392,440,524,440
     dw 392,330,294,262,220,196,220
     dw 262,262,262,262,294,262
     dw 262,330,392
     dw 440,440,440,440,524,440
     dw 392,392,392,440,392,330,294
     dw 262,262,262,262,294
     dw 330,330,294
     dw 262,262,262,262,524,440
     dw 392,392,392,440,392,330,392
     dw 440,524,524,440,392
     dw 392,330,392
     dw 440,440,440,440,524,440
     dw 392,392,392,440,392,330,294
     dw 262,262,262,262,392
     dw 330,330,294
     dw 262,262,262,262,294,330
     dw 392,392,330,392,330,392
     dw 440
     dw 9,9,196,660,294,294,262
     dw 262,-1

time dw 400,400
     dw 400,200,400,400,800,400,400
     dw 400,200,400,200,200,800,400,400
     dw 400,200,400,400,800,400,400
     dw 400,200,400,200,200,800,400,400
     dw 400,800,400,800,400,400
     dw 400,200,200,400,400,800,400,400
     dw 400,200,400,400,800,800
     dw 1600,800,800
     dw 400,800,400,800,400,400
     dw 400,400,400,400,800,400,400
     dw 400,800,400,800,400,200
     dw 2400,400,400
     dw 400,800,400,800,400,400
     dw 400,800,200,200,800,400,400
     dw 400,800,400,800,800
     dw 2400,400,400
     dw 400,800,400,800,400,400
     dw 400,800,200,200,800,400,400
     dw 800,400,800,400,200
     dw 2400,400,400
     dw 400,800,400,800,400,400
     dw 400,800,200,200,800,400,400
     dw 400,800,400,800,800
     dw 2400,400,400
     dw 400,800,400,800,400,400
     dw 400,800,400,800,400,400
     dw 3200
     dw 800,400,400,400,400,400,400
     dw 4000
data ends

code segment
assume cs:code,ds:data
main proc far
start:mov ax,data
      mov ds,ax
      mov si,offset freq
      mov di,offset time
l1:  mov cx,[si]
      cmp cx,-1
      je exit
      mov bx,[di]
      call gensound
      add si,2
      add di,2
      jmp l1
exit:mov ax,4c00h
      int 21h
main endp

gensound proc near
       push dx
       mov al,0b6h
       out 43h,al
       mov dx,8h
       mov ax,3208h
       div cx
       out 42h,al
       mov al,ah
       out 42h,al
       in al,61h
       mov ah,al
       or al,3
       out 61h,al
l2:    push dx
       push ax
       mov dx,8h
       mov ax,0f05h
s1:    sub ax,1
       sbb dx,0
       jnz s1
       pop ax
       pop dx
       dec bx
       jnz l2
  
  mov al,ah
  out 61h,al
  pop dx
  ret
  gensound endp
  code ends
  end start

回复列表 (共68个回复)

31 楼

能力超强呀,我也是刚学,学了一个月了,还有好多不明白的,要多向楼主学习呀

32 楼

楼主,节奏太没找准了!延时没做好吧!

33 楼

怎么运行啊?
麻烦哪位老大详细的说一下,感激不尽!
我初学汇编,搞了N久竟还不会运行!

34 楼

to  phybbice

节奏因CPU频率而异

35 楼


为啥我用MASM32(8.0)编译不能通过?

ml /c /coff dahai.asm
Assembling: dahai.asm
dahai.asm(116) : error A2006: undefined symbol : start
dahai.asm(68) : error A2004: symbol type conflict
dahai.asm(116) : error A2148: invalid symbol type in expression : start

哪位能帮忙看一下?我是新手,谢谢了!

36 楼

明白了,我用了MASM32,

37 楼

强什么啊,大家运行一下啊,错误百出,太差劲了,根本不能听!!!!

38 楼

基本上音是对的,少数不准而已,楼主厉害!!!

37楼的,楼主都说了,CPU的频率不同音就不一样的,可能你的CPU跟楼主的差异太大了吧!

39 楼

I like!!

40 楼

我以前也用C写过音乐程序,还为他写了头文件,头文件里包含了4拍到16分之1拍
高中底三个音阶
呵呵

我来回复

您尚未登录,请登录后再回复。点此登录或注册