flat assembler
Message board for the users of flat assembler.

Index > Compiler Internals > previous instruction label

Author
Thread Post new topic Reply to topic
comrade



Joined: 16 Jun 2003
Posts: 1137
Location: Russian Federation
comrade
Is it possible to do something like $B that points to previous instruction?
Code:
nop
; at this point, $B points to nop
xor eax,eax
; at this point, $B points to xor eax,eax
inc eax
; at this point, $B points to inc eax    


For example, to find size of instruction I do:
Code:
.x = $
movzx   eax,al
display $-.x+30h    


But with $B would be much simpler, and I could have a macro to do it:
Code:
macro showsize {
display ($-$B)+30h
}    

_________________
comrade (comrade64@live.com; http://comrade.ownz.com/)
Post 29 May 2004, 17:27
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger ICQ Number Reply with quote
Tommy



Joined: 17 Jun 2003
Posts: 489
Location: Norway
Tommy
Seems to be a good idea if it's possible... Wink
Post 29 May 2004, 18:54
View user's profile Send private message Visit poster's website Reply with quote
comrade



Joined: 16 Jun 2003
Posts: 1137
Location: Russian Federation
comrade
Maybe there could other uses for it, but I cannot think of any.

_________________
comrade (comrade64@live.com; http://comrade.ownz.com/)
Post 29 May 2004, 19:05
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger ICQ Number Reply with quote
Tommy



Joined: 17 Jun 2003
Posts: 489
Location: Norway
Tommy
A solution:
Code:
macro showsize asm_code {
  local x
  x = $
  asm_code
  display $ - x + 30h, 13, 10
}

use32
showsize <movzx eax, al>    
    
Post 29 May 2004, 19:37
View user's profile Send private message Visit poster's website Reply with quote
comrade



Joined: 16 Jun 2003
Posts: 1137
Location: Russian Federation
comrade
That works, but not as elegant as it would be with $B. Encapsulating instruction into showsize <> is extra work I was hoping to avoid.

_________________
comrade (comrade64@live.com; http://comrade.ownz.com/)
Post 29 May 2004, 21:37
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger ICQ Number Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 7725
Location: Kraków, Poland
Tomasz Grysztar
Well, to avoid <> characters you can do it this way:
Code:
macro showsize [asm_code] {
  common local x
  x = $
  asm_code
  display $ - x + 30h, 13, 10
}

showsize movzx eax, al    


And I'm sorry, there seems to be no simple way to add such feature as $B you suggested.
Post 30 May 2004, 01:30
View user's profile Send private message Visit poster's website Reply with quote
comrade



Joined: 16 Jun 2003
Posts: 1137
Location: Russian Federation
comrade
that's good enough, thanks Smile

_________________
comrade (comrade64@live.com; http://comrade.ownz.com/)
Post 30 May 2004, 03:51
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger ICQ Number Reply with quote
Tommy



Joined: 17 Jun 2003
Posts: 489
Location: Norway
Tommy
Smile There I learned something new about FASM macro-technology... Thanks, Privalov!
Post 30 May 2004, 09:59
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. Also on YouTube, Twitter.

Website powered by rwasa.