|
Ассемблер в примерах - Замена оператора IF...else на оператор cmp
- Вопрос:
- Мне надо поменять оператор IF...else на оператор cmp
Тока в данном куске кода синтаксис масма, а мне надо чтоб был синтаксис фасма.
.....
WndProc proc hWnd:HWND, uMsg:UINT, wParam:WPARAM, lParam:LPARAM
.IF uMsg==WM_DESTROY
invoke PostQuitMessage,NULL
.ELSEIF uMsg==WM_CREATE
invoke CreateWindowEx,WS_EX_CLIENTEDGE, ADDR EditClassName,NULL,\
WS_CHILD or WS_VISIBLE or WS_BORDER or ES_LEFT or\
ES_AUTOHSCROLL,\
50,35,200,25,hWnd,8,hInstance,NULL
mov hwndEdit,eax
invoke SetFocus, hwndEdit
invoke CreateWindowEx,NULL, ADDR ButtonClassName,ADDR ButtonText,\
WS_CHILD or WS_VISIBLE or BS_DEFPUSHBUTTON,\
75,70,140,25,hWnd,ButtonID,hInstance,NULL
mov hwndButton,eax
.ELSEIF uMsg==WM_COMMAND
mov eax,wParam
.IF lParam==0
.IF ax==IDM_HELLO
invoke SetWindowText,hwndEdit,ADDR TestString
.ELSEIF ax==IDM_CLEAR
invoke SetWindowText,hwndEdit,NULL
.ELSEIF ax==IDM_GETTEXT
invoke GetWindowText,hwndEdit,ADDR buffer,512
invoke MessageBox,NULL,ADDR buffer,ADDR AppName,MB_OK
.ELSE
invoke DestroyWindow,hWnd
.ENDIF
.ELSE
.IF ax==ButtonID
shr eax,16
.IF ax==BN_CLICKED
invoke SendMessage,hWnd,WM_COMMAND,IDM_GETTEXT,0
.ENDIF
.ENDIF
.ENDIF
.ELSE
invoke DefWindowProc,hWnd,uMsg,wParam,lParam
ret
.ENDIF
xor eax,eax
ret
WndProc endp
end start
- Ответ:
-
WndProc proc hWnd:HWND, uMsg:UINT, wParam:WPARAM, lParam:LPARAM
cmp [uMsg], WM_DESTROY ;.IF uMsg==WM_DESTROY
jne l_create
invoke PostQuitMessage,NULL
jmp l_ret
l_create:
cmp [uMsg], WM_CREATE ;.ELSEIF uMsg==WM_CREATE
jne l_command
invoke CreateWindowEx,WS_EX_CLIENTEDGE, ADDR EditClassName,NULL,\
WS_CHILD or WS_VISIBLE or WS_BORDER or ES_LEFT or\
ES_AUTOHSCROLL,\
50,35,200,25,hWnd,8,hInstance,NULL
mov hwndEdit,eax
invoke SetFocus, hwndEdit
invoke CreateWindowEx,NULL, ADDR ButtonClassName,ADDR ButtonText,\
WS_CHILD or WS_VISIBLE or BS_DEFPUSHBUTTON,\
75,70,140,25,hWnd,ButtonID,hInstance,NULL
mov hwndButton,eax
jmp l_ret
l_command:
cmp [uMsg], WM_COMMAND ;.ELSEIF uMsg==WM_COMMAND
jne l_default
mov eax,wParam
cmp [lParam], 0 ;.IF lParam==0
jne l_lParam_not_0
cmp ax, IDM_HELLO ;.IF ax==IDM_HELLO
jne l_IDM_CLEAR
invoke SetWindowText,hwndEdit,ADDR TestString
jmp l_ret
l_IDM_CLEAR:
cmp ax, IDM_CLEAR ;.ELSEIF ax==IDM_CLEAR
jne l_IDM_GETTEXT
invoke SetWindowText,hwndEdit,NULL
jmp l_ret
l_IDM_GETTEXT:
cmp ax, IDM_GETTEXT ;.ELSEIF ax==IDM_GETTEXT
jne l_destroy
invoke GetWindowText,hwndEdit,ADDR buffer,512
invoke MessageBox,NULL,ADDR buffer,ADDR AppName,MB_OK
jmp l_ret
l_destroy:
invoke DestroyWindow,hWnd ;.ELSE
jmp l_ret ;.ENDIF
l_lParam_not_0: ;.ELSE
cmp ax, ButtonID ;.IF ax==ButtonID
jne l_ret
shr eax,16
cmp ax, BN_CLICKED
jne l_ret ;.IF ax==BN_CLICKED
invoke SendMessage,hWnd,WM_COMMAND,IDM_GETTEXT,0
jmp l_ret ;.ENDIF .ENDIF .ENDIF
l_default: ;.ELSE
invoke DefWindowProc,hWnd,uMsg,wParam,lParam
ret
l_ret: ;.ENDIF
xor eax,eax
ret
WndProc endp
end start
| |