flat assembler
Message board for the users of flat assembler.

Index > Compiler Internals > TCHAR as label

Author
Thread Post new topic Reply to topic
ouadji



Joined: 24 Dec 2008
Posts: 1081
Location: Belgium
ouadji 15 Nov 2011, 23:46
Code:
include 'win32a.inc'

TCHAR:

mov eax,[TCHAR] ;(A) ok, does compile

jmp TCHAR       ;(B) does not compile (invalid operand)
    
(A) does compile, but (B) does not compile ... I am surprised.
I can understand that the compiler does not allow both cases ...
but one and not the other, I don't understand.
Can anyone tell me why? Thank you in advance.


yes, I know that "TCHAR" is a macro.
It is precisely for this reason I am surprised that "A" does compile and not "B".


_________________
I am not young enough to know everything (Oscar Wilde)- Image
Post 15 Nov 2011, 23:46
View user's profile Send private message Send e-mail Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20451
Location: In your JS exploiting you and your system
revolution 16 Nov 2011, 00:17
ouadji wrote:
yes, I know that "TCHAR" is a macro.
Therein lies the problem. TCHAR is not a macro, it is a structure.
Post 16 Nov 2011, 00:17
View user's profile Send private message Visit poster's website Reply with quote
ouadji



Joined: 24 Dec 2008
Posts: 1081
Location: Belgium
ouadji 16 Nov 2011, 00:22
Code:
struc TCHAR [val] { common match any, val \{ . db val \}
                           match , val \{ . db ? \} }
    
Indeed revolution, "TCHAR" is a structure
sorry for this mistake.


that said, I think a "struc" is a "macro"

_________________
I am not young enough to know everything (Oscar Wilde)- Image
Post 16 Nov 2011, 00:22
View user's profile Send private message Send e-mail Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20451
Location: In your JS exploiting you and your system
revolution 16 Nov 2011, 00:52
A structure is a different from a macro in that it requires a leading label, whereas a macro cannot have a leading label.
Code:
macro ABC {do something}
struc ABC {do something else}
;
       ABC ;macro instantiation
label1 ABC ;structure instantiation
;
jmp TCHAR ;TCHAR structure with "jmp" as the label    


Last edited by revolution on 16 Nov 2011, 01:03; edited 1 time in total
Post 16 Nov 2011, 00:52
View user's profile Send private message Visit poster's website Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20451
Location: In your JS exploiting you and your system
revolution 16 Nov 2011, 00:56
BTW: Why you no look at the error messages? Mad
Code:
jmp TCHAR       ;(B) does not compile (invalid operand)
C:\Documents and Settings\We are the Borg\Our Documents\include/win32a.inc [12] TCHAR [1]:
                           match , val \{ . db ? \} }
C:\Documents and Settings\We are the Borg\Our Documents\include/win32a.inc [12] match [0]:
                           match , val \{ . db ? \} }
error: invalid operand.    
Post 16 Nov 2011, 00:56
View user's profile Send private message Visit poster's website Reply with quote
typedef



Joined: 25 Jul 2010
Posts: 2909
Location: 0x77760000
typedef 16 Nov 2011, 01:29
Code:
jmp TCHAR
    

is the same as
Code:
jmp DWORD
    


LAUGH OUT LOUD x 2
Post 16 Nov 2011, 01:29
View user's profile Send private message Reply with quote
ouadji



Joined: 24 Dec 2008
Posts: 1081
Location: Belgium
ouadji 16 Nov 2011, 09:10

of course i look at the error messages.
What I didn't understand was that "A" does compile and "B" does not.
Now I understand why. Thank you revolution


typedef:
not "jmp dword", but "jmp byte" (a dword and a byte are two different things, do you know that ?) Wink


_________________
I am not young enough to know everything (Oscar Wilde)- Image
Post 16 Nov 2011, 09:10
View user's profile Send private message Send e-mail Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20451
Location: In your JS exploiting you and your system
revolution 16 Nov 2011, 09:42
BTW: In case you are wondering how to do what you wanted:
Code:
jmp short TCHAR    
Although I would not really encourage using things like TCHAR as label names. It all gets very confusing when you do that.
Post 16 Nov 2011, 09:42
View user's profile Send private message Visit poster's website Reply with quote
ouadji



Joined: 24 Dec 2008
Posts: 1081
Location: Belgium
ouadji 16 Nov 2011, 10:23
Quote:
Although I would not really encourage using things like TCHAR as label names.
It all gets very confusing when you do that.
Of course, it was just a theoretical reflection.
(in the context of wink improvement)


_________________
I am not young enough to know everything (Oscar Wilde)- Image
Post 16 Nov 2011, 10:23
View user's profile Send private message Send e-mail Reply with quote
typedef



Joined: 25 Jul 2010
Posts: 2909
Location: 0x77760000
typedef 16 Nov 2011, 19:18
ouadji wrote:


typedef:
not "jmp dword", but "jmp byte" (a dword and a byte are two different things, do you know that ?) Wink



Ok, here's a better one maybe you have hard time with comparisons, or you just make quantitative judgements.

Code:
JMP [DATA_TYPE]
    


Clearly, "DATA_TYPE" is a compiler reserved keyword.

STILL, LAUGH OUT LOUD
Post 16 Nov 2011, 19:18
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20451
Location: In your JS exploiting you and your system
revolution 16 Nov 2011, 19:28
typedef wrote:
Clearly, "DATA_TYPE" is a compiler reserved keyword.
TCHAR is not a compiler reserved keyword. It is defined in win32a.inc as a structure. If you decide not to include win32a.inc then you are free to use TCHAR as you please for other things.
Post 16 Nov 2011, 19:28
View user's profile Send private message Visit poster's website Reply with quote
typedef



Joined: 25 Jul 2010
Posts: 2909
Location: 0x77760000
typedef 16 Nov 2011, 20:32
revolution wrote:
typedef wrote:
Clearly, "DATA_TYPE" is a compiler reserved keyword.
TCHAR is not a compiler reserved keyword. It is defined in win32a.inc as a structure. If you decide not to include win32a.inc then you are free to use TCHAR as you please for other things.


But if you include win32a.inc, it becomes reserved doesn't it ?

LOL
Post 16 Nov 2011, 20:32
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20451
Location: In your JS exploiting you and your system
revolution 16 Nov 2011, 21:14
typedef wrote:
But if you include win32a.inc, it becomes reserved doesn't it ?
No. You can always make a label the same name as a macro or struc. Also you can use restruc to clear the structure at any time.
Post 16 Nov 2011, 21:14
View user's profile Send private message Visit poster's website Reply with quote
ouadji



Joined: 24 Dec 2008
Posts: 1081
Location: Belgium
ouadji 16 Nov 2011, 21:51

if "TCHAR" is a compiler reserved word, "tchar" should be one too.
However, it's not the case.

_________________
I am not young enough to know everything (Oscar Wilde)- Image
Post 16 Nov 2011, 21:51
View user's profile Send private message Send e-mail Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8359
Location: Kraków, Poland
Tomasz Grysztar 20 Nov 2011, 01:04
TCHAR is not a reserved word. It gets defined in some Win32 macroinstructions, but since preprocessor in fasm is case-sensitive, you get "TCHAR" expanded as macro/struc, while "tchar" is not recognized as a macro (but you may as well define another macro called "tchar" which will get expanded in "tchar" places).
Post 20 Nov 2011, 01:04
View user's profile Send private message Visit poster's website 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-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.