flat assembler
Message board for the users of flat assembler.
Index
> Main > [fasmg] how to use virtual for the output file? |
Author |
|
Roman 23 Apr 2023, 13:41
We need in to preprocessing implemented call user dll from Virtual or usr_dll.
User dll get fasm data ,parsed and out back to fasm. Than fasm can easily calculated sqrt,sin,cos,matrix multiplication, apply vectors xyz and many etc. |
|||
23 Apr 2023, 13:41 |
|
v142857 23 Apr 2023, 14:19
what are you talking about Roman? You got me real confused here...
I want to have sections in the output file that I can later append as I process the source file... What is this usr_dll? |
|||
23 Apr 2023, 14:19 |
|
macomics 23 Apr 2023, 14:45
Tell us more detail what it means: append later
Everything that will ever be used in the program is described within its source code. If something needs to be added, then it's easy enough to add it to the source. You are talking about some incomprehensible action that is not related to what virtual is intended for. |
|||
23 Apr 2023, 14:45 |
|
Tomasz Grysztar 23 Apr 2023, 14:56
The output areas cannot be expanded after they are defined. But there is a specific pattern that a multi-pass assembler like fasmg allows: reserve exact space that is needed, by forward-referencing the final count, something like:
Code: rd NUMBER_OF_FUNCTIONS
postpone
NUMBER_OF_FUNCTIONS := FUNCTION_COUNTER
end postpone If you look at my old WASM prototype, you may find similar approach used to construct all the collected tables. |
|||
23 Apr 2023, 14:56 |
|
Tomasz Grysztar 23 Apr 2023, 16:26
If you prefer to work with appended virtual areas, there's even an option of forward-referencing the entire final content (kept as a string of bytes):
Code: db LIST_BYTES virtual at 0 List:: end virtual virtual List dd 'item' end virtual virtual List dd 'more' end virtual load LIST_BYTES: sizeof List from List:0 Code: load LIST_BYTES: LIST_LENGTH from List:0 db LIST_BYTES virtual at 0 List:: end virtual postpone LIST_LENGTH := sizeof List end postpone virtual List dd 'item' end virtual virtual List dd 'more' end virtual |
|||
23 Apr 2023, 16:26 |
|
Tomasz Grysztar 23 Apr 2023, 16:42
And yet another option - the macroinstructions can be forward-referenced as well, so you can just collect blocks of source code and then execute them all in a single place to dynamically generate the structure you need:
Code: repeat NUMBER_OF_OBJECTS Object#% end repeat OBJECT_ID = 0 postpone NUMBER_OF_OBJECTS := OBJECT_ID end postpone calminstruction object? compute OBJECT_ID, OBJECT_ID + 1 arrange declaration, =macro =Object#OBJECT_ID assemble declaration end calminstruction macro end?.object?! esc end macro end macro object db 'abc' end object object db 'efg' end object |
|||
23 Apr 2023, 16:42 |
|
v142857 23 Apr 2023, 18:12
macomics wrote: Tell us more detail what it means: append later I am parsing a source code with a syntax that resembles WAT, to WASM encoding. But the issue is: a WASM module has an explicit order where the types signatures go first, then the export section, then the function section, then the code section... but my source code can look like Code: func main result i32 i32.const 42 end func export func main as "main" and this source has to be broken down dynamically and fill each section and the size of each section... the virtual operation was the closest I saw in the fasmg docs, so thats why I started asking about it Tomasz already gave multiple options about how to do that so now I have some idea in how to approach this problem |
|||
23 Apr 2023, 18:12 |
|
v142857 23 Apr 2023, 23:01
So, about the virtual memory approach one because looks like the easier to understand and how to apply in my specific case:
Code: define sections_names custom, type, import, func, table, mem, global, export, start, elem, code, data iterate name, sections_names name#_section: end iterate virtual at 0 iterate name, sections_names name:: end iterate end virtual postpone iterate name, sections_names load name#_section:sizeof name from name:0 end iterate end postpone will that assemble the contents of each virtual section to the output, in order, in the end of the assembly process? I am getting issues with the iterate and I dont have yet the parsing to fill the sections, so thats why I need to ask that in this phase |
|||
23 Apr 2023, 23:01 |
|
v142857 24 Apr 2023, 15:24
just for the record, thats the final form of the solution:
Code: define sections_names custom, type, import, func, table, mem, global, export, start, elem, code, data ... iteratelist name, sections_names if name#_section <> 0 db section.name.id encode_u sizeof name db name#_section end if end iterate iteratelist name, sections_names virtual at 0 name:: end virtual end iterate postpone iteratelist name, sections_names load name#_section:sizeof name from name:0 end iterate end postpone calminstruction iteratelist?! param, var transform var arrange param, =iterate param, var assemble param end calminstruction ... |
|||
24 Apr 2023, 15:24 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.