|
jmce - 1_02 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjmce.sim.AbstractHardware
jmce.sim.cpu.AbstractCPU
jmce.intel.mcs51.MCS51
public class MCS51
Implementation of Intel MCS51.
The Intel 8051 have a unique 8 bit data memory addressing : When accessed in indirect mode always the DATA memory is referenced, when accessed in direct mode the first 128 byte reference the DATA memory the other 128 byte (Location from 128 to 255) reference the SFR memory.
This class is derived form a previus 8051 emulator and the simulation very well tested.
This CPU honor the AbstractCPU.setCallListener(int, jmce.sim.CallListener)
method.
Field Summary | |
---|---|
static java.lang.String |
CODE_MEMORY
Code memory name |
static java.lang.String |
DATA_MEMORY
Data memory name |
protected static Logger |
log
|
static java.lang.String |
SFR_MEMORY
Special function register memory name |
static java.lang.String |
XDATA_MEMORY
External data memory name |
Fields inherited from class jmce.sim.cpu.AbstractCPU |
---|
interrupts, io, memory, NS100MS, NS1MS |
Fields inherited from interface jmce.intel.mcs51.MCS51Constants |
---|
ACC, AUXR1, B, DPH, DPL, IE, IE_EA, IE_EC, IE_ES, IE_ET0, IE_ET1, IE_ET2, IE_EX0, IE_EX1, P0, P0M1, P0M2, P1, P1M1, P1M2, P2, P2M1, P2M2, P3, P3M1, P3M2, PSW, PSW_AC, PSW_CY, PSW_F0, PSW_F1, PSW_OV, PSW_P, PSW_RS0, PSW_RS1, SBUF, SCON, SCON_RI, SCON_TI, SP, TCON, TCON_TF0, TCON_TF1, TCON_TR0, TCON_TR1, TH0, TH1, TL0, TL1, TMOD, TMOD_C_T0, TMOD_C_T1, TMOD_GATE0, TMOD_GATE1, TMOD_T0_M0, TMOD_T0_M1, TMOD_T1_M0, TMOD_T1_M1 |
Fields inherited from interface jmce.sim.CPU |
---|
BIG_ENDIAN, IO_MEMORY, LITTLE_ENDIAN, MAIN_MEMORY |
Constructor Summary | |
---|---|
MCS51()
Default constructor |
Method Summary | |
---|---|
boolean |
ac()
|
void |
ac(boolean value)
|
protected int |
acc()
Return the value of the accumulator. |
protected void |
acc(int value)
Set the accumulator. |
void |
addSfrReadListener(int a,
MemoryReadListener l)
Deprecated. Use addIOReadListener |
void |
addSfrWriteListener(int address,
MemoryWriteListener l)
Deprecated. Use addIOWriteListener |
int |
code(int addr)
Return byte from the code memory. |
void |
code(int addr,
int value)
|
int |
code16(int addr)
Return a word from the code memory. |
void |
cplBit(int bit)
Complement bit |
boolean |
cy()
|
void |
cy(boolean value)
|
int |
data(int add)
|
void |
data(int add,
int value)
|
int |
fireISR(Interrupt isr)
This function must be overridden from sub class that implements interrupt. |
boolean |
getBit(int add)
Return a bit |
boolean |
getBitCode(int add)
|
java.lang.String |
getBitName(int add)
Return a bit name |
protected Memory |
getData()
Return the memory used as DATA |
protected java.lang.String |
getDataName(int r)
Return a name for DATA address space. |
int |
getDirect(int add)
Get a directy byte of memory. |
protected int |
getDirectCode(int pc)
|
java.lang.String |
getDirectName(int add)
Return the name of a direct byte of memory. |
int |
getDptr(int i)
Return the DPTR register with the specified index |
protected Memory |
getSfr()
Return the memory used as SFR. |
MemoryBit |
getSfrBit(int address,
int bit)
|
OpenCollectorMemoryBit |
getSfrBitOpenCollector(int address,
int bit)
|
protected java.lang.String |
getSfrName(int address)
Return a name for SFR address space |
int |
getWord(int a)
Read one word (16 bit) from the main memory. |
protected Memory |
getXdata()
Return the memory used as XDATA |
protected int |
getXdataHi()
Return the 8 high bit during 8 bit access to XDATA |
void |
init(Hardware parent)
Initialize the hardware. |
protected void |
initListeners()
Add all required memory listeners |
protected void |
initMemories()
Initialize the memories. |
protected void |
initNames()
|
protected void |
initOpcodeDecoder()
|
protected void |
initOpcodes()
Initialize the opcodes. |
protected void |
initPeripherals()
Initialize peripherals. |
protected void |
initRegisters()
Initialize the register. |
boolean |
isInterruptEnabled()
Return the status of the interrupt enable |
boolean |
ov()
|
void |
ov(boolean value)
|
int |
pc()
Return the register used as program counter |
void |
pc(int pc)
Set the program counter. |
int |
pop()
Pop a byte from the stack |
int |
popw()
Pop a word from the stack. |
int |
psw()
Return the PSW. |
void |
psw(int value)
Set the PSW. |
void |
push(int value)
Push a byte in to the stack. |
void |
pushw(int value)
Push a word in to the stack. |
protected int |
r(int r)
|
protected void |
r(int r,
int n)
|
void |
reset()
Reset the CPU and call all installed ResetListener. |
protected void |
setAuxrDptrEnabled()
Enabled the standard AUXR1 dptr. |
void |
setBit(int add,
boolean value)
Set a bit |
void |
setBitName(int add,
java.lang.String name)
Set a bit name |
protected void |
setData(Memory m)
Set the memory used as DATA |
protected void |
setDataName(int r,
java.lang.String name)
Set the name for DATA address space. |
void |
setDirect(int add,
int value)
Set a directy byte of memory. |
void |
setDptrIndex(int i)
Set the current DPTR index |
protected void |
setSfr(Memory m)
Setr the memory used as SFR. |
void |
setSfrBitmap(int i,
int add)
Set the internal address of one bit |
protected void |
setSfrName(int address,
java.lang.String name)
Set a name for SFR address space. |
protected void |
setSfrXdataHi(int sfr)
|
void |
setWord(int a,
int v)
Set one word (16 bit) in the main memory |
protected void |
setXdata(Memory m)
Set the memory used aas XDATA |
int |
sfr(int add)
Return a SFR register. |
void |
sfr(int add,
int value)
Set a SFR. |
boolean |
sfrIsBit(int add,
int mask)
|
void |
sfrReset(int sfr,
int mask)
Reset bits in the the SFR memory. |
void |
sfrSet(int sfr,
int mask)
Set bit in the SFR MEMORY. |
void |
sfrSetBit(int add,
int mask)
|
int |
xdata(int add)
|
void |
xdata(int add,
int value)
|
Methods inherited from class jmce.sim.AbstractHardware |
---|
addHardware, createFrame, getHardware, getHardware, getHardware, getHardware, getHardware, getHardwareCount, getHardwareForName, getHardwareInstances, getHardwareTree, getName, getParent, initSwing, removeHardware, removeHardware, setHardware, setHardware, setName, toString |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface jmce.sim.Hardware |
---|
addHardware, getHardware, getHardware, getHardware, getHardware, getHardwareCount, getHardwareInstances, getHardwareTree, getName, getParent, initSwing, removeHardware, removeHardware, setHardware, setHardware, setName |
Field Detail |
---|
protected static final Logger log
public static final java.lang.String CODE_MEMORY
public static final java.lang.String XDATA_MEMORY
public static final java.lang.String DATA_MEMORY
public static final java.lang.String SFR_MEMORY
Constructor Detail |
---|
public MCS51()
Method Detail |
---|
public final void setWord(int a, int v) throws SIMException
CPU
setWord
in interface CPU
a
- - Addressv
- - value
SIMException
public final int getWord(int a) throws SIMException
CPU
getWord
in interface CPU
a
- - Address
SIMException
protected int getXdataHi() throws SIMException
SIMException
protected void setSfrXdataHi(int sfr)
protected Memory getXdata()
protected Memory getSfr()
protected void setSfr(Memory m)
protected void setXdata(Memory m)
protected Memory getData()
protected void setData(Memory m)
public final int sfr(int add) throws SIMException
SIMException
public final void sfr(int add, int value) throws SIMException
SIMException
public final int getDirect(int add) throws SIMException
The first 128 location (0..127) reference DATA memory the last (128 .. 255) the SFR memory.
add
- - Address 0 .. 255
SIMException
public final void setDirect(int add, int value) throws SIMException
The first 128 location (0..127) reference DATA memory the last (128 .. 255) the SFR memory.
add
- - Address 0 .. 255
SIMException
public java.lang.String getDirectName(int add)
The first 128 location (0..127) reference DATA memory the last (128 .. 255) the SFR memory.
add
- - Address 0 .. 255public final boolean getBitCode(int add) throws SIMException
SIMException
protected final int getDirectCode(int pc) throws SIMException
SIMException
protected void initOpcodes()
public void setBitName(int add, java.lang.String name)
public java.lang.String getBitName(int add)
public void setSfrBitmap(int i, int add)
public final boolean getBit(int add) throws SIMException
SIMException
public final void cplBit(int bit) throws SIMException
SIMException
public final void setBit(int add, boolean value) throws SIMException
SIMException
protected void initRegisters()
protected void setDataName(int r, java.lang.String name)
protected java.lang.String getDataName(int r)
protected void setSfrName(int address, java.lang.String name)
protected java.lang.String getSfrName(int address)
protected void initMemories()
protected void initNames()
protected void initOpcodeDecoder()
protected void initPeripherals() throws SIMException
SIMException
protected void initListeners() throws SIMException
SIMException
public final boolean isInterruptEnabled()
CPU
isInterruptEnabled
in interface CPU
public void init(Hardware parent) throws SIMException
Hardware
init
in interface Hardware
init
in class AbstractCPU
parent
- Parent of this hardware.
SIMException
public void sfrReset(int sfr, int mask) throws SIMException
sfr
- - Address.mask
- - Bit to reset.
SIMException
public void sfrSet(int sfr, int mask) throws SIMException
sfr
- - Address.mask
- - Bit(s) to set.
SIMException
public OpenCollectorMemoryBit getSfrBitOpenCollector(int address, int bit)
public MemoryBit getSfrBit(int address, int bit)
@Deprecated public void addSfrReadListener(int a, MemoryReadListener l)
@Deprecated public void addSfrWriteListener(int address, MemoryWriteListener l)
public final void pc(int pc) throws SIMException
CPU
pc
in interface CPU
pc
- - New value for the program counter.
SIMException
public final int pc() throws SIMException
CPU
pc
in interface CPU
SIMException
protected final int r(int r) throws SIMException
SIMException
protected final void r(int r, int n) throws SIMException
SIMException
public void code(int addr, int value) throws SIMException
SIMException
protected final int acc() throws SIMException
SIMException
protected final void acc(int value) throws SIMException
SIMException
public final int psw() throws SIMException
SIMException
public final void psw(int value) throws SIMException
SIMException
public final void cy(boolean value) throws SIMException
SIMException
public final boolean cy() throws SIMException
SIMException
public final void ac(boolean value) throws SIMException
SIMException
public final boolean ac() throws SIMException
SIMException
public final void ov(boolean value) throws SIMException
SIMException
public final boolean ov() throws SIMException
SIMException
public final int code(int addr) throws SIMException
SIMException
public final int code16(int addr) throws SIMException
SIMException
public final int xdata(int add) throws SIMException
SIMException
public final void xdata(int add, int value) throws SIMException
SIMException
public final int data(int add) throws SIMException
SIMException
public final void data(int add, int value) throws SIMException
SIMException
public final int popw() throws SIMException
SIMException
public final int pop() throws SIMException
SIMException
public final void pushw(int value) throws SIMException
SIMException
public final void push(int value) throws SIMException
SIMException
public void reset() throws SIMException
AbstractCPU
Reset is performed in this order :
reset
in interface Hardware
reset
in class AbstractCPU
SIMException
public boolean sfrIsBit(int add, int mask) throws SIMException
SIMException
public void sfrSetBit(int add, int mask) throws SIMException
SIMException
public final void setDptrIndex(int i) throws SIMException
SIMException
public final int getDptr(int i) throws SIMException
SIMException
public int fireISR(Interrupt isr) throws SIMException
AbstractCPU
fireISR
in interface CPU
fireISR
in class AbstractCPU
SIMException
protected final void setAuxrDptrEnabled()
|
jmce - 1_02 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |