//---------------------------------------------------------------------- // // MemoryGetOperandAddress // // This routine takes an instruction and a pointer to a PCB, and // returns the address that the instruction is trying to use // for its memory operand. If the instruction doesn't access memory, // it returns 0xffffffff. // //---------------------------------------------------------------------- uint32 MemoryGetOperandAddress (PCB *pcb, uint32 instr) { static uint32 invalidOps = 0x3404; uint32 opcode = (instr >> 26) & 0x3f; uint32 reg; uint32 addr; uint32 offset; if ((opcode<0x20) || (opcode>0x2f) || ((invalidOps >> (opcode-0x20)) & 1)) { return (0xffffffff); } reg = (instr >> 21) & 0x1f; offset = instr & 0xffff; if (offset & 0x8000) { offset |= 0xffff0000; } addr = pcb->registers[reg] + offset; dbprintf ('m', "Operand for instruction %08x is 0x%x (reg=<%d,0x%x>)\n", instr, addr, reg, pcb->registers[reg]); return (addr); }