| View previous topic :: View next topic |
| Author |
Message |
jonny
Joined: 22 Sep 2005 Posts: 351
|
Posted: Mon Oct 24, 2005 4:56 am Post subject: Help with macro parameters + asm |
|
|
how can i make something like this to work?
| Code: |
#define mtest(val0) \
"sb $24, val0($3)\n"
|
mtest(10) expand to: sb $24, val0($3), not sb $24, 10($3)
thanks |
|
| Back to top |
|
 |
mrbrown
Joined: 17 Jan 2004 Posts: 1536
|
Posted: Mon Oct 24, 2005 5:53 am Post subject: |
|
|
This is basic C preprocessor stuff. You need to "stringify" the macro argument:
| Code: | | #define mtest(val0) "sb $24, " # val0 "\n" |
You get this one for free, but the next time I'm going to point you to a compiler manual or C tutorial :). |
|
| Back to top |
|
 |
jonny
Joined: 22 Sep 2005 Posts: 351
|
Posted: Mon Oct 24, 2005 6:37 am Post subject: |
|
|
| lol thanks :D |
|
| Back to top |
|
 |
jsgf
Joined: 12 Jul 2005 Posts: 254
|
Posted: Mon Oct 24, 2005 8:33 am Post subject: |
|
|
| jonny wrote: | | "sb $24, val0($3)\n" |
But also, using literal register numbers in an asm probably isn't going to do what you want (the compiler is free to use any registers it wants, and its free to move your asm around as much as it wants if you don't give it a reason not to). You should look at how to pass parameters into an asm, and set constraints. |
|
| Back to top |
|
 |
jonny
Joined: 22 Sep 2005 Posts: 351
|
Posted: Mon Oct 24, 2005 8:57 am Post subject: |
|
|
| yep i know the basics about register literals ( found this useful thread :) http://forums.ps2dev.org/viewtopic.php?t=3558 ), i need macro+parameters because i was experimenting with loop unrolling, macros are good to fix a couple of offsets and don't get mad with copy/paste/modify. |
|
| Back to top |
|
 |
jsgf
Joined: 12 Jul 2005 Posts: 254
|
Posted: Mon Oct 24, 2005 9:00 am Post subject: |
|
|
| Register literals are only needed if a specific register really needs to be set (like for calling a syscall). Otherwise its better to let the compiler choose all your registers for you. |
|
| Back to top |
|
 |
|