union reg_data
Represent a register. It is useless, but in use. No overhead anyway, just longer code.
| reg_data | Represent a register. |
| Variables | |
| W | The value of the register |
| CPU | This class represents an ARM7TDMI CPU running at 16.78MHZ with 32 bit registers and two execution modes (ARM32bit, THUMB16bit). |
| Variables | |
| mMemory | Pointer to the GBA Memory Structure. |
| mGPRegisters | The general purpose registers. |
| mCPSR | The Current Program Status Register |
| mSPSR | The Saved Program Status Registers of all the modes that support it. |
| mPrefetch | The pipeline instruction prefetch of the CPU. |
| Functions | |
| CPU | Initializes the CPU. |
| Initialize | Set the cpu to a starting state |
| GetOperationName | Converts arm opcode into assembly language. |
| ExecuteThumbAluOperation | Executes an Alu operation in THUMB Mode. |
| ExecuteOperation | Executes the next operation. |
| WriteRegisterName | Obsolete Function, now not working. |
| Interrupt | Writes to the IF Register the interrupt code. |
| CpsrGetCarry | Getter for the Carry Flag. |
| CpsrGetOverflow | Getter for the Overflow Flag. |
| CpsrGetZero | Getter for the Zero Flag. |
| CpsrGetSign | Getter for the Sign Flag. |
| CpsrGetIRQDisable | Getter for the Interrupt Disable Flag. |
| CpsrGetFIQDisable | Getter for the Fast Interrupt Disable Flag. |
| CpsrGetThumbMode | Getter for the Thumb Mode Flag. |
| CpsrGetMode | Getter for the CPU Mode. |
| CpsrSetCarry | Setter for the Carry Flag. |
| CpsrSetOverflow | Setter for the Overflow Flag. |
| CpsrSetZero | Setter for the Zero Flag. |
| CpsrSetSign | Setter for the Sign Flag. |
| CpsrSetSignByVal | Sets the sign flag according to a value. |
| CpsrSetZeroByVal | Sets the zero flag according to a value. |
| CpsrSetOverflowByVals | Sets the overflow flag looking at the operands. |
| CpsrSetCarryByAddVals | Sets the carry flag looking at the operands of an addition. |
| CpsrSetCarryByAddVals | Sets the carry flag looking at the operands of a subtraction. |
| CpsrSetIRQDisable | Setter for the I Flag. |
| CpsrSetFIQDisable | Setter for the F Flag. |
| CpsrSetThumbMode | Setter for the T Flag. |
| CpsrSetMode | Setter for the Mode field of the CPSR. |
| GetGPRegisterID | Gets the id of a GP register depending on the current mode. |
| GetCpsr | Retrieve Current Program Status Register |
| GetSpsrID | Gets the ID of the register SPSR with a particular mode. |
| GetSpsrVal | Retrieves the value of SPSR. |
| GetGPRegValue | Returns the value contained inside a register (in the current mode). |
| SetAddFlags | Sets the correct flags after an addition. |
| SetSubFlagsByVal | Sets the correct flags after a subtraction. |
| SetSubFlags | Sets the correct flags after a subtraction. |
| SetAddFlagsByVal | Sets the correct flags after an addition. |
| SetGPRegisterValue | Set the value of a register in current Mode. |
| GetPrefetch | Retrieves pipeline prefetch. |
| SetPC | Sets the program counter. |
| SWI_CpuSet | Fastly executes Software Interrupt 0xB (CpuSet). |
| SWI_CpuFastSet | Fastly executes Software Interrupt 0xC (CpuFastSet). |
| SoftwareInterrupt | Generates a Software Interrupt. |
class CPU
This class represents an ARM7TDMI CPU running at 16.78MHZ with 32 bit registers and two execution modes (ARM32bit, THUMB16bit).
| Variables | |
| mMemory | Pointer to the GBA Memory Structure. |
| mGPRegisters | The general purpose registers. |
| mCPSR | The Current Program Status Register |
| mSPSR | The Saved Program Status Registers of all the modes that support it. |
| mPrefetch | The pipeline instruction prefetch of the CPU. |
| Functions | |
| CPU | Initializes the CPU. |
| Initialize | Set the cpu to a starting state |
| GetOperationName | Converts arm opcode into assembly language. |
| ExecuteThumbAluOperation | Executes an Alu operation in THUMB Mode. |
| ExecuteOperation | Executes the next operation. |
| WriteRegisterName | Obsolete Function, now not working. |
| Interrupt | Writes to the IF Register the interrupt code. |
| CpsrGetCarry | Getter for the Carry Flag. |
| CpsrGetOverflow | Getter for the Overflow Flag. |
| CpsrGetZero | Getter for the Zero Flag. |
| CpsrGetSign | Getter for the Sign Flag. |
| CpsrGetIRQDisable | Getter for the Interrupt Disable Flag. |
| CpsrGetFIQDisable | Getter for the Fast Interrupt Disable Flag. |
| CpsrGetThumbMode | Getter for the Thumb Mode Flag. |
| CpsrGetMode | Getter for the CPU Mode. |
| CpsrSetCarry | Setter for the Carry Flag. |
| CpsrSetOverflow | Setter for the Overflow Flag. |
| CpsrSetZero | Setter for the Zero Flag. |
| CpsrSetSign | Setter for the Sign Flag. |
| CpsrSetSignByVal | Sets the sign flag according to a value. |
| CpsrSetZeroByVal | Sets the zero flag according to a value. |
| CpsrSetOverflowByVals | Sets the overflow flag looking at the operands. |
| CpsrSetCarryByAddVals | Sets the carry flag looking at the operands of an addition. |
| CpsrSetCarryByAddVals | Sets the carry flag looking at the operands of a subtraction. |
| CpsrSetIRQDisable | Setter for the I Flag. |
| CpsrSetFIQDisable | Setter for the F Flag. |
| CpsrSetThumbMode | Setter for the T Flag. |
| CpsrSetMode | Setter for the Mode field of the CPSR. |
| GetGPRegisterID | Gets the id of a GP register depending on the current mode. |
| GetCpsr | Retrieve Current Program Status Register |
| GetSpsrID | Gets the ID of the register SPSR with a particular mode. |
| GetSpsrVal | Retrieves the value of SPSR. |
| GetGPRegValue | Returns the value contained inside a register (in the current mode). |
| SetAddFlags | Sets the correct flags after an addition. |
| SetSubFlagsByVal | Sets the correct flags after a subtraction. |
| SetSubFlags | Sets the correct flags after a subtraction. |
| SetAddFlagsByVal | Sets the correct flags after an addition. |
| SetGPRegisterValue | Set the value of a register in current Mode. |
| GetPrefetch | Retrieves pipeline prefetch. |
| SetPC | Sets the program counter. |
| SWI_CpuSet | Fastly executes Software Interrupt 0xB (CpuSet). |
| SWI_CpuFastSet | Fastly executes Software Interrupt 0xC (CpuFastSet). |
| SoftwareInterrupt | Generates a Software Interrupt. |
void GetOperationName( char * buffer, int opcode, int opaddr, bool thumb = false, char * comment = nullptr )
Converts arm opcode into assembly language. Effectively it is a disassembler function.
| buffer | Where the disassembled instruction is placed. The caller have to allocate it. |
| opcode | The opcode you want to disassembly |
| opaddr | The address of the operation (in parameter) useful for computing branch addresses |
| thumb | A boolean value that tells wether it should consider the opcode a thumb instruction or not |
| comment | An optional comment (like DEC-to-HEX translations of values). You have to allocate it. |
inline void ExecuteThumbAluOperation( int op, int rd, int op1, int op2 )
Executes an Alu operation in THUMB Mode.
| op | The alu operation code |
| rd | The destination register id |
| op1 | The first operand (passed as direct value even if in all arm opcodes it is a register) |
| op2 | The second operand (passed as direct value) |
<ExecuteAluOperation> ExecuteOperation
int ExecuteOperation()
Executes the next operation.
The number of consumed cycles.
<ExecuteAluOperation> ExecuteThumbAluOperation
Represent a register.
union reg_data
The value of the register
uint32_t W
This class represents an ARM7TDMI CPU running at 16.78MHZ with 32 bit registers and two execution modes (ARM32bit, THUMB16bit).
class CPU
Pointer to the GBA Memory Structure.
Memory* mMemory
The general purpose registers.
reg_data mGPRegisters[29]
The Current Program Status Register
reg_data mCPSR
The Saved Program Status Registers of all the modes that support it.
reg_data mSPSR[4]
The pipeline instruction prefetch of the CPU.
uint32_t mPrefetch
Initializes the CPU.
CPU( Memory * mem )
Set the cpu to a starting state
void Initialize()
Converts arm opcode into assembly language.
void GetOperationName( char * buffer, int opcode, int opaddr, bool thumb = false, char * comment = nullptr )
Executes an Alu operation in THUMB Mode.
inline void ExecuteThumbAluOperation( int op, int rd, int op1, int op2 )
Executes the next operation.
int ExecuteOperation()
Obsolete Function, now not working.
void WriteRegisterName( char * buffer, int id )
Writes to the IF Register the interrupt code.
inline void Interrupt( int code )
Getter for the Carry Flag.
inline bool CpsrGetCarry()
Getter for the Overflow Flag.
inline bool CpsrGetOverflow()
Getter for the Zero Flag.
inline bool CpsrGetZero()
Getter for the Sign Flag.
inline bool CpsrGetSign()
Getter for the Interrupt Disable Flag.
inline bool CpsrGetIRQDisable()
Getter for the Fast Interrupt Disable Flag.
inline bool CpsrGetFIQDisable()
Getter for the Thumb Mode Flag.
inline bool CpsrGetThumbMode()
Getter for the CPU Mode.
inline int CpsrGetMode()
Setter for the Carry Flag.
inline void CpsrSetCarry( bool value )
Setter for the Overflow Flag.
inline void CpsrSetOverflow( bool value )
Setter for the Zero Flag.
inline void CpsrSetZero( bool value )
Setter for the Sign Flag.
inline void CpsrSetSign( bool value )
Sets the sign flag according to a value.
inline void CpsrSetSignByVal( int val )
Sets the zero flag according to a value.
inline void CpsrSetZeroByVal( int val )
Sets the overflow flag looking at the operands.
inline void CpsrSetOverflowByVals( int op1, int op2, int res )
Sets the carry flag looking at the operands of an addition.
inline void CpsrSetCarryByAddVals( int op1, int op2, int res )
Setter for the I Flag.
inline void CpsrSetIRQDisable( bool value )
Setter for the F Flag.
inline void CpsrSetFIQDisable( bool value )
Setter for the T Flag.
inline void CpsrSetThumbMode( bool value )
Setter for the Mode field of the CPSR.
inline void CpsrSetMode( int value )
Gets the id of a GP register depending on the current mode.
inline int GetGPRegisterID( int regid, int mode )
Retrieve Current Program Status Register
inline uint32_t GetCpsr()
Gets the ID of the register SPSR with a particular mode.
inline int GetSpsrID( int mode )
Retrieves the value of SPSR.
inline int GetSpsrVal()
Returns the value contained inside a register (in the current mode).
inline uint32_t GetGPRegValue( int regid, int pcOff = 8 )
Sets the correct flags after an addition.
inline void SetAddFlags( int op1, int op2, int destinationID )
Sets the correct flags after a subtraction.
inline void SetSubFlagsByVal( int op1, int op2, uint32_t val )
Sets the correct flags after a subtraction.
inline void SetSubFlags( int op1, int op2, int destinationID )
Sets the correct flags after an addition.
inline void SetAddFlagsByVal( int op1, int op2, uint32_t val )
Set the value of a register in current Mode.
inline void SetGPRegisterValue( int regid, uint32_t val )
Retrieves pipeline prefetch.
inline uint32_t GetPrefetch()
Sets the program counter.
inline void SetPC( uint32_t val )
Fastly executes Software Interrupt 0xB (CpuSet).
inline void SWI_CpuSet()
Fastly executes Software Interrupt 0xC (CpuFastSet).
inline void SWI_CpuFastSet()
Generates a Software Interrupt.
inline void SoftwareInterrupt( uint8_t id, int pcOff )
Represents the entire address space of the GBA.
struct Memory
This is the class representing the entire device.
class GBA