flat assembler
Message board for the users of flat assembler.
 Home   FAQ   Search   Register 
 Profile   Log in to check your private messages   Log in 
flat assembler > Windows > Switch between sections?

Author
Thread Post new topic Reply to topic
MUFOS



Joined: 17 Apr 2016
Posts: 47
Switch between sections?
Hey there.

I was wondering how I switch between sections. Writing "section '.data' data readable writeable" different places (between code sections) just create a new data section.

What I thought was that everything with the same section name would go into the same section -- however, that is not the case.

Any idea how I can achieve this?
Post 29 Apr 2017, 13:59
View user's profile Send private message Reply with quote
VEG



Joined: 06 Feb 2013
Posts: 51
Location: Minsk, Belarus
AFAIK, it is not possible with FASM1. But it will be possible to write such "section" macros for the FASMG. I have no working code, but the idea of generation of data non-consequentially and insertion of the result in a specific place of the file was demonstrated here. I think that this technique can be used for collecting machine code for sections from different places of the source file also.
Post 29 Apr 2017, 15:00
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar
Assembly Artist


Joined: 16 Jun 2003
Posts: 6306
Location: Kraków, Poland
Re: Switch between sections?

MUFOS wrote:
I was wondering how I switch between sections. Writing "section '.data' data readable writeable" different places (between code sections) just create a new data section.

This has been discussed numerous times on this board. If you'd like to see some older discussions you may start here: https://board.flatassembler.net/topic.php?t=9934


VEG wrote:
AFAIK, it is not possible with FASM1. But it will be possible to write such "section" macros for the FASMG. I have no working code, but the idea of generation of data non-consequentially and insertion of the result in a specific place of the file was demonstrated here. I think that this technique can be used for collecting machine code for sections from different places of the source file also.

This was possible with fasm 1, just not as easily. In the threads where combining data sections is discussed you may find several examples. And in the thread you mentioned I did share a link to the macros with Boyer-Moore-Hornspool search for reusable strings I once wrote for fasm 1, which I still have not ported to fasmg.
Post 29 Apr 2017, 15:44
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: 14673
Location: Origae-6
Re: Switch between sections?

MUFOS wrote:
I was wondering how I switch between sections. Writing "section '.data' data readable writeable" different places (between code sections) just create a new data section.

What I thought was that everything with the same section name would go into the same section -- however, that is not the case.

Any idea how I can achieve this?

You can also use a linker to merge sections of the same type if you use a object file output format.
Post 29 Apr 2017, 16:40
View user's profile Send private message Visit poster's website Reply with quote
MUFOS



Joined: 17 Apr 2016
Posts: 47
Re: Switch between sections?

revolution wrote:

MUFOS wrote:
I was wondering how I switch between sections. Writing "section '.data' data readable writeable" different places (between code sections) just create a new data section.

What I thought was that everything with the same section name would go into the same section -- however, that is not the case.

Any idea how I can achieve this?

You can also use a linker to merge sections of the same type if you use a object file output format.



How?
Post 29 Apr 2017, 20:04
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 14673
Location: Origae-6
Have a look at the MSCOFF.ASM example included in the download. Add all your sections in any order you please. Assemble the file to a .obj file. Then use your linker to make the final .exe file.
Post 30 Apr 2017, 05:44
View user's profile Send private message Visit poster's website Reply with quote
rugxulo



Joined: 09 Aug 2005
Posts: 2109
Location: Usono (aka, USA)

revolution wrote:
Then use your linker to make the final .exe file.



In other words, this is specific to your linker, so check your docs:

Linker Options - MSDN - VS2015
Post 02 May 2017, 00:30
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


Powered by phpBB © 2001-2005 phpBB Group.

Main index   Download   Documentation   Examples   Message board
Copyright © 2004-2016, Tomasz Grysztar.