From 41b339dfd012af4f00de77f572b9987dadb32daa Mon Sep 17 00:00:00 2001 From: koniifer Date: Mon, 16 Sep 2024 21:56:52 +0100 Subject: [PATCH] =?UTF-8?q?omfg=20it's=20fixed=20=F0=9F=99=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Cargo.lock | 21 ++------- sysdata/libraries/stn/src/buffer.hb | 6 +-- sysdata/libraries/stn/src/memory.hb | 41 ++++------------ sysdata/libraries/stn/src/string.hb | 62 +++++++++++++------------ sysdata/programs/ps2_driver/src/main.hb | 6 +-- 5 files changed, 50 insertions(+), 86 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 929e8d2..a5253d8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -390,26 +390,25 @@ dependencies = [ [[package]] name = "hbbytecode" version = "0.1.0" -source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#faf068885a42aedbb6a2bc50e21cb6d34f211cdb" +source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#254d5ed96234c8291770d84b2ac11ef7dd403b28" [[package]] name = "hbbytecode" version = "0.1.0" -source = "git+https://git.ablecorp.us/ableos/holey-bytes.git#faf068885a42aedbb6a2bc50e21cb6d34f211cdb" +source = "git+https://git.ablecorp.us/ableos/holey-bytes.git#254d5ed96234c8291770d84b2ac11ef7dd403b28" [[package]] name = "hblang" version = "0.1.0" -source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#faf068885a42aedbb6a2bc50e21cb6d34f211cdb" +source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#254d5ed96234c8291770d84b2ac11ef7dd403b28" dependencies = [ "hbvm 0.1.0 (git+https://git.ablecorp.us/AbleOS/holey-bytes.git)", - "regalloc2", ] [[package]] name = "hbvm" version = "0.1.0" -source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#faf068885a42aedbb6a2bc50e21cb6d34f211cdb" +source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#254d5ed96234c8291770d84b2ac11ef7dd403b28" dependencies = [ "hbbytecode 0.1.0 (git+https://git.ablecorp.us/AbleOS/holey-bytes.git)", ] @@ -417,7 +416,7 @@ dependencies = [ [[package]] name = "hbvm" version = "0.1.0" -source = "git+https://git.ablecorp.us/ableos/holey-bytes.git#faf068885a42aedbb6a2bc50e21cb6d34f211cdb" +source = "git+https://git.ablecorp.us/ableos/holey-bytes.git#254d5ed96234c8291770d84b2ac11ef7dd403b28" dependencies = [ "hbbytecode 0.1.0 (git+https://git.ablecorp.us/ableos/holey-bytes.git)", ] @@ -900,16 +899,6 @@ dependencies = [ "bitflags 1.3.2", ] -[[package]] -name = "regalloc2" -version = "0.10.2" -source = "git+https://github.com/jakubDoka/regalloc2.git#34d8424a0d74746d231a96239fdb32e3d5ec0245" -dependencies = [ - "hashbrown", - "rustc-hash", - "smallvec", -] - [[package]] name = "regex-syntax" version = "0.8.4" diff --git a/sysdata/libraries/stn/src/buffer.hb b/sysdata/libraries/stn/src/buffer.hb index ef5bf71..aa7c43f 100644 --- a/sysdata/libraries/stn/src/buffer.hb +++ b/sysdata/libraries/stn/src/buffer.hb @@ -4,10 +4,8 @@ receive_message := fn(buffer_id: int, memory_map_location: ^u8, length: int): ^u return @eca(^u8, 4, buffer_id, memory_map_location, length) } -send_message := fn(msg: ^u8, buffer_id: int): void { - msg_length := @inline(string.length, msg) - @eca(i32, 3, buffer_id, msg, msg_length) - return +send_message := fn(msg: ^u8, buffer_id: int, length: int): void { + return @eca(void, 3, buffer_id, msg, length) } create := fn(msg: ^u8): int { diff --git a/sysdata/libraries/stn/src/memory.hb b/sysdata/libraries/stn/src/memory.hb index f9cb6df..4feafa0 100644 --- a/sysdata/libraries/stn/src/memory.hb +++ b/sysdata/libraries/stn/src/memory.hb @@ -17,48 +17,23 @@ release_page := fn(ptr: ^u8, page_count: u8): void { return @eca(void, 3, 2, msg, 12) } -// outb := fn(addr: u16, value: u8): void { -// msg := [u8; 5].(1, 0, @as(u8, addr & 0xFF), @as(u8, addr >> 8 & 0xFF), value) -// return @eca(void, 3, 3, &msg, 5) -// } - -// inb := fn(addr: u16): u8 { -// msg := [u8; 4].(0, 0, @as(u8, addr & 0xFF), @as(u8, addr >> 8 & 0xFF)) -// return @eca(u8, 3, 3, &msg, 4) -// } +OutbMsg := struct {a: u8, b: u8, addr: u16, value: u8} +InbMsg := struct {a: u8, b: u8, addr: u16} +OutlMsg := struct {a: u8, b: u8, addr: u16, value: u32} +InlMsg := struct {a: u8, b: u8, addr: u16} outb := fn(addr: u16, value: u8): void { - msg := "\0\0\0\0\0"; - *@as(^u8, msg) = @as(u8, 1); - *@as(^u8, msg + 1) = @as(u8, 0); - *@as(^u16, @bitcast(msg + 2)) = addr; - *@as(^u8, msg + 4) = value - @eca(void, 3, 3, msg, 5) - return + return @eca(void, 3, 3, &OutbMsg.(1, 0, addr, value), @sizeof(OutbMsg)) } inb := fn(addr: u16): u8 { - msg := "\0\0\0\0"; - *@as(^u8, msg) = @as(u8, 0); - *@as(^u8, msg + 1) = @as(u8, 0); - *@as(^u16, @bitcast(msg + 2)) = addr - return @eca(u8, 3, 3, msg, 4) + return @eca(u8, 3, 3, &InbMsg.(0, 0, addr), @sizeof(InbMsg)) } outl := fn(addr: u16, value: u32): void { - msg := "\0\0\0\0\0\0\0\0"; - *@as(^u8, msg) = @as(u8, 1); - *@as(^u8, msg + 1) = @as(u8, 2); - *@as(^u16, @bitcast(msg + 2)) = addr; - *@as(^u32, @bitcast(msg + 4)) = value - @eca(void, 3, 3, msg, 8) - return + return @eca(void, 3, 3, &OutlMsg.(1, 2, addr, value), @sizeof(OutlMsg)) } inl := fn(addr: u16): u32 { - msg := "\0\0\0\0"; - *@as(^u8, msg) = @as(u8, 0); - *@as(^u8, msg + 1) = @as(u8, 2); - *@as(^u16, @bitcast(msg + 2)) = addr - return @eca(u32, 3, 3, msg, 4) + return @eca(u32, 3, 3, &InlMsg.(0, 2, addr), @sizeof(InlMsg)) } \ No newline at end of file diff --git a/sysdata/libraries/stn/src/string.hb b/sysdata/libraries/stn/src/string.hb index 5b5c8ef..042de02 100644 --- a/sysdata/libraries/stn/src/string.hb +++ b/sysdata/libraries/stn/src/string.hb @@ -4,43 +4,45 @@ length := fn(ptr: ^u8): int { return len } +// WTFFF is wrong with display_int display_int := fn(num: int, p: ^u8): ^u8 { - i := 0 - if num == 0 { - *p = 48; - *(p + 1) = 0 - return p - } - - neg := num < 0 - if neg { + ptr := p + negative := num < 0 + if negative { num = -num } - - loop if num == 0 break else { - *(p + i) = num % 10 + 48 - num /= 10 - i += 1 + if num == 0 { + *ptr = 48 + ptr += 1 + } else { + loop if num == 0 break else { + *ptr = num % 10 + 48 + ptr += 1 + num /= 10 + } } - - if neg { - *(p + i) = 45 - i += 1 - } - @inline(reverse, p, i) - + if negative { + *ptr = 45 + ptr += 1 + }; + *ptr = 0 + @inline(reverse, p) return p } -reverse := fn(p: ^u8, len: int): void { - start := 0 - end := len - 1 - loop if start >= end break else { - temp := *(p + start); - *(p + start) = *(p + end); - *(p + end) = temp - start += 1 - end -= 1 +reverse := fn(s: ^u8): void { + //reverse a string, don't remove digits + len := 0 + loop if *(s + len) == 0 break else len += 1 + i := 0 + j := len - 1 + temp := 0 + loop if i >= j break else { + temp = *(s + i); + *(s + i) = *(s + j); + *(s + j) = temp + i += 1 + j -= 1 } return } \ No newline at end of file diff --git a/sysdata/programs/ps2_driver/src/main.hb b/sysdata/programs/ps2_driver/src/main.hb index f727978..5096f7a 100644 --- a/sysdata/programs/ps2_driver/src/main.hb +++ b/sysdata/programs/ps2_driver/src/main.hb @@ -12,7 +12,7 @@ main := fn(): int { log.info("PS/2 Keyboard Echoed\0") } a := 0 - a += 1 + // a += 1 if send_byte(244) == 250 { log.info("Enabled scanning\0") } @@ -26,8 +26,8 @@ main := fn(): int { } prev_input = input keycode_str := string.display_int(input, ptr) - log.info(string.display_int(input, ptr)) - buffer.send_message(keycode_str, buf) + log.info(keycode_str) + buffer.send_message(&input, buf, 1) } return 0 } \ No newline at end of file