Assemble code different in AS 3 and AS 4

Allen, Jack Jack.Allen at McKesson.com
Tue Aug 23 01:18:17 UTC 2005



-----Original Message-----
From: Rick Stevens [mailto:rstevens at vitalstream.com] 
Sent: Monday, August 22, 2005 9:02 PM
To: Getting started with Red Hat Linux
Subject: Re: Assemble code different in AS 3 and AS 4


Allen, Jack wrote:
>         My application is written in "C" except for 1 small routine, 
> really 2. The code below complied (assembled) with no errors and run 
> fine in AS 3, but I get compile errors on the pushl lines with AS 4. I 
> know enough about assemble langue code to recognize it and that is about 
> it. Does anyone have any ideas what needs to be changed. Or is there 
> some library call that does the same thing. IBM's AIX provides one that 
> we use.
> 
>         The spinlc (spinlock conditional) routine takes and address to a 
> 4 byte location and does an exchange with a register and the memory 
> location. If the memory location was 0, then it will contain a 1 and the 
> return value will be 1. If the memory location already contained a 1 
> then 0 is returned. From what I read on the xchgl operator in the past, 
> it locks the memory bus while doing the exchanging so no other process 
> can be changing the memory location at the same time. The memory 
> location is in SYS V type shared memory.
> 
> /
> / int
> / spinlc(location)
> / long *location
> /
>         .text
>         .align  4
> spinlc:
>         pushl   %ebp
>         movl    %esp, %ebp
>         subl    $0x4, %esp
>         movl    0x8(%ebp), %eax
>         movl    $0x1, %edx
>         xchgl   %edx, (%eax)
>         cmpl    $0x0, %edx
>         jne     spinlc_fail
>         movl    $0x1, %eax
>         leave
>         ret
> spinlc_fail:
>         xorl    %eax, %eax
>         leave
>         ret
> 
> 
> The spinlr (spinlock release) routine just puts a 0 in the memory 
> location. It really could be written in "C" because there is no locking 
> done here. But because these routines have to be written in the native 
> assemble for other hardware platform it is easier to have all of them 
> that way.
> 
> /
> /
> / void
> / spinlr(location)
> / long *location
> /
>         .text
>         .align  4
> spinlr:
>         pushl   %ebp
>         movl    %esp, %ebp
>         subl    $0x4, %esp
>         movl    0x8(%ebp), %eax
>         movl    $0x0, (%eax)
>         xorl    %eax, %eax
>         leave
>         ret

Uh, Jack, you ARE aware of the fact that AS3 is a 2.4 kernel and AS4 is
a 2.6 kernel, right?  The interfaces to the kernel are radically
different between the two as is the C compiler (gcc 3.2.3 in AS3, gcc
4.0.1 in AS4) and assembler (as 2.14.x in AS3, as 2.15.x in AS4).  I
don't know if that would have an effect, but it's very possible.
----------------------------------------------------------------------
- Rick Stevens, Senior Systems Engineer     rstevens at vitalstream.com -
- VitalStream, Inc.                       http://www.vitalstream.com -
-                                                                    -
-   Never test for an error condition you don't know how to handle.  -
----------------------------------------------------------------------

	Yes I know all that. That is the reason I am trying to find out
exactly what the difference is. Also I have loaded the 64 bit version of AS
4.

	I did some more testing after I sent this. I wrote a simple C
program:

abc(int *arg_addr)
{
	if(*arg_addr > 0) {
		return(1);
		}
	return(0);
}

Then if did cc -S t.c and noticed some things. The assemble code uses
different names for the registers and uses pushq instead of pushl, and movq
instead of movl. Then I searched the WED and found some document on gnu as.
So now I am trying to make change to use the new register and opcodes.

	I was hoping someone else had already had to do something like this
and save me some time and headaches.

Thanks:
Jack Allen




More information about the Redhat-install-list mailing list