flat assembler
Message board for the users of flat assembler.

Index > Compiler Internals > lea eax,[esi-buffer]

Author
Thread Post new topic Reply to topic
comrade



Joined: 16 Jun 2003
Posts: 1150
Location: Russian Federation
comrade 24 Jun 2003, 02:58
Code:
lea eax,[esi-buffer]    


Cannot compile that line... MASM can.

_________________
comrade (comrade64@live.com; http://comrade.ownz.com/)
Post 24 Jun 2003, 02:58
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger ICQ Number Reply with quote
BiDark



Joined: 22 Jun 2003
Posts: 109
Location: .th
BiDark 24 Jun 2003, 06:47
I guess relocation cause Rolling Eyes
(It's not absolute value, buffer address can be change everytime you load?)

Just a guess Rolling Eyes
Post 24 Jun 2003, 06:47
View user's profile Send private message Reply with quote
roticv



Joined: 19 Jun 2003
Posts: 374
Location: Singapore
roticv 24 Jun 2003, 07:43
Code:
lea eax,[esi-buffer]    

Weird, what are you doing actaully?
Post 24 Jun 2003, 07:43
View user's profile Send private message Visit poster's website MSN Messenger Reply with quote
BiDark



Joined: 22 Jun 2003
Posts: 109
Location: .th
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.
Post 24 Jun 2003, 08:05
View user's profile Send private message Reply with quote
scientica
Retired moderator


Joined: 16 Jun 2003
Posts: 689
Location: Linköping, Sweden
scientica 24 Jun 2003, 11:56
comrade wrote:
Code:
lea eax,[esi-buffer]    

What is buffer? Is it a local, a global variable?

_________________
... a professor saying: "use this proprietary software to learn computer science" is the same as English professor handing you a copy of Shakespeare and saying: "use this book to learn Shakespeare without opening the book itself.
- Bradley Kuhn
Post 24 Jun 2003, 11:56
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8351
Location: Kraków, Poland
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.
Post 24 Jun 2003, 13:15
View user's profile Send private message Visit poster's website Reply with quote
JohnFound



Joined: 16 Jun 2003
Posts: 3499
Location: Bulgaria
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? Very Happy
Post 24 Jun 2003, 14:34
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8351
Location: Kraków, Poland
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.
Post 02 Jul 2003, 12:04
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8351
Location: Kraków, Poland
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
    
Post 02 Jul 2003, 12:12
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8351
Location: Kraków, Poland
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    
Post 10 Jul 2003, 08:57
View user's profile Send private message Visit poster's website Reply with quote
comrade



Joined: 16 Jun 2003
Posts: 1150
Location: Russian Federation
comrade 10 Jul 2003, 12:27
Cool, thanks!

_________________
comrade (comrade64@live.com; http://comrade.ownz.com/)
Post 10 Jul 2003, 12:27
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger ICQ Number Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.