Page 1 of 1

A new hobby programming language for OS developement?

Posted: Sun Jul 31, 2022 11:18 am
by Spleesh
Just came up with this and wanted some feedback on it. I was just rewriting various assembly programs I've written with more C or Rust like syntax. I'm mostly just doing this for fun and for myself and accept that there are various reasons not to try and replace assembly with a programming language in OS developement. The idea is that this would simultaneously replace C and assembly. I also want it to be describing whats actually happening rather than abstracting it away as much as is reasonable. Reasonable being kind of arbitrary.

Code: Select all

// HELLO WORLD EXAMPLE
const MESSAGE:[b8] = "Hello World";

func main() -> sys_exit {
	stdout = MESSAGE;
	return 0;
}
// PART OF KERNEL MAIN EXAMPLE
func error(val: b8) -> hlt {
	0xb8000 = "ERR: ";
	0xb800a = val;
}

func check_multiboot() {
	if (eax != 0x36d76289) {
		error("M");
	}
	return;
}

func main32() -> hlt {
	check_multiboot();
}

// MULTIBOOT HEADER EXAMPLE
#pragma section .multiboot_header
#define MULTIBOOT2 			0xe85250d6
#define i386				0
#define FRAME_BUFFER_TAG 	5
{
	const MAGIC:b32 = MULTIBOOT2;
	const ARCHITECTURE:b32 = i386;
}
{
	const TAG_TYPE:b16 = FRAME_BUFFER_TAG;
	const OPTIONAL:b16 = 0;
	const WIDTH:b32 = 500;
	const HEIGHT:b32 = 500;
	const DEPTH:b32 = 32;
}
{
	const END0:b16 = 0;
	const END1:b16 = 0;
	const END2:b16 = 0;
}

Re: A new hobby programming language for OS developement?

Posted: Mon Aug 22, 2022 1:25 pm
by Maqstcharub
It doesnt seem too bad, the only problem is actually creating a compiler for that language

Re: A new hobby programming language for OS developement?

Posted: Fri Aug 26, 2022 8:41 am
by AndrewAPrice
Congrats on starting your own language!

You've got a few inconsistencies:

Code: Select all

0xb8000 = "ERR: ";

Code: Select all

if (eax != 0x36d76289)
In the first line, you're assigning to the memory in '0xb8000'. In the second line, you're treating 0x36d76289 as a number literal.

Code: Select all

stdout = MESSAGE;
Are you assigning a variable? If this is a function call, how do you assign a variable?

Code: Select all

func error(val: b8) -> hlt

Code: Select all

const OPTIONAL:b16 = 0;
I like putting the the type after the declaration. It actually makes implementing the parser a little easier.

Code: Select all

if (eax != 0x36d76289)
How do you now 'eax' doesn't get clobbered during the function call to check_multiboot?


Are you trying to invent a high level language (e.g. C?) or trying to invent a high level assembler?

You might be able to start by writing a assembly processor, where you replace mov with =, e.g.:

Code: Select all

[eax] = ebx
and replace local stack locations with typed variables?

Re: A new hobby programming language for OS developement?

Posted: Sun Sep 11, 2022 7:46 am
by azblue
this reminds me of terse

Re: A new hobby programming language for OS developement?

Posted: Thu Sep 15, 2022 1:53 am
by Solar
AndrewAPrice wrote:Are you trying to invent a high level language (e.g. C?)
:lol: :lol: :lol: Good one.

Generally speaking, pick one project. Language, standard library, OS kernel, version control system, ... -- if you work on more than one of those, you're just more likely to fail at all of them.

You don't invent a better hammer in order to make a better sword. You might invent a better hammer, because you feel the ones available aren't good enough. Only when the hammer is done and has proven itself, then think about what your next project might be.