flat assembler
Message board for the users of flat assembler.
![]() |
Author |
|
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.
|
|||
![]() |
|
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. |
|||
![]() |
|
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. |
|||
![]() |
|
Tomasz Grysztar 07 Oct 2003, 14:20
decard wrote: call doesn't generate relative code. Yes it does. Though only the "near" one. |
|||
![]() |
|
decard 07 Oct 2003, 15:18
Yes, my mistake
![]() |
|||
![]() |
|
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. |
|||
![]() |
|
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. |
|||
![]() |
|
scientica 09 Oct 2003, 15:34
HarryTuttle wrote:
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 |
|||
![]() |
|
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. |
|||
![]() |
|
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, |
|||
![]() |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2023, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.