Module cpu
CPU provides access to read/write operations on the emulated CPU's general purpose registers (GPRs).
The CPU that is targetted by these functions is the one being emulated on the current caller thread. Because of that, these functions can not be run on threads that are not emulating CPUs, as it may result in undefined behaviour.
Functions
getReg (idx) | Read value of register from R0 - R15. |
getCpsr () | Read the CPSR register value. |
getPc () | Get the current program counter (PC) of the CPU. |
getSp () | Get the current stack pointer (SP) of the CPU. |
getLr () | Get the current stack pointer (LR) of the CPU. |
setReg (idx, val) | Set value of register from R0 - R15. |
Functions
- getReg (idx)
-
Read value of register from R0 - R15.
Parameters:
- idx The index of the register (0 - 15). Value outside the given range may produce undefined behaviour.
Returns:
-
The value currently stored in the targetted register.
- getCpsr ()
-
Read the CPSR register value.
Returns:
-
CPSR register value.
- getPc ()
-
Get the current program counter (PC) of the CPU.
This call is identical to cpu.getReg(15) (PC is R15)
Returns:
-
Register PC's value
- getSp ()
-
Get the current stack pointer (SP) of the CPU.
This call is identical to cpu.getReg(13) (SP is R13)
Returns:
-
Register SP's value
- getLr ()
-
Get the current stack pointer (LR) of the CPU.
This call is identical to cpu.getReg(14) (LR is R14)
Returns:
-
Register SP's value
- setReg (idx, val)
-
Set value of register from R0 - R15.
Parameters:
- idx The index of the register (0 - 15). Value outside the given range may produce undefined behaviour.
- val The value that is to write to the destinated register.