From e328cf9fed47978e8adee911762d7b0e66dc4720 Mon Sep 17 00:00:00 2001 From: steve Date: Sun, 6 May 2001 17:42:22 +0000 Subject: [PATCH] Add the %ix/get instruction. (Stephan Boettcher) --- vvp/codes.h | 6 +++++- vvp/compile.cc | 6 +++++- vvp/opcodes.txt | 16 ++++++++++++++-- vvp/vthread.cc | 20 +++++++++++++++++++- 4 files changed, 43 insertions(+), 5 deletions(-) diff --git a/vvp/codes.h b/vvp/codes.h index 909114d7b..77ed698b7 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.24 2001/05/05 23:55:46 steve Exp $" +#ident "$Id: codes.h,v 1.25 2001/05/06 17:42:22 steve Exp $" #endif @@ -51,6 +51,7 @@ extern bool of_END(vthread_t thr, vvp_code_t code); extern bool of_FORK(vthread_t thr, vvp_code_t code); extern bool of_INV(vthread_t thr, vvp_code_t code); extern bool of_IX_ADD(vthread_t thr, vvp_code_t code); +extern bool of_IX_GET(vthread_t thr, vvp_code_t code); extern bool of_IX_LOAD(vthread_t thr, vvp_code_t code); extern bool of_IX_MUL(vthread_t thr, vvp_code_t code); extern bool of_IX_SUB(vthread_t thr, vvp_code_t code); @@ -128,6 +129,9 @@ extern void codespace_dump(FILE*fd); /* * $Log: codes.h,v $ + * Revision 1.25 2001/05/06 17:42:22 steve + * Add the %ix/get instruction. (Stephan Boettcher) + * * Revision 1.24 2001/05/05 23:55:46 steve * Add the beginnings of an interactive debugger. * diff --git a/vvp/compile.cc b/vvp/compile.cc index 3a00c3ab3..17a573ce4 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.56 2001/05/06 03:51:37 steve Exp $" +#ident "$Id: compile.cc,v 1.57 2001/05/06 17:42:22 steve Exp $" #endif # include "compile.h" @@ -82,6 +82,7 @@ const static struct opcode_table_s opcode_table[] = { { "%end", of_END, 0, {OA_NONE, OA_NONE, OA_NONE} }, { "%inv", of_INV, 2, {OA_BIT1, OA_BIT2, OA_NONE} }, { "%ix/add", of_IX_ADD, 2, {OA_BIT1, OA_NUMBER, OA_NONE} }, + { "%ix/get", of_IX_GET, 2, {OA_BIT1, OA_BIT2, OA_NUMBER} }, { "%ix/load",of_IX_LOAD,2, {OA_BIT1, OA_NUMBER, OA_NONE} }, { "%ix/mul", of_IX_MUL, 2, {OA_BIT1, OA_NUMBER, OA_NONE} }, { "%ix/sub", of_IX_SUB, 2, {OA_BIT1, OA_NUMBER, OA_NONE} }, @@ -1048,6 +1049,9 @@ void compile_dump(FILE*fd) /* * $Log: compile.cc,v $ + * Revision 1.57 2001/05/06 17:42:22 steve + * Add the %ix/get instruction. (Stephan Boettcher) + * * Revision 1.56 2001/05/06 03:51:37 steve * Regularize the mode-42 functor handling. * diff --git a/vvp/opcodes.txt b/vvp/opcodes.txt index 4a1d5567b..e23225841 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.18 2001/05/05 23:55:46 steve Exp $ + * $Id: opcodes.txt,v 1.19 2001/05/06 17:42:22 steve Exp $ */ @@ -141,12 +141,24 @@ bit: z --> x +* %ix/get , , + +This instruction loads a thread vector starting at , size , +into the index register . The is the lsb of the value in +thread bit space, and is the width of the vector. + +The function converts the 4-value bits into a binary number, without +sign extension. If any of the bits of the vector is x or z, then the +index register gets the value 0. + + * %ix/load , This instruction loads an immediate value into the addressed index register. The index register holds numeric values, so the is a number. The idx value selects the index register, and may be 0, 1, 2 -or 3. +or 3. This is different from %is/get, which loads the index register +from a value in the thread bit vector. * %ix/add , diff --git a/vvp/vthread.cc b/vvp/vthread.cc index 970032421..48d67f0cb 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.35 2001/05/05 23:55:46 steve Exp $" +#ident "$Id: vthread.cc,v 1.36 2001/05/06 17:42:22 steve Exp $" #endif # include "vthread.h" @@ -663,6 +663,21 @@ bool of_IX_LOAD(vthread_t thr, vvp_code_t cp) return true; } +bool of_IX_GET(vthread_t thr, vvp_code_t cp) +{ + unsigned long v = 0; + for (int i = 0; inumber; i++) { + unsigned char vv = thr_get_bit(thr, cp->bit_idx2 + i); + if (vv&2) { + v = ~0UL; + break; + } + v |= vv << i; + } + thr->index[cp->bit_idx1 & 3] = v; + return true; +} + /* * The various JMP instruction work simply by pulling the new program @@ -978,6 +993,9 @@ bool of_ZOMBIE(vthread_t thr, vvp_code_t) /* * $Log: vthread.cc,v $ + * Revision 1.36 2001/05/06 17:42:22 steve + * Add the %ix/get instruction. (Stephan Boettcher) + * * Revision 1.35 2001/05/05 23:55:46 steve * Add the beginnings of an interactive debugger. *