Skip to content

Commit aa382f7

Browse files
authored
Merge pull request ZigEmbeddedGroup/aviron#22 from Grazfather/patch-2
Actually store result for add
2 parents 830d8d6 + 2c17fcc commit aa382f7

File tree

3 files changed

+55
-1
lines changed

3 files changed

+55
-1
lines changed

simulators/aviron/src/lib/Cpu.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,6 @@ const instructions = struct {
371371
const src = cpu.regs[info.d.num()];
372372

373373
const res = src -% 1;
374-
375374
cpu.regs[info.d.num()] = res;
376375

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

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

391391
const R: Bits8 = @bitCast(res);
392392

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
//! {
2+
//! "exit_code": 0,
3+
//! "stdout": "",
4+
//! "stderr": "Hi"
5+
//! }
6+
7+
#include "../regs.inc"
8+
9+
.global _start
10+
_start:
11+
12+
; '\' + '!' = 'H'
13+
ldi r16, '\''
14+
ldi r18, '!'
15+
add r16, r18
16+
out IO_STDERR, r16
17+
ldi r16, 0x80
18+
ldi r18, 0x80
19+
add r16, r18
20+
; '4' + '4' + carry = 'i'
21+
ldi r17, '4'
22+
ldi r19, '4'
23+
adc r17, r19
24+
out IO_STDERR, r17
25+
26+
clr r16
27+
out IO_EXIT, r16
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
//! {
2+
//! "exit_code": 0,
3+
//! "stdout": "",
4+
//! "stderr": "Hi"
5+
//! }
6+
7+
#include "../regs.inc"
8+
9+
.global _start
10+
_start:
11+
12+
; 'q' - ')' = 'H'
13+
ldi r16, 'q'
14+
ldi r18, ')'
15+
sub r16, r18
16+
out IO_STDERR, r16
17+
ldi r16, 0x80
18+
ldi r18, 0x80
19+
add r16, r18
20+
; '~' - 0x14 - carry = 'i'
21+
ldi r17, '~'
22+
ldi r19, 0x14
23+
sbc r17, r19
24+
out IO_STDERR, r17
25+
26+
clr r16
27+
out IO_EXIT, r16

0 commit comments

Comments
 (0)