flat assembler
Message board for the users of flat assembler.
Index
> Main > local macro namespace and virtual names conflict |
Author |
|
Tomasz Grysztar 28 Feb 2009, 16:44
The "dv.x" is seen by fasm as one whole name, so the "dv" local is not recognized inside it. The correct way to do it is:
Code: struc ST {.x db ?} d1 ST d2 ST macro MC NST { local dv virtual at d#NST dv ST end virtual mov eax,dv#.x } MC 1 MC 2 |
|||
28 Feb 2009, 16:44 |
|
strap89 28 Feb 2009, 17:11
Big thanks!
I have another small problem (similar), may it be writed in this thread? Code: macro DD NV {d#NV dd NV} rept 4 counter { DD counter-1 } |
|||
28 Feb 2009, 17:11 |
|
LocoDelAssembly 28 Feb 2009, 17:16
TFM kindly says wrote: The counter symbol by default counts from 1, but you can declare different |
|||
28 Feb 2009, 17:16 |
|
strap89 28 Feb 2009, 17:22
That is not complete solution:
Code: macro DD NV {d#NV dd NV} rept 4 counter { DD counter*2 } it’s done after the arguments and local names are replaced with their values". So it must be a number... or not calculated expression? |
|||
28 Feb 2009, 17:22 |
|
revolution 28 Feb 2009, 17:27
Code: irp counter,0,2,4,6 { ... } |
|||
28 Feb 2009, 17:27 |
|
revolution 28 Feb 2009, 17:29
See here also.
|
|||
28 Feb 2009, 17:29 |
|
strap89 28 Feb 2009, 18:09
Great examples! I'm like such code. But problem not solved:
Code: macro pre_dec result,x { match xx,x { rept xx j:0 { result equ j \\} \} } macro DD NV { display 'NV=',NV+30h,13,10 d#NV dd NV } rept 4 counter { pre_dec result,counter mov eax,result DD result } It work as EQU, mov eax ,result compiled OK. But after # it not compiled. May be after # we work with expression, not with it value (may be problem come only at one of pass). By the way, in this code compiler error is: symbol already defined, but display show different numbers, but previous code say: illegal instruction. May be it's posiible to know: what symbol already defined. Is it d0 or d1 or d3 or may be dresult? Please, i'm try to understand rules to use such code. |
|||
28 Feb 2009, 18:09 |
|
revolution 28 Feb 2009, 23:55
strap89 wrote: compiler error is: symbol already defined Code: local result |
|||
28 Feb 2009, 23:55 |
|
strap89 01 Mar 2009, 04:24
I'm try define GLOBAL symbols with different names - local not usable.
|
|||
01 Mar 2009, 04:24 |
|
revolution 01 Mar 2009, 04:35
Use both local and then match to dereference "result" into the value EUQated. Or, if the list is lot too large, use irp as above.
|
|||
01 Mar 2009, 04:35 |
|
strap89 01 Mar 2009, 05:04
In previous sample i'm ry to use EQU - it not work.
IMHO I'm understand problem: name after # resolved to there value, but resolution have only one level (nested expression no resolved). Code: macro A { name#1 dd 0 XF equ 1 pame#XF dd 1 YF fix 2 rame#YF dd 1 ZF fix YF wame#ZF dd 1 } A name1: defined in {line generated by a.asm[11] from a.asm[3]} pameXF: defined in {line generated by a.asm[11] from a.asm[5]} rame2: defined in {line generated by a.asm[11] from a.asm[7]} wameXF: defined in {line generated by a.asm[11] from a.asm[9]} 1. digit converted to digit itself 2. equ not converted (it's name used). It's not shown but XF=1 work as equ. 3. fix converted to it's value 4. double fix (ZF) converted to name of previous level (YF). |
|||
01 Mar 2009, 05:04 |
|
revolution 01 Mar 2009, 05:13
strap89 wrote: (nested expression no resolved) |
|||
01 Mar 2009, 05:13 |
|
strap89 01 Mar 2009, 05:33
I'm see last post but i'm not understand what you meen. How dereference LOCAL name into GLOBAL namespace? Simple EQU not work.
|
|||
01 Mar 2009, 05:33 |
|
revolution 01 Mar 2009, 06:11
strap89 wrote: I'm see last post but i'm not understand what you meen. How dereference LOCAL name into GLOBAL namespace? Simple EQU not work. Code: macro DD NV {d#NV dd NV} macro pre_mul result,x,y { match xx yy,x y { result equ xx rept xx { match w,result { rept yy j:w { result equ j \\\\} \\\} \\} \} } rept 400 counter:0 { local result pre_mul result,counter,2 match r,result \{ DD r \} } mov eax,d4 mov eax,d10 mov eax,d400 |
|||
01 Mar 2009, 06:11 |
|
strap89 01 Mar 2009, 12:42
Thanks!
Now i'm begin to undestand how it work. But at least at this example local is not needed, compiled ok without it. 'pre_mul' preset 'result' and not use it previous value. |
|||
01 Mar 2009, 12:42 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.