Added memory offset mode
This commit is contained in:
parent
5e2ea9394a
commit
c4de3e6d04
9 changed files with 35 additions and 15 deletions
Binary file not shown.
|
|
@ -77,7 +77,7 @@
|
|||
|
||||
@define S_REG_1 0x07
|
||||
@define S_REG_2 0x08
|
||||
@define S_REG_3 0x09
|
||||
@define S_REG_OFFSET 0x09
|
||||
|
||||
@define INST_BIOS_NODE_TOGGLE 0x02
|
||||
## ===============================================================================================
|
||||
|
|
|
|||
|
|
@ -26,6 +26,10 @@
|
|||
mov FL, ACC
|
||||
## ----
|
||||
|
||||
mov reg(S_REG_OFFSET), 0x0000 ## Zero the offset register
|
||||
or FL, 0b0000000000000010 ## Enable offset mode for memory addressing
|
||||
mov FL, ACC
|
||||
|
||||
%low INST_BIOS_NODE_TOGGLE 0x00 ## Disable BIOS Mode before leaving the BIOS
|
||||
jmp MemoryAddresses.MBR ## Jump to start of MBR in memory
|
||||
hlt ## Just in case somehow execution reaches this point
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
.load [dynamic]
|
||||
.load [dynamic, base=0x1740]
|
||||
|
||||
.data
|
||||
$string "Hello BOOTSECTOR!!"
|
||||
|
|
|
|||
|
|
@ -285,7 +285,7 @@ namespace dragon
|
|||
str.add("\n");
|
||||
str.add("|---------------|------------------------------------|------------------------------------|-----|-----------|-----------|");
|
||||
str.add("\n");
|
||||
str.add("| FL: |*%PREV_FL%**************************|**%CURR_FL%*************************| S3 |*%PREV_S3%*|*%CURR_S3%*|");
|
||||
str.add("| FL: |*%PREV_FL%**************************|**%CURR_FL%*************************| OF |*%PREV_OF%*|*%CURR_OF%*|");
|
||||
str.add("\n");
|
||||
str.add("|---------------|------------------------------------|------------------------------------|=====|===========|===========|");
|
||||
str.add("\n");
|
||||
|
|
@ -833,28 +833,28 @@ namespace dragon
|
|||
|
||||
|
||||
tmp = " ", tmpStyle = "";
|
||||
tmp.add(ostd::Utils::getHexStr(minfo.previousInstructionRegisters[dragon::data::Registers::S3], true, 2));
|
||||
tmp.add(ostd::Utils::getHexStr(minfo.previousInstructionRegisters[dragon::data::Registers::OFFSET], true, 2));
|
||||
tmp.addPadding(item_len, ' ', ostd::String::ePaddingBehavior::AllowOddExtraLeft);
|
||||
tmpStyle = "[@@style foreground:Blue]";
|
||||
tmpStyle.add(tmp).add("[@@/]");
|
||||
str.replaceAll("%PREV_S3%", tmpStyle);
|
||||
str.replaceAll("%PREV_OF%", tmpStyle);
|
||||
|
||||
tmp = " ";
|
||||
tmp.add(ostd::Utils::getHexStr(minfo.currentInstructionRegisters[dragon::data::Registers::S3], true, 2));
|
||||
tmp.add(ostd::Utils::getHexStr(minfo.currentInstructionRegisters[dragon::data::Registers::OFFSET], true, 2));
|
||||
tmp.addPadding(item_len, ' ', ostd::String::ePaddingBehavior::AllowOddExtraLeft);
|
||||
if (minfo.currentInstructionRegisters[dragon::data::Registers::S3] != minfo.previousInstructionRegisters[dragon::data::Registers::S3])
|
||||
if (minfo.currentInstructionRegisters[dragon::data::Registers::OFFSET] != minfo.previousInstructionRegisters[dragon::data::Registers::OFFSET])
|
||||
tmpStyle = "[@@style foreground:Black,background:BrightRed]";
|
||||
else
|
||||
tmpStyle = "[@@style foreground:Blue]";
|
||||
tmpStyle.add(tmp).add("[@@/]");
|
||||
str.replaceAll("%CURR_S3%", tmpStyle);
|
||||
str.replaceAll("%CURR_OF%", tmpStyle);
|
||||
}
|
||||
|
||||
ostd::RegexRichString rgxstr(str);
|
||||
rgxstr.fg("InstAddr|Code|StackFrame|DBG BRK|INT Handler|BIOS Mode|SubRoutine", "Magenta");
|
||||
rgxstr.fg("IP|SP|FP|RV|PP|FL|ACC", "Cyan");
|
||||
rgxstr.fg("R10|R2|R3|R4|R5|R6|R7|R8|R9|R1", "BrightGreen");
|
||||
rgxstr.fg("S1|S2|S3", "BrightRed");
|
||||
rgxstr.fg("S1|S2|OF", "BrightRed");
|
||||
rgxstr.fg("PREV", "Red");
|
||||
rgxstr.fg("CURR", "Green");
|
||||
out.pStyled(rgxstr);
|
||||
|
|
|
|||
|
|
@ -203,6 +203,11 @@ namespace dragon
|
|||
m_currentExtension = nullptr;
|
||||
m_currentExtInst = 0x00;
|
||||
m_isDebugBreakPoint = false;
|
||||
m_isOffsetAddressingEnabled = readFlag(data::Flags::OffsetModeEnabled);
|
||||
if (m_isOffsetAddressingEnabled)
|
||||
m_currentOffset = readRegister(data::Registers::OFFSET);
|
||||
else
|
||||
m_currentOffset = 0x0000;
|
||||
uint8_t inst = fetch8();
|
||||
m_currentInst = inst;
|
||||
if (loadExtension())
|
||||
|
|
|
|||
|
|
@ -47,6 +47,8 @@ namespace dragon
|
|||
inline int32_t getSubRoutineCounter(void) const { return m_subroutineCounter; }
|
||||
inline data::CPUExtension* getCurrentCPUExtension(void) const { return m_currentExtension; }
|
||||
inline uint8_t getCurrentCPUExtensionInstruction(void) const { return m_currentExtInst; }
|
||||
inline bool isOffsetAddressingModeEnabled(void) const { return m_isOffsetAddressingEnabled; }
|
||||
inline uint16_t getCurrentOffset(void) const { return m_currentOffset; }
|
||||
|
||||
private:
|
||||
void __debug_store_stack_frame_string_on_push(void);
|
||||
|
|
@ -65,6 +67,9 @@ namespace dragon
|
|||
bool m_debugModeEnabled { false };
|
||||
int32_t m_subroutineCounter { 0 };
|
||||
|
||||
bool m_isOffsetAddressingEnabled { false };
|
||||
uint16_t m_currentOffset { 0x0000 };
|
||||
|
||||
data::CPUExtension* m_extensions[16];
|
||||
data::CPUExtension* m_currentExtension { nullptr };
|
||||
uint8_t m_currentExtInst { 0x00 };
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
#include "VirtualRAM.hpp"
|
||||
|
||||
#include "../tools/GlobalData.hpp"
|
||||
#include "../runtime/DragonRuntime.hpp"
|
||||
|
||||
namespace dragon
|
||||
{
|
||||
|
|
@ -14,26 +15,30 @@ namespace dragon
|
|||
int8_t VirtualRAM::read8(uint16_t addr)
|
||||
{
|
||||
int8_t outVal = 0;
|
||||
if (!m_memory.r_Byte(addr, outVal)) return 0x00; //TODO: Error
|
||||
uint16_t offset = DragonRuntime::cpu.getCurrentOffset();
|
||||
if (!m_memory.r_Byte(addr + offset, outVal)) return 0x00; //TODO: Error
|
||||
return outVal;
|
||||
}
|
||||
|
||||
int16_t VirtualRAM::read16(uint16_t addr)
|
||||
{
|
||||
int16_t outVal = 0;
|
||||
if (!m_memory.r_Word(addr, outVal)) return 0x00; //TODO: Error
|
||||
uint16_t offset = DragonRuntime::cpu.getCurrentOffset();
|
||||
if (!m_memory.r_Word(addr + offset, outVal)) return 0x00; //TODO: Error
|
||||
return outVal;
|
||||
}
|
||||
|
||||
int8_t VirtualRAM::write8(uint16_t addr, int8_t value)
|
||||
{
|
||||
if (!m_memory.w_Byte(addr, value)) return 0; //TODO: Error
|
||||
uint16_t offset = DragonRuntime::cpu.getCurrentOffset();
|
||||
if (!m_memory.w_Byte(addr + offset, value)) return 0; //TODO: Error
|
||||
return value;
|
||||
}
|
||||
|
||||
int16_t VirtualRAM::write16(uint16_t addr, int16_t value)
|
||||
{
|
||||
if (!m_memory.w_Word(addr, value)) return 0; //TODO: Error
|
||||
uint16_t offset = DragonRuntime::cpu.getCurrentOffset();
|
||||
if (!m_memory.w_Word(addr + offset, value)) return 0; //TODO: Error
|
||||
return value;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -166,7 +166,7 @@ namespace dragon
|
|||
inline static constexpr uint8_t ACC = 0x06;
|
||||
inline static constexpr uint8_t S1 = 0x07;
|
||||
inline static constexpr uint8_t S2 = 0x08;
|
||||
inline static constexpr uint8_t S3 = 0x09;
|
||||
inline static constexpr uint8_t OFFSET = 0x09;
|
||||
inline static constexpr uint8_t R1 = 0x0A;
|
||||
inline static constexpr uint8_t R2 = 0x0B;
|
||||
inline static constexpr uint8_t R3 = 0x0C;
|
||||
|
|
@ -185,6 +185,7 @@ namespace dragon
|
|||
{
|
||||
public:
|
||||
inline static constexpr uint8_t InterruptsEnabled = 0;
|
||||
inline static constexpr uint8_t OffsetModeEnabled = 1;
|
||||
};
|
||||
|
||||
class InterruptCodes
|
||||
|
|
|
|||
Loading…
Reference in a new issue