WolPSX
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | List of all members
Instruction Struct Reference

Structure to access different parts of an instruction by value. More...

#include <cpu.hpp>

Public Member Functions

 Instruction ()
 Construct a new Instruction object.
 
 Instruction (uint32_t ins)
 Construct a new Instruction object.
 
uint32_t opcode ()
 Opcode of the instruction. Size: 6 bits [31-26].
 
uint32_t rs ()
 Source register for the instruction. Size: 5 bits [25-21].
 
uint32_t rt ()
 Target register for the instruction. Size: 5 bits [20-16].
 
uint32_t rd ()
 Destination register for the instruction. Size: 5 bits [15-11].
 
uint32_t shamt ()
 Shift amount for the instruction. Size: 5 bits [10-6].
 
uint32_t funct ()
 Function field for the instruction. Size: 6 bits [5-0].
 
uint32_t imm ()
 Immediate value for the instruction. Size: 16 bits [15-0].
 
uint32_t addr ()
 Address value for jump/branch instructions. Size: 26 bits [25-0].
 

Public Attributes

uint32_t ins
 

Detailed Description

Structure to access different parts of an instruction by value.

Definition at line 15 of file cpu.hpp.

Constructor & Destructor Documentation

◆ Instruction() [1/2]

Instruction::Instruction ( )
inline

Construct a new Instruction object.

Definition at line 23 of file cpu.hpp.

◆ Instruction() [2/2]

Instruction::Instruction ( uint32_t ins)
inline

Construct a new Instruction object.

Parameters
insInstruction in the form of a 32-bit unsigned integer

Definition at line 30 of file cpu.hpp.

Member Function Documentation

◆ addr()

uint32_t Instruction::addr ( )
inline

Address value for jump/branch instructions. Size: 26 bits [25-0].

Returns
uint32_t Address

Definition at line 88 of file cpu.hpp.

◆ funct()

uint32_t Instruction::funct ( )
inline

Function field for the instruction. Size: 6 bits [5-0].

Used to lookup the functions in case of 'SPECIAL' instructions where the opcode is 0b000000.

Returns
uint32_t Function ID

Definition at line 74 of file cpu.hpp.

◆ imm()

uint32_t Instruction::imm ( )
inline

Immediate value for the instruction. Size: 16 bits [15-0].

Returns
uint32_t Immediate argument

Definition at line 81 of file cpu.hpp.

◆ opcode()

uint32_t Instruction::opcode ( )
inline

Opcode of the instruction. Size: 6 bits [31-26].

Returns
uint32_t Opcode

Definition at line 37 of file cpu.hpp.

◆ rd()

uint32_t Instruction::rd ( )
inline

Destination register for the instruction. Size: 5 bits [15-11].

Returns
uint32_t Register ID

Definition at line 58 of file cpu.hpp.

◆ rs()

uint32_t Instruction::rs ( )
inline

Source register for the instruction. Size: 5 bits [25-21].

Returns
uint32_t Register ID

Definition at line 44 of file cpu.hpp.

◆ rt()

uint32_t Instruction::rt ( )
inline

Target register for the instruction. Size: 5 bits [20-16].

Returns
uint32_t Register ID

Definition at line 51 of file cpu.hpp.

◆ shamt()

uint32_t Instruction::shamt ( )
inline

Shift amount for the instruction. Size: 5 bits [10-6].

Used in the case of shift instructions.

Returns
uint32_t Shift amount

Definition at line 66 of file cpu.hpp.

Member Data Documentation

◆ ins

uint32_t Instruction::ins

Definition at line 17 of file cpu.hpp.


The documentation for this struct was generated from the following file: