flat assembler
Message board for the users of flat assembler.
Index
> Macroinstructions > parallel definitions |
Author |
|
revolution 12 Feb 2022, 08:03
Simpler IMO:
Code: ah equ r8 vah equ r7 But seriously, if you want to assign numeric things backwards then perhaps: Code: macro assign [reg] { common num equ 8 forward reg equ r#num rept 1 n:num-1 \{num equ n\} } assign ah, vah It can be fixed like this: Code: macro assign [reg] { common num equ 8 forward rept 1 n:num \{reg equ r\#n\} rept 1 n:num-1 \{num equ n\} } assign ah, vah Last edited by revolution on 12 Feb 2022, 11:52; edited 2 times in total |
|||
12 Feb 2022, 08:03 |
|
Tomasz Grysztar 12 Feb 2022, 10:53
revolution wrote:
A simple solution that comes to mind is to pre-fill a pool of register names and then use them. In this case the reverse order comes naturally as a consequence of stacking the names: Code: rept 8 i { define regpool r#i } macro assign [reg] { match r, regpool \{ define reg r \} restore regpool } assign ah, vah ; r8, r7 |
|||
12 Feb 2022, 10:53 |
|
macomics 12 Feb 2022, 11:37
Is it necessary to create implicit naming? Maybe it would be better to make an explicit assignment.
Code: macro assign [def] { forward match name==reg,def \{ define reg name \} } assign ah=r8, vah=r7 |
|||
12 Feb 2022, 11:37 |
|
revolution 12 Feb 2022, 11:54
Tomasz Grysztar wrote:
I edited the post with the new line to replace it: Code: rept 1 n:num \{reg equ r\#n\} |
|||
12 Feb 2022, 11:54 |
|
sylware 12 Feb 2022, 15:18
I use "define my_local_reg_alias reg", then in classic macros (which can call other macros) to work with reg aliases (did not try calm), I go down to the definition of a reg, namely an "element", then I reconstruct the right register.
Maybe I am totally wrong though and there is an obvious other way to do that I did not see (as usual). |
|||
12 Feb 2022, 15:18 |
|
rostok 13 Feb 2022, 07:04
I have seen the code I wrote is wrong as rept parameter must accept numbers only. It is not the actual code of my solution.
My intention is to give arbitrary names to registers whenever I want. For example at the beginning of a routine, so I can use meaningful names for that routine. Giving explicit names is a good idea. rept 8 i { define regpool r#i } macro assign [reg] { match r, regpool \{ define reg r \} restore regpool } assign ah, vah ; r8, r7 This solution is a bit shorter but not simpler than mine. I.e. it uses restore to assign a member of a list to the member of another list . I am a newbie of FASM and I am glad I found the only possible method. Thanks for the answers. |
|||
13 Feb 2022, 07:04 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.