flat assembler
Message board for the users of flat assembler.

Index > Compiler Internals > A few things missed in fasm

Author
Thread Post new topic Reply to topic
superwu



Joined: 10 Mar 2007
Posts: 1
superwu 10 Mar 2007, 04:21
To the author of fasm or someone that know the solution,
How can I use local data with type TCHAR inside a procedure, i.e.:

proc someProc
LOCAL szLocalString[260]:TCHAR
...
ret
endp

And for the author, you forget putting constant MAX_PATH in win32 header and no shlwapi header found.
And why you define WIN32_FIND_DATA struct name as FINDDATA? It confused me since I'm used to the original one.
Also could you make the operator 'sizeof' can be used with array/buffer too like masm does, i.e:

.data
szPath db 260 dup (?)

.code
...
mov eax, sizeof.szPath ; sizeof should return 260

Please do something about this, fasm cannot lose from masm (NEVER!).
BTW, I like the SSSO way.

Thanks.
Post 10 Mar 2007, 04:21
View user's profile Send private message Reply with quote
asmfan



Joined: 11 Aug 2006
Posts: 392
Location: Russian
asmfan 10 Mar 2007, 09:08
TCHAR is either BYTE or WORD depending on include file fith suffix a or w, e.g. win32a.inc (win32w.inc)
Post 10 Mar 2007, 09:08
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8357
Location: Kraków, Poland
Tomasz Grysztar 11 Mar 2007, 14:29
As for the sizeof feature of DB, see the example in section 2.3.4 of manual, and perhaps this one.

The FINDDATA name was there because some of the old docs I had used this name. You're right, the newer docs call it WIN32_FIND_DATA, I'm correcting it.
Those definitions were left in the "temporary state" for years, they really need to be revised.
Post 11 Mar 2007, 14:29
View user's profile Send private message Visit poster's website Reply with quote
demonwu



Joined: 01 Apr 2007
Posts: 2
demonwu 01 Apr 2007, 03:19
First, I must say thank you for the answer.
About local data in TCHAR, it won't get error if local variable declaration doesn't use brackets [], i.e.:
local data:TCHAR

According to macro in proc32.inc and win32a.inc (assume we want to use ANSI version), statement above will be translated into:
data db ?

Let's see how it works from each include files. From win32a.inc:

struc TCHAR [val] { common match any, val \{ . db val \}
match , val \{ . db ? \} }

Symbol TCHAR would be translated into:
db ?

And from proc32.inc:
macro local [var]
{
...
match , done@local \\{ varname vartype
restore done@local \\} \}
...
}

Statement local data:TCHAR would be translated into:
data db ?

But, if we use brackets [] for local TCHAR data declaration, the compiler would complain, i.e.:
local data[260]:TCHAR

The problem lays in macro local from proc32.inc:
Let's see, what will be executed in macro local if we use brackets:
macro local [var]
{
...
match , done@local \\{ virtual
varname vartype
end virtual
rb count*sizeof.\#vartype
restore done@local \\} \}
...
}

So, according to macro above, it will be translated into:
rb 260*sizeof.TCHAR

The problem is that we cannot use operator sizeof for macro struc (TCHAR is built from macro struc).


Keep up the good work.
Post 01 Apr 2007, 03:19
View user's profile Send private message Reply with quote
demonwu



Joined: 01 Apr 2007
Posts: 2
demonwu 01 Apr 2007, 03:20
First, I must say thank you for the answer.
About local data in TCHAR, it won't get error if local variable declaration doesn't use brackets [], i.e.:
local data:TCHAR

According to macro in proc32.inc and win32a.inc (assume we want to use ANSI version), statement above will be translated into:
data db ?

Let's see how it works from each include files. From win32a.inc:

struc TCHAR [val] { common match any, val \{ . db val \}
match , val \{ . db ? \} }

Symbol TCHAR would be translated into:
db ?

And from proc32.inc:
macro local [var]
{
...
match , done@local \\{ varname vartype
restore done@local \\} \}
...
}

Statement local data:TCHAR would be translated into:
data db ?

But, if we use brackets [] for local TCHAR data declaration, the compiler would complain, i.e.:
local data[260]:TCHAR

The problem lays in macro local from proc32.inc:
Let's see, what will be executed in macro local if we use brackets:
macro local [var]
{
...
match , done@local \\{ virtual
varname vartype
end virtual
rb count*sizeof.\#vartype
restore done@local \\} \}
...
}

So, according to macro above, it will be translated into:
rb 260*sizeof.TCHAR

The problem is that we cannot use operator sizeof for macro struc (TCHAR is built from macro struc).


Keep up the good work.
Post 01 Apr 2007, 03:20
View user's profile Send private message Reply with quote
hidden



Joined: 14 Feb 2007
Posts: 49
hidden 01 Apr 2007, 04:11
There is a way to make array of TCHARs
Code:
format PE GUI
entry start

include 'win32a.inc'

proc start
local szLocalString:TCHAR 260 dup(?)
      ret
endp    
Post 01 Apr 2007, 04:11
View user's profile Send private message Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid 01 Apr 2007, 09:01
demonwu: what is point of using TCHAR in assembly?
Post 01 Apr 2007, 09:01
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number 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.