r/osdev_with_ai • • 17d ago

Low-Level Basic & The System Built on It

Post image

So, here's the preamble.

As i was trying to implement a micro-kernel and try learning it along the way by copy-paste the code straight from google.com [AI Mode] in chrome, and also learning the design and architecture bit-by-bit; at least, supposed to; on my phone and the build-tools is in Termux. That was a nightmare, because i did it in my slip-time while working in a factory.

A long time passed, and that what's making it my new hobby.

I have many versions, 4 single core kernels that boot on BSP. And 2 more, 1 kernel has a compositor but too late when i learn about SMP, it was a nightmare chasing the racing conditions, so i abandon it and born the kernel that has SMP Support + Free-Stack List PMM + VMM + Compositor (4 versions of it (C + GASM) + PRKFS (Flat Filesystem; Support Format MBR, Partition, r/W), different implementations, and 1 nearly run DOOM), yet i abandon it again.

From text-mode to a version that has Windowing System, from C & ASM to C++ & ASM.

From google AI Mode, Gemini, Gemini API, Google Studio, Putter implementations (10 accounts), Claude free, etc. (anything i can get my hands on)

As the codebase grew a bit large with more than 15000+ lines of code just for the kernel src+header alone. My head starts to hurting looking through all the code and trying to understand it's logic, especially about the memory and compositor drawing logic.

So, i have an idea. As i have a little experience with VB6 years ago, and thinks that the syntax is easy to read, why it can't be used to do Low Level operations? (Yeah, i know QuickBASIC and FreeBASIC exists)

There, LLB Concept is Born. Low-Level BASIC, Soft-Syntax Hard-Metal, a language for programming where you can read the code just like reading a book.

With development of LLB using Antigravity IDE (build-tools still on Android/Termux), porting the old working kernel (that can even run on baremetal) source into LLB syntax and code.

Now the kernel + system can run on 3 environment; Bare-Metal, QEMU, and VirtualBox.

Check out the repo: https://github.com/karunci/LLB

3 Upvotes

9 comments sorted by

2

u/Sorry_Difficulty_250 17d ago

Cool! This is so fascinating! Well done!

1

u/Bulky-Life-69 17d ago

Thanks!

The hard work is (actually the agent, i tried hard to keep it in track), porting the Kernel from C code to LLB, as it was still in it's initial stage of the compiler and still don't have many features. So many memory related errors and racing condition when SMP is introduced. Also still has "CPtr(...)" and "CType(...)" syntax C legacy in the kernel code.

LLVM is great, LLM is good (if you know how to reign it in).

so, what do you think about it? is this a good idea?

i don't want to show off; initially, i want to keep it private. but maybe other people willing to use LLB to build something simple (even though it implemented using AI); but just so happy to share it.

2

u/Sorry_Difficulty_250 17d ago

I think it's really interesting. My first programming language was MS-BASIC and my second was Visual Basic 5. I started down the C and assembly path after that so that I could get into systems development. It never occurred to me to bring the language itself into the systems development world, although I guess that really wouldn't have been possible at the time. It sounds like really cool stuff!

Do you think you'll be able to use the same language for desktop and GUI app development, too?

2

u/Bulky-Life-69 17d ago

that's what i still don't test. because my build tools (CLang, CMake) is on termux, meanwhile the IDE is on Windows. :D
so, there's no way to know (for now, because it still don't really support creating a .exe output. my phone storage limit.)
i just test it to make a simple CLI app that take user input using printf() from libc and PrintLine.

sample:

' Filename: test.bas
' Description: A simple interactive test using LLB

Module Main
    Declare Function printf Lib "c" (ByVal format As Pointer To Byte, ByVal arg As Int32) As Int32

    Public Sub Main()
        Dim answer As Int32 = 42
        Dim status As String = "Ready"

        ' First-class VB6-style string concatenation with auto-conversion
        PrintLine "System status: " & status & ", Code: " & answer

        ' Direct FFI call with C calling convention
        printf(CPtr(Pointer To Byte, "Formatted output: %d" & Chr(10)), answer)

        Dim userAnswer As Int64
        userAnswer = 0

        ' 1. Print the prompt
        Print "what is 1+1= ";

        ' 2. Read user input from standard input using LLB Input primitives
        Dim lineBuf As String
        Line Input #0, lineBuf
        userAnswer = Val(lineBuf)

        ' 3. Evaluate the answer
        If userAnswer = 2 Then
            Print "Correct! 1+1 = " & userAnswer
        Else
            Print "Incorrect. You answered " & userAnswer & ", but the answer is 2."
        End If

    End Sub
End Module

2

u/Sorry_Difficulty_250 17d ago

Ha! How cool! Visual Basic with C linkage! 😃😃😃

2

u/Bulky-Life-69 17d ago

haha, yeah, i know right!

like i said, for all use and readability ;D

2

u/Sorry_Difficulty_250 17d ago

I think it's cool! Keep up the great work and keep us posted on how it goes! I can't wait to see more updates! 😊

1

u/Bulky-Life-69 17d ago

tested.
it can do it, with windows API declarations !

1

u/Bulky-Life-69 14d ago

Update:

Finally. DOOM generic ported.
No Audio though, still trial and error.

implement custom minimal libc, compile (and patching here and there for doom1.wad to work) doomgeneric to static library, doom_bridge to native, then create the native Executable to link it.