Hi, I'm trying to figure out how to convert this into GCC-compliant AT&T ASM syntax



__asm
{
mov ebx, String1
mov ecx, String2
label:
mov al, // move the character into al
mov ah, // move the character into ah
inc ebx // increment ebx (next character)
inc ecx // increment ecx (next character)
cmp al, ah // test for equality
jne negative    // mismatch
cmp al, 0      // zero terminator
jne label // keep going, if not zero terminator
mov rt, 0 // move the result to our return integer
jmp positive // we've hit a zero terminator, so return equal
negative:
mov rt, 1 // move the result to our return integer
positive:
}


Here's what I have so far, and it doesn't even assemble properly (AT&T syntax newbie-ism, sorry):

__asm ( "movl _String1, %ebx ;"
"movl _String2, %ecx ;"
"1: ;"
"movb (%ebx), %al ;"
"movb (%ecx), %ah ;"
"incl %ebx ;"
"incl %ecx ;"
"cmpb %ah, %al ;"
"jne short 2b ;"
"cmpb $0, %al ;"
"jne short 1b ;"
"movl $0, _rt ;"
"jmp short 3b ;"
"2:  ;"
"movl $1, _rt ;"
"3: ;");


I get the feeling this syntax is WAY off from what it should be... Can anyone tell me what I'm doing wrong?

Thanks

-Tycho
Posted on 2005-09-07 01:21:05 by tycho
hi! i'm not familiar with inline usage of asm, but it seems your function should work. check if StringX are valid pointers and preserve ebx, or it will crash on w2k . also it can be optimized (to do it better when it will work at all). regards!
Posted on 2005-09-07 02:19:59 by Shoo
tycho, I would suggest you to use an external .asm module instead of inline assembly - it allows you to keep one format for all assemblers, you won't have to suffer the headache of AT&T assembly syntax, external modules don't mess up the optimizer part of even retarded compilers, et cetera.

You can write the assembly in FASM if you need to support both windows and lunix, fasm supports coff as well as elf output.
Posted on 2005-09-07 07:24:52 by f0dder
Posted on 2005-09-07 10:30:58 by bluffer