flat assembler
Message board for the users of flat assembler.

Index > Main > COM ORG

Author
Thread Post new topic Reply to topic
HarryTuttle



Joined: 26 Sep 2003
Posts: 211
Location: Poland
HarryTuttle 07 Oct 2003, 09:19
COM file is something like RAW file when the offset is EntryPoint.

it means ORG 100 will start at address 100.

It is logical ,but what will happened if I put ORG 0?
Can the program be run under DOS/WIN or can be not?

_________________
Microsoft: brings power of yesterday to computers of today.
Post 07 Oct 2003, 09:19
View user's profile Send private message Reply with quote
JohnFound



Joined: 16 Jun 2003
Posts: 3499
Location: Bulgaria
JohnFound 07 Oct 2003, 10:45
In all cases, DOS (or windows) will load your com file from address $100, because first 256 bytes from the segment are used for DOS system data. On other hand if you use org $100, the compiler thinks that this program will be loaded/executed from address $100 and all labels are computed on this bases. Remember, that compiler don't care where your program will be executed, it simply creates the file. So probably your program should not work, because of wrong addresses. In some very simple (rare) cases, it is possible to be created fully relocatible program, that will not depent of where it is loaded. It is hard work to create this kind of program.
Post 07 Oct 2003, 10:45
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
HarryTuttle



Joined: 26 Sep 2003
Posts: 211
Location: Poland
HarryTuttle 07 Oct 2003, 13:07
Hi JohnFound,
the small stupid program under can be run with org 0.
Does it take place in the stack adress space? or it is loaded to $100 and run because it has no op-codes dependent on constant address?

Is the jmp relocatible?and what about calls?
Code:
org 0

sub ax,ax
mov al,13h
int 10h
go:
jmp go

        
    

_________________
Microsoft: brings power of yesterday to computers of today.
Post 07 Oct 2003, 13:07
View user's profile Send private message Reply with quote
decard



Joined: 11 Sep 2003
Posts: 1092
Location: Poland
decard 07 Oct 2003, 13:16
This program is also loaded to 100h address.
In this case "jmp go" will generate relative jump that doesn't depend on current address.
Using 'call' won't work because call doesn't generate relative code.
Post 07 Oct 2003, 13:16
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8263
Location: Kraków, Poland
Tomasz Grysztar 07 Oct 2003, 14:20
decard wrote:
call doesn't generate relative code.

Yes it does. Though only the "near" one.
Post 07 Oct 2003, 14:20
View user's profile Send private message Visit poster's website Reply with quote
decard



Joined: 11 Sep 2003
Posts: 1092
Location: Poland
decard 07 Oct 2003, 15:18
Yes, my mistake Smile
Post 07 Oct 2003, 15:18
View user's profile Send private message Visit poster's website Reply with quote
MazeGen



Joined: 06 Oct 2003
Posts: 977
Location: Czechoslovakia
MazeGen 07 Oct 2003, 16:30
JohnFound wrote:
In some very simple (rare) cases, it is possible to be created fully relocatible program, that will not depent of where it is loaded. It is hard work to create this kind of program.


It's not so hard. Just get current eIP, calculate the difference within register and add this difference to all data offsets using the register.

_________________
x86asm.net
Post 07 Oct 2003, 16:30
View user's profile Send private message Visit poster's website Reply with quote
HarryTuttle



Joined: 26 Sep 2003
Posts: 211
Location: Poland
HarryTuttle 09 Oct 2003, 11:39
thanx a lot ,

I have another question:


what does it mean?:
Code:


ORG 100
use32

    


could be the code run in 32bit mode or not?
What is a difference between use16 and use32 for programs runing in console mode.
is there console16 and console32 for COM files or only console16?

_________________
Microsoft: brings power of yesterday to computers of today.
Post 09 Oct 2003, 11:39
View user's profile Send private message Reply with quote
scientica
Retired moderator


Joined: 16 Jun 2003
Posts: 689
Location: Linköping, Sweden
scientica 09 Oct 2003, 15:34
HarryTuttle wrote:
Code:


ORG 100
use32

    


could be the code run in 32bit mode or not?
What is a difference between use16 and use32 for programs runing in console mode.
is there console16 and console32 for COM files or only console16?

org 100h means that adressing starts at 100h, and the use32 does mean that the standard/default operant and and addressing mode is 32-bit not 16-bit.
Take for instance this operand:
90h - nop, actually it's: xchg eax,eax
in 16-bit mode 90h means:
xchg ax,ax
and in 32 bit mode is means
xchg eax,eax
you can override this by adding 66h (operand size override):
66 90 in 16-bit mode means:
xchg eax,eax
and in 32 bit mode it means
xchg ax,ax
use32 also affects the addressing, there is also an memory size override 67h.

I'm no expert in COM file programming, actually I don't know if it's as simple as just type use32 and use 32-bit regs or if you have to do some magic first.

_________________
... a professor saying: "use this proprietary software to learn computer science" is the same as English professor handing you a copy of Shakespeare and saying: "use this book to learn Shakespeare without opening the book itself.
- Bradley Kuhn
Post 09 Oct 2003, 15:34
View user's profile Send private message Visit poster's website Reply with quote
HarryTuttle



Joined: 26 Sep 2003
Posts: 211
Location: Poland
HarryTuttle 10 Oct 2003, 05:43
so, what is the native environmental for com?


[suppose]I think 16bit is the native, and like stientica said there is byte add before some of op-codes. [/suppose]

_________________
Microsoft: brings power of yesterday to computers of today.
Post 10 Oct 2003, 05:43
View user's profile Send private message Reply with quote
JohnFound



Joined: 16 Jun 2003
Posts: 3499
Location: Bulgaria
JohnFound 10 Oct 2003, 11:58
use32 switch FASM (not DOS) that the code is 32bit. i.e. when you use:
mov eax, eax - FASM will NOT set 66h prefix, but if you use mov ax,ax FASM WILL put 66h prefix. If you run it in DOS (16bit mode) - where you write in source file eax, will be executed as ax, etc. You can't so simply switch the mode of the DOS to 32bit.

Regards,
Post 10 Oct 2003, 11:58
View user's profile Send private message Visit poster's website ICQ Number 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-2023, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.