title: Porting MASM5 code in Quake 2 to GAS -- Unexpected rendering results
body: <p>I am porting Quake 2's inline assembly code for MSVC to MASM then finally to GAS (for use with MinGW).  The specific code in question is for the Skin drawing (R_PolysetCalcGradients for those who want to look it up).  The code almost "works" what happens is the skin seems to stretched over the model incorrectly.</p>
  
  <p><a href="https://i.stack.imgur.com/FhHOB.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/FhHOB.jpg" alt="Incorrect skin stretching"></a>
  A few interesting things I noticed is when I run <strong>objdump -dwrC r_polysa.obj > r_polysa.masm</strong> and the same for the GAS version the code is mostly similar except for the fact <strong>fsubp</strong> and <strong>fsubrp</strong> have been swapped in MASM.  Please note not the operands (I already know about this issue in GAS).
  <a href="https://i.stack.imgur.com/9QCFn.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/9QCFn.png" alt="Swapped fsubp/fsubrp"></a>
  In the picture the left side is the GAS version, the right side is the MASM version.  The original MASM code (and therefore what I have in GAS) is what should be on the left side.  I am unsure why MASM is apparently swapping this or if objdump is reporting it incorrectly.  However, if I swap the two this does not fix the issue.  It just gets inverted in another wrong way.
  <a href="https://i.stack.imgur.com/CUF8l.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/CUF8l.jpg" alt="Still wrong skin stretching"></a></p>
  
  <p>I mention this FSUBP/FSUBRP swap because this was a problem in porting the Particle blending inline ASM code.  This had one call to use an FSUBRP in the MASM version, objdump reported it now being FSUBP and I had to change it to FSUBP in the GAS version for it to work!  I don't understand why this is happening?</p>
  
  <p>In any case, I am new to assembly, but understand some basics and have been doing some reading.  Obviously the math here is not quite right, but it seems as though it should be.  I don't know how or what to do next.  How do I fix and debug this problem?</p>
  
  <p>The code repository to what I am working on is at: <a href="https://bitbucket.org/neozeed/q2dos/commits/branch/win32_asm" rel="nofollow noreferrer">https://bitbucket.org/neozeed/q2dos/commits/branch/win32_asm</a>  (specifically the Win32_ASM branch).  The files I am working with are <strong>gas\r_polysa.s</strong> and <strong>ref_soft\r_polysa.asm</strong>.</p>