Assemble code different in AS 3 and AS 4
Rick Stevens
rstevens at vitalstream.com
Tue Aug 23 01:02:29 UTC 2005
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. -
----------------------------------------------------------------------
More information about the Redhat-install-list
mailing list