Pelles C forum

C language => Beginner questions => Topic started by: numpad1 on September 11, 2011, 06:39:52 AM

Title: assembler tutorial
Post by: numpad1 on September 11, 2011, 06:39:52 AM
Can you recommend a good assembly tutorial that can help me understand how to use inline assembly.
Title: Re: assembler tutorial
Post by: Vortex on September 11, 2011, 09:43:11 PM
Hi numpad1,

If you are looking for a Pelles C example :


#include <stdio.h>

#define a 97
#define z 122

char *szUpper(char *text)
{
__asm{
mov eax, text
dec eax

@repeat:

add eax, 1
cmp BYTE PTR [eax], 0
je @end
cmp BYTE PTR [eax], a
jb @repeat
cmp BYTE PTR [eax], z
ja @repeat
sub BYTE PTR [eax], 32
jmp @repeat

@end:

}
return text;
}

int main(int argc,char *argv[])
{
char message[]="string converted to uppercase";
printf("%s",szUpper(message));
return 0;
}
Title: Re: assembler tutorial
Post by: CommonTater on September 12, 2011, 12:00:50 AM
Quote from: numpad1 on September 11, 2011, 06:39:52 AM
Can you recommend a good assembly tutorial that can help me understand how to use inline assembly.

It's very much like MASM so you should be able to get a good start on it from MASM tutorials.
The Pelles C help file has a considerable amount of exact documentation as well.

Also take a look in the Assembler Discussions forum right here on this board....