mirror of
https://github.com/ringtailsoftware/uvm32.git
synced 2026-06-06 06:53:39 +00:00
Make syscall names closer to libc
This commit is contained in:
parent
1b868adf87
commit
6735b159ac
17 changed files with 103 additions and 79 deletions
|
|
@ -7,7 +7,7 @@ void main(void) {
|
|||
while(c = getc()) {
|
||||
if (c != 0xFFFFFFFF) {
|
||||
print("Got: ");
|
||||
printx(c);
|
||||
printhex(c);
|
||||
println("");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,11 +11,11 @@ void printFib(int n) {
|
|||
int curr = prev1 + prev2;
|
||||
prev2 = prev1;
|
||||
prev1 = curr;
|
||||
printd(curr);
|
||||
printdec(curr);
|
||||
} else if (i == 1) {
|
||||
printd(prev2);
|
||||
printdec(prev2);
|
||||
} else if (i == 2) {
|
||||
printd(prev1);
|
||||
printdec(prev1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -27,14 +27,14 @@ void fib_recursive(int n, int prev1, int prev2) {
|
|||
}
|
||||
|
||||
int curr = prev1 + prev2;
|
||||
printd(curr);
|
||||
printdec(curr);
|
||||
|
||||
return fib_recursive(n - 1, prev2, curr);
|
||||
}
|
||||
|
||||
void printFibRec(int n) {
|
||||
printd(0);
|
||||
printd(1);
|
||||
printdec(0);
|
||||
printdec(1);
|
||||
fib_recursive(n, 0, 1);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
void main(void) {
|
||||
for (int i=0;i<10;i++) {
|
||||
printd(i);
|
||||
printdec(i);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -28,14 +28,14 @@ fn println(message: &str) {
|
|||
syscall(UVM32_SYSCALL_PRINTLN, addr_value);
|
||||
}
|
||||
|
||||
fn printd(n: u32) {
|
||||
syscall(UVM32_SYSCALL_PRINTD, n);
|
||||
fn printdec(n: u32) {
|
||||
syscall(UVM32_SYSCALL_PRINTDEC, n);
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn main() {
|
||||
for i in 0..10 {
|
||||
printd(i);
|
||||
printdec(i);
|
||||
}
|
||||
println("Hello, world!\0");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
uint32_t count;
|
||||
|
||||
bool loop(void) {
|
||||
printd(count);
|
||||
printdec(count);
|
||||
if (count++ >= 10) {
|
||||
return false;
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -26,10 +26,10 @@ fn mandel() void {
|
|||
y2 = (y * y) >> 12;
|
||||
uvm.yield();
|
||||
}
|
||||
uvm.printc(' ' + @as(u8, @intCast(iter)));
|
||||
uvm.putc(' ' + @as(u8, @intCast(iter)));
|
||||
cx += dx;
|
||||
}
|
||||
uvm.printc('\n');
|
||||
uvm.putc('\n');
|
||||
cy += dy;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ pub inline fn yield() void {
|
|||
_ = syscall(uvm32.UVM32_SYSCALL_YIELD, 0);
|
||||
}
|
||||
|
||||
pub inline fn printc(c:u8) void {
|
||||
_ = syscall(uvm32.UVM32_SYSCALL_PRINTC, c);
|
||||
pub inline fn putc(c:u8) void {
|
||||
_ = syscall(uvm32.UVM32_SYSCALL_PUTC, c);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ export fn main() void {
|
|||
|
||||
while(gameRunning) {
|
||||
const now = uvm.millis();
|
||||
if (uvm.getch()) |key| {
|
||||
if (uvm.getc()) |key| {
|
||||
switch(key) {
|
||||
' ' => nextEvent = mibu.events.Event{.key = .{.code = .{.char = ' '}}},
|
||||
'a' => nextEvent = mibu.events.Event{.key = .{.code = .left}},
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ pub inline fn syscall(id: u32, param: u32) u32 {
|
|||
return val;
|
||||
}
|
||||
|
||||
pub inline fn getch() ?u8 {
|
||||
pub inline fn getc() ?u8 {
|
||||
const key = syscall(uvm32.UVM32_SYSCALL_GETC, 0);
|
||||
if (key == 0xFFFFFFFF) {
|
||||
return null;
|
||||
|
|
@ -49,7 +49,7 @@ pub inline fn yield() void {
|
|||
_ = syscall(uvm32.UVM32_SYSCALL_YIELD, 0);
|
||||
}
|
||||
|
||||
pub inline fn printc(c:u8) void {
|
||||
_ = syscall(uvm32.UVM32_SYSCALL_PRINTC, c);
|
||||
pub inline fn putc(c:u8) void {
|
||||
_ = syscall(uvm32.UVM32_SYSCALL_PUTC, c);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue