mirror of
https://github.com/RGBCube/serenity
synced 2025-07-24 13:57:35 +00:00
UserspaceEmulator: Add proper segment registers
Some things will flow better if we're able to index into a table of our segment registers.
This commit is contained in:
parent
4f41fada39
commit
30ef30ca09
2 changed files with 13 additions and 4 deletions
|
@ -36,6 +36,11 @@ SoftCPU::SoftCPU(Emulator& emulator)
|
|||
: m_emulator(emulator)
|
||||
{
|
||||
memset(m_gpr, 0, sizeof(m_gpr));
|
||||
|
||||
m_segment[(int)X86::SegmentRegister::CS] = 0x18;
|
||||
m_segment[(int)X86::SegmentRegister::DS] = 0x20;
|
||||
m_segment[(int)X86::SegmentRegister::ES] = 0x20;
|
||||
m_segment[(int)X86::SegmentRegister::SS] = 0x20;
|
||||
}
|
||||
|
||||
void SoftCPU::dump() const
|
||||
|
|
|
@ -56,6 +56,9 @@ public:
|
|||
void push32(u32);
|
||||
u32 pop32();
|
||||
|
||||
u16 segment(X86::SegmentRegister seg) const { return m_segment[(int)seg]; }
|
||||
u16& segment(X86::SegmentRegister seg) { return m_segment[(int)seg]; }
|
||||
|
||||
u32 gpr32(X86::RegisterIndex32 reg) const { return m_gpr[reg].full_u32; }
|
||||
u32& gpr32(X86::RegisterIndex32 reg) { return m_gpr[reg].full_u32; }
|
||||
|
||||
|
@ -109,10 +112,10 @@ public:
|
|||
void set_pf(bool value) { m_pf = value; }
|
||||
void set_cf(bool value) { m_cf = value; }
|
||||
|
||||
u16 cs() const { return 0x18; }
|
||||
u16 ds() const { return 0x20; }
|
||||
u16 es() const { return 0x20; }
|
||||
u16 ss() const { return 0x20; }
|
||||
u16 cs() const { return m_segment[(int)X86::SegmentRegister::CS]; }
|
||||
u16 ds() const { return m_segment[(int)X86::SegmentRegister::DS]; }
|
||||
u16 es() const { return m_segment[(int)X86::SegmentRegister::ES]; }
|
||||
u16 ss() const { return m_segment[(int)X86::SegmentRegister::SS]; }
|
||||
|
||||
u32 read_memory32(X86::LogicalAddress);
|
||||
void write_memory32(X86::LogicalAddress, u32);
|
||||
|
@ -592,6 +595,7 @@ private:
|
|||
Emulator& m_emulator;
|
||||
|
||||
PartAddressableRegister m_gpr[8];
|
||||
u16 m_segment[8] { 0 };
|
||||
|
||||
bool m_of { false };
|
||||
bool m_sf { false };
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue