flat assembler
Message board for the users of flat assembler.

Index > Macroinstructions > variable individualy constants & initialized value

Author
Thread Post new topic Reply to topic
ProMiNick



Joined: 24 Mar 2012
Posts: 802
Location: Russian Federation, Sochi
ProMiNick 06 Mar 2023, 22:06
Code:
macro setlocaloverrides [name,defailts,defvals] { macro name args& \{ match defailts,defvals \\{ name args \\} \} }
macro init1 [arg] { macro arg args:=1 \{ arg args \} }
macro init0 [arg] { macro arg args:=0 \{ arg args \} }    

set individualy constants "lin=1", "mov=0", "6=2" that may presence in expression that variable hello is equal
Code:
setlocaloverrides hello,lin mov 6,1 0 2    

set short form initialized as 1
Code:
init1 hello    

Code:
hello;hello=1
hello = lin*mov+6;hello=1*0+2
; at here there is no such constants as lin and mov, constants are realy variable expression individualy
lin =0
lin =5
lin equ (1 shl 5)
mov equ 7
hello = lin*mov+6;hello=1*0+2
hello2 = lin*mov+6;hello2=(1 shl 5)*7+6
restore lin
hello = lin*mov+6;hello=1*0+2
hello3 = lin*mov+6;hello2=5*7+6
hello equ lin*mov+6;hello equ 1*0+2
hello equ hello*2;hello equ 1*0+2*2     


by the way init1 init0 are limited to be used on assembly time variables
but setlocaloverrides has no such limitation it could be applied to any macro and case of assembly time variable is only one of numerous implementations
init1/init0 & setlocaloverrides could be combined together on some assembly time variable, or applied separatedly.

If someone wish to apply such weird syntax these 3 lowweight macros (or one of them) will help.
init1 & init0 could be replaced with
Code:
macro init [arg,def*] { macro arg args:=def \{ arg args \} }    

_________________
I don`t like to refer by "you" to one person.
My soul requires acronim "thou" instead.
Post 06 Mar 2023, 22:06
View user's profile Send private message Send e-mail Reply with quote
ProMiNick



Joined: 24 Mar 2012
Posts: 802
Location: Russian Federation, Sochi
ProMiNick 06 Mar 2023, 22:37
nesting for single symbolic could be more more greedy to resources, byt it is possible by design(syntax)
Code:
setlocaloverrides hello,lin mov 6,1 0 2,hello,haha, 325-lin*20    

Code:
hello = haha+6;hello=325-1*20+2    

in reverse order value of lin get from out of expression assignments
Code:
setlocaloverrides hello,haha, 325-lin*20,hello,lin mov 6,1 0 2    
Code:
hello = haha+6;lin is undefined, define it with equ, define or =    
Post 06 Mar 2023, 22:37
View user's profile Send private message Send e-mail Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.