flat assembler
Message board for the users of flat assembler.

Index > Macroinstructions > override virtuals by macro for variable bases

Author
Thread Post new topic Reply to topic
ProMiNick



Joined: 24 Mar 2012
Posts: 642
Location: Russian Federation, Sochi
ProMiNick
Code:
datadef@directives equ db,dw,du,dd,dp,dq,dt
datarsv@directives equ rb,rw,rd,rp,rq,rt
def.rb equ db
def.rw equ dw
def.rd equ dd
def.rp equ dp
def.rq equ dq
def.rt equ dt
;==============================================================
macro set var,value {var equ value }
;==============================================================
macro virtual@overridedefs [datadef] {
        struc datadef [val:?] \{ \common
                        \local ..anonimous
                        ..anonimous datadef val
                        match any,@virtbase \\{ define . ..anonimous + any \\} \} }
;==============================================================
macro virtual@overridersvs [datadef] {
        match ddd,def.#datadef \{
        struc datadef count \\{ \\common
                        \\local ..anonimous
                        ..anonimous ddd count dup (?)
                        match any,@virtbase \\\{ define . ..anonimous + any \\\} \\} \} }
;==============================================================
macro virtual@restoredefs [datadef] { restruc datadef }
;==============================================================
macro extendvirtual {
        macro virtual statement& \{
                match ,statement \\{
                        \\local ..anonimous
                        label ..anonimous
                        @virtbase equ ..anonimous \\}
                match =at base,statement \\{
                        @virtbase equ base \\}

                match any,datadef@directives \\{ virtual@overridedefs any \\}
                match any,datarsv@directives \\{ virtual@overridersvs any \\}
                virtual at 0 \}
        macro endv \{
                virtual@restoredefs datadef@directives,datarsv@directives
                restore @virtbase
                end virtual \} }
@virtbase equ
; use case: ========================
extendvirtual
virtual at 0+fixer
        a dd ?
        b db 6
endv; end virtual

use32
fixer = 5
mov eax,[a] ;a is 5, and dword size specifier stored in a
display 'a=',a+'0',13,10,'b=',b+'0',13,10; must show a=5,b=9

fixer = 3
mov al,[b]  ;b is 7, and byte size specifier stored in b
display 'a=',a+'0',13,10,'b=',b+'0'; must show a=3,b=7    


only 1 minus, such virtual blocks must be ended with endv not end virtual
Sad. - I guess when something is realized via existing macrosyntax there is no chance for feature to became built in in sometime future.
But here is some limitations within such blocks: labels via keyword label are not realized in that realization & labels via ":" are unrealizable at all.

_________________
I don`t like to refer by "you" to one person.
My soul requires acronim "thou" instead.
Post 03 Oct 2021, 00:01
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-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.

Website powered by rwasa.