Assembler errors, not sure what to do...

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
User avatar
stevenup7002
Member
Member
Posts: 60
Joined: Tue Sep 20, 2005 11:00 pm
Location: Ireland
Contact:

Assembler errors, not sure what to do...

Post 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
User avatar
Daedalus
Member
Member
Posts: 74
Joined: Sun Oct 16, 2005 11:00 pm
Location: Australia
Contact:

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

Post 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.
Myth OS is awaiting a revival ...
User avatar
carbonBased
Member
Member
Posts: 382
Joined: Sat Nov 20, 2004 12:00 am
Location: Wellesley, Ontario, Canada
Contact:

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

Post by carbonBased »

You should try using local labels in your inline assembly (ie 1:, 2:, etc) and see what happens.

--Jeff
User avatar
stevenup7002
Member
Member
Posts: 60
Joined: Tue Sep 20, 2005 11:00 pm
Location: Ireland
Contact:

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

Post by stevenup7002 »

Thanks Jeff, I'll try that.

Edit: Thanks Jeff, it assembles now. I'll just have to fix up the linking now.
Last edited by stevenup7002 on Tue May 23, 2006 11:00 pm, edited 1 time in total.
Post Reply