flat assembler
Message board for the users of flat assembler.

Index > Main > section problem

Author
Thread Post new topic Reply to topic
rostok



Joined: 12 Feb 2022
Posts: 5
rostok 16 Feb 2022, 06:44
I have just read the flatg manual. It is seen that the author knows all the problems of FASM1 and solves most of them there. What I don't understand is that why passing from one section to another is not allowed in both versions as in all the other assemblers. In executable section, one can only use "store" instruction to store data in a data section. In flatg, the amount of data to be stored/load is unlimited and extensions of the sections are allowed somehow. However, storing data to another section is still a pain and like showing the right ear by the left arm. Implementing a "section" command just like the "virtual" command should not be a very hard job.
Post 16 Feb 2022, 06:44
View user's profile Send private message Reply with quote
Overclick



Joined: 11 Jul 2020
Posts: 669
Location: Ukraine
Overclick 16 Feb 2022, 07:35
Seems like you need my multisections macro:
https://board.flatassembler.net/topic.php?t=21545

Switch between sections anytime anywhere even in proc and macros.
Example:
Code:
.data
...
.code
...
.data
...
.code
...    
Post 16 Feb 2022, 07:35
View user's profile Send private message Visit poster's website Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20430
Location: In your JS exploiting you and your system
revolution 16 Feb 2022, 09:19
The reason is because fasm is not a linker. So the sections are not merged. They are output as-is, in the same order specified in the source code.

To solve this, you can use a linkable output format and it will all be merged by the linker. This is what the other assemblers do.

But fasm has extra functionality, that other assemblers don't have, to output an executable file directly, without a linker. This is where you can fall into trouble with multiple sections. As Overclick says above, you can use macros to do the merging within the source code.
Post 16 Feb 2022, 09:19
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8357
Location: Kraków, Poland
Tomasz Grysztar 16 Feb 2022, 09:34
You you could say that this property is what makes flat assembler "flat", although that would be a tongue-in-cheek explanation.

I designed fasmg to provide a set of primitives that could be combined to implement various kinds of assembler syntax and behaviors, including but not limited to ones compatible with fasm 1. The re-enterable virtual blocks you mentioned, or commands like RESTARTOUT, are among such basic components - to be used to construct various higher level features.

As intended by this design, not only instruction sets but also output formats are implemented through add-ons. The standard ones are compatible with fasm 1 and thus similarly "flat", however this does not always need to be the case, as demonstrated by successful attempts to assemble source texts written for some old assemblers. It is up to the designer of a specific header set to choose what features to provide and how to lay out everything. For example, filling several sections in parallel would make it harder to provide features like $%, although with help of multi-pass predictions you could probably make it work if you really wanted - but these are the kinds of decisions that belong in the higher layer, allowing the actual primitives to be simpler and more reliable.

The design of fasmg was my answer to all the mutually exclusive requests that I kept receiving during the decades of fasm's development. This is why it is so unrestrained in its flexibility, offering all the possibilities while giving very little to begin with. You can have all the features you wanted in fasm 1, but the caveat is that might need to write a new set of headers to implement the specific syntax and features almost from scratch. Perhaps making fasmg was my ultimate way of saying "give me a rest" - another toungue-in-cheek explanation that nonetheless has some grain of truth in it.
Post 16 Feb 2022, 09:34
View user's profile Send private message Visit poster's website Reply with quote
FlierMate



Joined: 21 Jan 2021
Posts: 219
FlierMate 16 Feb 2022, 10:00
Tomasz Grysztar wrote:
Perhaps making fasmg was my ultimate way of saying "give me a rest"....


fasm 1 is more than enough for me, because I try to use raw CPU instructions whenever possible, not relying on macros.

A huge "thank you" to you and revolution for always be there on this message board.
As what revolution says, fasm 1 can generate output binary executable directly, which is normally what I need, except in OS development where mixing with HLL is only possible with a linker script.

I fully understand the responsibility of author in maintaining a software project and am amazed this flat assembler has continually serve the asm community for the past two decades.
Post 16 Feb 2022, 10:00
View user's profile Send private message Reply with quote
rostok



