Ejemplo n.º 1
0
int32 mba_rdbufW (uint32 mb, int32 bc, uint16 *buf)
{
int32 i, j, ba, mbc, pbc;
uint32 pa, dat;

if (mb >= MBA_NUM)                                      /* valid MBA? */
    return 0;
ba = mba_va[mb];                                        /* get virt addr */
mbc = (MBABC_WR + 1) - mba_bc[mb];                      /* get Mbus bc */
if (bc > mbc)                                           /* use smaller */
    bc = mbc;
for (i = 0; i < bc; i = i + pbc) {                      /* loop by pages */
    if (!mba_map_addr (ba + i, &pa, mb))                /* page inv? */
        break;
    if (!ADDR_IS_MEM (pa)) {                            /* NXM? */
        mba_upd_sr (MBASR_RTMO, 0, mb);
        break;
        }
    pbc = VA_PAGSIZE - VA_GETOFF (pa);                  /* left in page */
    if (pbc > (bc - i))                                 /* limit to rem xfr */
        pbc = bc - i;
    if (DEBUG_PRI (mba_dev[mb], MBA_DEB_XFR))
        fprintf (sim_deb, ">>MBA%d: read, pa = %X, bc = %X\n", mb, pa, pbc);
    if ((pa | pbc) & 1) {                               /* aligned word? */
        for (j = 0; j < pbc; pa++, j++) {               /* no, bytes */
            if ((i + j) & 1) {                          /* odd byte? */
                *buf = (*buf & BMASK) | (ReadB (pa) << 8);
                buf++;
                }
            else *buf = (*buf & ~BMASK) | ReadB (pa);
            }
        }
    else if ((pa | pbc) & 3) {                          /* aligned LW? */
        for (j = 0; j < pbc; pa = pa + 2, j = j + 2) {  /* no, words */
            *buf++ = ReadW (pa);                        /* get word */
            }
        }
    else {                                              /* yes, do by LW */
        for (j = 0; j < pbc; pa = pa + 4, j = j + 4) {
            dat = ReadL (pa);                           /* get lw */
            *buf++ = dat & WMASK;                       /* low 16b */
            *buf++ = (dat >> 16) & WMASK;               /* high 16b */
            }
        }
    }
mba_bc[mb] = (mba_bc[mb] + i) & MBABC_WR;
mba_va[mb] = (mba_va[mb] + i) & MBAVA_WR;
return i;
}
Ejemplo n.º 2
0
void CLispEng::Disassemble(ostream& os, CP p) {
	CClosure *c = ToCClosure(p);
	g_pClos = c;
	os << "Closure " << hex << p << "\n";
	Print(c->NameOrClassVersion);
	os << "\nConsts:";
	if (AsArray(p)->DataLength)
		for (size_t i=0; i<AsArray(p)->DataLength; ++i) {
			os << "\n  CONST[" << i << "] = ";
			Print(c->Consts[i]);
		}
	os << "\n\n";
	int off = c->Flags & FLAG_KEY ? CCV_START_KEY : CCV_START_NONKEY;
	byte *prevPb = CurVMContext->m_pb;
	for (ssize_t i = off; i<AsArray(c->CodeVec)->GetVectorLength();) {
		byte *pb = (byte*)AsArray(c->CodeVec)->m_pData; 
		os << DWORD(i-off) << "\t";
		byte b = pb[i++];
		os << Convert::ToString(b, "X2") << "  " << g_arOpcode[b] << "\t";
		VM_CONTEXT;
		CurVMContext->m_pb = pb+i;
		switch (b) {
		case COD_CALLS1:
		case COD_CALLS2:
		case COD_CALLS1_PUSH:
		case COD_CALLS2_PUSH:
			os << int(ReadB());
			break;
		case COD_CALLSR:
		case COD_CALLSR_PUSH:
			os << ReadU() << " ";
			os << int(ReadB());
			break;
		case COD_CALLS1_JMPIF:
		case COD_CALLS1_JMPIFNOT:
		case COD_CALLS2_JMPIF:
		case COD_CALLS2_JMPIFNOT:
			os << int(ReadB()) << " ";
			ReadPrintLabel(os);
			break;
		case COD_BLOCKOPEN:
		case COD_LOAD_JMPIF:
		case COD_LOAD_JMPIFNOT:
		case COD_CALL1_JMPIF:
		case COD_CALL1_JMPIFNOT:
		case COD_CALL2_JMPIF:
		case COD_CALL2_JMPIFNOT:
		case COD_JMPIFBOUNDP:
		case COD_JMPIFEQTO:
		case COD_JMPIFNOTEQTO:
			os << ReadU() << " ";
			ReadPrintLabel(os);
			break;
		case COD_CALLSR_JMPIF:
		case COD_CALLSR_JMPIFNOT:
			os << ReadU() << " " << ReadU() << " ";
			ReadPrintLabel(os);
			break;
		case COD_CATCHOPEN:
		case COD_UWPOPEN:
		case COD_JSR:
		case COD_JMP:
		case COD_JMPIF:
		case COD_JMPIF1:
		case COD_JMPIFNOT:
		case COD_JMPIFNOT1:
		case COD_JMPIFATOM:
		case COD_JMPIFCONSP:
		case COD_JMPIFEQ:
		case COD_JMPIFNOTEQ:
			ReadPrintLabel(os);
			break;
		case COD_RETURNFROM:
		case COD_JMPHASH:
		case COD_JMPHASHV:
		case COD_APPLY:
		case COD_CALL0:
		case COD_CALL1:
		case COD_CALL2:
		case COD_CALL1_PUSH:
		case COD_CALL2_PUSH:
		case COD_CONST_PUSH:
		case COD_POP_STORE:
		case COD_LOAD:
		case COD_LOAD_PUSH:
		case COD_SETVALUE:
		case COD_LOAD_CAR_PUSH:
		case COD_LOAD_CDR_STORE:
		case COD_LOAD_INC_PUSH:
		case COD_LOAD_DEC_PUSH:
		case COD_LOAD_INC_STORE:
		case COD_LOAD_DEC_STORE:
		case COD_GETVALUE:
		case COD_GETVALUE_PUSH:
		case COD_PUSH_UNBOUND:
		case COD_PUSH_NIL:
		case COD_BIND:
		case COD_UNBIND:
		case COD_UNBOUND_NIL:
		case COD_NVTOSTACK:
		case COD_SKIP:
		case COD_SKIP_RET:
		case COD_SKIP_RETGF:
		case COD_FUNCALL:
		case COD_FUNCALL_PUSH:
		case COD_MAKEVECTOR1_PUSH:
		case COD_CONST:
		case COD_CONST_SYMBOLFUNCTION:
		case COD_CONST_SYMBOLFUNCTION_PUSH:
		case COD_LIST_PUSH:
		case COD_LISTSTERN_PUSH:
		case COD_STACKTOMV:
		case COD_BOUNDP:
		case COD_HANDLEROPEN:
			os << ReadU();
			break;
		case COD_CALL:
		case COD_CALL_PUSH:
		case COD_LOADC:
		case COD_LOADV:
		case COD_LOADV_PUSH:
		case COD_STOREC:
		case COD_STOREV:
		case COD_COPYCLOSURE:
		case COD_COPYCLOSURE_PUSH:
		case COD_FUNCALL_SKIP_RETGF:
		case COD_APPLY_SKIP_RET:
		case COD_UNLISTSTERN:
		case COD_UNLIST:
		case COD_SKIPSP:
			os << ReadU() << " ";
			os << ReadU();
			break;
		case COD_RETURNFROMI:
		case COD_LOADI:
		case COD_LOADI_PUSH:
		case COD_CALLSR_STORE:
			os << ReadU() << " ";
			os << ReadU() << " ";
			os << ReadU();
			break;
		case COD_STOREIC:
			os << ReadU() << " ";
			os << ReadU() << " ";
			os << ReadU() << " ";
			os << ReadU();
			break;
		}
		i = CurVMContext->m_pb-pb;

		os << "\n";
	}
	CurVMContext->m_pb = prevPb;
	os << endl;
}