aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
Diffstat (limited to 'examples')
-rw-r--r--examples/zero_stream/src/main.zig12
1 files changed, 8 insertions, 4 deletions
diff --git a/examples/zero_stream/src/main.zig b/examples/zero_stream/src/main.zig
index 7ba9ecf..7147972 100644
--- a/examples/zero_stream/src/main.zig
+++ b/examples/zero_stream/src/main.zig
@@ -2,6 +2,8 @@
//
// SPDX-License-Identifier: AGPL-3.0-or-later
+const std = @import("std");
+
const Result = extern struct {
value: usize,
status: usize,
@@ -51,7 +53,8 @@ pub fn main() void {
: "a7", "a1"
);
- const s3 = "Resource opened";
+ var s3_buf: [128]u8 = undefined;
+ const s3 = std.fmt.bufPrint(&s3_buf, "Resource opened, handle = {d}", .{handle}) catch unreachable;
asm volatile (
\\ li a7, 100000
\\ ecall
@@ -61,17 +64,18 @@ pub fn main() void {
: "a7"
);
- var buf: [8]u8 = undefined;
+ var buf = [8]u8{ 1, 2, 3, 4, 5, 6, 7, 8 };
asm volatile (
\\ li a7, 100009
\\ ecall
:
: [handle] "{a0}" (handle),
[buffer] "{a1}" (&buf),
- [len] "{a2}" (buf.len),
+ [len] "{a2}" (buf.len - 1),
);
- const s4 = "Bytes read";
+ var s4_buf: [384]u8 = undefined;
+ const s4 = std.fmt.bufPrint(&s4_buf, "Bytes after reading: {any}\r\n", .{buf}) catch unreachable;
asm volatile (
\\ li a7, 100000
\\ ecall