Skip to content
This repository was archived by the owner on Apr 21, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/lib/Cpu.zig
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,6 @@ const instructions = struct {
const src = cpu.regs[info.d.num()];

const res = src -% 1;

cpu.regs[info.d.num()] = res;

cpu.sreg.z = (res == 0);
Expand All @@ -387,6 +386,7 @@ const instructions = struct {
const Rr: Bits8 = @bitCast(rhs);

const res: u8 = lhs +% rhs +% @intFromBool(c);
cpu.regs[info.d.num()] = res;

const R: Bits8 = @bitCast(res);

Expand Down
27 changes: 27 additions & 0 deletions testsuite/instructions/add.S
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
//! {
//! "exit_code": 0,
//! "stdout": "",
//! "stderr": "Hi"
//! }

#include "../regs.inc"

.global _start
_start:

; '\' + '!' = 'H'
ldi r16, '\''
ldi r18, '!'
add r16, r18
out IO_STDERR, r16
ldi r16, 0x80
ldi r18, 0x80
add r16, r18
; '4' + '4' + carry = 'i'
ldi r17, '4'
ldi r19, '4'
adc r17, r19
out IO_STDERR, r17

clr r16
out IO_EXIT, r16
27 changes: 27 additions & 0 deletions testsuite/instructions/sub.S
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
//! {
//! "exit_code": 0,
//! "stdout": "",
//! "stderr": "Hi"
//! }

#include "../regs.inc"

.global _start
_start:

; 'q' - ')' = 'H'
ldi r16, 'q'
ldi r18, ')'
sub r16, r18
out IO_STDERR, r16
ldi r16, 0x80
ldi r18, 0x80
add r16, r18
; '~' - 0x14 - carry = 'i'
ldi r17, '~'
ldi r19, 0x14
sbc r17, r19
out IO_STDERR, r17

clr r16
out IO_EXIT, r16