Joined: 12 Feb 2022
Posts: 5
rostok 17 Feb 2022, 07:37
Overclick wrote:
Seems like you need my multisections macro:
https://board.flatassembler.net/topic.php?t=21545

Switch between sections anytime anywhere even in proc and macros.
Example:
Code:
.data
...
.code
...
.data
...
.code
...    


Ok. I will investigate it. Thanks
Post 17 Feb 2022, 07:37
View user's profile Send private message Reply with quote
rostok



Joined: 12 Feb 2022
Posts: 5
rostok 17 Feb 2022, 09:09
Tomasz Grysztar wrote:
You you could say that this property is what makes flat assembler "flat", although that would be a tongue-in-cheek explanation.

I designed fasmg to provide a set of primitives that could be combined to implement various kinds of assembler syntax and behaviors, including but not limited to ones compatible with fasm 1. The re-enterable virtual blocks you mentioned, or commands like RESTARTOUT, are among such basic components - to be used to construct various higher level features.

As intended by this design, not only instruction sets but also output formats are implemented through add-ons. The standard ones are compatible with fasm 1 and thus similarly "flat", however this does not always need to be the case, as demonstrated by successful attempts to assemble source texts written for some old assemblers. It is up to the designer of a specific header set to choose what features to provide and how to lay out everything. For example, filling several sections in parallel would make it harder to provide features like $%, although with help of multi-pass predictions you could probably make it work if you really wanted - but these are the kinds of decisions that belong in the higher layer, allowing the actual primitives to be simpler and more reliable.

The design of fasmg was my answer to all the mutually exclusive requests that I kept receiving during the decades of fasm's development. This is why it is so unrestrained in its flexibility, offering all the possibilities while giving very little to begin with. You can have all the features you wanted in fasm 1, but the caveat is that might need to write a new set of headers to implement the specific syntax and features almost from scratch. Perhaps making fasmg was my ultimate way of saying "give me a rest" - another toungue-in-cheek explanation that nonetheless has some grain of truth in it.




In my opinion, able to mix/expand sections is a very basic feaure of an x86 assembler. I.e. every assembler has a machine instruction set, macros, directives, data store and allocation features etc. and every x86 assembler has section mix/expand features. I think you also have seen this otherwise you would not add extra features to flatg to be able to do this even indirectly. So you have already implemented it somehow and what I asked actually is why don't you add it as a basic feature even by some macros? Now what I understand from your answer is that this is a choice. Then ok. I have no objection and will continue to use fasm as it is because it is still the best and the most flexible one among the others.
Post 17 Feb 2022, 09:09
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20430
Location: In your JS exploiting you and your system
revolution 17 Feb 2022, 10:08
The section "problem" is an extra.

You can choose to use it if you wish. Then you get all the extra power that comes with it. But with extra power comes extra responsibility. Use it with care.

OR: You can choose to use fasm in a way similar to all the other assemblers and just use linkable output formats only, and avoid the direct executables. Then you lose the power. But you also have less responsibility. Razz
Post 17 Feb 2022, 10:08
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8357
Location: Kraków, Poland
Tomasz Grysztar 17 Feb 2022, 10:13
rostok wrote:
In my opinion, able to mix/expand sections is a very basic feaure of an x86 assembler. I.e. every assembler has a machine instruction set, macros, directives, data store and allocation features etc. and every x86 assembler has section mix/expand features.
The word "every" is obviously misplaced, as fasm itself has been a counterexample, for more than 20 years already. Also, as pointed out by revolution earlier, if you use fasm in a way similar to some of the other x86 assemblers, producing an object file and then linking it, you're going to see section merging as well.
rostok wrote:
(...) and what I asked actually is why don't you add it as a basic feature even by some macros?
The Fresh project provides the globals macro set, which allows collecting data definitions to store them in one place (which is commonly the actual expectation when someones asks about the section merging), so these have been publicly available to anyone needing them for fasm 1. As for fasmg, it even has a chapter dedicated to this in the auxiliary documentation, and I'm considering extending it with further examples to provide sets of macros similar to what Fresh did for fasm. Or something even more advanced - for data the best solution would be to sort definitions by required alignment.
Post 17 Feb 2022, 10:13
View user's profile Send private message Visit poster's website 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.