Skip to content

Commit

Permalink
Fix carry between works for %add instruction.
Browse files Browse the repository at this point in the history
  • Loading branch information
steve committed Oct 23, 2001
1 parent 859318b commit 2adea8d
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions vvp/vthread.cc
Expand Up @@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT)
#ident "$Id: vthread.cc,v 1.59 2001/10/20 23:20:32 steve Exp $"
#ident "$Id: vthread.cc,v 1.60 2001/10/23 03:49:13 steve Exp $"
#endif

# include "vthread.h"
Expand Down Expand Up @@ -159,7 +159,7 @@ static unsigned long* vector_to_array(struct vthread_s*thr,
val[idx] = 0;

for (unsigned idx = 0 ; idx < wid ; idx += 1) {
unsigned bit = thr_get_bit(thr, addr);
unsigned long bit = thr_get_bit(thr, addr);

if (bit & 2)
goto x_out;
Expand Down Expand Up @@ -348,9 +348,17 @@ bool of_ADD(vthread_t thr, vvp_code_t cp)
unsigned long carry;
carry = 0;
for (unsigned idx = 0 ; (idx*CPU_BITS) < cp->number ; idx += 1) {
unsigned long tmp = (lva[idx] | lvb[idx]) & TOP_BIT;
lva[idx] += lvb[idx] + carry;
carry = (tmp > lva[idx]) ? 1 : 0;

unsigned long tmp = lvb[idx] + carry;
unsigned long sum = lva[idx] + tmp;
carry = 0;
if (tmp < lvb[idx])
carry = 1;
if (sum < tmp)
carry = 1;
if (sum < lva[idx])
carry = 1;
lva[idx] = sum;
}

for (unsigned idx = 0 ; idx < cp->number ; idx += 1) {
Expand Down Expand Up @@ -1665,6 +1673,9 @@ bool of_ZOMBIE(vthread_t thr, vvp_code_t)

/*
* $Log: vthread.cc,v $
* Revision 1.60 2001/10/23 03:49:13 steve
* Fix carry between works for %add instruction.
*
* Revision 1.59 2001/10/20 23:20:32 steve
* Catch and X division by 0.
*
Expand Down

0 comments on commit 2adea8d

Please sign in to comment.