flat assembler
Message board for the users of flat assembler.

Index > Windows > Surely this should compile? (Solved!)

Author
Thread Post new topic Reply to topic
Bodger



Joined: 16 Jan 2006
Posts: 7
Bodger 16 Jan 2006, 02:44
EDIT: This problem was solved in this thread. It was my fault all along, no surprises there! javascript:emoticon('Embarassed')
Embarassed

Greetings,

I'm new to FASM, and I like what I've seen about it.

but...

There seems to be a problem with the includes I have (possibly IMPORT32.INC), because this will not compile

;------------------------
format PE GUI 4.0

include "win32ax.inc"

.code
start:
invoke ExitProcess,0
.end start
;------------------------

It reports:

(blah)....include/win32ax.inc [149] .end [7]:
import_kernel32
(blah)....include/win32ax.inc [117] import_kernel32 [0]:
{ common macro import_#lib \{ import lib,functions \} }
(blah)....include/macro/import32.inc [26] import [3]:
if used label
error: invalid expression.

Can anybody advise me on a solution to this?

Thanks in advance,
Bodger Embarassed

_________________
-- quidquid latine dictum sit altum viditur --


Last edited by Bodger on 17 Jan 2006, 00:33; edited 1 time in total
Post 16 Jan 2006, 02:44
View user's profile Send private message Reply with quote
vbVeryBeginner



Joined: 15 Aug 2004
Posts: 884
Location: \\world\asia\malaysia
vbVeryBeginner 16 Jan 2006, 03:23
hi bodger,
maybe you need to set up fasm dev environment first before proceeding to start coding :p

1. download fasm zipped file from flatassembler.net
2. extract the file into a directory, (eg. c:\fasm)
3. right click my computer > properties > advance [tab] > environment variable.
4. click new button under "system variables" and type variable name = "fasminc", variable value = "c:\fasm\include" then OK
5. double click path and add ";c:\fasm" (";" is separator)
6. now. click start > run and type cmd
7. type "fasm" and enter
you would see something like below
Code:
flat assembler  version 1.65.8
usage: fasm source [output]
    

8. if you need to include eg. include "win32ax.inc", change it to
Code:
include "%fasminc%\win32ax.inc"
    

9. cmd to the directory where your file located.
10. fasm yourfile.asm

and you would have your "yourfile.exe" assembled (assume u r doing win32 app).

if you want more easy, set the fasminc variable and use the fasmw editor.
Post 16 Jan 2006, 03:23
View user's profile Send private message Visit poster's website Reply with quote
Bodger



Joined: 16 Jan 2006
Posts: 7
Bodger 16 Jan 2006, 04:41
Hi vbVeryBeginner, and thank you for your reply.

I have set up fasm already, and am using the fasminc environmental variable. Fasm is definately finding the includes, as I tried to put in a 'display' command into the macro and it didn't like it.

I originally had a more complex program that was doing a lot more, but it wouldn't assemble. I created this super-short one to test the win32ax.inc.

So Fasm is now reporting an error in the win32ax.inc with the import macro; specifically the line:

{ common macro import_#lib \{ import lib,functions \} }

(which I don't understand what it does).

This error is in turn derrived from import32.inc in it's import macro. Here are the first lines of this macro:

macro import name,[label,string]
{ common
name#.lookup:
forward
if used label

The line in bold is generating the error. So I'm guessing that it's been called with garbage from the win32ax.inc?

Thanks again, I hope you can help me out.

_________________
-- quidquid latine dictum sit altum viditur --
Post 16 Jan 2006, 04:41
View user's profile Send private message Reply with quote
vbVeryBeginner



Joined: 15 Aug 2004
Posts: 884
Location: \\world\asia\malaysia
vbVeryBeginner 16 Jan 2006, 06:14
hi bodger,
i use the latest fasm and assembly the following without any problem?
?? how bout you try re-download the fasm and see if you could assemble your code Razz

Code:
;------------------------ 
format PE GUI 4.0 

include "%fasminc%\win32ax.inc" 

.code 
start: 
invoke ExitProcess,0 
.end start 
;------------------------    
Post 16 Jan 2006, 06:14
View user's profile Send private message Visit poster's website Reply with quote
FrozenKnight



Joined: 24 Jun 2005
Posts: 128
FrozenKnight 16 Jan 2006, 09:08
i think he just needs to set the include path.
Post 16 Jan 2006, 09:08
View user's profile Send private message Reply with quote
Bodger



Joined: 16 Jan 2006
Posts: 7
Bodger 16 Jan 2006, 22:54
Hi again,

I downloaded the latest fasm (1.65.Cool, mine was 1.65.7. And the code does indeed assemble now.

The includes were being included as fasm was reporting errors *in* them, but other than that I haven't got a clue why it wasn't working.

Still on-topic I think; I've noticed that GetDeviceCaps in gdi32 is unrecognized at assemble time, other function from gdi32 seem to work fine. Also RegisterClassEx in user32.

Now, I've checked the includes and the deffinitions are there along with others that do assemble.

Any Ideas?

_________________
-- quidquid latine dictum sit altum viditur --
Post 16 Jan 2006, 22:54
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8356
Location: Kraków, Poland
Tomasz Grysztar 16 Jan 2006, 23:00
They are recognized when I try them. Can you post the source that doesn't work?
Post 16 Jan 2006, 23:00
View user's profile Send private message Visit poster's website Reply with quote
Bodger



Joined: 16 Jan 2006
Posts: 7
Bodger 16 Jan 2006, 23:45
As advised, here is some code that I can't assemble. Several api functions (in bold) appear not to be recognized. Interestingly these differ from my other, larger, project. Strangely GetDeviceCaps works in this code...

----------------------------------

format PE GUI 4.0

include "win32ax.inc"

start:
invoke GetModuleHandle, NULL
mov [hInstance],eax
stdcall WinMain, [hInstance],NULL,NULL, SW_SHOWDEFAULT
invoke ExitProcess, eax


proc WinMain hInst,hPrevInst,CmdLine,CmdShow
local wc:WNDCLASSEX
local msg:MSG

invoke GetDC,0
mov [DeskDC],eax
push eax
invoke GetDeviceCaps,eax,HORZSIZE
mov [ScreenW],eax
invoke GetDeviceCaps,[DeskDC],VERTSIZE
mov [ScreenH],eax
pop eax
invoke ReleaseDC,0,eax

mov [wc.cbSize],sizeof.WNDCLASSEX
mov [wc.style], CS_HREDRAW or CS_VREDRAW
mov [wc.lpfnWndProc], WndProc
mov [wc.cbClsExtra],NULL
mov [wc.cbWndExtra],NULL
push [hInstance]
pop [wc.hInstance]
mov [wc.hbrBackground],COLOR_BTNFACE+1
mov [wc.lpszMenuName],NULL
mov [wc.lpszClassName],ClassName
invoke [b]LoadIcon[\b], [hInst],IDR_ICON ;not working
mov [hIcon],eax
mov [wc.hIcon],eax
mov [wc.hIconSm],eax

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

invoke [b]RegisterClassEx[\b], addr.wc ;not working

mov ecx,[ScreenW]
mov edx,[ScreenH]
sub ecx,265
sub edx,203
shr ecx,1
shr edx,1

;not working
invoke [b]CreateWindowEx[\b],WS_EX_TOPMOST,\
ClassName,\
magCaption,\
WS_OVERLAPPEDWINDOW,\
ecx,edx,265,203,\
NULL,\
eax,\
[hInst],\
NULL

mov [hMain],eax
invoke ShowWindow, eax,[CmdShow]
invoke UpdateWindow, [hMain]

wmMessageLoop:
invoke [b]GetMessage[\b], addr.msg,NULL,0,0 ;not working
or eax,eax
jz wmDone
invoke [b]TranslateMessage[\b], addr.msg ;not working
invoke [b]DispatchMessage[\b], addr.msg ;not working
jmp wmMessageLoop
wmDone:
mov eax,[msg.wParam]
ret
endp



proc WndProc hWnd, uMsg, wParam, lParam
mov eax,[uMsg]
cmp eax,WM_DESTROY
jne wpDefault
invoke PostQuitMessage,NULL
jmp wpDone
wpDefault:
invoke DefWindowProc,[hWnd],[uMsg],[wParam],[lParam]
ret
wpDone:
xor eax,eax
ret
endp

.data
ClassName db 'MyClassName',0

section '.bss' readable writeable
hInstance dd ?
hIcon dd ?
ScreenW dd ?
ScreenH dd ?
hMain dd ?

.end start
------------------------------------

EDIT: Well they were supposed to be in bold Sad
I've added comments instead.

_________________
-- quidquid latine dictum sit altum viditur --
Post 16 Jan 2006, 23:45
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8356
Location: Kraków, Poland
Tomasz Grysztar 17 Jan 2006, 00:08
LoadIcon is not working because IDR_ICON is not defined (fasmw shows you that the error is on "push IDR_ICON" instruction.
RegisterClassEx has the "addr.wc" as argument - it should be "addr wc" to work correctly, as "addr.wc" is just treated as a one long name, and again it's undefined symbol.

The next ones for the similar reasons.
Post 17 Jan 2006, 00:08
View user's profile Send private message Visit poster's website Reply with quote
Bodger



Joined: 16 Jan 2006
Posts: 7
Bodger 17 Jan 2006, 00:31
DOH!

I thought I'd read that addr.var somewhere in the fasm docs, but now I'm not so sure (maybe my mind is going).

Thanks a lot Tomasz. I've now tracked down all my bads in my first propper fasm project.

I was really fighting to get fasm to work, I was hoping it was something I was doing wrong. Generally I don't give software much of a chance, but this seemed worth it.

Thanks again,
Bodger.

_________________
-- quidquid latine dictum sit altum viditur --
Post 17 Jan 2006, 00:31
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.