Need help with inline assembly in C code

Hi everyone, I'm new to this site and hope you might be able to help me out?
So I've been given an assignment to produce this output:
[code]% ./hw3b foo
slow foo but foo sure
% ./hw3b XYZ123
slow XYZ123 but XYZ123 sure
% ./hw3b 'stinky junk'
slow stinky junk but stinky junk sure[/code]
using asm to insert the word/phrase, and only these libraries: stdlib.h, stdio.h, & string.h.
I've already done most of the the C coding (shown below) I think, but I'm stuck on the asm assembler code insertion.

char word[] = "here and there";
int sz;
int wordsz;
char *arg;
char *result;

int main(int argc, char* argv[]) {
if (argc != 2) {
printf("Usage: %s takes one string argument.
", argv[0]);

sz = strlen(argv[1]) + 1;
arg = malloc(sz);
strcpy(arg, argv[1]);
wordsz = strlen(word) + 1;
result = malloc(sz * wordsz);


*In here will be a loop which will use iter
to iterate one char (byte) at a time.
When it comes upon a space char it will exit
to the print statement, but when it comes
upon a newline, it will ret and exit*
//I'm thinkin of something like this, where temp_save is there
//to save the index of the beginning of the last word to
//provide a range ([temp_save,iter]) for strncpy()
//So essentially this will copy the correct range out of word
//and append it (followed by the keyword arg) onto result
strcat(result,"%s %s",strncpy(result,word+temp_save,iter),arg);


*If newline delimiter not reached, return to
previous loop*
", result);
return 0;
Herein lies my issue: how can I detect a space (' ') char using assembly?
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!