flat assembler
Message board for the users of flat assembler.

Index > Macroinstructions > Checking for literals in macro arguments

Author
Thread Post new topic Reply to topic
sid123



Joined: 30 Jul 2013
Posts: 339
Location: Asia, Singapore
sid123 10 Oct 2015, 12:46
Hello,

I've a little problem trying to figure this out. Basically, I'm using fasm to generate some custom byte code, so here's my problem:

I'm planning to have one, let's say, "move" instruction which takes in two arguments. Going by the name, it assigns the latter argument to the former, which can either be a register or a constant. The former is guaranteed be a register.

So, I need to do something like this:
Code:
macro move dest, src {
 if src eq literal(r0) ;check if source is equal to "literal" r0
    ; generate code on basis of that.
 ...
  
}
    


Is there any possible way I can achieve this?

Regards,
sid123

_________________
"Those who can make you believe in absurdities can make you commit atrocities" -- Voltaire https://github.com/Benderx2/R3X
XD
Post 10 Oct 2015, 12:46
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8351
Location: Kraków, Poland
Tomasz Grysztar 10 Oct 2015, 12:58
The "if src eq r0" construction should in fact be enough for this purpose, unless there is more to your problem than it appears to be.

But if you aim is to generate custom byte code, I also recommend to try out fasm g, which was designed as a next generation fasm engine with exactly this purpose in mind. In the official package you will find example implementations of various instructions sets in form of macros (including 8051, 8086, AVR, and JVM bytecode).
Post 10 Oct 2015, 12:58
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-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.