across the network: Kyle Brady: Blog  |  Kyle Brady: Fiction  |  Kyle Brady: Status  |  Kyle Brady: Stream  |  Kyle Brady: Projects  |  Kyle Brady: Profile contact
across the internet: on Twitter | on Facebook | more...

Old Content:

asmParser – A Lesson In Research




In my CS47 class, we've just started working on using Inline Assembly (assembly code processing built into the gcc compiler), and I thought the way you do it is pretty ugly.  The assembly, which is put inside a C file, looks like this:

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!

Old Content posts are leftovers from a less structured, less civilzed era that are kept for posterity.
Kyle can be found on Twitter and MySpace, or reached via email.

submit to reddit Add to Mixx! Share on Facbeook Retweet
Printable Version Printable Version

More Old Content Pieces

see more...


Commenting Rules

The following is a basic set of rules that are enforced for all commenters.

Any violations of these rules will result in comment deletion, user bans, or both.

  1. No excessively foul language.
  2. No racist remarks.
  3. No SPAMing, unrelated linking, or otherwise unnecessary promotion of outside material.
  4. No trolling.
  5. Be respectful.
  6. Be valuable.
  7. Feel free to respond, argue, or counter-point an article - but do so coherently and intelligently.
  8. Use a personal nickname, commenting account, or moniker. Do not use your business' or website name/account.
  9. Do not trackback/pingback to this post unless your content is relevant.
also available as a standalone page

blog comments powered by Disqus
Kyle Brady: Blog
coherent thoughts on diverse topics


Site Navigation:
About Columns Ethics Rules Contact