flat assembler
Message board for the users of flat assembler.
Index
> Compiler Internals > lea eax,[esi-buffer] |
Author |
|
comrade 24 Jun 2003, 02:58
Code: lea eax,[esi-buffer] Cannot compile that line... MASM can. |
|||
24 Jun 2003, 02:58 |
|
BiDark 24 Jun 2003, 06:47
I guess relocation cause
(It's not absolute value, buffer address can be change everytime you load?) Just a guess |
|||
24 Jun 2003, 06:47 |
|
roticv 24 Jun 2003, 07:43
Code: lea eax,[esi-buffer] Weird, what are you doing actaully? |
|||
24 Jun 2003, 07:43 |
|
BiDark 24 Jun 2003, 08:05
Try my quick fix,
Code: imagebase = 400000h lea eax,[esi-rva buffer or imagebase] Will be its absolute value. |
|||
24 Jun 2003, 08:05 |
|
Tomasz Grysztar 24 Jun 2003, 13:15
It will work for you in binary mode, but not in PE/COFF/ELF output modes, because addresses there are relocatable.
|
|||
24 Jun 2003, 13:15 |
|
JohnFound 24 Jun 2003, 14:34
Hi, Privalov.
Is it imposible to make lea instruction with relocateable operand, like: jmp buffer or mov eax, buffer Actually loader simply adds some constants to some memory locations. Hm, or my question is stupid? |
|||
24 Jun 2003, 14:34 |
|
Tomasz Grysztar 02 Jul 2003, 12:04
Yes, you can use lea instruction with such operand, but the problem was with substracting relocatable constant to some absolute value instead of adding it, and such type of fixups is not available in PE/COFF formats.
|
|||
02 Jul 2003, 12:04 |
|
Tomasz Grysztar 02 Jul 2003, 12:12
If you are sure you won't need relocation info for your program, you can override this problem this way:
Code: BASE_ADDRESS = 400000h format PE at BASE_ADDRESS entry start section '.bss' readable writeable buffer = BASE_ADDRESS + RVA $ rb 100h section '.code' code readable executable start: lea eax,[esi-buffer] ret |
|||
02 Jul 2003, 12:12 |
|
Tomasz Grysztar 10 Jul 2003, 08:57
I've just realized it can be done much better, only few definitions at the beginning of source and then everything in normal way (assuming you won't include the relocation info):
Code: BASE_ADDRESS = 400000h format PE at BASE_ADDRESS entry start-BASE_ADDRESS+$-RVA $ macro section params { section params org BASE_ADDRESS + RVA $ } section '.bss' readable writeable buffer rb 100h section '.code' code readable executable start: lea eax,[esi-buffer] ret |
|||
10 Jul 2003, 08:57 |
|
comrade 10 Jul 2003, 12:27
Cool, thanks!
|
|||
10 Jul 2003, 12:27 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.