flat assembler
Message board for the users of flat assembler.

flat assembler > Heap > could be decorators became a wide class of extensions

Author
Thread Post new topic Reply to topic
ProMiNick



Joined: 24 Mar 2012
Posts: 190
Location: Russian Federation, Sochi
That only idea. I am sure that there are bugs inside (I used fasmg syntax too freely, some redundant # , maybe I should use eval with name of set hidden in set#.mask, end equing decorator_#name with set#.mask not with set#.settings ).
I want to realize this in outer module
Code:
element decorator

macro add_decorator? set,block,names&
        if ~defined set
                define set
                set#.mask_bits = 0
                set#.settings = 0
                element set#.mask: decorator +`set ; maybe unneeded, not used, that was one of ways for extracting set name for later eval
        end if
        if defined set#.#block
                err `set, '.', `block, ' redefinition'
        else
                set#.#block = 0
                iterate name, names
                        if %% ; is that if filtrate smthing? or it always true
                                set#.#block = ((1 shl (1+bsr %%)-1) shl set#.mask_bits
                        end if
                        break
                end iterate
                if set#.#block
                        set#.mask_bits = set#.mask_bits + set#.#block
                        iterate name, names
                                set#.settings_#block#@#% = % shl bsf set#.#block + set#.#block * set#.mask
                                match any,name
                                        set#.settings_#name = set#.settings_#block#@#%
                                        if defined decorator_#name
                                                err 'decorator ', `name, ' redefinition'
                                                break
                                        else
                                                decorator_#name equ set#.settings; set#.mask
                                        end if
                                end match
                        end iterate
                end if
        end if
end macro

macro complex_decorator set*,complex*,names&
        if ~defined set
                err `set, ' unexisted'
        end if
        if defined decorator_#complex
                err 'decorator ', `name, ' redefined'
        else
                set#.settings_#complex = 0
                iterate name, names
                        match ,name
                                err 'empty name for complex decorator'
                        else
                                set#.settings_#complex = set#.settings_#complex+set#.settings_#name
                        end match
                end iterate
                decorator_#complex equ set#.settings; set#.mask
        end if
end macro

macro use options&
        iterate name, options
                match settings, decorator_#name
                        settings = (settings and not settings_#name scale 1) or settings_#name scale 0
                end match
        end iterate
end macro

macro ? line&
        match {decorator} instruction, line
                macro ? any&
                        purge ?
                        iterate name, decorator
                                decorator_#name := decorator_#name
                        end itarate
                        x86.settings =: x86.settings
                        use decorator
                        instruction
                        iterate name, decorator
                                restore decorator_#name
                        end itarate
                end macro
        end match
        outscope line
end macro     

and in x86.inc will left:
Code:
add_decorator x86?,MODE,16,32,64
add_decorator x86?,CPU,8086,80186,80286,80386,80486,P5,P6,,x64
add_decorator x86?,FPU,noFPU,8087,80187,80287,80387
add_decorator x86?,SIMD,noSIMD,MMX,SSE,SSE2,SSE3
add_decorator x86?,IMM,immauto,imm8,imm16,,imm32,,,,imm64
add_decorator x86?,RM,rmauto,rmdst,rmsrc; RM@1 analogue to rmdst, RM@2 analogue to rmsrc, but no rm1,rm2 synonims

complex_decorator x86?,i86,             8086, noFPU,noSIMD
complex_decorator x86?,i186,            80186,noFPU,noSIMD
complex_decorator x86?,i286,            80286,noFPU,noSIMD
complex_decorator x86?,i386,            80386,noFPU,noSIMD
complex_decorator x86?,i486,            80486,noFPU,noSIMD
complex_decorator x86?,Pentium,         P5,   80387,noSIMD
complex_decorator x86?,PentiumPro,      P6,   80387,noSIMD
complex_decorator x86?,PentiumMMX,      P5,   80387,MMX
complex_decorator x86?,Pentium2,        P6,   80387,MMX
complex_decorator x86?,Pentium3,        P6,   80387,SSE
complex_decorator x86?,Pentium4,        P6,   80387,SSE3
complex_decorator x86?,AMD64,           x64,  80387,SSE2  

macro use16?
        use 16
end macro

macro use32?
        use 32
end macro

macro use64?
        use 64
end macro

use16

x86.mode equ 1 shl (4 + x86.settings and x86.MODE) shr bsf x86.MODE
x86.cpu equ (x86.settings and x86.CPU) shr bsf x86.CPU
x86.fpu equ (x86.settings and x86.FPU) shr bsf x86.FPU
x86.immsize equ (x86.settings and x86.IMM) shr bsf x86.IMM
x86.rmposition equ (x86.settings and x86.RM) shr bsf x86.RM

macro x86.require? options&
        iterate option, options
                match name+, option
                        if x86.settings and x86.setting_#name scale 1 < x86.setting_#name scale 0
                                err `name, ' required'
                                break
                        end if
                else
                        if x86.settings and x86.setting_#option scale 1 <> x86.setting_#option scale 0
                                err `option, ' required'
                                break
                        end if
                end match
        end iterate
end macro 

element x86.reg
....
    


because decorator would be outer element without strong relation to x86 I will be able to use such decorator syntax everywhere...

I want somethng:
Code:
add_decorator cpu?,N_ARY,,,binary,ternary
add_decorator cpu?,ENDIANESS?,LITTLEENDIAN?,BIGENDIAN?,LITTLEENDIANWORD?,BIGENDIANWORD?
add_decorator cpu?,instrsize,VARY,1,2,3,4 ; in minimal addressable units of CPU (bytes, trytes,...) 
add_decorator cpu?.binary?,wordsize,,1,2,,4
add_decorator cpu?.binary?,ptrsize,,1,2,,4,,6,,8
...
add_decorator cpu?.binary?.x86.windows?,RING,RING0,RING1,RING2,RING3
add_decorator cpu?.binary?.x86.windows?,VERSION,3.0,3.1,95,95SE,98,98SE,ME,2000,NT,NTSP1,NTSP2,NTSP3,NTSP4,XP,XPSP1,XPSP2,XPSP3,XPx64,XPx64SP1,XPx64SP2,Vista,7,7SP1,7x64,7x64SP1,8,8x64,8.1,8.1x64,10,10x64 ; some api and structures are different for other versions    


My FASMG knowlege stuck on above...

_________________
I don`t like to refer by "you" to one person.
My soul requires acronim "thou" instead.


Last edited by ProMiNick on 11 Oct 2018, 15:06; edited 7 times in total
Post 10 Oct 2018, 15:05
View user's profile Send private message Send e-mail Reply with quote
ProMiNick



Joined: 24 Mar 2012
Posts: 190
Location: Russian Federation, Sochi
I will be very appreciate for help in creating of working variant.
Post 11 Oct 2018, 14:10
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 can attach files in this forum
You can download files in this forum


Copyright © 1999-2018, Tomasz Grysztar.

Powered by rwasa.