Page 1 of 1

Assembler errors, not sure what to do...

Posted: Tue May 23, 2006 11:00 pm
by stevenup7002
Hi, you may know me, I'm the mad creator of Sendla OS, rawrr, and stuff.. ahem. Anyway, I have a problem with some source, I was debugging some code that one of our polish developers gave to me. It compiled successfully but it threw some assembler errors. I am not to good with assembler so I thought I'd ask ye to help me out.

Heres the Function that throws the errors:

Code: Select all

void mutex_SetSpinLock(spinlock *lock) {
    __asm__ __volatile__ ( "pushal\n"
                          "_repeat:\n"
                          "movl $0, %%eax\n"
                          "movl %0, %%ebx\n"
                          "cmpl (%%ebx), %%eax\n"
                          "jne _repeat\n"
                          "pushfl\n"
                          "cli\n"
                          "movl $0, %%eax\n"
                          "movl %0, %%ebx\n"
                          "cmpl (%%ebx), %%eax\n"
                          "je _finish\n"
                          "popfl\n"
                          "jmp _repeat\n"
                          "_finish:\n"
                          "incl (%%ebx)\n"
                          "popfl\n"
                          "popal\n" :: "g" (lock) );
}
And Heres the errors that gcc throw:
c:/shared/gcc/tmp/cci2Hf8i.s: Assembler messages:
c:/shared/gcc/tmp/cci2Hf8i.s:63: Error: symbol `_repeat' is already defined
c:/shared/gcc/tmp/cci2Hf8i.s:76: Error: symbol `_finish' is already defined
c:/shared/gcc/tmp/cci2Hf8i.s:94: Error: symbol `_repeat' is already defined
c:/shared/gcc/tmp/cci2Hf8i.s:107: Error: symbol `_finish' is already defined
Probably an obvious error, but I'm afraid that i will mess it up.

Thanks in advance,
-Steven

Re: Assembler errors, not sure what to do...

Posted: Tue May 23, 2006 11:00 pm
by Daedalus
Is there any other occurances of the labels '_repeat:', etc in the source ?
I'm thinking that maybe those labels were used elsewhere in the file and are whats causing the problem.

Re: Assembler errors, not sure what to do...

Posted: Tue May 23, 2006 11:00 pm
by carbonBased
You should try using local labels in your inline assembly (ie 1:, 2:, etc) and see what happens.

--Jeff

Re: Assembler errors, not sure what to do...

Posted: Tue May 23, 2006 11:00 pm
by stevenup7002
Thanks Jeff, I'll try that.

Edit: Thanks Jeff, it assembles now. I'll just have to fix up the linking now.