回 帖 发 新 帖 刷新版面

主题:yi?

咦?这不是书上的原题么?难不成是马瑞芳。。。
data     segment
table   dw 262
    dw 294
    dw 330
    dw 349
    dw 392
    dw 440
    dw 494
    dw 523
data    ends

code    segment
    assume cs:code,ds:data
main    proc far
    mov ax,data
    mov ds,ax

new_note:
    mov ah,0
    int 16h
    cmp ah,10h
    je  exit
    mov bx,offset table
    cmp al,'1'
    jb  new_note
    cmp al,'8'
    ja  new_note
    and ax,0fh
    shl ax,1
    sub ax,2
    mov si,ax
    mov di,[bx][si]
    mov bx,10
    call soundf
    
    jmp new_note
exit:
    
    mov ax,4c00h
    int 21h
    ret
main    endp
;=======================================================
;-------------------------------------------------------------------------------
;SOUNDF发声子程序
;-------------------------------------------------------------------------------
soundf  proc far
    push ax
    push bx
    push cx
    push dx
    push di
    mov  al,0b6h
    out  43h,al
    mov  dx,12h
    mov ax,384ch
    div di
    out 42h,al
    mov al,ah
    out 42h,al
    
    in  al,61h
    mov ah,al
    or  al,3
    out 61h,al
    
wait1:    mov cx,663
    call waitf
    dec bx
    jnz wait1
    mov al,ah
    out 61h,al
    pop di
    pop dx
    pop cx
    pop bx
    pop ax
    
    ret
soundf  endp

;-----------------------------------------------------------------------------------
;WAITF延迟子程序
;-----------------------------------------------------------------------------------
waitf   proc far
    push ax
waitf1:    in  al,61h
    and al,10h
    cmp al,ah
    je  waitf1
    mov ah,al
    loop waitf1
    pop ax
    ret
waitf    endp

;==========================================
code ends
end main

回复列表 (共2个回复)

沙发


thx,
汇编没怎么学过,就学C的,

板凳

都学学,会有用的

我来回复

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