flat assembler
Message board for the users of flat assembler.
 Home   FAQ   Search   Register 
 Profile   Log in to check your private messages   Log in 
flat assembler > Main > equ with if

Author
Thread Post new topic Reply to topic
CandyMan



Joined: 04 Sep 2009
Posts: 227
Location: film "CandyMan" directed through Bernard Rose
equ with if

Code:
Bitness =       16

if Bitness=16
BaseReg equ     bp
else
BaseReg equ     ebp
end if
        mov     al,[BaseReg+4;always ebp


it is possible to replace "equ" with something, if only works with "Bitness=16" and "Bitness=32" without using the separate file?

_________________
smaller is better
Post 12 Nov 2017, 18:03
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 15242
Location: 1I/ʻOumuamua
You can replace the if with match and make bitness an equ.

Code:
Bitness equ       16

match =16,Bitness {
  BaseReg equ     bp
}
match =32,Bitness {
  BaseReg equ     ebp
}

Post 12 Nov 2017, 18:06
View user's profile Send private message Visit poster's website Reply with quote
CandyMan



Joined: 04 Sep 2009
Posts: 227
Location: film "CandyMan" directed through Bernard Rose
thank you!
Post 12 Nov 2017, 18:09
View user's profile Send private message Reply with quote
Tomasz Grysztar
Assembly Artist


Joined: 16 Jun 2003
Posts: 6635
Location: Kraków, Poland
Alternatively:

Code:
Bitness = 16

if Bitness=16
  label BaseReg at bp
else
  label BaseReg at ebp
end if

Post 12 Nov 2017, 18:17
View user's profile Send private message Visit poster's website Reply with quote
CandyMan



Joined: 04 Sep 2009
Posts: 227
Location: film "CandyMan" directed through Bernard Rose
Tomasz, your alternative is the best!
Post 12 Nov 2017, 18:32
View user's profile Send private message Reply with quote
Tomasz Grysztar
Assembly Artist


Joined: 16 Jun 2003
Posts: 6635
Location: Kraków, Poland
Note that it has a potential problem that you cannot re-define BaseReg for other part of code when it is defined as a label. If such problem occurs, you can get around it with a simple "undefine" macro:

Code:
macro undefine name
 { local new
   define name new }

Bitness = 32

undefine BaseReg
if Bitness=16
  label BaseReg at bp
else
  label BaseReg at ebp
end if

Post 12 Nov 2017, 18:47
View user's profile Send private message Visit poster's website Reply with quote
CandyMan



Joined: 04 Sep 2009
Posts: 227
Location: film "CandyMan" directed through Bernard Rose
version with "equ" however is better because it doesn't refer only to addressing.

Code:
push BaseReg ;push (e)bp is possible


_________________
smaller is better
Post 12 Nov 2017, 22:34
View user's profile Send private message Reply with quote
Tomasz Grysztar
Assembly Artist


Joined: 16 Jun 2003
Posts: 6635
Location: Kraków, Poland
Oh, you're right. This is a limitation of fasm 1 engine that I managed to get rid of in fasm g.
Post 12 Nov 2017, 22:54
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


Powered by phpBB © 2001-2005 phpBB Group.

Main index   Download   Documentation   Examples   Message board
Copyright © 2004-2016, Tomasz Grysztar.