Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.postscript > #1120

Re: Calculate a 16-bit Carry Flag?

From "luser.droog" <luser.droog@gmail.com>
Newsgroups comp.lang.postscript
Subject Re: Calculate a 16-bit Carry Flag?
Date 2012-11-30 16:18 -0600
Organization unorganized
Message-ID <k9bbcb$l24$1@dont-email.me> (permalink)
References <k9a31h$ngc$1@dont-email.me> <yNGdnRpPq9tZeyXNnZ2dnUVZ_tSdnZ2d@posted.nuvoxcommunications>

Show all headers | View raw


Robert Bonomi wrote:

> In article <k9a31h$ngc$1@dont-email.me>,
> luser.droog <luser.droog@gmail.com> wrote:
>>I'm debugging my 8086 emulator
>>http://codegolf.stackexchange.com/questions/4732/emulate-an-intel-8086-cpu/9065#9065
>>
>>And I'm hung up on the arithmetic. How do you tell if a 16bit addition
>>yield a Carry using postscript's 32-bit (PLRM stnd) integers. Since it's
>>all 2's complement, I figured I could just sign-extend all the inputs,
>>call the ps math op (`add`, `sub`), and then check the bits.
> 
> First, implement 'subtract' as 'complement and add'
> 
> Then:
>   *IF* bit {7 15} of the two operands are different you can't have a
>   Carry. If they're the same, do the addition, and if bit {7 15} of the
>   result is different from operands, overflow occurred

Awesome, thanks. So, I shouldn't be sign-extending everything willy-nilly,
right? Just treat them as unsigned values since they're all in the positive
range of a 32bit signed int?  And by implementing subtract as you say, I
only have to do the carry nonsense once.

When you say 'overflow', you mean what I mean by 'carry', right? Cause I've
got a Carry Flag and an Overflow Flag, and for unsigned overflow, I've got
to XOR({7 15},{8 16}). unless I'm mistaken.

Back to comp.lang.postscript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Calculate a 16-bit Carry Flag? "luser.droog" <luser.droog@gmail.com> - 2012-11-30 04:50 -0600
  Re: Calculate a 16-bit Carry Flag? bonomi@host122.r-bonomi.com (Robert Bonomi) - 2012-11-30 11:03 -0600
    Re: Calculate a 16-bit Carry Flag? "luser.droog" <luser.droog@gmail.com> - 2012-11-30 16:18 -0600
      Re: Calculate a 16-bit Carry Flag? bonomi@host122.r-bonomi.com (Robert Bonomi) - 2012-12-02 00:12 -0600
        Re: Calculate a 16-bit Carry Flag? "luser.droog" <luser.droog@gmail.com> - 2012-12-03 00:06 -0600
        Re: Calculate a 16-bit Carry Flag? vojta@math.berkeley.edu (Paul Vojta) - 2012-12-05 02:57 +0000
          Re: Calculate a 16-bit Carry Flag? "luser.droog" <luser.droog@gmail.com> - 2012-12-05 23:34 -0600
            Re: Calculate a 16-bit Carry Flag? Bogus@Embarq.com (Steve) - 2012-12-07 15:59 +0000

csiph-web