GeorgRottensteiner / C64Studio

C64Studio is a .NET based IDE specializing in game development for the C64 in assembler and BASIC
Other
252 stars 38 forks source link

#define like in c or c++ #127

Open truebluepl opened 3 weeks ago

truebluepl commented 3 weeks ago

Hello Georg,

is there any way to define a kind of macro like in c or c++?

For example I would like find closest power of two of any value. So the code is:

v = v - 1
v = v | v>>1
v = v | v>>2
v = v | v>>4
v = v + 1

I can't (maybe I'm wrong) use macro like:

!macro ClosestPowerOfTwo v
v = v - 1
v = v | v>>1
v = v | v>>2
v = v | v>>4
v = v + 1
!end

and put in the source: and #+ClosestPowerOfTwo 12

GeorgRottensteiner commented 3 weeks ago

Currently not unfortunately. Macros are at the moment doing dumb replacement of the full caller line, so this wouldn't work out.

I have to figure out how to implement the above somehow, but that may take a while.