flat assembler
Message board for the users of flat assembler.

Index > Main > how to update the size metadata of a label?

Author
Thread Post new topic Reply to topic
sylware



Joined: 23 Oct 2020
Posts: 437
Location: Marseille/France
sylware 20 Dec 2021, 15:24
I tried to update the size metadata of a label after its definition, and it seems we cannot do it, or I forgot the right part of the manual again.
Post 20 Dec 2021, 15:24
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8351
Location: Kraków, Poland
Tomasz Grysztar 20 Dec 2021, 15:33
It's not possible, as this would effectively be a change of the contents of the symbol, while label must only be defined exactly once (which ensures that forward-references work correctly and that all uses of the symbol are consistent across the whole scope).

It is theoretically possible change the metadata (together with the value) when updating a variable symbol (like one defined with "="), but there is currently no syntax for that, it has never been requested before.
Post 20 Dec 2021, 15:33
View user's profile Send private message Visit poster's website Reply with quote
sylware



Joined: 23 Oct 2020
Posts: 437
Location: Marseille/France
sylware 20 Dec 2021, 19:11
I thought so but needed verification. I guess I have to use forward-referencable constants to define the size metadata of my labels using the "label" command.
thx.
Post 20 Dec 2021, 19:11
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8351
Location: Kraków, Poland
Tomasz Grysztar 20 Dec 2021, 19:17
sylware wrote:
I thought so but needed verification. I guess I have to use forward-referencable constants to define the size metadata of my labels using the "label" command.
Yes, that's the usual way to do it.
Post 20 Dec 2021, 19:17
View user's profile Send private message Visit poster's website Reply with quote
ProMiNick



Joined: 24 Mar 2012
Posts: 798
Location: Russian Federation, Sochi
ProMiNick 20 Dec 2021, 21:44
almost...
Code:
macro typecast [sizer] {
        label dummy@#sizer sizer at 0
        macro sizer statement& \{
                match any rest,statement : \\{
                        match =:,rest \\\{
                                restore statement
                                statement equ dummy@#sizer+statement \\\} \\}
                match sym == val,statement \\{
                        restore sym
                        statement
                        sym equ dummy@#sizer+sym \\} \} }

typecast byte,word,dword,qword    

usecase:
Code:
dword a=0
byte b=a+20
use32
mov [b],0    

looks working but not work
match resolves statement, but in curent case needed match equivalent that dont resolve statement
because
Code:
dword a=0
byte a=a+20 ; restore hidden in macros get not a
use32
mov [a],0; not works    

this one works
Code:
dword a=0
restore a ; if we force restoring a outside of macro all works
byte a=a+20
use32
mov [a],0    


So, feature request: needed match analog that dosn`t resolves equs & defines.
Post 20 Dec 2021, 21:44
View user's profile Send private message Send e-mail Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8351
Location: Kraków, Poland
Tomasz Grysztar 20 Dec 2021, 22:10
ProMiNick wrote:
So, feature request: needed match analog that dosn`t resolves equs & defines.
Such variant was never needed, as it's enough to use a proxy variable to get such result.
Code:
define proxy statement
match sym ==== val, proxy
; ...    
Post 20 Dec 2021, 22:10
View user's profile Send private message Visit poster's website Reply with quote
ProMiNick



Joined: 24 Mar 2012
Posts: 798
Location: Russian Federation, Sochi
ProMiNick 20 Dec 2021, 23:16
Thanks
final working variant
Code:
macro typecast [sizer] {
        label dummy@#sizer sizer at 0
        macro sizer statement& \{
                local proxy
                define proxy statement
                match any rest,proxy : \\{
                        restore any 
                        match == val =:,rest \\\{ proxy \\\} 
                        any equ dummy@#sizer+any \\} \} }

macro void statement& {
        local proxy
        define proxy statement
        match any rest,proxy : \\{
                restore any 
                match == val =:,rest \\\{ proxy \\\} \\} \} }

typecast byte,word,dword,qword    
usecase:
Code:
dword a=0

use32
mov [a],0
byte a=a+20
mov [a],0
void a ; or restore a - released a for future calculations
 b=a+1    


But I can`t see any advantage of such syntax.
for ex, this set leave us free to calculate a without additional overhead to preprocessor for restoring & storing a
Code:
label dummy@byte byte at 0
label dummy@word word at 0
label dummy@dword dword at 0

define a.byte a + dummy@byte
define a.word a + dummy@word
define a.dword a + dummy@dword    
Post 20 Dec 2021, 23:16
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.