A new hobby programming language for OS developement?

Programming, for all ages and all languages.
Post Reply
Spleesh
Posts: 1
Joined: Sun Jul 31, 2022 11:11 am

A new hobby programming language for OS developement?

Post 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;
}
Maqstcharub
Posts: 4
Joined: Thu Mar 31, 2022 1:39 pm
Libera.chat IRC: gimbo

Re: A new hobby programming language for OS developement?

Post by Maqstcharub »

It doesnt seem too bad, the only problem is actually creating a compiler for that language
User avatar
AndrewAPrice
Member
Member
Posts: 2299
Joined: Mon Jun 05, 2006 11:00 pm
Location: USA (and Australia)

Re: A new hobby programming language for OS developement?

Post 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?
My OS is Perception.
azblue
Member
Member
Posts: 147
Joined: Sat Feb 27, 2010 8:55 pm

Re: A new hobby programming language for OS developement?

Post by azblue »

this reminds me of terse
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Re: A new hobby programming language for OS developement?

Post 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.
Every good solution is obvious once you've found it.
Post Reply