pouët.net

accessing stack variables with inline assembly for gnu c (68000 assembly)

category: code [glöplog]
 
I'm tired of enumerating variables in stack and would like to use inline assembly!! so I write this:

Code: void test(int what) { asm("move.l %[what], %d0" :: [what] "r" (what)); }


and the gnu c compiler says this:

Code: invalid 'asm': operand number out of range


I'm trying to move what into %d0. I think I have a conceptual problem, I think I get inline assembly

I'm trying to move what into %d0

what should this look like?
added on the 2013-09-06 05:58:06 by sigflup sigflup
nevermind, I figured it out
added on the 2013-09-06 07:51:03 by sigflup sigflup
and years from now, someone will have the exact same problem, and they'll find your post with google and get frustrated because you didn't tell what it was you figured out.
added on the 2013-09-06 08:09:21 by sol_hsa sol_hsa
here's a hint: stop playing with men's toys, damn woman.
added on the 2013-09-06 09:44:11 by superplek superplek
also look up at&t syntax
added on the 2013-09-06 09:45:18 by superplek superplek
Quote:
here's a hint: stop playing with men's toys, damn woman.

What? Not that I know either of your genders, what the heck does that have to do with anything? What's wrong with you?
added on the 2013-09-06 10:21:22 by sol_hsa sol_hsa
@superplek: fuck off with that sexist attitude.
added on the 2013-09-06 10:30:06 by visy visy
Fail to locate the funny. Also, 68k, not intel.
added on the 2013-09-06 10:35:57 by Preacher Preacher
@visy: shut up you socialist dick
added on the 2013-09-06 12:34:56 by superplek superplek
C'mon people /o\

But yes, @sigflup: please post what the solution was (even if just the new line you used), somebody else may find it useful... or even yourself some time from now on =P
added on the 2013-09-08 11:22:26 by Sik Sik
sigflup, I went to your website, and I thought that little thing dancing around was really cool! :)

ignore this asshole, i can safely say you can fuck around as much as you want with "men's toys" :)
Well, I'm hesitant to say why it doesn't work. I changed my register to d1 and it worked fine. I found that if you put your registers in the clobber list it works fine
added on the 2013-09-10 05:01:02 by sigflup sigflup
I wonder who the bitch respects more; superplek the jerk, or the paternalistic jerkoffs. Hmm. And why am I worried about what some bitch thinks, must be the 68k skillz.
Wat?
added on the 2013-09-20 12:50:31 by Optimus Optimus
okay, so who's trolling?
added on the 2013-09-20 13:05:11 by Preacher Preacher
don't feed the trolls

and hey, if nobody is allowed to mess up, nobody learns, Sigflup
Yes, you have to put the register in the clobber list to reserve it for your asm code. Otherwise GCC tries to use it and complains that you'll be messing with it in your asm code.

Useful references :
* http://www.ibiblio.org/gferg/ldp/GCC-Inline-Assembly-HOWTO.html
* [url]http://www.gtoal.com/compilers101/small_c/vectrexc/INCLUDE/VECTREX.H[/urll] has some useful examples (it's targetted for Vectrex and 6809, but some of it is applicable to other platforms as well, after some register renaming).

login