com.cmpware.cmp.models
Class PowerPC64

java.lang.Object
  extended by com.cmpware.cmp.Memory
      extended by com.cmpware.cmp.Processor
          extended by com.cmpware.tools.AutoModel
              extended by com.cmpware.cmp.models.PowerPC64
All Implemented Interfaces:
ReadWriteInterface

public class PowerPC64
extends AutoModel

This is an AutoModel implementation of the PowerPC 64 bit processor istructions. It implements all of the standard PowerPC Instruction Set Architecture. In particular, no extensions such as floating point, embedded or the non-portable extensions are implemented in this version, although they can be added fairly easily to this model. The large number of special registers and the unusual addressing are perhaps the biggest complication in the PowerPC model. Only the registers actually used in the implemented instructions are implemented, all others are ignored. This information is taken from the IBM document "PPC405Fx Embedded Processor Core: User's Manual (Preliminary)", IBM Document Number SA14-2764-00, January 28, 2005. PowerPC 64-bit instructions added using the document: "Power ISA" version 2.04, April 3, 2007. Implementation notes: The document specifies Big Endian, but uses bit 0 as the MSB. Field numbers in this model will be (31-n) compared to the IBM document. BCA and BCL decodes swapped. Fixed 4/23/2008 Added missing MULHWU instruction 4/23/2008 AND instruction decoding incorrectly. Fixed 4/23/2008 AND, ANDC, ANDI and ANDIS implemented incorrectly. Fixed 4/24/2008. Added proper disassembly for ANDI, ANDIS, ORI, ORIS, XORI, XORIC. Fixed 4/24/2008. Added proper disassembly for AND, ANDC, NAND, NOR, OR, ORC, XOR. Fixed 4/24/2008.

Copyright (c) 2006 Cmpware, Inc. All Rights Reserved.

Author:
SAG

Nested Class Summary
static class PowerPC64.CR0
          This class defines the fields in the CR Special Register
static class PowerPC64.MSR
          This class defines the fields in the MSR Special Register
static class PowerPC64.SR
          This class defines the Special Register indicies
static class PowerPC64.XER
          This class defines the fields in the XER Special Register
 
Nested classes/interfaces inherited from class com.cmpware.tools.AutoModel
AutoModel.Asm, AutoModel.Decode, AutoModel.Field, AutoModel.Format, AutoModel.Function, AutoModel.Instruction, AutoModel.Symbol
 
Field Summary
static java.lang.String copyright
          Copyright string
static PowerPC_fp fp
          The floating point instructions
 long[] r64
          The 64-bit register file (shadow)
static java.lang.String[] reg64Names
          The IDE names for the 32-bit half registers (two per register)
static AutoModel.Symbol[] regSymbols
          The General Purpose Register Symbols
(package private)  boolean reserve
          The reserve semaphore for lwarx / stwcx / ldarx / stdcx.
(package private)  long reserveAddr
          The reserve address for ldarx / stdcx.
 long[] sr64
          The 64-bit special register file (shadow)
static AutoModel.Symbol[] sregSymbols
          The Special Purpose Register Symbols
 
Fields inherited from class com.cmpware.tools.AutoModel
currentInstr, currentInstrType, instructionSizes, TRACE
 
Fields inherited from class com.cmpware.cmp.Processor
bkpt, branchAddr, branchDelay, breakpointHit, currentBranchDelay, currentInstrCode, cycleCount, elf, idlePower, iMix, instructionSize, name, noop, opcodeName, pc, prevInstr, prevInstrCode, r, regName, runningPower, sr, sregName, stall, stallCount
 
Fields inherited from class com.cmpware.cmp.Memory
BIG, LITTLE
 
Constructor Summary
PowerPC64()
          The constructor
 
Method Summary
static long addCarry(long result, long src1, long src2)
          This method is used to determine if an add carry has occurred.
static long addOverflow(long result, long src1, long src2)
          This method is used to determine if an add overflow has occurred.
 int[] getDebugRegisters()
          This method returns the current values of all of the general purpose registers as they are used by a debugger.
 int getRegister(int i)
          This method returns a general purpose register.
 int[] getRegisters()
          This method returns the current values of all of the general purpose registers.
static void main(java.lang.String[] args)
          This enables the stand-alone assembler and disassembler.
 void postLoad()
          This method it used to perform any operations that may be required after a file is loaded.
 void preExecute(int instr)
          This method is called immediately before execution and may be overloaded to do things like save instruction field values to locals.
 void reset()
          This method resets the processor.
static long rotateLeft(int a, int r)
          This method rotates the value a left by r.
static long rotateLeft(long a, int r)
          This method rotates the value a left by r.
static long sign(long a)
          This method returns the sign bit for 64 bit value.
static long subCarry(long result, long src1, long src2)
          This method is used to determine if a sub carry has occurred.
static long subOverflow(long result, long src1, long src2)
          This method is used to determine if a sub overflow has occurred.
 
Methods inherited from class com.cmpware.tools.AutoModel
advancePC, asmFixup, bitsToBytes, concatenate, dasm, dasm, dasmFixup, decode, defineInstructions, execute, fetch, fetch, getInstruction, getInstructions, getInstructionSizes, getPC, getSymbolNames, instrMatch, main, postExecute, setPC, signExtend, signExtend, toHexString, toHexString, toLong, traceOff, traceOn
 
