예제 #1
0
파일: Exprs.cs 프로젝트: ZiCog/HomeSpun
        protected void MakeStackOp(StackOp op, int size, MemorySpace space, int offset, Expr indexExpr, ArrayList bytecodeList)
        {
            // Not for MemorySpace.MEM ops.

            if (indexExpr != null)
            {
                indexExpr.MakeByteCode(true, bytecodeList);
            }

            int opcode;
            if (offset < 32
                && size == 4
                && (space == MemorySpace.VAR || space == MemorySpace.LOCAL)
                && indexExpr == null)
            {	// Use the short form if possible
                if ((offset & 3) != 0)
                    throw new ParseException("Non-long offset", Token);

                opcode = space == MemorySpace.VAR ? 0x40 : 0x60;	// VAR / LOCAL
                opcode |= (byte)op;

                bytecodeList.Add((byte)(opcode + offset));
            }
            else	// we have to use the long form
            {
                opcode = 0x80 | ((size >> 1) << 5) | ((int)space << 2) | (int)op;
                if (indexExpr != null)
                {
                    opcode |= 0x10;
                }

                if (offset < 128)
                {
                    bytecodeList.Add((byte)opcode);
                    bytecodeList.Add((byte)offset);
                }
                else
                {
                    bytecodeList.Add((byte)opcode);
                    bytecodeList.Add((byte)(offset >> 8 | 0x80));
                    bytecodeList.Add((byte)offset);
                }
            }
        }
예제 #2
0
파일: Exprs.cs 프로젝트: ZiCog/HomeSpun
        protected static void MakeStackOp(StackOp op, int size, Expr indexExpr1, Expr indexExpr2, ArrayList bytecodeList)
        {
            // Only for MemorySpace.MEM ops.
            // indexExpr1 should be non-null; indexExpr1 might be null.

            indexExpr1.MakeByteCode(true, bytecodeList);

            if (indexExpr2 != null)
            {
                indexExpr2.MakeByteCode(true, bytecodeList);
            }

            int opcode;
            opcode = 0x80 | ((size >> 1) << 5) | ((int)MemorySpace.MEM << 2) | (int)op;
            if (indexExpr2 != null)
            {
                opcode |= 0x10;
            }
            bytecodeList.Add((byte)opcode);
        }