flat assembler
Message board for the users of flat assembler.

flat assembler > Heap > help with syntax request:fasmgdllselfhosting+x86-2+struct

Author
Thread Post new topic Reply to topic
ProMiNick



Joined: 24 Mar 2012
Posts: 315
Location: Russian Federation, Sochi
Tomasz could thou help?
I maked a tool in attachment - fasmg with modification (I dislike format ability and cut it off):
in directives.inc I added if block around
Code:
if ~definite format_binary_rollback
format_directive:
        mov     edx,[ebx+SymbolTree_Leaf.branch]
        call    get_symbol_namespace
        and     [symbol_definition],0
        mov     dl,SYMCLASS_INSTRUCTION
        call    identify_symbol_in_namespace
        jc      invalid_argument
        test    ebx,ebx
        jz      invalid_argument
        mov     al,[ebx+SymbolTree_Leaf.class]
        cmp     al,SYMCLASS_INSTRUCTION
        jne     invalid_argument
        call    get_available_value
        jc      invalid_argument
        mov     al,[edx+ValueDefinition.type]
        cmp     al,VALTYPE_SYMBOLIC
        je      use_macro
        cmp     al,VALTYPE_NATIVE_COMMAND
        jne     invalid_argument
        jmp     [edx+ValueDefinition.value]
format_binary:
        call    get_constituent_value
        jc      instruction_assembled
        cmp     al,1Ah
        jne     invalid_argument
        test    edx,edx
        jz      invalid_argument
        cmp     [edx+ValueDefinition.type],VALTYPE_NATIVE_PREPOSITION
        jne     invalid_argument
        cmp     [edx+ValueDefinition.value],PREPOSITION_AS
        jne     invalid_argument
        cmp     [output_extension],0
        jne     repeated_declaration
        call    get_constant_value
        cmp     al,22h
        jne     invalid_argument
        mov     edi,esi
        mov     ecx,[edx]
        lea     esi,[edx+4]
        mov     [output_extension_length],ecx
        mov     ebx,[auxiliary_output_areas]
        call    get_from_map
        jnc     extension_stored
        xor     eax,eax
        mov     ecx,[output_extension_length]
        call    put_into_map
    extension_stored:
        mov     [output_extension],esi
end if    


in tables.inc I added if block around
Code:
if ~definite format_binary_rollback
  db 6,'format',SYMCLASS_INSTRUCTION,VALTYPE_NATIVE_COMMAND,VAL_INTERNAL,0
  dd format_directive
end if    

and
Code:
if ~definite format_binary_rollback
db 6,'format'

  db 6,'binary',SYMCLASS_INSTRUCTION,VALTYPE_NATIVE_COMMAND,VAL_INTERNAL,0
  dd format_binary

  db 0
end if    

and ofcource makes defenition in fasmg.asm
Code:
define format_binary_rollback 1    


so "format" symbol became not builtin and not defined.

how to realize next syntax to selfhosting of fasmg.dll with above tool?

first goes "format PE large NX DLL" is forward refferenced & defined later.
then match case of fasm1 via fasmg
in fasmg part goes
included struct.inc from fasmgwin package
then included alterencoding"x86-2.inc"
then included file with declaration of format PE
then standard windows includes (constant,structures,macroses exept already declared above ones)
somewhere here instruction alterations to make fasmg code be suitable for dll (best case if they not somewhere, but exactly here).

then goes unmodified source of fasmg.asm for dll from line "include '../../version.inc'".

all it works at older fasm g ver hw7gf. without tricks. or with wery old tricks that became unassembled now with "not enought memory" message.
but from that time too many changes in core.
so I failed to modify it step by step from one working state to another.


Description: fasmg ij2b8 without format binary ability
Download
Filename: fasmg(format binary rollback).zip
Filesize: 31.17 KB
Downloaded: 14 Time(s)


