<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>

<META NAME="Generator" CONTENT="MS Exchange Server version 5.5.2658.2">
<TITLE>Assemble code different in AS 3 and AS 4</TITLE>
</HEAD>
<BODY>

<P>        <FONT SIZE=2 FACE="Arial">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.</FONT></P>

<P>        <FONT SIZE=2 FACE="Arial">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.</FONT></P>

<P><FONT SIZE=2 FACE="Arial">/</FONT>
<BR><FONT SIZE=2 FACE="Arial">/ int</FONT>
<BR><FONT SIZE=2 FACE="Arial">/ spinlc(location)</FONT>
<BR><FONT SIZE=2 FACE="Arial">/ long *location</FONT>
<BR><FONT SIZE=2 FACE="Arial">/</FONT>
<BR><FONT SIZE=2 FACE="Arial">        .text</FONT>
<BR><FONT SIZE=2 FACE="Arial">        .align  4</FONT>
<BR><FONT SIZE=2 FACE="Arial">spinlc:</FONT>
<BR><FONT SIZE=2 FACE="Arial">        pushl   %ebp</FONT>
<BR><FONT SIZE=2 FACE="Arial">        movl    %esp, %ebp</FONT>
<BR><FONT SIZE=2 FACE="Arial">        subl    $0x4, %esp</FONT>
<BR><FONT SIZE=2 FACE="Arial">        movl    0x8(%ebp), %eax</FONT>
<BR><FONT SIZE=2 FACE="Arial">        movl    $0x1, %edx</FONT>
<BR><FONT SIZE=2 FACE="Arial">        xchgl   %edx, (%eax)</FONT>
<BR><FONT SIZE=2 FACE="Arial">        cmpl    $0x0, %edx</FONT>
<BR><FONT SIZE=2 FACE="Arial">        jne     spinlc_fail</FONT>
<BR><FONT SIZE=2 FACE="Arial">        movl    $0x1, %eax</FONT>
<BR><FONT SIZE=2 FACE="Arial">        leave</FONT>
<BR><FONT SIZE=2 FACE="Arial">        ret</FONT>
<BR><FONT SIZE=2 FACE="Arial">spinlc_fail:</FONT>
<BR><FONT SIZE=2 FACE="Arial">        xorl    %eax, %eax</FONT>
<BR><FONT SIZE=2 FACE="Arial">        leave</FONT>
<BR><FONT SIZE=2 FACE="Arial">        ret</FONT>
</P>
<BR>

<P><FONT SIZE=2 FACE="Arial">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.</FONT></P>

<P><FONT SIZE=2 FACE="Arial">/</FONT>
<BR><FONT SIZE=2 FACE="Arial">/</FONT>
<BR><FONT SIZE=2 FACE="Arial">/ void</FONT>
<BR><FONT SIZE=2 FACE="Arial">/ spinlr(location)</FONT>
<BR><FONT SIZE=2 FACE="Arial">/ long *location</FONT>
<BR><FONT SIZE=2 FACE="Arial">/</FONT>
<BR><FONT SIZE=2 FACE="Arial">        .text</FONT>
<BR><FONT SIZE=2 FACE="Arial">        .align  4</FONT>
<BR><FONT SIZE=2 FACE="Arial">spinlr:</FONT>
<BR><FONT SIZE=2 FACE="Arial">        pushl   %ebp</FONT>
<BR><FONT SIZE=2 FACE="Arial">        movl    %esp, %ebp</FONT>
<BR><FONT SIZE=2 FACE="Arial">        subl    $0x4, %esp</FONT>
<BR><FONT SIZE=2 FACE="Arial">        movl    0x8(%ebp), %eax</FONT>
<BR><FONT SIZE=2 FACE="Arial">        movl    $0x0, (%eax)</FONT>
<BR><FONT SIZE=2 FACE="Arial">        xorl    %eax, %eax</FONT>
<BR><FONT SIZE=2 FACE="Arial">        leave</FONT>
<BR><FONT SIZE=2 FACE="Arial">        ret</FONT>
</P>

<P><FONT SIZE=2 FACE="Arial">Thank in advance:</FONT>
<BR><FONT SIZE=2 FACE="Arial">Jack Allen</FONT>
</P>

</BODY>
</HTML>