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,120 of 4,675   
   luserdroog to luserdroog   
   Re: Comparing to zero   
   27 Aug 20 23:22:02   
   
   From: luser.droog@nospicedham.gmail.com   
      
   On Thursday, August 27, 2020 at 8:01:51 PM UTC-5, luserdroog wrote:   
   > On Thursday, August 27, 2020 at 3:12:28 PM UTC-5, luserdroog wrote:   
   > > Hi everyone,   
   > >   
   > > I'm working on primitives for my newly working forth interpreter and I'm   
   > > having difficulty with comparisons 0= 0> and 0> . These each take a   
   > > number from the stack and push 0 or all-bits-1.   
   > >   
   > > My code for 0= and 0> appear to be producing results, but I get the wrong   
   > > result for 0< even though it seems to follow appropriate parallel logic   
   > > as 0>. Any ideas? Does this suggest a bug in assembly or in my emulator?   
   > >   
   [snip]   
   >   
   > So, in "CMP CX=0,AX=12" CX is the destination. So 0-12. Hmmm.   
   > I still don't get it. But all the pieces seem to be here....   
      
   I went to the fig-forth source and adapted that and now it appears   
   to be working.   
      
   CODE(0=,    zeq,       POP(AX), OR(,R,AX,AX), MOVAXI(0xff,0xff),   
   JZ,2,INC_(R,AX), PUSH(AX))   
   CODE(0<,    zless,     POP(AX), OR(,R,AX,AX), MOVAXI(0xff,0xff),   
   JL,2,INC_(R,AX), PUSH(AX))   
   CODE(0>,    zmore,     POP(AX), OR(,R,AX,AX), MOVAXI(0xff,0xff),   
   JG,2,INC_(R,AX), PUSH(AX))   
   ...   
   WORD(run,   run,       c_lit,0, c_zeq, c_dot,   
                          c_lit,2, c_zeq, c_dot,   
                          c_lit,12,            c_zless, c_dot,   
                          c_lit,1+(0xffff^50), c_zless, c_dot,   
                          c_lit,12,            c_zmore, c_dot,   
                          c_lit,1+(0xffff^50), c_zmore, c_dot,   
                          c_ok, c_bye)   
      
   $ !m   
   make a8086 CFLAGS='-g -Og'   
   cc -g -Og    a8086.c   -o a8086   
   $ !.   
   ./a8086   
   100110OK   
      
   So the values all make sense now.   
      
   --- 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