Скомпилировать программу, и найти ошибки если есть - Assembler
Формулировка задачи:
Помогите пожалуйста скомпилировать программу, и найти ошибки если есть
Все я сам скомпилировал, куча ошибок... Буду стараться сам исправить.
P386
MODEL FLAT,stdcall
INCLUDE Win32.INC
IDD_DIALOG = 100
IDD_BLOCKDLG1 = 101
IDD_BLOCKDLG2 = 102
IDD_BLOCKDLG3 = 103
IDD_BLOCKDLG4 = 104
IDD_BLOCKDLG5 = 105
IDR_ABOUT = 106
extrn GetCurrentThreadId:PROC
extrn GetModuleHandleA:PROC
extrn ExitProcess:PROC
extrn PostQuitMessage:PROC
extrn CreateThread:PROC
extrn CreateDialogParamA:PROC
extrn MessageBoxA:PROC
extrn ShowWindow:PROC
extrn EndDialog:PROC
extrn GetDlgItem:PROC
extrn GetDlgItemTextA:PROC
extrn SetFocus:PROC
extrn GetWindowLongA:PROC
extrn SetWindowLongA:PROC
extrn SetWindowTextA:PROC
extrn RedrawWindow:PROC
extrn UpdateWindow:PROC
extrn InvalidateRect:PROC
extrn GetMessageA:PROC
extrn TranslateMessage:PROC
extrn DispatchMessageA:PROC
extrn WaitForSingleObject:PROC
extrn CreateSemaphoreA:PROC
extrn ReleaseSemaphore:PROC
extrn SetEvent:PROC
extrn GetLastError:PROC
extrn FormatMessageA:PROC
extrn lstrcpy:PROC
.DATA
WH_KEYBOARD = 2
MAX_USER_NAME = 20
msg MSGSTRUCT
hinst dd 0
hwnd_dlg dd 0
hwnd_cld1 dd 0
hwnd_cld2 dd 0
hwnd_cld3 dd 0
hwnd_cld4 dd 0
hwnd_cld5 dd 0
Hwnd_Btn dd 0
hSemaphore dd 0
ThreadId1 dd 0
ThreadId2 dd 0
ThreadId3 dd 0
ThreadId4 dd 0
ThreadId5 dd 0
lpSemName db 'MySemaphore',0
errmes db 0
lcwait db 'Waiting...', 0
lcmsg db 'Waiting...', 0
lnmeslen dd 7
lnmaxlen dd 10
lcallright db 'Отработал', 0
cap db 'Отладочное сообщение',0
mes db 'Нужный вам участок кода выполнился',0
.CODE
Start: call GetModuleHandleA, 0
mov [hinst], eax
call CreateDialogParamA, [hinst], IDD_DIALOG, 0, offset MAINWNDPROC, 0
mov [hwnd_dlg], eax
call ShowWindow, [hwnd_dlg], SW_SHOWNORMAL
call CreateDialogParamA, [hinst], IDD_BLOCKDLG1, [hwnd_dlg], offset CHILDWNDPROC, 0
mov [hwnd_cld1], eax
call ShowWindow, [hwnd_cld1], SW_SHOWNORMAL
call CreateDialogParamA, [hinst], IDD_BLOCKDLG2, [hwnd_dlg], offset CHILDWNDPROC, 0
mov [hwnd_cld2], eax
call ShowWindow, [hwnd_cld2], SW_SHOWNORMAL
call CreateDialogParamA, [hinst], IDD_BLOCKDLG3, [hwnd_dlg], offset CHILDWNDPROC, 0
mov [hwnd_cld3], eax
call ShowWindow, [hwnd_cld3], SW_SHOWNORMAL
call CreateDialogParamA, [hinst], IDD_BLOCKDLG4, [hwnd_dlg], offset CHILDWNDPROC, 0
mov [hwnd_cld4], eax
call ShowWindow, [hwnd_cld4], SW_SHOWNORMAL
call CreateDialogParamA, [hinst], IDD_BLOCKDLG5, [hwnd_dlg], offset CHILDWNDPROC, 0
mov [hwnd_cld5], eax
call ShowWindow, [hwnd_cld5], SW_SHOWNORMAL
call CreateSemaphoreA, 0, 2, 2, offset lpSemName
mov [hSemaphore], eax
; Локальный обработчик ошибок
cmp eax, 0
jne lblnoerror1
call GetLastError
call FormatMessageA, 1000h, 0, eax, 0, offset errmes, 400h, 0
call MessageBoxA, [Hwnd_Btn], offset errmes, offset cap, MB_OK
lblnoerror1:
call CreateThread, 0, 0, offset TH_PROC, [hwnd_cld1], 0, offset ThreadId1
call CreateThread, 0, 0, offset TH_PROC, [hwnd_cld2], 0, offset ThreadId2
call CreateThread, 0, 0, offset TH_PROC, [hwnd_cld3], 0, offset ThreadId3
call CreateThread, 0, 0, offset TH_PROC, [hwnd_cld4], 0, offset ThreadId4
call CreateThread, 0, 0, offset TH_PROC, [hwnd_cld5], 0, offset ThreadId5
@@msg_loop:
call GetMessageA, offset msg, 0, 0, 0
cmp ax, 0
je @@end_msgloop
call TranslateMessage, offset msg
call DispatchMessageA, offset msg
jmp @@msg_loop
@@end_msgloop:
bye: call ExitProcess, 0
TH_PROC Proc USES ebx edi esi, @@hwnd:DWORD, @@wMsg:DWORD, WParam:DWORD, LParam:DWORD
call lstrcpy, offset lcmsg, offset lcwait
@@TH_Init:
mov ebx, lnmeslen
@@TH_Start:
call WaitForSingleObject, [hSemaphore], 200
cmp eax, 0
je @@TH_Finish
mov [lcmsg]+ebx, 0
call GetDlgItem, LParam, IDR_ABOUT
call SetWindowTextA, eax, offset lcmsg
mov [lcmsg]+ebx, 46
add ebx, 1
cmp ebx, lnmaxlen
ja @@TH_Init
jmp @@TH_Start
call GetDlgItem, LParam, IDOK
mov [Hwnd_Btn], eax
call GetWindowLongA, [Hwnd_Btn], GWL_STYLE
mov ebx, WS_DISABLED
not ebx
and eax, ebx
call SetWindowLongA, [Hwnd_Btn], GWL_STYLE, eax
call InvalidateRect, [Hwnd_Btn], 0, 1
call GetDlgItem, LParam, IDR_ABOUT
mov [Hwnd_Btn], eax
call SetWindowTextA, [Hwnd_Btn], offset lcallright
mov eax, 0
ret
TH_PROC endp
public MAINWNDPROC
MAINWNDPROC Proc stdcall, @@hDlg :dword, @@iMsg :dword, @@wPar :dword, @@lPar :dword
USES ebx, edi, esi
mov eax,[@@iMsg]
cmp eax,WM_INITDIALOG
je @@init
cmp eax,WM_COMMAND
jne @@ret_false
mov eax,[@@wPar]
cmp eax,IDOK
je @@cancel
cmp eax,IDCANCEL
je @@cancel
jmp @@ret_false
@@cancel: call EndDialog, @@hDlg, eax
call PostQuitMessage
@@ret_false: xor eax, eax
ret
@@init:
call GetDlgItem, @@hDlg, IDOK
call SetFocus, eax
jmp @@ret_false
MAINWNDPROC endp
public CHILDWNDPROC
CHILDWNDPROC Proc stdcall, @@hDlg :dword, @@iMsg :dword, @@wPar :dword, @@lPar :dword
USES ebx, edi, esi
mov eax,[@@iMsg]
cmp eax,WM_INITDIALOG
je @@cld_init
cmp eax,WM_COMMAND
jne @@cld_return
mov eax,[@@wPar]
cmp eax,IDOK
je @@semaphor
jmp @@cld_return
call GetDlgItem, @@hDlg, IDOK
mov [Hwnd_Btn], eax
call GetWindowLongA, [Hwnd_Btn], GWL_STYLE
or eax, WS_DISABLED
call SetWindowLongA, [Hwnd_Btn], GWL_STYLE, eax
call InvalidateRect, [Hwnd_Btn], 0, 1
call ReleaseSemaphore, [hSemaphore], 1
call ReleaseSemaphore, [hSemaphore], 1
jmp @@cld_return
@@cld_init: call GetDlgItem, @@hDlg, IDOK
mov [Hwnd_Btn], eax
call GetWindowLongA, [Hwnd_Btn], GWL_STYLE
or eax, WS_DISABLED
call SetWindowLongA, [Hwnd_Btn], GWL_STYLE, eax
jmp @@cld_return
@@cld_return: xor eax, eax
ret
CHILDWNDPROC endp
end StartРешение задачи: «Скомпилировать программу, и найти ошибки если есть»
textual
Листинг программы
.CODE Start: pushad call printf, offset f_string, offset Logo add esp, 8 call printf, offset szAbout add esp, 4 jmp ok1__
Объяснение кода листинга программы
.CODE Start:
- pushad - сохранение регистров в стеке
- call printf, offset f_string, offset Logo - вывод строки
f_stringс символами из регистра - add esp, 8 - восстановление стека после вызова функции
- call printf, offset szAbout - вывод строки
szAbout - add esp, 4 - восстановление стека после вызова функции
- jmp ok1 - переход на метку ok1 (предполагается, что ошибка не произошла)