flat assembler
Message board for the users of flat assembler.
Index
> DOS > segments arithmetic |
Author |
|
vid 28 Aug 2006, 09:58
it's not a bug, i suggest you to study something about MZ relocations
|
|||
28 Aug 2006, 09:58 |
|
litwr 01 Sep 2006, 05:05
I want to load full DD (segment:offset) address by one command with 32-bit immediate value. It's easy if I can multiply segment address. So impossibility of such ordinal operation is obvious bug.
Code: mov [myaddr],segment_addr*10000H+offset , myaddr has DD type. I hope that next version of nice FASM will find a way to solve this problem... |
|||
01 Sep 2006, 05:05 |
|
Tomasz Grysztar 01 Sep 2006, 08:44
No 16-bit-capable assembler I'm aware of has such feature, since it would be a quite tricky one to detect such very special cases when the shifted relocation placement would do the job.
However you may try to do the trick with a macro (though not a trivial one): Code: macro mov dest,src { local pending match seg:offs,src \{ local ..ins,L,B ..ins: virtual at $ mov dest,dword 0 L = $-4-..ins end virtual repeat L virtual at ..ins mov dest,dword 0 load B byte from ..ins+%-1 end virtual db B end repeat dw offs,seg pending equ \} match =pending,pending \{ mov dest,src \} } mov [X],SEG1:X |
|||
01 Sep 2006, 08:44 |
|
litwr 01 Sep 2006, 09:00
Wow!!! But anyway, thank you very much for this example. I only have to note that FASM is 32-bit assembler. I remember odd things with famous Borland TASM - it had always generated 3 bytes JMP instruction (it didn't want to choice 2 bytes code in the appropriate cases), etc... These TASM BUGS may also be avoided by macros.
|
|||
01 Sep 2006, 09:00 |
|
Tomasz Grysztar 01 Sep 2006, 09:05
litwr wrote: I only have to note that FASM is 32-bit assembler. What do you mean? Well, it is written itself in a 32-bit code, but as for the capabilities - it's capable of outputting the 16-bit, 32-bit and 64-bit code. |
|||
01 Sep 2006, 09:05 |
|
litwr 01 Sep 2006, 10:13
Maybe other old assemblers can't do requested task but FASM is new, rapidly developed, and 32-bit code oriented. My example code directly uses 32-bit arithmetic. Such cases are easily separated from 16-bit segment arithmetic where multiplication is not good choice. I can insist that if expression with segment address is a 32-bit value then the segment address must be considered as ordinary number with type of word.
There is another way. It may be special function converted segment address to number. Old good TASM also couldnot work with far JUMPs and CALLs for some IMPORTANT reasons. I've just showed logically correct assembler command and I can expect that it will do its job. The mentioned IMPORTANT scholastic reasons are out of my scope. |
|||
01 Sep 2006, 10:13 |
|
Tomasz Grysztar 01 Sep 2006, 10:18
I said "the 16-bit capable" assemblers, which doesn't mean the same as "old". And your example code is not just a simple 32-bit arithmetic, since it involves the relocatable values, which give are pretty limited possibilities of calculations at all, no matter how "modern" the assembler is. The relocatable values cannot be considered an ordinary numbers - this is imposed by the output format (MZ in this case), and cannot be altered (I suggest following the vid's suggestion to read more on relocatable formats).
|
|||
01 Sep 2006, 10:18 |
|
vid 01 Sep 2006, 14:06
i must repeat myself: i suggest you to study something about MZ relocations
... before arguing |
|||
01 Sep 2006, 14:06 |
|
litwr 04 Sep 2006, 09:44
Sorry, sorry, sorry... I was wrong. I have only to add that keyword to the problem is not "segment relocation" but "OS loader". Thanks to all!
|
|||
04 Sep 2006, 09:44 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.