flat assembler
Message board for the users of flat assembler.

Index > Compiler Internals > virtual at <register> unexpected error?

Author
Thread Post new topic Reply to topic
bitRAKE



Joined: 21 Jul 2003
Posts: 2913
Location: [RSP+8*5]
bitRAKE
Within a virtual block sometime the register expressions error, and I have to find another similar expression:
Code:
push r9 r8 rdx rcx
enter .frame,0
virtual at rbp-.frame
              rq 4
        .rt RECT
    .pt POINT
   .frame = NOT 15 AND ($-$$+15)
               rb .frame-($-$$) ; stack alignment
  .RBP    rq 1
        .hWnd   rq 1
        .uMsg   rq 1
        .wParam rq 1
        .lParam rq 1

    .RET            rq 1
                        rq 4
        .original       rq 1    ; uIdSubclass
       .underline      rq 1    ; dwRefData
end virtual    
...I was able to resolve my problem with ($-$$), but all expressions with RBP seem to fail. For example, I tried:
Code:
rb rbp-$ ; stack alignment    
...which results in "error: invalid argument".
(shouldn't it be the same as "rb 0"?)

I'm just trying to better understand when expressions will work and when they won't.

_________________
¯\(°_o)/¯ unlicense.org
Post 07 Jun 2009, 15:47
View user's profile Send private message Visit poster's website Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 2913
Location: [RSP+8*5]
bitRAKE
Okay, I see my error now.

".frame" will be larger than "$" - making the result negative. Embarassed

"rb .frame+rbp-$" also works as expected.
Post 07 Jun 2009, 15:52
View user's profile Send private message Visit poster's website Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid
why don't you just use "align" directive?
Post 07 Jun 2009, 16:46
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 2913
Location: [RSP+8*5]
bitRAKE
"error: section is not aligned enough"

...which seems odd, because: "section '$' code align 64 readable executable". Guess FASM doesn't know where RBP will be. "virtual at rbp-.frame" is the basis for the section, imho.
Post 07 Jun 2009, 17:14
View user's profile Send private message Visit poster's website Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17270
Location: In your JS exploiting you and your system
revolution
Virtual with a register offset can be tricky to work with, aligns don't seem to work. Also address arithmetic needs to be done in such a way so as to not end up with an intermediate sum that has a negative register value.
Post 07 Jun 2009, 17:18
View user's profile Send private message Visit poster's website Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 2913
Location: [RSP+8*5]
bitRAKE
Prior to figuring it out I was using two virtual blocks: the first one from RSP to determine the frame size, and the second one to reference from RBP. Prior to that I just put the offsets manually, but updating the code in half a dozen places every change gets rather old - especially, when FASM can do all the hard work.

Now I just update in one place, and the virtual block also serves as terse documentation for the interface. The syntax is still flexible enough to insure byte offsets, or changing to RSP - with no difference in the code which relies on it.
Post 07 Jun 2009, 19:00
View user's profile Send private message Visit poster's website 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-2020, Tomasz Grysztar.

Powered by rwasa.