flat assembler
Message board for the users of flat assembler.
Index
> Macroinstructions > if, else and defined |
Author |
|
comrade 05 May 2004, 13:20
use = instead of equ for UNICODE definition
|
|||
05 May 2004, 13:20 |
|
uri 05 May 2004, 13:23
ok, i changed
UNICODE equ 2 to UNICODE = 2 but nothing changed. I see UNCIDE but call MessageBoxA |
|||
05 May 2004, 13:23 |
|
pelaillo 05 May 2004, 13:27
[edit]oops... too slow answer. Change also in name equ ... [/edit]
There is a difference between "equ" in fasm and tasm/masm. For the code you have, you need to use "=" instead. However, let me suggest this way in order to avoid non used declarations to go in obj file: Code: format MS COFF macro .code { section '.text' code readable executable} MB_OK = 00h UNICODE = 2 public main as '_main' if defined UNICODE extrn '__imp__MessageBoxA@16' as MessageBox:dword else extrn '__imp__MessageBoxW@16' as MessageBox:dword end if .code main: call WinMain macro stdcall proc,[arg] { reverse if arg eq else pushd arg end if common call [proc] } WinMain: stdcall MessageBox,0,_title,_title,MB_OK xor eax,eax retn _title db 'the message',0 There are also automated tools to prepare imports depending on linkers http://board.flatassembler.net/topic.php?t=72 http://board.flatassembler.net/topic.php?t=1068 And info about Fasm and MS Link: http://board.flatassembler.net/topic.php?t=479 Best Regards, pelaillo |
|||
05 May 2004, 13:27 |
|
uri 05 May 2004, 16:04
pelaillo
Code: if defined UNICODE extrn '__imp__MessageBoxA@16' as MessageBox:dword else extrn '__imp__MessageBoxW@16' as MessageBox:dword end if Yes, i can use this definition, but i want to have possibility to use MessageBoxW too. like this: Code: invoke MessageBox,1,'smt','smt',0 invoke MessageBoxW,1,'smt','smt',0 but i can do this with Code: extrn '__imp__MessageBoxA@16' as MessageBoxA:dword extrn '__imp__MessageBoxW@16' as MessageBoxW:dword if defined UNICODE extrn '__imp__MessageBoxA@16' as MessageBox:dword else extrn '__imp__MessageBoxW@16' as MessageBox:dword end if but! when i want to port my masm macroses to fasm i will use constructions like Code: if defined smt smt1 equ smt2 else smt1 equ smt3 end if many times, and this construction and do not work I do not think what it's bug, I think what i do not understand some moments. can you help me to correct build above construction (if else end if)? sorry for my english:) do you understand me? |
|||
05 May 2004, 16:04 |
|
vid 05 May 2004, 19:17
i'm not sure if i understand what you want, but if yes then you can use
Code: extrn '__imp__MessageBoxA@16' as MessageBoxA:dword extrn '__imp__MessageBoxW@16' as MessageBoxW:dword if defined UNICODE label MessageBox dword at MessageBoxW else label MessageBox dword at MessageBoxA end if and you can also define macro like this: Code: macro importproc name { extrn '__imp__'#`name#'A@16' as name#A:dword extrn '__imp__'#`name#'W@16' as name#W:dword if defined UNICODE label name dword at name#W else label name dword at name#A end if } to save some typing (and loose some time at every compilation ) |
|||
05 May 2004, 19:17 |
|
pelaillo 05 May 2004, 19:37
Your construct is ok.
Maybe the problem is in Code: smt1 equ smt2 It depends on smt2 contents. If you want to textually change smt1 in smt2 before substitutions, try with Code: smt1 fix smt2 If it is simply a constant value, you should use Code: smt1 = smt2 In your example: Code: format MS COFF macro .code { section '.text' code readable executable} public main as '_main' .code main: call WinMain extrn '__imp__MessageBoxA@16' as MessageBoxA:dword extrn '__imp__MessageBoxW@16' as MessageBoxW:dword macro STDCALL name { if defined UNICODE display 'UNICODE' name = name#W display name#W else display 'ANSI' name = name#A display name end if } UNICODE = 2 STDCALL MessageBox WinMain: call dword [MessageBox] xor eax,eax retn |
|||
05 May 2004, 19:37 |
|
uri 06 May 2004, 05:07
thanks all. you are realy helpd me. see you in this forum.
thanks. |
|||
06 May 2004, 05:07 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.