步骤B:vm 执行 LOAD_PTR/STORE_PTR(rs1 值区地址基址+偏移,越界 BadSlot)

This commit is contained in:
2026-08-27 09:14:51 +08:00
parent 68261cd78b
commit f32a8c6aa6
+19
View File
@@ -351,6 +351,25 @@ bool Machine::exec_one() {
} }
return true; return true;
} }
if (std::strcmp(name, "LOAD_PTR") == 0) {
// 基址寻址:rs1 寄存器 = 值区地址(实例指针)+ 偏移,跳过槽表直读
const uint32_t base = static_cast<uint32_t>(fr.regs[d.rs1]);
if (!read_value(base + static_cast<uint32_t>(d.off_hi), func, &v1)) {
fault_ = Fault::BadSlot;
return false;
}
fr.regs[d.rd] = v1;
return true;
}
if (std::strcmp(name, "STORE_PTR") == 0) {
const uint32_t base = static_cast<uint32_t>(fr.regs[d.rs1]);
if (!write_value(base + static_cast<uint32_t>(d.off_hi), func,
fr.regs[d.rd])) {
fault_ = Fault::BadSlot;
return false;
}
return true;
}
if (std::strcmp(name, "NOT") == 0) { if (std::strcmp(name, "NOT") == 0) {
// 逻辑非(恒产 0/1):BOOL 域语义;位串逐位取反需专用指令(v1 无) // 逻辑非(恒产 0/1):BOOL 域语义;位串逐位取反需专用指令(v1 无)
fr.regs[d.rd] = (fr.regs[d.rs1] == 0) ? 1 : 0; fr.regs[d.rd] = (fr.regs[d.rs1] == 0) ? 1 : 0;