flat assembler
Message board for the users of flat assembler.
Index
> Macroinstructions > Small proc macro extention |
Author |
|
Fanael 03 Jan 2010, 14:48
Change prologuedef macro in 'include/macro/proc32.inc' to
Code: macro prologuedef procname,flag,parmbytes,localbytes,reglist { local loc loc = (localbytes+3) and (not 3) parmbase@proc equ ebp+8 localbase@proc equ ebp-loc if parmbytes | localbytes push ebp mov ebp,esp if localbytes sub esp,loc end if end if irps reg, reglist \{ if reg eq eflags pushfd else push reg end if \} } Code: macro epiloguedef procname,flag,parmbytes,localbytes,reglist { irps reg, reglist \{ reverse if reg eq eflags popfd else pop reg end if \} if parmbytes | localbytes leave end if if flag and 10000b retn else retn parmbytes end if } |
|||
03 Jan 2010, 14:48 |
|
baldr 12 Jan 2010, 17:17
Another approach is to redefine push/pop to accept flags as an operand.
Code: irp mnem, push,pop { macro mnem val \{ if val eq flags mnem#f else mnem val end if \} } |
|||
12 Jan 2010, 17:17 |
|
LocoDelAssembly 12 Jan 2010, 20:49
Quote:
But not so direct (remember expressions). However, perhaps modeling a simple state machine and accumulating symbols in an equate until it is time to issue a PUSH/POP will do it. |
|||
12 Jan 2010, 20:49 |
|
baldr 12 Jan 2010, 22:05
LocoDelAssembly,
You're right, even FASM itself blunders on that (plain push 2 -1 compiles as push 1 despite explicit space; thank you, preprocessor). |
|||
12 Jan 2010, 22:05 |
|
revolution 12 Jan 2010, 22:21
baldr wrote: You're right, even FASM itself blunders on that (plain push 2 -1 compiles as push 1 despite explicit space; thank you, preprocessor). |
|||
12 Jan 2010, 22:21 |
|
baldr 12 Jan 2010, 23:14
revolution,
I forgot to insert smiley. Anyway, evaluator's greediness has nothing to do with this — look at preprocessed source. I don't expect space to be an operand separator, FASM does. |
|||
12 Jan 2010, 23:14 |
|
Tomasz Grysztar 13 Jan 2010, 07:47
baldr wrote: revolution, I think you misunderstood him. Evaluator's greediness has very much to do with it. And the fact that the source is pre-tokenized came into design because of some other assumptions, not the opposite way. baldr wrote: I don't expect space to be an operand separator, FASM does. No, it does not. This one is going to be assembled without any spaces: Code: push(1)(2)(3) And BTW, this PUSH/POP syntax is not something standard to fasm, it merely simulates a feature of other assembler that is frequently used. |
|||
13 Jan 2010, 07:47 |
|
baldr 13 Jan 2010, 08:33
Tomasz Grysztar,
I meant that evaluator has no means to detect that space was there: 2 -1 is indistinguishable from 2-1 after preprocessing. And space is essential part of push/pop specification in manual. Pretty far off-topic, I think. |
|||
13 Jan 2010, 08:33 |
|
Tomasz Grysztar 13 Jan 2010, 08:46
baldr wrote: I meant that evaluator has no means to detect that space was there: 2 -1 is indistinguishable from 2-1 after preprocessing. baldr wrote: And space is essential part of push/pop specification in manual. I wouldn't call it "essential". It's used there because the reader is not assumed to understand the process of tokenization yet. I may consider rephrasing it, though. |
|||
13 Jan 2010, 08:46 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.