flat assembler
Message board for the users of flat assembler.
![]() |
Author |
|
revolution 28 Oct 2016, 06:16
1. Because the address pointer is greater than 64k
2. It is necessary because you need to convert the address to 32-bit 3. You can, but you need to keep the address pointer below 64k Why are you using ELF format? ELF has no support for 16-bit code so you are using it out of its normal usage. In short don't do that. |
|||
![]() |
|
alexfru 28 Oct 2016, 06:43
revolution wrote: 1. Because the address pointer is greater than 64k Not quite. The top 16 bits of EIP are ignored in (un)real mode. For relative jumps you only care about the distance fitting into 8 or 16/32 bits. revolution wrote: 2. It is necessary because you need to convert the address to 32-bit Only if this address ends up in the relocation table, which is not the case for jumps within the same section of the same assembly file. revolution wrote: 3. You can, but you need to keep the address pointer below 64k I don't need to do much special about it. As I said above, the E part of EIP is ignored in the CPU. All the functions produced by my compiler will be far-callable and limited to 64KB in size. I can always make their far address to have the offset less than 16 (I do it already for "huge" mode with NASM/YASM). revolution wrote: Why are you using ELF format? I don't want to support many formats. ELF is perfectly suitable for what I'm doing. revolution wrote: ELF has no support for 16-bit code so you are using it out of its normal usage. In short don't do that. Not quite so. Relative branches, at least the rel8 kind within the same section of the same assembly file, should just work and assemble without unnecessary "dword" or operand size prefixes. rel32 is excessive here, but it works too, however the "dword" requirement is extremely inconvenient. Not requiring "dword" would solve the biggest problem of the code simply not assembling. I can probably live with overly long instructions. |
|||
![]() |
|
Tomasz Grysztar 28 Oct 2016, 06:56
alexfru wrote: Not quite so. Relative branches, at least the rel8 kind within the same section of the same assembly file, should just work and assemble without unnecessary "dword" or operand size prefixes. If you need to assemble the code under a different assumption, you have to alter the base address so that assembler knows that it is not going to be a large value. For example: Code: format elf section ".text" executable org 0 use16 public main main: mov eax, [main] mov eax, [ebx + main] push dword main jz foo1 jmp foo1 foo1: jz foo2 jmp foo2 rb 200 foo2: ret Also, the "main" symbol defined this way is going to be exported as an absolute number (because we made it an absolute number). If you need to export it as an address in relocatable section, you have to modify it like this: Code: format elf section ".text" executable label _main at $$+main public _main as 'main' org 0 use16 main: mov eax, [main] mov eax, [ebx + main] push dword main jz foo1 jmp foo1 foo1: jz foo2 jmp foo2 rb 200 foo2: ret |
|||
![]() |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.