fix outputs in inline assembly

This commit is contained in:
Jacob G-W 2021-10-17 01:14:27 -04:00
parent 09992f8acc
commit fe314e60bb
2 changed files with 6 additions and 5 deletions

View File

@ -60,8 +60,8 @@ pub const SYS = enum(usize) {
_NSEC = 53,
};
pub fn pwrite(fd: usize, buf: [*]const u8, count: usize, offset: usize) void {
syscall_bits.syscall4(.PWRITE, fd, @ptrToInt(buf), count, offset);
pub fn pwrite(fd: usize, buf: [*]const u8, count: usize, offset: usize) usize {
return syscall_bits.syscall4(.PWRITE, fd, @ptrToInt(buf), count, offset);
}
pub fn exits(status: ?[*:0]const u8) void {

View File

@ -2,8 +2,8 @@ const plan9 = @import("../plan9.zig");
// TODO get ret from inline asm
// TODO better inline asm
pub fn syscall4(sys: plan9.SYS, arg0: usize, arg1: usize, arg2: usize, arg3: usize) void {
asm volatile (
pub fn syscall4(sys: plan9.SYS, arg0: usize, arg1: usize, arg2: usize, arg3: usize) usize {
return asm volatile (
\\push %%r11
\\push %%r10
\\push %%r9
@ -15,7 +15,8 @@ pub fn syscall4(sys: plan9.SYS, arg0: usize, arg1: usize, arg2: usize, arg3: usi
\\pop %%r11
\\pop %%r11
\\pop %%r11
:
: [ret] "={rax}" (-> usize),
// :
: [arg0] "{r8}" (arg0),
[arg1] "{r9}" (arg1),
[arg2] "{r10}" (arg2),