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,152 of 4,675   
   Alexei A. Frounze to luserdroog   
   Re: CMP flags going wrong in my emu?   
   14 Sep 20 15:51:41   
   
   From: alexfrunews@nospicedham.gmail.com   
      
   On Monday, September 14, 2020 at 2:38:49 PM UTC-7, luserdroog wrote:   
   > On Monday, September 14, 2020 at 3:51:24 AM UTC-5, Alexei A. Frounze wrote:   
   > > On Sunday, September 13, 2020 at 11:51:13 PM UTC-7, luserdroog wrote:   
   > > >     // additional flags set by math operators   
   > > > #define MATHFLAGS *fl |= ( (z&(w?0xffff0000:0xff00))     ?CF:0) \   
   > > >                        | ( ((z^x)&(z^y)&(w?0x8000:0x80)) ?OF:0) \   
   > > >                        | ( ((x^y^z)&0x10)                ?AF:0); \   
   > > >                        SETPF   
   > > >   
   > > > I don't know where I came up with that expression for OF.   
   > > > It's gibberish to me now.   
   > >   
   > > It's making sure that the result's sign is the same   
   > > as the signs of x and y. If that isn't true, OF gets set.   
   > > That works for addition, z = x + y,   
   > > but not subtraction, z = x - y.   
   > > Unless you exchange things a bit...   
   > >   
   > > add: z = x + y   
   > > (z^x)&(z^y)&...   
   > >   
   > > sub: z = x - y   
   > > OR, speaking in terms of addition...   
   > > sub: x = z + y   
   > > (x^z)&(x^y)&...   
   > >   
   > > IOW, for the purposes of OF calculation you need to   
   > > exchange x and z in that formula of yours.   
   > >   
   > > Alex   
   >   
   > Do I also need to swap x and y if the direction is   
   > reversed and z = y - x?   
   > then y = z + x.   
   > sthg like:   
   >   ((d?x:y)^z)&(x^y)&...   
      
   I didn't follow the meaning of "direction" in your code,   
   but yes, if you're swapping the diminuend and the subtrahend.   
      
   That gives you 3 cases:   
      
   z=x+y:   
   (z^x)&(z^y)&...   
      
   z=x-y (mathematically equivalent to x=z+y):   
   (x^z)&(x^y)&...   
      
   z=y-x (mathematically equivalent to y=x+z):   
   (y^x)&(y^z)&...   
      
   Putting it all together:   
      
   (((is_add||sub_dir)?z:y)^x) &   
   (((is_add||!sub_dir)?z:x)^y) & ...   
      
   Alex   
      
   --- 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