_________________
I don`t like to refer by "you" to one person.
My soul requires acronim "thou" instead.
Post 25 Apr 2019, 14:42
View user's profile Send private message Send e-mail Reply with quote
Tomasz Grysztar
Assembly Artist


Joined: 16 Jun 2003
Posts: 7289
Location: Kraków, Poland
Since you removed a feature from fasmg and the sources rely on that feature, you need to re-introduce the same feature through macros. Fortunately, for FORMAT it can be done easily (except for the part that actually selected the output extension):
Code:
define format?
macro format?.binary? as
end macro
macro format?: declaration
        format.declaration
end macro    
Just add this to the sources and they should assemble ok.
Post 25 Apr 2019, 17:48
View user's profile Send private message Visit poster's website Reply with quote
ProMiNick



Joined: 24 Mar 2012
Posts: 315
Location: Russian Federation, Sochi
Thanks.
That is realy interesting how to emulate absent feature.
And my sources will remain in general line. It is more convinient than alter them each time.
Post 25 Apr 2019, 18:05
View user's profile Send private message Send e-mail Reply with quote
ProMiNick



Joined: 24 Mar 2012
Posts: 315
Location: Russian Federation, Sochi
Another idea come to my mind.
What if instead of swither of assembler in very begining of each variation of fasmg source stay only clean untrickery fasm1 source, and for fasmg make wrapper over it in another folder.

In such wrapper we need to define format & instruction set - after that fasmg would become same as fasm and it will be able to assemble same source.

Idea in attachment.
problem with localpointer.inc - still needed switcher. for fasmg I can place it in fasmg includes. But for fasm1 it needed to be in accesible place(in same as source). So I still cannot escape from switcher.
And fasmg lookup precedence dosn`t help - first fasmg looks for file in same folder and only after in includes directory.
May be if not changing fasmg default lookup includes precedence, so may be add directive that inverse that precedence?

there (in package) 2 files in selfhosting subfolder are compilable if open them via fasmw.exe in package & launch menu "Run" - submenu "FasmG:stdout2text" or "FasmG:mkbin" or "FasmG:mkbin2output" - they demonstrate idea but basing on standard encoding macroses. or drop src file on 1 of *.bat: stdOUT2TXT.bat, makeBIN2OUTPUT.BAT, makeBIN2CURDIR.BAT (what do the same as from IDE).

And 1 not compilable - at path "\source\selfhosting\windows\dllviax86-2\fasmg.dll.asm" I tryed to escape ro alterencoding but got error "Processed: P5 = CPU 5
Error: symbol 'CPU' is undefined or out of scope.".

How can I add alterencoding there so that it wotk? I very like that encoding variant. Dosn`t matter if it more resource greedy.

And last: Is IDE for fasmg planned? I still use myself patched fasmw for that purpose. It is more than enought but...


Description: ready to be at "C:\TEST", Init.bat will adapt for different folder.

fasmg sources realized as wraper over native fasm1 sources without tricking assembler switcher.

Download
Filename: TEST.zip
Filesize: 276.15 KB
Downloaded: 11 Time(s)


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



Joined: 24 Mar 2012
Posts: 315
Location: Russian Federation, Sochi
Wait.Wait.Wait.
Complex example above even no needed.
https://github.com/tgrysztar/fasmg/tree/master/packages/x86-2
content of that folder uncompilable with same error:
Code:
Processed: P5 = CPU 5
Error: symbol 'CPU' is undefined or out of scope.    


I can`t say from what update exacly x86-2.inc stopped to work.

But I take first encient fasmg version what I found - i4npt - it is successfully compiled.

So I gues x86-2.inc is outdated to work with current fasmg version.
Post 28 Apr 2019, 00:51
View user's profile Send private message Send e-mail Reply with quote
ProMiNick



Joined: 24 Mar 2012
Posts: 315
Location: Russian Federation, Sochi
I replaced
Code:
macro ? line&
        match name == selections, line
                local v
                v = 0
                iterate sel, selections
                        match X value, sel
                                v = v + value shl bsf x86.X + x86.X * x86.mask
                        end match
                end iterate
                x86.setting_#name? := v
        else
                line
        end match
end macro
16 = MODE 0
32 = MODE 1
64 = MODE 2

8086 = CPU 0
80186 = CPU 1
80286 = CPU 2
80386 = CPU 3
80486 = CPU 4
P5 = CPU 5
P6 = CPU 6
x64 = CPU 8

8087 = FPU 1
80187 = FPU 2
80287 = FPU 3
80387 = FPU 4

MMX = SIMD 1
SSE = SIMD 2
SSE2 = SIMD 3
SSE3 = SIMD 4

i86 = CPU 0, FPU 0, SIMD 0
i186 = CPU 1, FPU 0, SIMD 0
i286 = CPU 2, FPU 0, SIMD 0
i386 = CPU 3, FPU 0, SIMD 0
i486 = CPU 4, FPU 0, SIMD 0
Pentium = CPU 5, FPU 4, SIMD 0
PentiumPro = CPU 6, FPU 4, SIMD 0
PentiumMMX = CPU 5, FPU 4, SIMD 1
Pentium2 = CPU 6, FPU 4, SIMD 1
Pentium3 = CPU 6, FPU 4, SIMD 2
Pentium4 = CPU 6, FPU 4, SIMD 4
AMD64 = CPU 8, FPU 4, SIMD 3

immauto = IMM 0
imm8 = IMM 1
imm16 = IMM 2
imm32 = IMM 4
imm64 = IMM 8

rmauto = RM 0
rm1 = RM 1
rmdst = RM 1
rm2 = RM 2
rmsrc = RM 2

purge ?     

with this
Code:
x86.setting_16 := 0 shl bsf x86.MODE + x86.MODE * x86.mask
x86.setting_32 := 1 shl bsf x86.MODE + x86.MODE * x86.mask
x86.setting_64 := 2 shl bsf x86.MODE + x86.MODE * x86.mask

x86.setting_8086 := 0 shl bsf x86.CPU + x86.CPU * x86.mask
x86.setting_80186 := 1 shl bsf x86.CPU + x86.CPU * x86.mask
x86.setting_80286 := 2 shl bsf x86.CPU + x86.CPU * x86.mask
x86.setting_80386 := 3 shl bsf x86.CPU + x86.CPU * x86.mask
x86.setting_80486 := 4 shl bsf x86.CPU + x86.CPU * x86.mask
x86.setting_P5 := 5 shl bsf x86.CPU + x86.CPU * x86.mask
x86.setting_P6 := 6 shl bsf x86.CPU + x86.CPU * x86.mask
x86.setting_x64 := 8 shl bsf x86.CPU + x86.CPU * x86.mask


x86.setting_8087 := 1 shl bsf x86.FPU + x86.FPU * x86.mask
x86.setting_80187 := 2 shl bsf x86.FPU + x86.FPU * x86.mask
x86.setting_80287 := 3 shl bsf x86.FPU + x86.FPU * x86.mask
x86.setting_80387 := 4 shl bsf x86.FPU + x86.FPU * x86.mask

x86.setting_MMX := 1 shl bsf x86.SIMD + x86.SIMD * x86.mask
x86.setting_SSE := 2 shl bsf x86.SIMD + x86.SIMD * x86.mask
x86.setting_SSE2 := 3 shl bsf x86.SIMD + x86.SIMD * x86.mask
x86.setting_SSE3 := 4 shl bsf x86.SIMD + x86.SIMD * x86.mask