Methods inherited from class com.cmpware.cmp.Processor
branch, branchNoDelay, defineBranchDelay, defineBreakpoint, defineInstructionSize, defineName, defineNoop, defineOpcodeNames, defineRegisterNames, defineRegisters, defineSpecialRegisterNames, defineSpecialRegisters, get, getBreakpoint, getBreakpointData, getBreakpoints, getCycleCount, getElf, getIdlePower, getInstructionMix, getInstructionSize, getName, getNoop, getOpcodeNames, getRegisterNames, getRunningPower, getSpecialRegister, getSpecialRegisterNames, getSpecialRegisters, getStallCount, isBreakpoint, isStalled, load, removeAllBreakpoints, removeBreakpoint, setBreakpoint, setIdlePower, setRegister, setRunningPower, setSpecialRegister, stall, statistics, step
 
Methods inherited from class com.cmpware.cmp.Memory
addInput, addMemory, addOutput, getEndian, getLocalMemory, getMemoryManager, getMmio, getProfile, hexDump, hexDump, isReadable, isValidAddress, isWriteable, profile, read, read, read16, read24, read32, read64, removeMemory, resize, setEndian, size, toInt, toShort, write, write, write16, write24, write32, write64
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

copyright

public static final java.lang.String copyright
Copyright string

See Also:
Constant Field Values

fp

public static final PowerPC_fp fp
The floating point instructions


r64

public long[] r64
The 64-bit register file (shadow)


sr64

public long[] sr64
The 64-bit special register file (shadow)


reserve

boolean reserve
The reserve semaphore for lwarx / stwcx / ldarx / stdcx. instructions


reserveAddr

long reserveAddr
The reserve address for ldarx / stdcx.


reg64Names

public static final java.lang.String[] reg64Names
The IDE names for the 32-bit half registers (two per register)


regSymbols

public static final AutoModel.Symbol[] regSymbols
The General Purpose Register Symbols


sregSymbols

public static final AutoModel.Symbol[] sregSymbols
The Special Purpose Register Symbols

Constructor Detail

PowerPC64

public PowerPC64()
The constructor

Method Detail

main

public static void main(java.lang.String[] args)
This enables the stand-alone assembler and disassembler. The command line should be either: java PowerPC64 -dasm or java PowerPC64 -asm

Parameters:
args - the command line arguments.

reset

public void reset()
This method resets the processor. Note that super.reset() must me called to completely intialize the processor.

Overrides:
reset in class Processor

getRegisters

public int[] getRegisters()
Description copied from class: Processor
This method returns the current values of all of the general purpose registers.

Overrides:
getRegisters in class Processor
Returns:
This method returns the current values of all of the general purpose registers.

getRegister

public int getRegister(int i)
Description copied from class: Processor
This method returns a general purpose register.

Overrides:
getRegister in class Processor
Parameters:
i - The index of the general purpose register to get.

getDebugRegisters

public int[] getDebugRegisters()
Description copied from class: Processor
This method returns the current values of all of the general purpose registers as they are used by a debugger. This is added for machines that (for instance) have 128 bit registers of which the debugger only uses 32 bits. This is intended to be overloaded in these situations. This method is used exclusively by debuggers and debugger-like tools.

Overrides:
getDebugRegisters in class Processor
Returns:
This method returns the current values of all of the general purpose registers.

postLoad

public void postLoad()
Description copied from class: Processor
This method it used to perform any operations that may be required after a file is loaded. In the PowerPC, for instance, this method sets the TOC address for ELF files which use a TOC section. This method currently does nothing and must be overloaded by specific architectures.

Overrides:
postLoad in class Processor

preExecute

public void preExecute(int instr)
Description copied from class: AutoModel
This method is called immediately before execution and may be overloaded to do things like save instruction field values to locals.

Overrides:
preExecute in class AutoModel
Parameters:
instr - The instruction

addOverflow

public static long addOverflow(long result,
                               long src1,
                               long src2)
This method is used to determine if an add overflow has occurred. This is done by checking the signs of the source operands against the sign of the result.

Parameters:
result - The result of the operation on the src1 and src2 parameters.
src1 - The first source operand.
src2 - The second source operand.
Returns:
This method returns a true if an overflow was detected and false otherwise.

subOverflow

public static long subOverflow(long result,
                               long src1,
                               long src2)
This method is used to determine if a sub overflow has occurred. This is done by checking the signs of the source operands against the sign of the result.

Parameters:
result - The result of the operation on the src1 and src2 parameters.
src1 - The first source operand.
src2 - The second source operand.
Returns:
This method returns a true if an overflow was detected and a false otherwise.

addCarry

public static long addCarry(long result,
                            long src1,
                            long src2)
This method is used to determine if an add carry has occurred. This is done by checking the signs of the source operands against the sign of the result.

Parameters:
result - The result of the operation on the src1 and src2 parameters.
src1 - The first source operand.
src2 - The second source operand.
Returns:
This method returns a one if a carry was detected and a zero otherwise.

subCarry

public static long subCarry(long result,
                            long src1,
                            long src2)
This method is used to determine if a sub carry has occurred. This is done by checking the signs of the source operands against the sign of the result.

Parameters:
result - The result of the operation on the src1 and src2 parameters.
src1 - The first source operand.
src2 - The second source operand.
Returns:
This method returns a one if a carry was detected and a zero otherwise.

sign

public static long sign(long a)
This method returns the sign bit for 64 bit value.

Parameters:
a - The 64 bit value.
Returns:
This method returns the sign bit for 64 bit value.

rotateLeft

public static long rotateLeft(int a,
                              int r)
This method rotates the value a left by r. The value r should be between 0 and 31. The result is undefined for other values of r.

Parameters:
a - the value to be rotated left.
r - The number of bits to left rotate.
Returns:
this method returns the value a left rotated by r bits.

rotateLeft

public static long rotateLeft(long a,
                              int r)
This method rotates the value a left by r. The value r should be between 0 and 63. The result is undefined for other values of r.

Parameters:
a - the value to be rotated left.
r - The number of bits to left rotate.
Returns:
this method returns the value a left rotated by r bits.