From 9d42abb28b464b9ae636540e5ff69994f21cdbf3 Mon Sep 17 00:00:00 2001 From: oharboe Date: Thu, 7 Aug 2008 11:19:42 +0000 Subject: added basic docs on emulated instructions. --- zpu/docs/zpu_arch.html | 431 ++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 427 insertions(+), 4 deletions(-) diff --git a/zpu/docs/zpu_arch.html b/zpu/docs/zpu_arch.html index 021e987..3597e82 100644 --- a/zpu/docs/zpu_arch.html +++ b/zpu/docs/zpu_arch.html @@ -358,7 +358,7 @@ end if 0000 1011 - No operation + No operation, clears IDIM flag as side effect Fix! @@ -366,18 +366,441 @@ end if - Fix! add emulated instructions! Listed in zpupkg.vhd + PUSHSPADD - 001x xxxx + 61 + + + a=sp;
+ b=popIntStack()*4;
+ pushIntStack(a+b);
+ + + Fix! + + + + + + POPPCREL + + + 57 + + + setPc(popIntStack()+getPc()); + + + Fix! + + + + + SUB + + + 49 + + + int a=popIntStack();
+ int b=popIntStack();
+ pushIntStack(b-a);
+ + + Fix! + + + + + XOR + + + 50 + + +pushIntStack(popIntStack() ^ popIntStack()); + + + Fix! + + + + + LOADB + + + 51 + + + pushIntStack(cpuReadByte(popIntStack())&0xff); + + + Fix! + + + + + STOREB + + + 52 + + + addr = popIntStack();
+ val = popIntStack();
+ cpuWriteByte(addr, val); + + + Fix! + + + + + LOADH + + + 34 + + + pushIntStack(cpuReadWord(popIntStack())); + + + Fix! + + + + + STOREH + + + 35 + + +addr = popIntStack();
+ val = popIntStack();
+ cpuWriteWord(addr, val); + + + Fix! + + + + + LESSTHAN + + + 36 + + + Signed comparison
+ a = popIntStack();
+ b = popIntStack();
+ pushIntStack((a < b) ? 1 : 0);
+ + + Fix! + + + + + LESSTHANOREQUAL + + + 37 + + + Signed comparison
+ a = popIntStack();
+ b = popIntStack();
+ pushIntStack((a <= b) ? 1 : 0); + + + Fix! + + + + + ULESSTHAN + + + 37 + + + Unsigned comparison
+ long a;//long is here 64 bit signed integer
+ long b;
+ a = ((long) popIntStack()) & INTMASK; // INTMASK is unsigned 0x00000000ffffffff
+ b = ((long) popIntStack()) & INTMASK;
+ pushIntStack((a < b) ? 1 : 0); + + + Fix! + + + + + ULESSTHANOREQUAL + + + 39 - Fix!! + Unsigned comparison
+ long a;//long is here 64 bit signed integer
+ long b;
+ a = ((long) popIntStack()) & INTMASK; // INTMASK is unsigned 0x00000000ffffffff
+ b = ((long) popIntStack()) & INTMASK;
+ pushIntStack((a <= b) ? 1 : 0); Fix! + + + EQBRANCH + + + 55 + + + int compare;
+ int target;
+ target = popIntStack() + pc;
+ compare = popIntStack();
+ if (compare == 0)
+ {
+ setPc(target);
+ } else
+ {
+ setPc(pc + 1);
+ } + + + Fix! + + + + + NEQBRANCH + + + 56 + + + int compare;
+ int target;
+ target = popIntStack() + pc;
+ compare = popIntStack();
+ if (compare != 0)
+ {
+ setPc(target);
+ } else
+ {
+ setPc(pc + 1);
+ }
+ + + Fix! + + + + + MULT + + + 41 + + + Signed 32 bit multiply
+ pushIntStack(popIntStack() * popIntStack()); + + + Fix! + + + + + DIV + + + 53 + + + Signed 32 bit integer divide.
+ a = popIntStack();
+ b = popIntStack();
+ if (b == 0)
+ {
+ // undefined
+ } + pushIntStack(a / b);
+ + + Fix! + + + + + MOD + + + 54 + + + Signed 32 bit integer modulo.
+ a = popIntStack();
+ b = popIntStack();
+ if (b == 0)
+ {
+ // undefined
+ }
+ pushIntStack(a % b);
+ + + Fix! + + + + + LSHIFTRIGHT + + + 42 + + + unsigned shift right.
+ long shift;
+ long valX;
+ int t;
+ shift = ((long) popIntStack()) & INTMASK;
+ valX = ((long) popIntStack()) & INTMASK;
+ t = (int) (valX >> (shift & 0x3f));
+ pushIntStack(t);
+ + + Fix! + + + + + ASHIFTLEFT + + + 43 + + + arithmetic(signed) shift left.
+ + long shift;
+ long valX;
+ shift = ((long) popIntStack()) & INTMASK;
+ valX = ((long) popIntStack()) & INTMASK;
+ int t = (int) (valX << (shift & 0x3f));
+ pushIntStack(t);
+ + + Fix! + + + + + ASHIFTRIGHT + + + 43 + + + arithmetic(signed) shift left.
+ long shift;
+ int valX;
+ shift = ((long) popIntStack()) & INTMASK;
+ valX = popIntStack();
+ int t = valX >> (shift & 0x3f);
+ pushIntStack(t);
+ + + + Fix! + + + + + + CALL + + + 45 + + + call procedure.
+
+ int address = pop();
+ push(pc + 1);
+ setPc(address);
+ + + Fix! + + + + + CALLPCREL + + + 63 + + + call procedure pc relative
+
+int address = pop();
+ push(pc + 1);
+ setPc(address+pc); + + Fix! + + + + + + + EQ + + + 46 + + + pushIntStack((popIntStack() == popIntStack()) ? 1 : 0); + Fix! + + + + + NEQ + + + 48 + + + pushIntStack((popIntStack() != popIntStack()) ? 1 : 0); + Fix! + + + + + NEG + + + 47 + + + pushIntStack(-popIntStack()); + Fix! + + + + -- cgit v1.1