x86.setting_i86 := 0 shl bsf x86.CPU + 0 shl bsf x86.FPU + 0 shl bsf x86.SIMD + (x86.CPU + x86.CPU + x86.CPU) * x86.mask
x86.setting_i186 := 1 shl bsf x86.CPU + 0 shl bsf x86.FPU + 0 shl bsf x86.SIMD + (x86.CPU + x86.CPU + x86.CPU) * x86.mask
x86.setting_i286 := 2 shl bsf x86.CPU + 0 shl bsf x86.FPU + 0 shl bsf x86.SIMD + (x86.CPU + x86.CPU + x86.CPU) * x86.mask
x86.setting_i386 := 3 shl bsf x86.CPU + 0 shl bsf x86.FPU + 0 shl bsf x86.SIMD + (x86.CPU + x86.CPU + x86.CPU) * x86.mask
x86.setting_i486 := 4 shl bsf x86.CPU + 0 shl bsf x86.FPU + 0 shl bsf x86.SIMD + (x86.CPU + x86.CPU + x86.CPU) * x86.mask
x86.setting_Pentium := 5 shl bsf x86.CPU + 4 shl bsf x86.FPU + 0 shl bsf x86.SIMD + (x86.CPU + x86.CPU + x86.CPU) * x86.mask
x86.setting_PentiumPro := 6 shl bsf x86.CPU + 4 shl bsf x86.FPU + 0 shl bsf x86.SIMD + (x86.CPU + x86.CPU + x86.CPU) * x86.mask
x86.setting_PentiumMMX := 5 shl bsf x86.CPU + 4 shl bsf x86.FPU + 1 shl bsf x86.SIMD + (x86.CPU + x86.CPU + x86.CPU) * x86.mask
x86.setting_Pentium2 := 6 shl bsf x86.CPU + 4 shl bsf x86.FPU + 1 shl bsf x86.SIMD + (x86.CPU + x86.CPU + x86.CPU) * x86.mask
x86.setting_Pentium3 := 6 shl bsf x86.CPU + 4 shl bsf x86.FPU + 2 shl bsf x86.SIMD + (x86.CPU + x86.CPU + x86.CPU) * x86.mask
x86.setting_Pentium4 := 6 shl bsf x86.CPU + 4 shl bsf x86.FPU + 4 shl bsf x86.SIMD + (x86.CPU + x86.CPU + x86.CPU) * x86.mask
x86.setting_AMD64 := 8 shl bsf x86.CPU + 4 shl bsf x86.FPU + 3 shl bsf x86.SIMD + (x86.CPU + x86.CPU + x86.CPU) * x86.mask

x86.setting_immauto := 0 shl bsf x86.IMM + x86.IMM * x86.mask
x86.setting_imm8 := 1 shl bsf x86.IMM + x86.IMM * x86.mask
x86.setting_imm16 := 2 shl bsf x86.IMM + x86.IMM * x86.mask
x86.setting_imm32 := 4 shl bsf x86.IMM + x86.IMM * x86.mask
x86.setting_imm64 := 8 shl bsf x86.IMM + x86.IMM * x86.mask

x86.setting_rmauto := 0 shl bsf x86.RM + x86.RM * x86.mask
x86.setting_rm1 := 1 shl bsf x86.RM + x86.RM * x86.mask
x86.setting_rmdst := 1 shl bsf x86.RM + x86.RM * x86.mask
x86.setting_rm2 := 2 shl bsf x86.RM + x86.RM * x86.mask
x86.setting_rmsrc := 2 shl bsf x86.RM + x86.RM * x86.mask     


and this part from test:
Code:
include 'x86-2.inc'

use i386, 32

{rmdst} xor eax,ebx     ; 31 D8
{rmsrc} xor eax,ebx     ; 33 C3

{imm8}  add ecx,1       ; 83 C1 01
{imm32} add ecx,1       ; 81 C1 01 00 00 00

;use AMD64, 64

;{imm32} mov rax,1000    ; 48 C7 C0 E8 03 00 00
;{imm64} mov rax,1000    ; 48 B8 E8 03 00 00 00 00 00 00    


successfully compiled, but if I uncomment comments:
I got:
Code:
C:\TEST\include\test.ASM [11]:
        use AMD64, 64
macro ? [10] macro use [5] macro require [4]
Custom error: AMD64 required    


I little confused why so.
Post 28 Apr 2019, 08:29
View user's profile Send private message Send e-mail Reply with quote
Tomasz Grysztar
Assembly Artist


Joined: 16 Jun 2003
Posts: 7289
Location: Kraków, Poland
It's a bug in fasmg I recently introduced while fixing another issue. I corrected in now.
Post 28 Apr 2019, 08:42
View user's profile Send private message Visit poster's website Reply with quote
guignol



Joined: 06 Dec 2008
Posts: 536
Location: Did I forgot to take off the kettle again?
thank God
Post 28 Apr 2019, 12:03
View user's profile Send private message 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-2019, Tomasz Grysztar.

Powered by rwasa.