Assemble code different in AS 3 and AS 4

Allen, Jack Jack.Allen at McKesson.com
Mon Aug 22 23:09:16 UTC 2005


        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 

Thank in advance: 
Jack Allen 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/redhat-install-list/attachments/20050822/ac62c5d9/attachment.htm>


More information about the Redhat-install-list mailing list