From 54140dadcf2cff42c29efc3f5700de5a72ebd28d Mon Sep 17 00:00:00 2001 From: steve Date: Sun, 22 Jul 2001 00:04:50 +0000 Subject: [PATCH] Add the load/x instruction for bit selects. --- vvp/codes.h | 6 +++++- vvp/compile.cc | 8 ++++++-- vvp/opcodes.txt | 10 +++++++++- vvp/udp.h | 7 ++++++- vvp/vthread.cc | 15 ++++++++++++++- 5 files changed, 40 insertions(+), 6 deletions(-) diff --git a/vvp/codes.h b/vvp/codes.h index 6ed230175..5cd2d0616 100644 --- a/vvp/codes.h +++ b/vvp/codes.h @@ -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.32 2001/07/19 04:40:55 steve Exp $" +#ident "$Id: codes.h,v 1.33 2001/07/22 00:04:50 steve Exp $" #endif @@ -63,6 +63,7 @@ extern bool of_JMP1(vthread_t thr, vvp_code_t code); 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_LOAD_MEM(vthread_t thr, vvp_code_t code); +extern bool of_LOAD_X(vthread_t thr, vvp_code_t code); extern bool of_MOD(vthread_t thr, vvp_code_t code); extern bool of_MOV(vthread_t thr, vvp_code_t code); extern bool of_MUL(vthread_t thr, vvp_code_t code); @@ -137,6 +138,9 @@ extern vvp_code_t codespace_index(vvp_cpoint_t ptr); /* * $Log: codes.h,v $ + * Revision 1.33 2001/07/22 00:04:50 steve + * Add the load/x instruction for bit selects. + * * Revision 1.32 2001/07/19 04:40:55 steve * Add support for the delayx opcode. * diff --git a/vvp/compile.cc b/vvp/compile.cc index a78fa7e40..950f74fd9 100644 --- a/vvp/compile.cc +++ b/vvp/compile.cc @@ -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.88 2001/07/19 04:40:55 steve Exp $" +#ident "$Id: compile.cc,v 1.89 2001/07/22 00:04:50 steve Exp $" #endif # include "arith.h" @@ -102,6 +102,7 @@ const static struct opcode_table_s opcode_table[] = { { "%join", of_JOIN, 0, {OA_NONE, OA_NONE, OA_NONE} }, { "%load", of_LOAD, 2, {OA_BIT1, OA_FUNC_PTR, OA_NONE} }, { "%load/m", of_LOAD_MEM,2, {OA_BIT1, OA_MEM_PTR, OA_NONE} }, + { "%load/x", of_LOAD_X, 3, {OA_BIT1, OA_FUNC_PTR, OA_BIT2} }, { "%mod", of_MOD, 3, {OA_BIT1, OA_BIT2, OA_NUMBER} }, { "%mov", of_MOV, 3, {OA_BIT1, OA_BIT2, OA_NUMBER} }, { "%mul", of_MUL, 3, {OA_BIT1, OA_BIT2, OA_NUMBER} }, @@ -707,7 +708,7 @@ void compile_udp_def(int sequ, char *label, char *name, u->sequ = sequ; u->nin = nin; u->init = init; - u->table = table; + u->compile_table(table); free(label); } @@ -1545,6 +1546,9 @@ vvp_ipoint_t debug_lookup_functor(const char*name) /* * $Log: compile.cc,v $ + * Revision 1.89 2001/07/22 00:04:50 steve + * Add the load/x instruction for bit selects. + * * Revision 1.88 2001/07/19 04:40:55 steve * Add support for the delayx opcode. * diff --git a/vvp/opcodes.txt b/vvp/opcodes.txt index 9adf04099..6dc15b778 100644 --- a/vvp/opcodes.txt +++ b/vvp/opcodes.txt @@ -1,7 +1,7 @@ /* * Copyright (c) 2001 Stephen Williams (steve@icarus.com) * - * $Id: opcodes.txt,v 1.26 2001/07/19 04:40:55 steve Exp $ + * $Id: opcodes.txt,v 1.27 2001/07/22 00:04:50 steve Exp $ */ @@ -233,6 +233,14 @@ Bit address zero is the LSB of the first memory word. This instruction loads only a single bit. +* %load/x , , + +This is an indexed load. It uses the contents of the specified index +register to select a bit from an array based at . The +bit is pulled from the addressed functor and loaded into the +destination bit. This function does not do any bounds checking. + + * %mod , , diff --git a/vvp/udp.h b/vvp/udp.h index e024ad266..5013cb437 100644 --- a/vvp/udp.h +++ b/vvp/udp.h @@ -20,7 +20,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) -#ident "$Id: udp.h,v 1.6 2001/05/06 03:51:37 steve Exp $" +#ident "$Id: udp.h,v 1.7 2001/07/22 00:04:50 steve Exp $" #endif #include "pointers.h" @@ -39,6 +39,8 @@ class vvp_udp_s : public vvp_fobj_s unsigned char init; char **table; + void compile_table(char **t) { table = t; } + private: unsigned char propagate_(vvp_ipoint_t i); }; @@ -49,6 +51,9 @@ struct vvp_udp_s *udp_find(char *label); /* * $Log: udp.h,v $ + * Revision 1.7 2001/07/22 00:04:50 steve + * Add the load/x instruction for bit selects. + * * Revision 1.6 2001/05/06 03:51:37 steve * Regularize the mode-42 functor handling. * diff --git a/vvp/vthread.cc b/vvp/vthread.cc index f72fac16f..6a8b230d5 100644 --- a/vvp/vthread.cc +++ b/vvp/vthread.cc @@ -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.50 2001/07/20 04:57:00 steve Exp $" +#ident "$Id: vthread.cc,v 1.51 2001/07/22 00:04:50 steve Exp $" #endif # include "vthread.h" @@ -835,6 +835,16 @@ bool of_LOAD_MEM(vthread_t thr, vvp_code_t cp) return true; } +bool of_LOAD_X(vthread_t thr, vvp_code_t cp) +{ + assert(cp->bit_idx1 >= 4); + assert(cp->bit_idx2 < 4); + + vvp_ipoint_t ptr = ipoint_index(cp->iptr, thr->index[cp->bit_idx2]); + thr_put_bit(thr, cp->bit_idx1, functor_get(ptr)); + return true; +} + bool of_MOD(vthread_t thr, vvp_code_t cp) { assert(cp->bit_idx1 >= 4); @@ -1326,6 +1336,9 @@ bool of_ZOMBIE(vthread_t thr, vvp_code_t) /* * $Log: vthread.cc,v $ + * Revision 1.51 2001/07/22 00:04:50 steve + * Add the load/x instruction for bit selects. + * * Revision 1.50 2001/07/20 04:57:00 steve * Fix of_END when a middle thread ends. *