Old Content:
asmParser – A Lesson In Research
May 7, 2009 by Kyle BradyTags: Assembly, Code, CS47, Inline Assembly
As required by the FTC, a Full Disclosure is available - this piece adheres to the Code of Ethics
asm("command1\t\n","command2\t\n","command3\t\n");
Keep in mind that's wrapped inside a C file. Assembly. In a C file.
Naturally, I thought there was probably a more clever way to do this - I knew that asm() wasn't a true function, that it was a compiler instruction, but I assumed that it would pretend to be like a function and accept a variable as an argument.
Nope.
But I didn't discover that I was wrong until I got weird errors while compiling:
gcc -S -masm=intel ./asmParser.c
-> error: argument of 'asm' is not a constant string
This is when I jumped onto #c on irc.freenode.net, and was essentially laughed at. I guess that's what I get for trying to be clever... too clever.
You can find the everything-works-but-the-asm()-part code here with the exampleCommands file, or download everything as a zip file.
Next time I'm going to do a little more research!
Kyle can be found on Twitter and MySpace, or reached via email.





