From 48027196b10a52d2afdb5856946bcdd32c8561df 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 | 51 +++++++++---------- sysdata/libraries/stn/src/buffer.hb | 6 +-- sysdata/libraries/stn/src/memory.hb | 41 +++------------- sysdata/libraries/stn/src/string.hb | 65 +++++++++++++------------ sysdata/programs/ps2_driver/src/main.hb | 6 +-- 5 files changed, 72 insertions(+), 97 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 8bc8814..43920a6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -391,37 +391,48 @@ dependencies = [ name = "hbbytecode" version = "0.1.0" <<<<<<< HEAD -source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#4a9b9de87fd56a6bbd5d0ca2c622104d4807612b" -======= -source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#faf068885a42aedbb6a2bc50e21cb6d34f211cdb" ->>>>>>> 1f4fce0 (please bugs begone) - -[[package]] -name = "hbbytecode" -version = "0.1.0" -source = "git+https://git.ablecorp.us/ableos/holey-bytes.git#faf068885a42aedbb6a2bc50e21cb6d34f211cdb" - -[[package]] -name = "hblang" -version = "0.1.0" <<<<<<< HEAD source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#4a9b9de87fd56a6bbd5d0ca2c622104d4807612b" ======= source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#faf068885a42aedbb6a2bc50e21cb6d34f211cdb" >>>>>>> 1f4fce0 (please bugs begone) +======= +source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#254d5ed96234c8291770d84b2ac11ef7dd403b28" +>>>>>>> 41b339d (omfg it's fixed 🙏) + +[[package]] +name = "hbbytecode" +version = "0.1.0" +source = "git+https://git.ablecorp.us/ableos/holey-bytes.git#254d5ed96234c8291770d84b2ac11ef7dd403b28" + +[[package]] +name = "hblang" +version = "0.1.0" +<<<<<<< HEAD +<<<<<<< HEAD +source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#4a9b9de87fd56a6bbd5d0ca2c622104d4807612b" +======= +source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#faf068885a42aedbb6a2bc50e21cb6d34f211cdb" +>>>>>>> 1f4fce0 (please bugs begone) +======= +source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#254d5ed96234c8291770d84b2ac11ef7dd403b28" +>>>>>>> 41b339d (omfg it's fixed 🙏) dependencies = [ "hbvm 0.1.0 (git+https://git.ablecorp.us/AbleOS/holey-bytes.git)", - "regalloc2", ] [[package]] name = "hbvm" version = "0.1.0" <<<<<<< HEAD +<<<<<<< HEAD source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#4a9b9de87fd56a6bbd5d0ca2c622104d4807612b" ======= source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#faf068885a42aedbb6a2bc50e21cb6d34f211cdb" >>>>>>> 1f4fce0 (please bugs begone) +======= +source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#254d5ed96234c8291770d84b2ac11ef7dd403b28" +>>>>>>> 41b339d (omfg it's fixed 🙏) dependencies = [ "hbbytecode 0.1.0 (git+https://git.ablecorp.us/AbleOS/holey-bytes.git)", ] @@ -429,7 +440,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)", ] @@ -912,16 +923,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 97bfb91..042de02 100644 --- a/sysdata/libraries/stn/src/string.hb +++ b/sysdata/libraries/stn/src/string.hb @@ -3,45 +3,46 @@ length := fn(ptr: ^u8): int { loop if *(ptr + len) == 0 break else len += 1 return len } -display_int := fn(num: int, p: ^u8): ^u8 { - i := 0 - if num == 0 { - *p = 48; - *(p + 1) = 0 - return p - } - neg := false - if num < 0 { - neg = true +// WTFFF is wrong with display_int +display_int := fn(num: int, p: ^u8): ^u8 { + 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 - } - - 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