diff options
author | Himbeer <himbeer@disroot.org> | 2024-07-02 17:02:14 +0200 |
---|---|---|
committer | Himbeer <himbeer@disroot.org> | 2024-07-02 17:02:14 +0200 |
commit | bf9f0522b91739c8c8915e3f2247fc67d051a56a (patch) | |
tree | 43b11349e634edbe2b49cdf743d60f2bb6d0c85c /examples | |
parent | 47f8d8460a6dca59118c2eff652f803a816ec8ae (diff) |
zero_stream: Print more detailed information about each step
Diffstat (limited to 'examples')
-rw-r--r-- | examples/zero_stream/src/main.zig | 12 |
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 |