flat assembler
Message board for the users of flat assembler.

Index > DOS > COM vs EXE

Goto page 1, 2  Next
Author
Thread Post new topic Reply to topic
a16b03



Joined: 24 Jan 2006
Posts: 43
Location: Riga, Latvia
a16b03
I'm wondering about COM format addresing.

Com file's max size is 64K. That's what's writen in all the books. But can i read/write values for example at DS:FF FF FF FF ?
Post 24 Jan 2006, 11:21
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger ICQ Number Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid
you can read up to DS:FFFF, any (even partial) read higher will cause protection error because your limit in real mode is 10000h. BUt i am not sure what it does when you try to read word from offset FFFF on 8086...

btw, COM's max size is somewhat smaller (by 256 bytes of Program Segment Prefix)
Post 24 Jan 2006, 11:42
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
MazeGen



Joined: 06 Oct 2003
Posts: 977
Location: Czechoslovakia
MazeGen
In real mode, you can't address memory above FFFF, otherwise you get hang (INT 6 raised, IIRC)
Post 24 Jan 2006, 11:47
View user's profile Send private message Visit poster's website Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid
same happens on "mov ax,[FFFF]" on 8086? Because there it's not exceeding selector limit, it is something other...
Post 24 Jan 2006, 11:53
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
a16b03



Joined: 24 Jan 2006
Posts: 43
Location: Riga, Latvia
a16b03
OK That's Protected mode, But What about Real Mode?

And Maby it's beter to use MZ format.
Post 24 Jan 2006, 11:59
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger ICQ Number Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid
that happens in real mode too
Post 24 Jan 2006, 12:29
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
MazeGen



Joined: 06 Oct 2003
Posts: 977
Location: Czechoslovakia
MazeGen
a16b03: we are still speaking about real mode. And I was probably wrong, it is not INT 6, see below.

vid: I'm not sure.
Here is the description of MOV instruction from the Intel manual:
Quote:

Real-Address Mode Exceptions
#GP If a memory operand effective address is outside the CS, DS, ES, FS, or
GS segment limit.
#SS If a memory operand effective address is outside the SS segment limit.
#UD If attempt is made to load the CS register.

#GP is INT 13dec, #SS is INT 12dec, #UD is INT 6.

There should be a note about it in System programming manual, but don't have time to find it now.
Post 24 Jan 2006, 12:38
View user's profile Send private message Visit poster's website Reply with quote
Octavio



Joined: 21 Jun 2003
Posts: 366
Location: Spain
Octavio
a16b03 wrote:
I'm wondering about COM format addresing.

Com file's max size is 64K. That's what's writen in all the books. But can i read/write values for example at DS:FF FF FF FF ?

files should be smaller than 64k ,there must be also space for the psp and the stack.
a .COM program can acces all the memory,in protected or unreal mode
the same as a .EXE program or any other format.
Post 24 Jan 2006, 17:20
View user's profile Send private message Visit poster's website Reply with quote
Remy Vincent



Joined: 16 Sep 2005
Posts: 155
Location: France
Remy Vincent
With a COM progrm, bounds controls are not needed at all, I think, because... because bounds can be SET BY the COM program,

So..., I think, may be it could be very usefull if a COM program could "say" to the MICROPROCESSOR: "I'm sorry but I don't need any bounds control of any kind..."...

FASTER or NOT ???

_________________
Groups lower your IQ
Post 25 Jan 2006, 00:02
View user's profile Send private message Visit poster's website Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid
Remy: That setting which you mean is very tricky (and originally undocumented) thing. And it's possible to do it from any real-mode code, EXE too. It isn't feature of COM f
Post 25 Jan 2006, 07:11
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
bogdanontanu



Joined: 07 Jan 2004
Posts: 403
Location: Sol. Earth. Europe. Romania. Bucuresti
bogdanontanu
For 8086 / 8088 there are NO bounds control. It is only the way of calcuating the physycal address that wraps at 0xFFFF and if you try to access something at 0xFFFF:0XFFFF then the behaviour depends on the CPU.

MY guess is that on Intel CPU it will actually wrap towards zero...

That is why the A20 line was introduced in new 386 motherboards : to emulate this kind of behaviour for very old 8086 tricky applications.

