commit af6d2674ebb15b2df9823c5b0206c6907253cf57
parent d6ef8732602f81993bad6a282df580b62eb5cc6a
Author: evenfri <evenfri256@gmail.com>
Date: Thu, 13 Aug 2026 01:13:35 +0800
fix: short to ushort, b1 to b0 in jmp_memory, add increment after write to memory
Diffstat:
2 files changed, 6 insertions(+), 5 deletions(-)
diff --git a/computer_interface.cs b/computer_interface.cs
@@ -15,7 +15,7 @@ public partial class computer_interface : Node {
[Export] public Button button_examine;
emulator emu;
-short curr_addr;
+ushort curr_addr;
byte curr_instr;
public override void _Ready() {
@@ -36,6 +36,7 @@ void write_byte() {
curr_instr = b;
emu.write_byte(b, curr_addr);
update_lamps(b);
+ curr_addr++;
GD.Print($"write byte 0x{b:x2} by 0x{curr_addr:x4}");
}
@@ -44,7 +45,7 @@ void jmp_memory() {
byte b0 = assem_byte(button_memory_bits, 0);
byte b1 = assem_byte(button_memory_bits, 8);
- short r = (short)((b1 << 8) | b0);
+ ushort r = (ushort)((b1 << 8) | b0);
curr_addr = r;
GD.Print($"jump to 0x{curr_addr:x4}");
diff --git a/emulator.cs b/emulator.cs
@@ -1,12 +1,12 @@
public class emulator {
-byte[] memory = new byte[1024*16];
+byte[] memory = new byte[65536];
-public void write_byte(byte b, short addr) {
+public void write_byte(byte b, ushort addr) {
memory[addr] = b;
}
-public byte read_byte(short addr) {
+public byte read_byte(ushort addr) {
return memory[addr];
}