Implement the less-then and %or instructions.
This commit is contained in:
parent
a2da2d59df
commit
c4e438d4ba
|
|
@ -19,7 +19,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
#if !defined(WINNT)
|
||||
#ident "$Id: codes.h,v 1.13 2001/04/01 06:40:44 steve Exp $"
|
||||
#ident "$Id: codes.h,v 1.14 2001/04/01 07:22:08 steve Exp $"
|
||||
#endif
|
||||
|
||||
|
||||
|
|
@ -53,6 +53,7 @@ extern bool of_JOIN(vthread_t thr, vvp_code_t code);
|
|||
extern bool of_LOAD(vthread_t thr, vvp_code_t code);
|
||||
extern bool of_MOV(vthread_t thr, vvp_code_t code);
|
||||
extern bool of_NOOP(vthread_t thr, vvp_code_t code);
|
||||
extern bool of_OR(vthread_t thr, vvp_code_t code);
|
||||
extern bool of_SET(vthread_t thr, vvp_code_t code);
|
||||
extern bool of_VPI_CALL(vthread_t thr, vvp_code_t code);
|
||||
extern bool of_WAIT(vthread_t thr, vvp_code_t code);
|
||||
|
|
@ -103,6 +104,9 @@ extern void codespace_dump(FILE*fd);
|
|||
|
||||
/*
|
||||
* $Log: codes.h,v $
|
||||
* Revision 1.14 2001/04/01 07:22:08 steve
|
||||
* Implement the less-then and %or instructions.
|
||||
*
|
||||
* Revision 1.13 2001/04/01 06:40:44 steve
|
||||
* Support empty statements for hanging labels.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
#if !defined(WINNT)
|
||||
#ident "$Id: compile.cc,v 1.25 2001/04/01 06:40:45 steve Exp $"
|
||||
#ident "$Id: compile.cc,v 1.26 2001/04/01 07:22:08 steve Exp $"
|
||||
#endif
|
||||
|
||||
# include "compile.h"
|
||||
|
|
@ -83,6 +83,7 @@ const static struct opcode_table_s opcode_table[] = {
|
|||
{ "%load", of_LOAD, 2, {OA_BIT1, OA_FUNC_PTR, OA_NONE} },
|
||||
{ "%mov", of_MOV, 3, {OA_BIT1, OA_BIT2, OA_NUMBER} },
|
||||
{ "%noop", of_NOOP, 0, {OA_NONE, OA_NONE, OA_NONE} },
|
||||
{ "%or", of_OR, 3, {OA_BIT1, OA_BIT2, OA_NUMBER} },
|
||||
{ "%set", of_SET, 2, {OA_FUNC_PTR, OA_BIT1, OA_NONE} },
|
||||
{ "%wait", of_WAIT, 1, {OA_FUNC_PTR, OA_NONE, OA_NONE} },
|
||||
{ 0, of_NOOP, 0, {OA_NONE, OA_NONE, OA_NONE} }
|
||||
|
|
@ -707,6 +708,9 @@ void compile_dump(FILE*fd)
|
|||
|
||||
/*
|
||||
* $Log: compile.cc,v $
|
||||
* Revision 1.26 2001/04/01 07:22:08 steve
|
||||
* Implement the less-then and %or instructions.
|
||||
*
|
||||
* Revision 1.25 2001/04/01 06:40:45 steve
|
||||
* Support empty statements for hanging labels.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* Copyright (c) 2001 Stephen Williams (steve@icarus.com)
|
||||
*
|
||||
* $Id: opcodes.txt,v 1.9 2001/04/01 06:12:14 steve Exp $
|
||||
* $Id: opcodes.txt,v 1.10 2001/04/01 07:22:08 steve Exp $
|
||||
*/
|
||||
|
||||
|
||||
|
|
@ -154,6 +154,15 @@ width and non-overlapping. The <dst> may not be 0-3, but if the <src>
|
|||
is one of the 4 constant bits, the effect is to replicate the value
|
||||
into the destination vector. Useful for filling a vector.
|
||||
|
||||
* %or <dst>, <src>, <wid>
|
||||
|
||||
Perform the bitwise or of the vectors.
|
||||
|
||||
1 or ? --> 1
|
||||
? or 1 --> 1
|
||||
0 or 0 --> 0
|
||||
otherwise x
|
||||
|
||||
* %set <var-label>, <bit>
|
||||
|
||||
This sets a bit of a variable, and is used to implement blocking
|
||||
|
|
|
|||
|
|
@ -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.18 2001/04/01 06:12:14 steve Exp $"
|
||||
#ident "$Id: vthread.cc,v 1.19 2001/04/01 07:22:08 steve Exp $"
|
||||
#endif
|
||||
|
||||
# include "vthread.h"
|
||||
|
|
@ -212,7 +212,7 @@ bool of_CMPU(vthread_t thr, vvp_code_t cp)
|
|||
{
|
||||
unsigned eq = 1;
|
||||
unsigned eeq = 1;
|
||||
unsigned lt = 2;
|
||||
unsigned lt = 0;
|
||||
|
||||
unsigned idx1 = cp->bit_idx1;
|
||||
unsigned idx2 = cp->bit_idx2;
|
||||
|
|
@ -221,8 +221,13 @@ bool of_CMPU(vthread_t thr, vvp_code_t cp)
|
|||
unsigned lv = thr_get_bit(thr, idx1);
|
||||
unsigned rv = thr_get_bit(thr, idx2);
|
||||
|
||||
if (lv != rv)
|
||||
if (lv > rv) {
|
||||
lt = 0;
|
||||
eeq = 0;
|
||||
} else if (lv < rv) {
|
||||
lt = 1;
|
||||
eeq = 0;
|
||||
}
|
||||
if (eq != 2) {
|
||||
if ((lv == 0) && (rv != 0))
|
||||
eq = 0;
|
||||
|
|
@ -236,6 +241,9 @@ bool of_CMPU(vthread_t thr, vvp_code_t cp)
|
|||
if (idx2 >= 4) idx2 += 1;
|
||||
}
|
||||
|
||||
if (eq == 2)
|
||||
lt = 2;
|
||||
|
||||
thr_put_bit(thr, 4, eq);
|
||||
thr_put_bit(thr, 5, lt);
|
||||
thr_put_bit(thr, 6, eeq);
|
||||
|
|
@ -410,6 +418,36 @@ bool of_NOOP(vthread_t thr, vvp_code_t cp)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool of_OR(vthread_t thr, vvp_code_t cp)
|
||||
{
|
||||
assert(cp->bit_idx1 >= 4);
|
||||
|
||||
unsigned idx1 = cp->bit_idx1;
|
||||
unsigned idx2 = cp->bit_idx2;
|
||||
|
||||
for (unsigned idx = 0 ; idx < cp->number ; idx += 1) {
|
||||
|
||||
unsigned lb = thr_get_bit(thr, idx1);
|
||||
unsigned rb = thr_get_bit(thr, idx2);
|
||||
|
||||
if ((lb == 1) || (rb == 1)) {
|
||||
thr_put_bit(thr, idx1, 1);
|
||||
|
||||
} else if ((lb == 0) && (rb == 0)) {
|
||||
thr_put_bit(thr, idx1, 0);
|
||||
|
||||
} else {
|
||||
thr_put_bit(thr, idx1, 2);
|
||||
}
|
||||
|
||||
idx1 += 1;
|
||||
if (idx2 >= 4)
|
||||
idx2 += 1;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool of_SET(vthread_t thr, vvp_code_t cp)
|
||||
{
|
||||
unsigned char bit_val = thr_get_bit(thr, cp->bit_idx1);
|
||||
|
|
@ -442,6 +480,9 @@ bool of_WAIT(vthread_t thr, vvp_code_t cp)
|
|||
|
||||
/*
|
||||
* $Log: vthread.cc,v $
|
||||
* Revision 1.19 2001/04/01 07:22:08 steve
|
||||
* Implement the less-then and %or instructions.
|
||||
*
|
||||
* Revision 1.18 2001/04/01 06:12:14 steve
|
||||
* Add the bitwise %and instruction.
|
||||
*
|
||||
|
|
|
|||
Loading…
Reference in New Issue