Skip to content
This repository was archived by the owner on Apr 21, 2025. It is now read-only.

Commit b900e49

Browse files
authored
Merge pull request #19 from Grazfather/patch-1
Fix popCodeLoc: Pop bytes in reverse order
2 parents 122807d + d931799 commit b900e49

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/lib/Cpu.zig

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -187,15 +187,16 @@ fn popCodeLoc(cpu: *Cpu) u24 {
187187
const mask = @intFromEnum(cpu.code_model);
188188

189189
var pc: u24 = 0;
190-
if ((mask & 0x0000FF) != 0) {
191-
pc |= (@as(u24, cpu.pop()) << 0);
190+
if ((mask & 0xFF0000) != 0) {
191+
pc |= (@as(u24, cpu.pop()) << 16);
192192
}
193193
if ((mask & 0x00FF00) != 0) {
194194
pc |= (@as(u24, cpu.pop()) << 8);
195195
}
196-
if ((mask & 0xFF0000) != 0) {
197-
pc |= (@as(u24, cpu.pop()) << 16);
196+
if ((mask & 0x0000FF) != 0) {
197+
pc |= (@as(u24, cpu.pop()) << 0);
198198
}
199+
199200
return pc;
200201
}
201202

0 commit comments

Comments
 (0)