flat assembler
Message board for the users of flat assembler.
![]() |
Author |
|
comrade
Code: lea eax,[esi-buffer] Cannot compile that line... MASM can. |
|||
![]() |
|
BiDark
I guess relocation cause
![]() (It's not absolute value, buffer address can be change everytime you load?) Just a guess ![]() |
|||
![]() |
|
roticv
Code: lea eax,[esi-buffer] Weird, what are you doing actaully? |
|||
![]() |
|
BiDark
Try my quick fix,
Code: imagebase = 400000h lea eax,[esi-rva buffer or imagebase] Will be its absolute value. |
|||
![]() |
|
Tomasz Grysztar
It will work for you in binary mode, but not in PE/COFF/ELF output modes, because addresses there are relocatable.
|
|||
![]() |
|
JohnFound
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? ![]() |
|||
![]() |
|
Tomasz Grysztar
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.
|
|||
![]() |
|
Tomasz Grysztar
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 |
|||
![]() |
|
Tomasz Grysztar
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 |
|||
![]() |
|
comrade
Cool, thanks!
|
|||
![]() |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.
Website powered by rwasa.