[問題] 組語如何發聲音?(已有程式了)
; THIS FILE WILL GENERATE Do, Re, Mi, Fa, So, La, Si, Do
; SEVEN BASIC SOUNDS
C1 EQU 11C4H ; 1190000/261.63 (之16進位)
C2 EQU 0FD4H ; 1190000/293.67 (之16進位)
C3 EQU 0E1AH ; 1190000/329.63 (之16進位)
C4 EQU 0D50H ; 1190000/349.23 (之16進位)
C5 EQU 0BDCH ; 1190000/392.00 (之16進位)
C6 EQU 0A91H ; 1190000/440.00 (之16進位)
C7 EQU 0969H ; 1190000/493.89 (之16進位)
D1 EQU 08E2H ; 1190000/(261.63*2) (之16進位)
.MODEL SMALL
.STACK
.DATA
MUSIC DW C1, C2, C3, C4, C5, C6, C7, D1, 00
.CODE
;----------------------------------------------------------------
; THIS PROCEDURE WILL PLAY THE INPUT FREQUENCY IN DX
; ON SPEAKER
PLAY PROC
PUSH AX
PUSH BX
PUSH CX
PUSH DX
MOV AL, 0B6H ; SET PARAMETERS OF 8254
OUT 43H, AL ; SET 8254 CONTROL MODE
MOV AL, DL ; SET 8254 TIMER 2 DATA
OUT 42H, AL ; FREQUENCY IN DX
MOV AL, DH ;
OUT 42H, AL
MOV AX, 0500H
DELAY: MOV CX, 0FFFFH
DELY2: NOP
LOOP DELY2
DEC AX
JNZ DELAY
POP DX
POP CX
POP BX
POP AX
RET
PLAY ENDP
;----------------------------------------------------------------
MAIN:
MOV AX, @DATA
MOV DS, AX
IN AL, 61H ; OPEN SPEAKER
OR AL, 00000011B
OUT 61H, AL
MOV BX, OFFSET MUSIC ; SET INITIAL MUSIC POINTER IN BX
SOUND: MOV DX, DS:[BX] ; GET SOUND FREQUENCY IN DX
CMP DX,0 ; CHECK END
JZ EXIT ;
CALL PLAY ; CALL PLAY PROCEDURE
ADD BX,2 ; INCREASE BX POINTER BY 2
JMP SOUND ; AGAIN
EXIT: IN AL, 61H ; CLOSE SPEAKER
AND AL, 11111100B
OUT 61H, AL
MOV AH, 4CH
INT 21H
END MAIN
****************************************************************************
我在dos模式.....
C:\>cd masm615
C:\Masm615>masm 555.asm
Microsoft (R) MASM Compatibility Driver
Copyright (C) Microsoft Corp 1993. All rights reserved.
Invoking: ML.EXE /I. /Zm /c /Ta 555.asm
Microsoft (R) Macro Assembler Version 6.15.8803
Copyright (C) Microsoft Corp 1981-2000. All rights reserved.
Assembling: 555.asm
C:\Masm615>link
Microsoft (R) Segmented Executable Linker Version 5.31.009 Jul 13 1992
Copyright (C) Microsoft Corp 1984-1992. All rights reserved.
Object Modules [.obj]:
Object Modules [.obj]:
LINK : fatal error L1020: no object files specified
C:\Masm615>masm 555.obj
Microsoft (R) MASM Compatibility Driver
Copyright (C) Microsoft Corp 1993. All rights reserved.
Invoking: ML.EXE /I. /Zm /c /Ta 555.obj
Microsoft (R) Macro Assembler Version 6.15.8803
Copyright (C) Microsoft Corp 1981-2000. All rights reserved.
Assembling: 555.obj
555.obj(1) : error A2044: invalid character in file
555.obj(2) : error A2044: invalid character in file
555.obj(3) : error A2044: invalid character in file
555.obj(3) : error A2088: END directive required at end of file
C:\Masm615>
*****************************************************************************
這個程式碼一定對!!!!(因為我有聽到老師發出聲音來!!)
但為什麼還會不能編譯成功捏??
感謝大大回答囉@@
*****************************************************************************
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 125.225.112.210
推
05/23 14:28, , 1F
05/23 14:28, 1F
討論串 (同標題文章)
以下文章回應了本文:
完整討論串 (本文為第 1 之 3 篇):
ASM 近期熱門文章
PTT數位生活區 即時熱門文章