|
10鱼币
这是我仿照C语言的书上写的录音程序,结果运行之后就是没有声音,急啊急求助!!!!!拜谢
.386
.model flat,stdcall
option casemap:none
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
include windows.inc
include user32.inc
includelib user32.lib
include kernel32.inc
includelib kERnel32.lib
include winmm.inc
includelib winmm.lib
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
ICO_MAIN equ 0x1000
DLG_MAIN equ 1
IDC_EDIT equ 100
IDC_1 equ 101
IDC_2 equ 102
IDC_3 equ 103
IDC_4 equ 104
IDC_5 equ 105
IDC_6 equ 106
IDC_7 equ 107
IDC_8 equ 108
IDC_9 equ 109
IDC_0 equ 110
IDC_CONNECT equ 111
IDC_POINT equ 112
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
; 数据段
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
.data?
hInstance dd ?
buffer dd ?
newbuffer dd ?
hWavein dd ?
hWaveout dd ?
hHeap dd ?
waveform WAVEFORMATEX <>
pwavehdr1 dd ?
pwavehdr2 dd ?
pwavehdr3 dd ?
pbuffer1 dd ?
pbuffer2 dd ?
aa123 dd ?
.data
ipbuffer byte 100 dup (0)
count dd 0
datalength dd 0
.const
point1 db '.',0
error db '调用错误',0
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
; 代码段
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
.code
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
; 子函数
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
_datacopy proc uses ebx edi esi purpose,source,count1
push ecx
mov edi,purpose
mov esi,source
mov ecx,count1
mov ebx,0
.while ebx<ecx
mov al,[esi]
mov [edi],al
add ebx,1
.endw
pop ecx
ret
_datacopy endp
_ProcDlgMain proc uses ebx edi esi hWnd,wMsg,wParam,lParam
mov eax,wMsg
.if eax == WM_CLOSE
invoke EndDialog,hWnd,NULL
.elseif eax == WM_INITDIALOG
invoke LoadIcon,NULL,IDI_APPLICATION
invoke SendMessage,hWnd,WM_SETICON,ICON_BIG,eax
invoke GetProcessHeap
mov hHeap,eax
invoke HeapAlloc,hHeap,HEAP_ZERO_MEMORY,sizeof WAVEHDR
mov pwavehdr1,eax
; mov eax,pwavehdr1
; mov DWORD ptr ipbuffer,eax
; invoke SetDlgItemInt,hWnd,IDC_EDIT,addr ipbuffer,FALSE
; invoke MessageBox,NULL,addr error,addr error,MB_OK
invoke HeapAlloc,hHeap,HEAP_ZERO_MEMORY,sizeof WAVEHDR
mov pwavehdr2,eax
invoke HeapAlloc,hHeap,HEAP_ZERO_MEMORY,sizeof WAVEHDR
mov pwavehdr3,eax
invoke HeapAlloc,hHeap,HEAP_ZERO_MEMORY,1
mov buffer,eax
.elseif eax== MM_WIM_OPEN
invoke GetProcessHeap
mov hHeap,eax
invoke HeapReAlloc,hHeap,HEAP_ZERO_MEMORY,buffer,1
mov buffer,eax
invoke waveInAddBuffer,hWavein,pwavehdr1,sizeof WAVEHDR
invoke waveInAddBuffer,hWavein,pwavehdr2,sizeof WAVEHDR
invoke waveInStart,hWavein
.elseif eax==MM_WIM_DATA
mov esi,lParam
invoke GetProcessHeap
mov hHeap,eax
mov eax,[esi+WAVEHDR.dwBytesRecorded]
add eax,datalength
invoke HeapReAlloc,hHeap,HEAP_ZERO_MEMORY,buffer,eax
mov buffer,eax
; push eax
; mov DWORD ptr ipbuffer,eax
; invoke SetDlgItemInt,hWnd,IDC_EDIT,addr ipbuffer,FALSE
; invoke MessageBox,NULL,addr error,addr error,MB_OK
; pop eax
mov eax,buffer
add eax,datalength
mov ebx,[esi+WAVEHDR.lpData]
mov edi,[esi+WAVEHDR.dwBytesRecorded]
invoke _datacopy,eax,ebx,edi
mov esi,lParam
mov edi,[esi+WAVEHDR.dwBytesRecorded]
add datalength,edi
.if aa123==FALSE
invoke waveInClose,hWavein
.endif
invoke waveInAddBuffer,hWavein,esi,sizeof WAVEHDR
.elseif eax==MM_WIM_CLOSE
invoke waveInUnprepareHeader,hWavein,pwavehdr1,sizeof WAVEHDR
invoke waveInUnprepareHeader,hWavein,pwavehdr2,sizeof WAVEHDR
.elseif eax==MM_WOM_OPEN
mov esi,pwavehdr3
mov eax,buffer
mov ebx,datalength
mov [esi+WAVEHDR.lpData],eax
mov [esi+WAVEHDR.dwBufferLength],ebx
mov [esi+WAVEHDR.dwBytesRecorded],WHDR_BEGINLOOP or WHDR_ENDLOOP
mov [esi+WAVEHDR.dwUser],1
mov [esi+WAVEHDR.dwFlags],0
mov [esi+WAVEHDR.dwLoops],2
mov [esi+WAVEHDR.lpNext],NULL
mov [esi+WAVEHDR.Reserved],0
invoke waveOutPrepareHeader,hWaveout,pwavehdr3,sizeof WAVEHDR
invoke waveOutWrite,hWaveout,pwavehdr3,sizeof WAVEHDR
.elseif eax==MM_WOM_DONE
.elseif eax==MM_WOM_CLOSE
.elseif eax == WM_COMMAND
mov eax,wParam
.if ax==IDC_1
mov aa123,TRUE
invoke GetProcessHeap
mov hHeap,eax
invoke HeapAlloc,hHeap,HEAP_ZERO_MEMORY,16384
mov pbuffer1,eax
mov esi,pwavehdr1
mov [esi+WAVEHDR.lpData],eax
mov [esi+WAVEHDR.dwBufferLength],16384
mov [esi+WAVEHDR.dwBytesRecorded],0
mov [esi+WAVEHDR.dwUser],0
mov [esi+WAVEHDR.dwFlags],0
mov [esi+WAVEHDR.dwLoops],1
mov [esi+WAVEHDR.lpNext],NULL
mov [esi+WAVEHDR.Reserved],0
invoke HeapAlloc,hHeap,HEAP_ZERO_MEMORY,16384
mov pbuffer2,eax
mov esi,pwavehdr2
mov [esi+WAVEHDR.lpData],eax
mov [esi+WAVEHDR.dwBufferLength],16384
mov [esi+WAVEHDR.dwBytesRecorded],0
mov [esi+WAVEHDR.dwUser],0
mov [esi+WAVEHDR.dwFlags],0
mov [esi+WAVEHDR.dwLoops],1
mov [esi+WAVEHDR.lpNext],NULL
mov [esi+WAVEHDR.Reserved],0
mov waveform.wFormatTag,WAVE_FORMAT_PCM
mov waveform.nChannels,1
mov waveform.nSamplesPerSec,11025
mov waveform.nAvgBytesPerSec,11025
mov waveform.nBlockAlign,1
mov waveform.wBitsPerSample,8
mov waveform.cbSize,0
lea ebx,hWavein
lea edi,waveform
invoke waveInOpen,ebx,WAVE_MAPPER,edi,hWnd,0,CALLBACK_WINDOW
invoke waveInPrepareHeader,hWavein,pwavehdr1,sizeof WAVEHDR
invoke waveInPrepareHeader,hWavein,pwavehdr2,sizeof WAVEHDR
.elseif ax==IDC_2
mov aa123,FALSE
invoke waveInReset,hWavein
.elseif ax==IDC_3
mov waveform.wFormatTag,WAVE_FORMAT_PCM
mov waveform.nChannels,1
mov waveform.nSamplesPerSec,11025
mov waveform.nAvgBytesPerSec,11025
mov waveform.nBlockAlign,1
mov waveform.wBitsPerSample,8
mov waveform.cbSize,0
lea ebx,hWaveout
lea edi,waveform
invoke waveOutOpen,ebx,WAVE_MAPPER,edi,hWnd,0,CALLBACK_WINDOW
.elseif ax==IDC_4
invoke waveOutRestart,hWaveout
.elseif ax==IDC_5
.elseif ax==IDC_6
.elseif ax==IDC_7
.elseif ax==IDC_8
.elseif ax==IDC_9
.elseif ax==IDC_0
.elseif ax==IDC_POINT
.elseif ax==IDC_CONNECT
.endif
.else
mov eax,FALSE
ret
.endif
mov eax,TRUE
ret
_ProcDlgMain endp
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
;主程序
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
start:
invoke GetModuleHandle,NULL
mov hInstance,eax
invoke DialogBoxParam,hInstance,DLG_MAIN,NULL,offset _ProcDlgMain,NULL
invoke ExitProcess,NULL
end start
下面的资源文件
//毕业设计主窗口资源//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> #include <resource.h>//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> #define ICO_MAIN 0x1000 #define DLG_MAIN 1 #define IDC_EDIT 100 #define IDC_1 101 #define IDC_2 102 #define IDC_3 103 #define IDC_4 104 #define IDC_5 105 #define IDC_6 106 #define IDC_7 107 #define IDC_8 108 #define IDC_9 109 #define IDC_0 110 #define IDC_CONNECT 111 #define IDC_POINT 112//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> ICO_MAIN ICON "Main.ico" DLG_MAIN DIALOG 190,180,151,210 STYLE DS_MODALFRAME|WS_POPUP|WS_VISIBLE|WS_CAPTION|WS_SYSMENU CAPTION "基于win32汇编语言的语音电话系统" FONT 9,"宋体" BEGIN EDITTEXT IDC_EDIT 17,16,118,30 CONTROL "",-1, "Static", SS_ETCHEDHORZ | WS_CHILD | WS_VISIBLE, 0, 63, 151, 1
PUSHBUTTON "1",IDC_1,16,93,30,17 PUSHBUTTON "2",IDC_2,57,93,30,17 PUSHBUTTON "3",IDC_3,103,93,30,17 PUSHBUTTON "4",IDC_4,16,123,30,17 PUSHBUTTON "5",IDC_5,57,123,30,17 PUSHBUTTON "6",IDC_6,103,123,30,17 PUSHBUTTON "7",IDC_7,16,155,30,17 PUSHBUTTON "8",IDC_8,57,155,30,17 PUSHBUTTON "9",IDC_9,103,155,30,17 PUSHBUTTON "0",IDC_0,57,185,30,17 PUSHBUTTON "拨号",IDC_CONNECT,16,185,30,17 PUSHBUTTON ".",IDC_POINT,103,185,30,17 END
|
最佳答案
查看完整内容
用汇编语言来做毕业设计有水平。不过这代码着实很长啊,看晕了
|