flat assembler
Message board for the users of flat assembler.

Index > Main > segment registers

Author
Thread Post new topic Reply to topic
phenix



Joined: 08 Feb 2009
Posts: 9
phenix 08 Feb 2009, 23:03
Hi All,
I'm looking for a place to park as I want to leave windowssssss.
I have been using MASM32 which is a flat assembler. By that I mean
it DOESN'T use segment registers. DOES fasm us segment registers
or is it a true flat assembler?
Thanks for any replies
Post 08 Feb 2009, 23:03
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20413
Location: In your JS exploiting you and your system
revolution 09 Feb 2009, 01:30
Erm, what do you mean?

The CPU uses segment registers, they are impossible to avoid. Windows sets them up for all flat access to memory but they are still there in the background.

fasm has a DOS version which uses FRM. So, just like Windows, the segment registers are set for flat memory access.
Post 09 Feb 2009, 01:30
View user's profile Send private message Visit poster's website Reply with quote
phenix



Joined: 08 Feb 2009
Posts: 9
phenix 09 Feb 2009, 01:56
Thanks for the reply.
I realize that the segment registers are still there.
When I used an old version of MASM I had to program for segments and
far jumps. That is not necessary in a true flat assembler. How does FASM
handle far jumps?
For instance MASM32 is a true flat assembler.
But alas it only works in Windows......
Post 09 Feb 2009, 01:56
View user's profile Send private message Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4624
Location: Argentina
LocoDelAssembly 09 Feb 2009, 02:16
fasm allows you to create flat binaries (no segments), ELF objects and executables (the ones used on Linux, FreeBSD, Solaris, etc), and Windows binaries. In all the mentioned cases the memory model is flat.

fasm also support the creation of MZ executables and those are segmented and for DOS only.

[edit]Better check the examples in the Windows package and also the Linux package to see by yourself how the coding is being done. Also, to understand how the windows headers work, check http://flatassembler.net/docs.php?article=win32
Post 09 Feb 2009, 02:16
View user's profile Send private message Reply with quote
phenix



Joined: 08 Feb 2009
Posts: 9
phenix 12 Feb 2009, 22:58
I'm still confused about whether this assembler does short or far calls.
This would NOT make it a flat assembler.
I am not interested in 16 bit code.
Therefore I would be using 32 bit code and should NOT have to get involved in
short and far jumps.
From the reading I have done it is not clear what this assembler does.
Could someone clarify this for me, Please?
Post 12 Feb 2009, 22:58
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20413
Location: In your JS exploiting you and your system
revolution 12 Feb 2009, 23:44
32 code does not use far calls unless you code those instructions. All calls are near.
Code:
call [somewhere] ;near call, no segment used
call far [somewhereElse] ;far call because you told the assembler you want it
call anotherPlace ;direct call, cannot be far    
Post 12 Feb 2009, 23:44
View user's profile Send private message Visit poster's website Reply with quote
DOS386



Joined: 08 Dec 2006
Posts: 1903
DOS386 13 Feb 2009, 07:46
phenix wrote:
When I used an old version of MASM I had to program for segments and far jumps.


Problem specific to MASM or some 16-bit HLL compilers Wink

Quote:
That is not necessary in a true flat assembler. How does FASM
handle far jumps?


Not at all. FASM can compile all types of jumps you might need. No problem at all (except you need 16-bit OMF).

Quote:
I'm still confused about whether this assembler does short or far calls.


Calls can be near or far only. They are all near except you deliberately make them far. Jumps can be short, near or far. FASM makes them short whenever possible, otherwise near, and far only if you deliberately make them far. Also, there is no "memory model" (small, compact, medium, large, huge, insane) support/trouble in FASM.

Quote:
For instance MASM32 is a true flat assembler


We don't need FASM anymore Laughing

Quote:
But alas it only works in Windows......


RTFL Laughing
Post 13 Feb 2009, 07:46
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8356
Location: Kraków, Poland
Tomasz Grysztar 13 Feb 2009, 09:58
revolution wrote:
Code:
call anotherPlace ;direct call, cannot be far    

Well, direct call can be far, too. Wink And even in the long mode.
Post 13 Feb 2009, 09:58
View user's profile Send private message Visit poster's website Reply with quote
MazeGen



Joined: 06 Oct 2003
Posts: 977
Location: Czechoslovakia
MazeGen 13 Feb 2009, 10:37
Tomasz Grysztar wrote:
revolution wrote:
Code:
call anotherPlace ;direct call, cannot be far    

Well, direct call can be far, too. Wink And even in the long mode.

If you refer to opcodes 9A and EA, they are invalid in 64-bit mode. I was looking forward to report another bug, but FASM conforms to this rule Very Happy
Post 13 Feb 2009, 10:37
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8356
Location: Kraków, Poland
Tomasz Grysztar 13 Feb 2009, 10:40
Oh, right, I mistook it with opcode FF. Smile
So... I correct myself: except for the long mode. Very Happy
Post 13 Feb 2009, 10:40
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: 20413
Location: In your JS exploiting you and your system
revolution 13 Feb 2009, 11:05
I think because we never use far calls that we easily get confused about what can be done and what cannot. I mean honestly, who uses far calls these days, who? All those that use far calls shout out "me". ... ... ... <sounds of crickets chirping> ... ... I thought so. Wink
Post 13 Feb 2009, 11:05
View user's profile Send private message Visit poster's website Reply with quote
Madis731



Joined: 25 Sep 2003
Posts: 2139
Location: Estonia
Madis731 13 Feb 2009, 11:25
@phenix: You don't seem to agree that 'F' in FASM means 'flat'. This assembler's name comes from its capabilities. Is it really that hard to accept?
Post 13 Feb 2009, 11:25
View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger Reply with quote
phenix



Joined: 08 Feb 2009
Posts: 9
phenix 13 Feb 2009, 13:25
Thanks guys for all the info.
It has finally dawned on me that FASM is a true flat assembler. Laughing
Post 13 Feb 2009, 13:25
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 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.