Учебник по ассемблеру (ASM)
 

Ассемблер в примерах - Ошибки при компиляции

Вопрос:
При компиляции выводится ошибка: undefined symbol 'localbytes?Pf'. Возможно ошибка из-за оператора IF...Else.
format pe gui 4.0
entry start

include 'C:\fasm\INCLUDE\win32a.inc'

;--------------------------------------
section '.data' data readable writeable

ClassName       db "SimpleWinClass",0
AppName         db "Our First Window",0
MouseClick      db  0

hInstance   dd ?
hMainWindow dd ?
hitpointx   dd ?
hitpointy   dd ?

msg MSG

wc WNDCLASSEX

;rect RECT




;--------------------------------------
section '.code'code readable executable

start:

invoke GetModuleHandle,0
mov [hInstance],eax

invoke LoadIcon, 0,IDI_APPLICATION
mov [wc.hIcon],eax
mov [wc.hIconSm],eax


invoke LoadCursor, 0,IDC_ARROW
mov [wc.hCursor],eax

mov [wc.cbSize],sizeof.WNDCLASSEX
mov [wc.style],CS_HREDRAW or CS_VREDRAW
mov [wc.lpfnWndProc],WindowProc

mov [wc.cbClsExtra],0
mov [wc.cbWndExtra],0

mov eax,[hInstance]

mov [wc.hInstance],eax

mov [wc.hbrBackground],COLOR_WINDOW+1
mov [wc.lpszMenuName],0
mov [wc.lpszClassName],ClassName
invoke RegisterClassEx,wc

invoke CreateWindowEx,0,\
  ClassName,\
  AppName,\
  WS_OVERLAPPEDWINDOW,\
  CW_USEDEFAULT,\
  CW_USEDEFAULT,\
  CW_USEDEFAULT,\
  CW_USEDEFAULT,\
  0,\
  0,\
  [hInstance],0

  mov [hMainWindow],eax

invoke ShowWindow, [hMainWindow],SW_SHOWNORMAL
;invoke UpdateWindow,[hMainWindow]

msg_loop:
  invoke GetMessage,msg,0,0,0
  or eax,eax
  jz end_loop

  invoke TranslateMessage,msg
  invoke DispatchMessage,msg
  jmp msg_loop

  end_loop:
  invoke ExitProcess,[msg.wParam]


proc WindowProc hwnd:DWORD, wmsg:DWORD, wparam:DWORD, lparam:DWORD
push ebx esi edi
local ps:PAINTSTRUCT, hdc:DWORD ;локальные переменные

cmp [wmsg],WM_DESTROY
je wmdestroy
cmp [wmsg],WM_LBUTTONDOWN
je invalid
jmp paint
invalid:
  mov eax,[lparam]
  and eax,0FFFFh
  mov [hitpointx],eax
  mov eax,[lparam]
  shr eax,16
  mov [hitpointy],eax
  mov [MouseClick],TRUE
;push [msg.wParam]
;pop [char]
invoke InvalidateRect,[hMainWindow],0,TRUE
paint:
cmp [wmsg],WM_PAINT
je beginP

jmp defwndproc

beginP:
        lea eax,[ps]
        invoke BeginPaint,[hwnd],eax
        mov [hdc],eax
        IF MouseClick
        invoke lstrlen,AppName
        invoke TextOut,[hdc],hitpointx,hitpointy,AppName,eax
        END IF
        invoke EndPaint,[hwnd],[ps]
        ELSE
        jmp defwndproc

wmdestroy:
        invoke PostQuitMessage,0
        xor eax,eax
        jmp finish

defwndproc:
        invoke  DefWindowProc,[hwnd],[wmsg],[wparam],[lparam]
  
finish:
pop edi esi ebx
ret
endp

;----------------------------------------------
section '.idata' import data readable writeable

library kernel,'KERNEL32.DLL',\
        user,'USER32.DLL',\
        gdi,'gdi32.dll'

;include 'c:\fasm\INCLUDE\api\kernel32.inc'
;include 'c:\fasm\INCLUDE\api\user32.inc'
;include 'c:\fasm\INCLUDE\api\gdi32.inc'

import kernel,\
lstrlen,'lstrlenA',\
GetModuleHandle,'GetModuleHandleA',\
ExitProcess,'ExitProcess'

import user,\
ShowWindow,'ShowWindow',\
InvalidateRect,'InvalidateRect',\
BeginPaint,'BeginPaint',\
EndPaint,'EndPaint',\
GetClientRect,'GetClientRect',\
RegisterClassEx,'RegisterClassExA',\
CreateWindowEx,'CreateWindowExA',\
DefWindowProc,'DefWindowProcA',\
GetMessage,'GetMessageA',\
TranslateMessage,'TranslateMessage',\
DispatchMessage,'DispatchMessageA',\
LoadCursor,'LoadCursorA',\
LoadIcon,'LoadIconA',\
PostQuitMessage,'PostQuitMessage'


import gdi,\
CreateFont,'CreateFontA',\
SetBkColor,'SetBkColor',\
TextOut,'TextOutA',\
SelectObject,'SelectObject',\
SetTextColor,'SetTextColor',\
DrawText,'DrawTextA'
Ответ:
1) Надо писать не IF, END IF а .if и .endif
2) Чтобы макро работали, надо подключить INCLUDE\MACRO\if.inc
3) Внес кое-какие правки в код...
;...
invoke InvalidateRect,[hMainWindow],0,TRUE
       jmp wmret
paint:
cmp [wmsg],WM_PAINT
je beginP

jmp defwndproc

beginP:
        lea eax,[ps]
        invoke BeginPaint,[hwnd],eax
        mov [hdc],eax
        .if [MouseClick]
;        IF MouseClick
        invoke lstrlen,AppName
        invoke TextOut,[hdc],[hitpointx],[hitpointy],AppName,eax
        .endif
;        END IF
        invoke EndPaint,[hwnd],[ps]
         jmp wmret
;        ELSE
;        jmp defwndproc

wmdestroy:
        invoke PostQuitMessage,0
wmret:
        xor eax,eax
        jmp finish

defwndproc:
        invoke  DefWindowProc,[hwnd],[wmsg],[wparam],[lparam]
  
finish:
pop edi esi ebx
ret


   Вперёд
   Содержание
https://intim-massage.com/ankets/metro/sokolyniki метро Сокольники