And YES, logically it is faster not to check bounds... however this is not possible in "modern" CPUs. If you "buy" the logical quiz that some operations are "costless" and "very fast" ... well happy shopping Wink

Again this is useless in modern hardware since you can not disable "bounds checking at every operation". The only thing you can disable is paging ...

And it will not help you much using the old 8086 because the clock is a few orders of magnitude lower than today CPU's so you can not really compete with new CPUs...
Post 25 Jan 2006, 07:20
View user's profile Send private message Visit poster's website Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid
bugdanontanu: So you say that reading word from 0:FFFF really reads entire word at absolute address FFFF, eg. byte at FFFF and byte at 10000h?
Post 25 Jan 2006, 09:57
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 7797
Location: Kraków, Poland
Tomasz Grysztar
On 386 in real mode this causes the pseudo-protection exception, unless you enabled FRM - and with FRM it just reads bytes from FFFF and 10000. On 8086, as I recall, it was wrapping inside the segment, so reading word from offset FFFF read byte from FFFF and byte from 0 (still in the same segment).
Post 25 Jan 2006, 10:41
View user's profile Send private message Visit poster's website Reply with quote
a16b03



Joined: 24 Jan 2006
Posts: 43
Location: Riga, Latvia
a16b03
Whel that's readin a word from FFFF, but sill i need a way to get access to any byte in entire memoty
Post 25 Jan 2006, 10:48
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger ICQ Number Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 7797
Location: Kraków, Poland
Tomasz Grysztar
You can either use FRM, though I guess it's not for beginner; or just swap the segments - I mean, write other value to DS or ES segment to access any other memory in conventional memory area. To access the extended memory use XMS or EMS.
Post 25 Jan 2006, 10:58
View user's profile Send private message Visit poster's website Reply with quote
a16b03



Joined: 24 Jan 2006
Posts: 43
Location: Riga, Latvia
a16b03
FRM? What's the full mane? I'll check it out.
Post 25 Jan 2006, 11:11
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger ICQ Number Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid
it's Flat Real Mode

Also look here
Post 25 Jan 2006, 12:49
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
a16b03



Joined: 24 Jan 2006
Posts: 43
Location: Riga, Latvia
a16b03
Thank's to all of You!

I've got to admit that I screwed up this time.


segment registers =16bit
general registers =16bit

16+16=32

2^32=4'294'967'296 = 4Gb = All the possible memory in x86.


All i heve to do now is to chose which mode is best for me.

Thank's Tomasz

P.S.
I gues i should quit night programming Smile
Post 25 Jan 2006, 20:46
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger ICQ Number Reply with quote
Borsuc



Joined: 29 Dec 2005
Posts: 2466
Location: Bucharest, Romania
Borsuc
a16b03 wrote:

segment registers =16bit
general registers =16bit

16+16=32

2^32=4'294'967'296 = 4Gb = All the possible memory in x86.


I don't think it's that simple. In Real Mode, the physical address is calculated as segment*16 + offset. Basically, once you load a segment register, the processor updates the descriptor tables so that the base is segment*16..

In conclusion, using 16-bit segments and 16-bit general registers, you can only address 20 bits of physical address (16MB).

What flat real mode really does is that you still use the same addressing scheme, but the general registers are 32-bits, so you can have up to 4 GB of physical memory. Theoretically, you can address more than 4GB, but the limit is set to 4GB I think.

In protected mode there's a slightly different story, because segments are selectors...

PS: Please correct me and I'm sorry if I'm wrong, but I think this is how it really goes.
Post 25 Jan 2006, 20:55
View user's profile Send private message Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid
protected mode: segment registers hold "selector", which is kind-of pointers (or indexes? i am not sure) into table of "descriptors", called "global descriptor table" (GDT), "local descriptor table" (LDT), "interrupt descriptor table" (IDT) etc. "descriptor" is structure which contains information about segment of memory. eg. where it starts, how long it is, access rights etc. And these are 32bit, so you can let segment be 4Gb long.

Usualy in flat-real or unreal mode, you set all segments length to 4Gb.
Post 25 Jan 2006, 21:56
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  
Goto page 1, 2  Next

< 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-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.

Website powered by rwasa.