Geliştiriciler İçin C To NASM Dönüştürme Örneği
-
#include <stdio.h> #include <stdlib.h> #include <windows.h> int xCounter1; int xCounter2; UINT_PTR TmrA; UINT_PTR TmrB; UINT_PTR TmrC; void ShowMessage() { MessageBoxA(0,"SELAM","MORUK",0); } VOID CALLBACK TimerProc1(HWND hwnd,UINT uMsg,UINT_PTR idEvent,DWORD dwTime) { xCounter1++; } VOID CALLBACK TimerProc2(HWND hwnd,UINT uMsg,UINT_PTR idEvent,DWORD dwTime) { xCounter2--; } VOID CALLBACK TimerProc3(HWND hwnd,UINT uMsg,UINT_PTR idEvent,DWORD dwTime) { if((xCounter1==21) && (xCounter2==6)) { KillTimer(NULL,TmrA); KillTimer(NULL,TmrB); KillTimer(NULL,TmrC); ShowMessage(); ExitProcess(0); } } void ProcessTimerMessages() { MSG msg; while (GetMessage(&msg, NULL,NULL, NULL)) { TranslateMessage(&msg); DispatchMessage(&msg); } } int main() { xCounter1=1; xCounter2=10; TmrA = SetTimer(NULL,0,1000,(TIMERPROC) TimerProc1); TmrB = SetTimer(NULL,0,5000,(TIMERPROC) TimerProc2); TmrC = SetTimer(NULL,0,100,(TIMERPROC) TimerProc3); ProcessTimerMessages(); return 0; } -
import MessageBoxA user32.dll extern MessageBoxA import SetTimer user32.dll extern SetTimer import GetMessageA user32.dll extern GetMessageA import TranslateMessage user32.dll extern TranslateMessage import DispatchMessageA user32.dll extern DispatchMessageA import KillTimer user32.dll extern KillTimer import Sleep kernel32.dll extern Sleep import ExitProcess kernel32.dll extern ExitProcess section .data szTitle db "MORUK", 0 szBody db "SELAM", 0 section .bss xCounter1 dd 1 xCounter2 dd 10 TmrA dd 0 TmrB dd 0 TmrC dd 0 msg resb 28 section .code Bits 32 global Main Message: push 0 push szTitle push szBody push 0 call [MessageBoxA] ret TimerProc1: push ebp mov ebp, esp inc dword [xCounter1] pop ebp ret 16 TimerProc2: push ebp mov ebp, esp dec dword [xCounter2] pop ebp ret 16 TimerProc3: push ebp mov ebp, esp mov eax, [xCounter1] cmp eax, 21 jnz .Finish mov eax, [xCounter2] cmp eax, 6 jnz .Finish push dword [TmrA] push 0 call [KillTimer] push dword [TmrB] push 0 call [KillTimer] push dword [TmrC] push 0 call [KillTimer] call Message push 0 call [ExitProcess] .Finish: pop ebp ret 16 Main: push TimerProc1 push 1000 push 0 push 0 call [SetTimer] mov dword [TmrA], eax push TimerProc2 push 5000 push 0 push 0 call [SetTimer] mov dword [TmrB], eax push TimerProc3 push 100 push 0 push 0 call [SetTimer] mov dword [TmrC], eax .Msg: lea ebx, [msg] push 0 push 0 push 0 push ebx call [GetMessageA] test eax, eax jz .Exit lea eax, [msg] push eax call [TranslateMessage] lea eax, [msg] push eax call [DispatchMessageA] jmp .Msg .Exit: retwh0 tarafından 20/Oca/15 16:40 tarihinde düzenlenmiştir -
for(;;)
{
printf("motoru yaktım.");
}
Toplam Hit: 2233 Toplam Mesaj: 3
