Improving the Linker

The problem As I said, changing from .data to .rodata got rid of the warning about one segment having all permissions, but that’s like a patch, not a fix. To fix it, I need to define more sections in my linker so that they end up in different segments. It’s as easy as defining them the same way I defined the .text section. The solution OUTPUT_ARCH(riscv) ENTRY(_start) SECTIONS { . = 0x80200000; .text : { *(.text) } .rodata : { *(.rodata) } .data : { *(.data) } .bss : { *(.bss) } } It is also important to say that while I didn’t explain properly, when I meant my code was being put in the correct address by luck, I didn’t mean it in that way. What I meant was that the start of my program was being put in the correct address because I had defined before in the linker where it would go, but the fact that it worked without using .global felt like luck because had I misplaced the code on memory it wouldn’t have ran.

June 21, 2026 · 1 min

Improving My Print Function

Touching something that works While it is true that if something works you should not touch it, I read that the best function is the one that behaves like a blackbox. The caller doesn’t know or need to know what’s going on inside the function and the function doesn’t know or need to know what will happen once it goes back. Right now, I have this code: .section .text _start: la t0, string // load the address of string in t0 call print // call the print function, which stores the address to come back in ra (return address) wfi // hang the CPU print: beqz t0, done // if t0 is 0, go to "done" lbu a0, 0(t0) // load the byte at t0 in a0 li a7, 0x01 // load write() into a7 ecall // write addi t0, t0, 1 // add 1 byte to the address in t0: t0 = t0 + 1 j print // go back to the start done: ret // return .section .data string: .asciz "This is a string" As you can see, I load the address of the string in t0 before I call print. This isn’t bad, but it’s not standard. Instead, I should use a0 and handle moving everything inside the function. Since I will need to then move the address into t0, I am gonna use a print label for the preparation step and a print_loop as the label for the “worker”, so like this: ...

June 21, 2026 · 3 min

Writing a printing function in assembly

Printing in assembly sucks One of the many things that help when developing any kind of software is being able to print. Printing can make it easier to follow the values of variables, error messages or even just be like “we’re in step 2 now!” so that you don’t lose track of where you are during testing. However, as it was shown in my previous devlog, printing in assembly is an absolute nightmare. For each and every time I want to show a message on the screen, I have to print each character individually, which means loading the “character” register and the “function” register individually each time and then make the call so that OpenSBI knows what I want to do. Because of that, I am gonna make a function so that I can pass strings and the function takes care of printing for me. ...

June 20, 2026 · 7 min

Hello World!

Greeting the world as we’re always taught No matter what, every single time you learn a new programming language or somehow mess with software that you haven’t yet tried out, you will or should start by the Hello World! program, which is nothing more than getting a text saying exactly that. Since I chose to target firmware instead of hardware so that when I switch to an actual chip I don’t have to rewrite my code, I need to learn what OpenSBI is. ...

June 20, 2026 · 8 min

The Beginning

The reasoning behind the bad idea Although the value of OS projects has been discussed for decades and it is completely true that it is impossible for a single human being to be able to beat what has been built in the span of almost half a century by sheer willpower alone, many fail to identify that it is as much of a waste of time as it is playing videogames, partying or painting (to list a few examples). While a person should aspire to become the best version of themselves and of course aim to be productive in their day-to-day life, they should also not deprive themselves of the comfort that is having activities that aren’t aimed at making the best out of the limited time they have on Earth. If people only worked towards goals that granted them success in areas like money, it would be unhealthy and much harder to maintain than doing the same things but with hobbies aside. If you want to spend your free time doing something, as long as you don’t harm others or yourself, you should do it. ...

June 19, 2026 · 5 min