Closed nww02 closed 4 years ago
I thought I'd found a way to solve it... but it turns out it doesn't work.. It throws an "unexpected token: 'BC'" error.
.if isreg16({{param1}})
.if {{param1}} == "bc"
;
.else
push {{param1}}
pop bc
.endif
.else
ld bc,{{param1}}
.endif
Soon, I will add parse-time function for all these registers: A, AF, B, C, BC, D, E, DE, H, L, HL, I, R, XH, XL, IX, YH, YL, IY, SP.
Here is the private build to try these new parse-time functions.
You can find the documentation here: https://dotneteer.github.io/spectnetide/documents/macros#macro-related-parse-time-functions (see the last row)
Awesome! Thank you! I'm trying to make some generic code I can call from wherever, and I have to spend less time planning on which register to have my parameters in. A macro that can pull in the values from different registers and work on them intelligently would make later coding a lot easier. I'll give this a try as soon as I can!! :)
Released in v2 Preview 6.
Awesome, thank you! I'll simplify my macro code. With this, I can now easily use library code from books and sites without needing to rewrite it for each application. Libraries can be used together, with just enough glue code to move values around registers if needed. Thank you! :)
This is just a little sugar to help with some optimisation.. Not a priority at all.... And I bet this'll be one you tell me is already implemented, but I've not read the docs :D haha.
I'm writing a piece of code which I'd like to abstract out to a macro. I'd like to know which 16 (or 8) bit register is being passed in, as this would alter the start of the section...
If I know I'll only ever call it with a static value or a 16 bit reg, I can do this:-
but if I am using this inline, and passing "bc" to the macro:
myfunc(bc)
Then I don't actually want anything to happen, cos the value's already in bc, so pushing and popping the same register would just be a waste of 20-or-so T-states.
What would be nice is if I could do:-
If course, another way would be to overload isreg16() and the other tests to also take a second parameter, such as:
.if isreg16(param1,bc)