flat assembler
Message board for the users of flat assembler.
Index
> Main > Is it possible to insert code from later in the file? |
Author |
|
vid 29 Nov 2006, 15:33
unfortunatelly, no.
only with some very dirty tricks, and i am not sure about it. |
|||
29 Nov 2006, 15:33 |
|
revolution 29 Nov 2006, 17:47
Macros cannot be forward referenced, not ever, never, no chance, not possible. Except if you rewrite fasm.
|
|||
29 Nov 2006, 17:47 |
|
vid 29 Nov 2006, 18:00
but you can store data in variables and forward reference variables... that's what i meant with "very dirty tricks"
|
|||
29 Nov 2006, 18:00 |
|
Tomasz Grysztar 29 Nov 2006, 18:28
This "dirty trick" is closely related to this problem: http://board.flatassembler.net/topic.php?t=5934
|
|||
29 Nov 2006, 18:28 |
|
Plue 29 Nov 2006, 19:17
revolution wrote: Macros cannot be forward referenced, not ever, never, no chance, not possible. Except if you rewrite fasm. It looks like what I want to do is actually possible by forward-referencing a variable from a macro and then generating the instructions from that macro. But I managed to do it some other way by buffering up all the code in between, writing the simple list of instructions without going through the buffer, and then writing the buffer. (I am writing a compiler.) _________________ Roses are red Violets are blue Some poems rhyme And some don't. |
|||
29 Nov 2006, 19:17 |
|
revolution 29 Nov 2006, 20:39
Plue wrote: As I said, I don't need full macro functionality, only a simple list of instructions. Plue wrote: I am writing a compiler. |
|||
29 Nov 2006, 20:39 |
|
Plue 29 Nov 2006, 21:44
revolution wrote:
Macro SymbolName { Simple list of instructions < Here!!! .. } Quote:
_________________ Roses are red Violets are blue Some poems rhyme And some don't. |
|||
29 Nov 2006, 21:44 |
|
Goplat 30 Nov 2006, 00:41
revolution wrote: Macros cannot be forward referenced, not ever, never, no chance, not possible. Code: match =1,second { mymacro } match =second,second { macro mymacro \{ db "blah" \} second equ 1 include 'fwdmac.asm' } |
|||
30 Nov 2006, 00:41 |
|
vid 30 Nov 2006, 08:03
Goplat: good one....
|
|||
30 Nov 2006, 08:03 |
|
revolution 30 Nov 2006, 11:16
Goplat wrote: Sounds like a challenge Okay, I change my statement a little. How about this: Macros cannot be forward referenced in a useful way, not ever, never, no chance, not possible. Hehe, now the challenge is to make it useful ... |
|||
30 Nov 2006, 11:16 |
|
Mr_Silent 30 Nov 2006, 15:44
2 revolution: What is your meaning of "useful"?
Code: .maincode fix _main macro _main { macro tag_main { } ;------------------------------------------------------------------------------ .postdef fix } _post macro _post { macro tag_post { } ;------------------------------------------------------------------------------ .end fix } _end macro _end { tag_post tag_main } ;////////////////////////////////////////////////////////////////////////////// .maincode zb sb1,'a','b','z','x' zd sd1,'a','b','z','x' .postdef macro zd p1,[p2] \{ \common label p1 \forward dd p2 \common dd 0 \} macro zb p1,[p2] \{ \common label p1 \forward db p2 \common db 0 \} .end |
|||
30 Nov 2006, 15:44 |
|
revolution 30 Nov 2006, 22:45
Mr_Silent: I think your code does not address the problem of defining the macros after you instantiate it. You code defines a few macros but does not use any of them until the final ".end" statement.
Goplat posted a nice example of reassembling the same file again that simulates defining macros after they are used, but I think it is not useful in any real program. It was all in good fun and my challenge was not anything serious. I would be delighted to see a real-world working example of Goplat's idea given above. |
|||
30 Nov 2006, 22:45 |
|
Mr_Silent 01 Dec 2006, 06:40
revolution wrote: I think your code does not address the problem of defining the macros after you instantiate it. Of course, it doesn't . There is no such problem, because strait fwd-ref is impossible (with current implementation of Fasm preprocessor) , point. The only matter could be discussed here is how to "trick fasm into doing something like..." (see post 1). Or did you want the community to find some critical bu... err... feature which will allow normal fwd-ref |
|||
01 Dec 2006, 06:40 |
|
revolution 01 Dec 2006, 12:31
Mr_Silent wrote: Or did you want the community to find some critical bu... err... feature which will allow normal fwd-ref |
|||
01 Dec 2006, 12:31 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.