Author Topic: A question about FASM compiling  (Read 3224 times)

step8

  • Regular Member
  • *
  • Posts: 10
A question about FASM compiling
« on: November 06, 2018, 12:10:30 AM »
I create a simple FASM project using EasyCode IDE.
It generate a asm source file:Project1.asm:
Code: [Select]
section '.data' data readable writeable

hInst dd 0

szClassName db 'EasyCode2MainWindow', 0
szTitle db 'Main Window', 0
szRiched20 db 'riched20.dll', 0

section '.text' code readable executable

proc start
invoke GetModuleHandle, NULL
mov [hInst], eax
invoke GetCommandLine
stdcall WinMain, [hInst], NULL, eax, SW_SHOWDEFAULT
invoke ExitProcess, eax
endp

proc WinMain hInstance:DWORD, hPrevInst:DWORD, lpCmdLine:DWORD, nCmdShow:DWORD
local msg:MSG
local wc:WNDCLASSEX
local icc:INITCOMMONCONTROLSEX ;Remove this line if common controls are not going to be used
local hRichEdit:DWORD ;Remove this line if Rich Edit control is not going to be used

;=========================================================================
;Remove these lines, and the corresponding 'comctl32.dll' dynamic library
;from project explorer, only if you are not going to use common controls
mov [icc.dwSize], sizeof.INITCOMMONCONTROLSEX
mov [icc.dwICC], 03FFFH
lea eax, [icc]
invoke InitCommonControlsEx, eax
;=========================================================================

;=========================================================================
;Remove these lines, and the corresponding 'riched20.dll' dynamic library
;from project explorer, only if you are not going to use rich edit control
invoke LoadLibrary, szRiched20
mov [hRichEdit], eax
;=========================================================================

mov [wc.cbSize], sizeof.WNDCLASSEX
mov [wc.style], CS_DBLCLKS
mov [wc.lpfnWndProc], WindowProcedure
mov [wc.cbClsExtra], 0
mov [wc.cbWndExtra], 0
mov eax, [hInst]
mov [wc.hInstance], eax
mov [wc.hIcon], NULL
invoke LoadImage, NULL, IDC_ARROW, IMAGE_CURSOR, 0, 0, (LR_DEFAULTSIZE OR LR_LOADMAP3DCOLORS OR LR_SHARED)
mov [wc.hCursor], eax
mov [wc.hbrBackground], (COLOR_BTNFACE + 1)
mov [wc.lpszMenuName], NULL
mov [wc.lpszClassName], szClassName
mov [wc.hIconSm], NULL
invoke RegisterClassEx, addr wc
invoke CreateWindowEx, 0, szClassName, szTitle, WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, [hInst], 0

push eax
invoke ShowWindow, eax, [nCmdShow]
pop eax
invoke UpdateWindow, eax

@@: invoke GetMessage, addr msg, NULL, 0, 0
cmp eax, 0
jle @f
invoke TranslateMessage, addr msg
invoke DispatchMessage, addr msg
jmp @b

;=========================================================================
;Remove these lines, and the corresponding 'riched20.dll' dynamic library
;from project explorer, only if you are not going to use rich edit control
@@: .if [hRichEdit] <> NULL
invoke FreeLibrary, [hRichEdit]
.endif
;=========================================================================

invoke DestroyCursor, [wc.hCursor]
invoke UnregisterClass, szClassName, [hInst]
mov eax, [msg.wParam]
ret
endp

proc WindowProcedure hWnd:DWORD, uMsg:DWORD, wParam:DWORD, lParam:DWORD
.if [uMsg] = WM_CREATE
;===================
; Initalization code
;===================
xor eax, eax
L2: ret
.elseif [uMsg] = WM_DESTROY
;===========
; Final code
;===========
invoke PostQuitMessage, 0
xor eax, eax
jmp L2
.endif
invoke DefWindowProc, [hWnd], [uMsg], [wParam], [lParam]
jmp L2
endp

In the IDE,this code compiles OK,but when I compile this file using command line ,it compiles failed.
And I notice the included files in the project explore window,I wander how the IDE manage these include files to work?

Thanks

rsala

  • Moderator
  • Member
  • *****
  • Posts: 357
    • Easy Code
Re: A question about FASM compiling
« Reply #1 on: November 06, 2018, 06:18:11 AM »
Hello,

All needed "include (*.inc)" files must appear in the "Include" node of the Project Explorer (by using the "Project-->Add Include/Header file (*.inc;*.h)..." menu option). In the same way all needed "library (*.lib)" files must appear in the "Library" node of the Project Explorer (by using the "Project-->Add Library file (*.lib)..." menu option). Then Easy Code internally takes care of all those files by including them in a temporary file that is deleted after compilation.

NOTE: Library files (*.lib) ARE NOT needed for FASM classic projects.
EC coder

step8

  • Regular Member
  • *
  • Posts: 10
Re: A question about FASM compiling
« Reply #2 on: November 06, 2018, 02:23:10 PM »
Thanks, EC is very good IDE.
I'm just curious how this IDE make these inc file works.I read the asm file,there are no instructions like
Code: [Select]
     format PE GUI 4.0
     entry start
and there are no Import instructions.
I don't know how to add these information out side the asm source file.
And,is it mean that once I create a project using EasyCode,I must compile it in the IDE,I can't compile it manually?

step8

  • Regular Member
  • *
  • Posts: 10
Re: A question about FASM compiling
« Reply #3 on: November 06, 2018, 05:52:44 PM »
I think I understand it now,thanks

rsala

  • Moderator
  • Member
  • *****
  • Posts: 357
    • Easy Code
Re: A question about FASM compiling
« Reply #4 on: November 07, 2018, 04:08:36 AM »
Thank you for using Easy Code!

Yes, when you create a project using EasyCode, you must compile it in the IDE which make things easier.

Regards.
EC coder