flat assembler
Message board for the users of flat assembler.

Index > Macroinstructions > Macro instruction counter

Author
Thread Post new topic Reply to topic
rydemstorm



Joined: 31 Oct 2012
Posts: 15
rydemstorm 31 Oct 2012, 21:49
I would like do it something like this:
macro pushx arg
{
cont = 0
if arg eqtype 32bits
cont += 4
else if arg eqtype 16bits
cont += 2
end if
add ax,cont
}
Post 31 Oct 2012, 21:49
View user's profile Send private message Reply with quote
Mike Gonta



Joined: 26 Dec 2010
Posts: 243
Mike Gonta 31 Oct 2012, 23:22
rydemstorm wrote:
I would like do it something like this:
macro pushx arg
{
cont = 0
if arg eqtype 32bits
cont += 4
else if arg eqtype 16bits
cont += 2
end if
add ax,cont
}
Code:
use32
macro pushx arg {
local ..override, ..count
virtual at 0
  push arg
  load ..override from 0
end virtual
  ..count=2
  if ..override <> 66h        ; no size override prefix - has to 32bit
    ..count=..count+2
  end if
  add eax, ..count
}

  pushx DWORD 0               ; add eax, 4
  pushx WORD 0                ; add eax, 2
  pushx DWORD [0]             ; add eax, 4
  pushx WORD [0]              ; add eax, 2
  pushx eax                   ; add eax, 4
  pushx ax                    ; add eax, 2    
Simply change it around for use16.

_________________
Mike Gonta
look and see - many look but few see

https://mikegonta.com


Last edited by Mike Gonta on 17 Jul 2013, 09:58; edited 2 times in total
Post 31 Oct 2012, 23:22
View user's profile Send private message Visit poster's website Reply with quote
rydemstorm



Joined: 31 Oct 2012
Posts: 15
rydemstorm 01 Nov 2012, 19:04
Thanks. Work well for 16 or 32 bits, but, what changes need to do to work with 8 bits to.

push al ;add al,1
Post 01 Nov 2012, 19:04
View user's profile Send private message 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-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.