home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   comp.lang.asm.x86      Ahh, the lost art of x86 assembly      4,675 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 4,142 of 4,675   
   luserdroog to All   
   CMP flags going wrong in my emu?   
   13 Sep 20 21:13:34   
   
   From: luser.droog@nospicedham.gmail.com   
      
   I'm trying to fill out my toy forth interpreter and I think I have   
   a bug in my emulator for the CMP instruction and therefore probably   
   also SUB and SBB.   
      
   The problem is showing up in my comparator functions   
   CODE(<,     less,      POP(CX),POP(BX), MOVAXI(0xff,0xff), CMP(,R,BX,CX),   
   JL,2,INC_(R,AX), PUSH(AX))   
   CODE(>,     more,      POP(CX),POP(BX), MOVAXI(0xff,0xff), CMP(,R,BX,CX),   
   JG,2,INC_(R,AX), PUSH(AX))   
      
   When I test it with   
      
   WORD(test2a,test2a,    enter, one, ten, less, dot,   
                                 one, ten, more, dot, ok)   
      
   no matter how I permute the arguments -- changing BX and CX in the CMP   
   instruction, or in the POP order, or in the test script -- the results   
   never change.   
      
     0 -1 OK   
      
   Here's the stack trace on the first one.   
      
   ax:ffff cx:000a dx:0000 bx:0001 sp:f000 bp:1ffc si:0e1a di:0000 ip:046d   
   fl:0004 NC NO NS NZ   
   3b(073) cmpwt: d9(331) x:1 y:10 ->fffffff7   
   ax:ffff cx:000a dx:0000 bx:0001 sp:f000 bp:1ffc si:0e1a di:0000 ip:046f   
   fl:0891 CA OV SN NZ   
   7c(174) jl: 02(002) <0>   
   ax:ffff cx:000a dx:0000 bx:0001 sp:f000 bp:1ffc si:0e1a di:0000 ip:0471   
   fl:0891 CA OV SN NZ   
   ff(377) grp2w: c0(300) INC ->0000   
      
   The CMP produces fffffff7 which seems like the correct subtraction   
   extended to 32 bits. But the JL isn't taken.   
      
   Are my flags wrong after the cmpwt instruction?   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca