flat assembler
Message board for the users of flat assembler.
Index
> Compiler Internals > FASM 1.67.5, ORG directive & jumps, possibly a bug. |
Author |
|
UCM 26 Aug 2006, 01:30
It is because FASM defaults to 16-bit mode and "org 401000h" is out of range for 16-bit. You should add "use32" at the beginning of the source.
|
|||
26 Aug 2006, 01:30 |
|
Serke 26 Aug 2006, 01:39
I'm an idiot. Thanks a lot, UCM.
|
|||
26 Aug 2006, 01:39 |
|
Alphonso 07 Feb 2008, 14:35
UCM wrote: It is because FASM defaults to 16-bit mode and "org 401000h" is out of range for 16-bit. You should add "use32" at the beginning of the source. I would have to agree with Serke's original assumption that this is indeed a bug. The jump is a 'relative' one and it should not matter what the ORG address is. Sorry for the late reply but I have this same problem now since I want to mix 32bit and 16bit code, seems all the jumps in the 16bit code have to be encapsulated with use32 / use16, looks messy. |
|||
07 Feb 2008, 14:35 |
|
Tomasz Grysztar 07 Feb 2008, 14:44
Read about the jumps assembly handling applied since the 1.65.20 release here: http://board.flatassembler.net/topic.php?t=5162
Using "use32"/"use16" switching for a single instructions is a very bad thing to do, those directives are not for such purpose. You should simply do "jmp dword ...". |
|||
07 Feb 2008, 14:44 |
|
Alphonso 07 Feb 2008, 15:46
Okay, I see that works but, now I have a jump with an operand override prefix where one is not required.
ie 66 EB 08 (jmp fwd 8 bytes) instead of plain EB 08 (jmp fwd 8 bytes) Also noticed jmp r32 is not assembled correctly under 16bit mode, ie jmp ecx '66 FF E1' assembles as jmp cx 'FF E1', this time the '66' prefix is omitted. Using 1.67.23 |
|||
07 Feb 2008, 15:46 |
|
Tomasz Grysztar 07 Feb 2008, 16:06
Alphonso wrote: Okay, I see that works but, now I have a jump with an operand override prefix where one is not required. If the jump is to address above 0FFFFh, the prefix is required, otherwise the instruction would clear the upper 16 bits of EIP, and thus would not really jump 8 bytes forward, but many bytes backward instead. |
|||
07 Feb 2008, 16:06 |
|
LocoDelAssembly 07 Feb 2008, 16:12
Quote:
You're right, even with "jmp dword ecx" stills assembles as "jmp cx" |
|||
07 Feb 2008, 16:12 |
|
Alphonso 08 Feb 2008, 16:39
Tomasz Grysztar wrote: If the jump is to address above 0FFFFh, the prefix is required, otherwise the instruction would clear the upper 16 bits of EIP, and thus would not really jump 8 bytes forward, but many bytes backward instead. Appreciate that, so it's designed that way. Would have liked an option to use just the 'normal' jump though, such as recommending to use JMP dword LABEL? but if you want just the plain jump use JMP LABEL?. However, it would seem to maybe create more problems than solve. I can use JMP short LABEL? - $$ or even just JMP LABEL? - $$ EDIT: 13-Feb Appears to only work if Origin is aligned on a 64k boundary and jmp doesn't go out of that segment. i.e. Code: org 8000000h ;Ok org 8010000h ;Ok org 8000100h ;Not Ok For your info, I was playing with an ELF file and trying to make it run as an ELF 32bit under Linux and as a 16bit under DOS just to see if it was possible. Under DOS it would run as a .COM file so 8/16bit jumps are fine. Perhaps mixing the two (Linux / DOS) is not such a good idea anyway. P.S. You've probably heard it a thousand or more times before but, thank you for what IMHO is a great assembler. [/code] Last edited by Alphonso on 13 Feb 2008, 16:25; edited 1 time in total |
|||
08 Feb 2008, 16:39 |
|
rugxulo 13 Feb 2008, 04:10
http://www.deater.net/weave/vmwprod/asm/
Quote:
There's also a FASM thread of similar dual-nature programs here. |
|||
13 Feb 2008, 04:10 |
|
Alphonso 13 Feb 2008, 05:59
Thanks rugxulo,
I had already written something but unless AX can be guaranteed to be initialised '0', then there is a very small possibility the program could not work. If the COM version gets past the AX fixup it should be OK but can't guarantee this 100%. Seem to recall reading DOS versions below 3 did not do much in regards to initialising registers. Had a look at 'dual', thanks for the link, it appears to rely solely on the flags being set to take the jump, in FreeDOS and PTSDOS, it will probably run into problems as the flags, at least when I tested, are set not to jump. If your interested in the code I could post it to Linux or DOS, probably Linux is better. |
|||
13 Feb 2008, 05:59 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.