flat assembler
Message board for the users of flat assembler.
![]() Goto page Previous 1, 2 |
Author |
|
AsmER 22 Apr 2008, 15:45
OMG I have been trying to get this to work up untill now, and I just cant take it no more :/
Code: _global@label equ macro label [args*] { common match name rest, args \{ virtual at 0 db \`name load _firstb@label byte from 0 end virtual if _firstb@label eq . public _global@label # name else public name end if \} label args } I ve got this piece of code. all I want it to do is: Code: label Start ; to generate: ; public Start ; label Start label .Sub_Label ; to generate: ; public Start.Sub_Label ; label .Sub_Label ; and so on It just dont want to do what its told. I have been trying sticking 'match' directive in, putting '\' in possible places and nothink works... after each check i made with fasmpre.exe following Code: display _firstb@label if _firstb@label eq . ... displays dot (.) like it should but next line on 'if' command it equals _firstb@label not stupid dot. Please help me out before I get a heart attack ![]() Seriously... gimme a decent documentation just for macros Quote:
This for example, didnt make me think that i HAVE TO use it with all the symbols etc etc (thought its for nesting macros but for '{' and '}' really) Thats all for me and macros for at least good few weeks ![]() |
|||
![]() |
|
revolution 22 Apr 2008, 16:06
You have to escape the hash (#) also. Try this:
Code: _global@label equ macro label [args*] { common match name rest, args \{ virtual at 0 db \`name load _firstb@label byte from 0 end virtual if _firstb@label = '.' public _global@label \# name else public name end if \} label args } |
|||
![]() |
|
revolution 22 Apr 2008, 16:21
To make it clear and pre-empt a few upcoming problems, you have to escape all preprocessor symbols and directives properly. That is:
common forward reverse local ` # } { (is optional for readability only) The number of backslashes determines the level at which the symbol/directive will be processed. If you have no backslashes then it is processed by the outer layer, 1 backslash is processed by the second layer, and so on. |
|||
![]() |
|
AsmER 22 Apr 2008, 17:01
Ok got it to work finally
Code: _global@label equ macro label [args*] { common _state@label equ 0 match name rest, args \{ virtual at 0 db \`name load _firstb@label byte from 0 end virtual if _firstb@label = '.' match gname lname, _global@label name ;another match to connect 2 strings in %C style (beginning of post) \\{ public gname \\# lname _state@label equ 1 ; set state to changed \\} match =0, _state@label ; if match occurs: there was sub label, but no global label before it \\{ public name _state@label equ 1 ; set state to changed \\} else public name match =0, _state@label ; check state with 'match' or wont work due to equ preprocessed at preprocessor state and 'else' at assembly time \\{ _global@label equ name \\} end if \} label args } I will really, really and I mean REALLY try to avoid writing macros which consist of items that get interpreted at different stages (and which need to interact with one another) end of day I guess im not that dumb after all - still dont know if i like macros more right now... revolution - thx for further explanation on '\' symbol Teamwork ![]() |
|||
![]() |
|
revolution 22 Apr 2008, 17:14
I think it won't give what you expect. Look at it from the preprocessor point-of-view by stripping out all the assembler code
Code: _global@label equ macro label [args*] { common _state@label equ 0 match name rest, args \{ match gname lname, _global@label name \\{ _state@label equ 1 \\};never matches match =0, _state@label \\{ _state@label equ 1 \\} ;always matches match =0, _state@label \\{ _global@label equ name \\} ;never matches \} } |
|||
![]() |
|
revolution 22 Apr 2008, 17:29
Before you drive yourself barmy with this, I think you can't solve it with the current fasm version. I suggest you just simply use two macros, one for setting the global label and another for the subordinate labels.
|
|||
![]() |
|
AsmER 22 Apr 2008, 19:49
I found out that the macro doesnt do the job after few nimutes since posting, but as you already said its wrong I just left it as it was.
As for the matter whenever you can make this macro to work simple answer: NO ![]() That is it. We need to wait for my =Equate[indx:len] or your irpc, split, find, search or extract ![]() |
|||
![]() |
|
r22 09 May 2008, 19:56
I once suggested the macro language be replaced with a strip-down version of JavaScript.
Something like like this would be much easier to pick up and use effectively. Less learning intricacies and more using. Code: <% var TEST_EQU = ".lbl"; var LAST_EQU = ""; var X_INC = 0; function nextLbl(){ LAST_EQU = TEST_EQU + X_INC; document.write(LAST_EQU + ":"); X_INC++; } %> MOV ecx,-1 <% nextLbl() %> loopz <%=LAST_EQU%> MOV ecx,-1 <% nextLbl(); %> loopz <% LAST_EQU %> Would process to Code: MOV ecx,-1 .lbl0: loopz .lbl0 MOV ecx.-1 .lbl1: loopz .lbl1 |
|||
![]() |
|
Goto page Previous 1, 2 < Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2023, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.