Okay, I think I got how this could be done.
The low level part of the kernel itself is best written in something like assembly and/or C, with a built-in custom BF interpreter (written in the same language as the kernel) on top. Writing a BrainFuck interpreter isn't that hard, it's just eight byte-long instructions in a row. Whitespace is ignored, as well as, as far as I know, other non-instructional characters. You could also write a "comment" extension.
As most of you interested in this topic know, the BrainFuck base language has eight instructions:
Code:
Command Description
----------------------
> Move the pointer to the right
< Move the pointer to the left
+ Increment the memory cell under the pointer
- Decrement the memory cell under the pointer
. Output the character signified by the cell at the pointer
, Input a character and store it in the cell at the pointer
[ Jump past the matching ] if the cell under the pointer is 0
] Jump back to the matching [ if the cell under the pointer is nonzero
There's also a few interesting extensions, including
the # and ! instructions and
BrainFuck++, which adds file I/O and, apparently, networking support. More "extensions" and related languages can be found
here.
I propose the following two additions for OS development:
Code:
Command Description
----------------------
% Reads the memory cell under the pointer as an I/O port number for an IN instruction, storing the inputted byte at *(p+1)
@ Reads the memory cell under the pointer as an I/O port number for an OUT instruction, outputting the byte at *(p+1)
A limitation I find with BrainFuck is the inability to nest [ ] sequences. However, this is likely an easy thing to implement (nested stack work is all. This is best done in assembly language.)
Okay, I think I'm going to try writing a BrainFuck OS now.
_________________
Solar wrote:
It keeps stunning me how friendly we - as a community - are towards people who start programming "their first OS" who don't even have a solid understanding of pointers, their compiler, or how a OS is structured.
I wish I could add more tex