OSDev.org

The Place to Start for Operating System Developers
It is currently Thu Mar 28, 2024 7:35 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: A new hobby programming language for OS developement?
PostPosted: Sun Jul 31, 2022 11:18 am 
Offline

Joined: Sun Jul 31, 2022 11:11 am
Posts: 1
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:
// 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;
}


Top
 Profile  
 
 Post subject: Re: A new hobby programming language for OS developement?
PostPosted: Mon Aug 22, 2022 1:25 pm 
Offline

Joined: Thu Mar 31, 2022 1:39 pm
Posts: 4
It doesnt seem too bad, the only problem is actually creating a compiler for that language


Top
 Profile  
 
 Post subject: Re: A new hobby programming language for OS developement?
PostPosted: Fri Aug 26, 2022 8:41 am 
Offline
Member
Member
User avatar

Joined: Mon Jun 05, 2006 11:00 pm
Posts: 2293
Location: USA (and Australia)
Congrats on starting your own language!

You've got a few inconsistencies:
Code:
0xb8000 = "ERR: ";

Code:
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:
stdout = MESSAGE;


Are you assigning a variable? If this is a function call, how do you assign a variable?

Code:
func error(val: b8) -> hlt

Code:
const OPTIONAL:b16 = 0;


I like putting the the type after the declaration. It actually makes implementing the parser a little easier.

Code:
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:
[eax] = ebx


and replace local stack locations with typed variables?

_________________
My OS is Perception.


Top
 Profile  
 
 Post subject: Re: A new hobby programming language for OS developement?
PostPosted: Sun Sep 11, 2022 7:46 am 
Offline
Member
Member

Joined: Sat Feb 27, 2010 8:55 pm
Posts: 147
this reminds me of terse


Top
 Profile  
 
 Post subject: Re: A new hobby programming language for OS developement?
PostPosted: Thu Sep 15, 2022 1:53 am 
Offline
Member
Member
User avatar

Joined: Thu Nov 16, 2006 12:01 pm
Posts: 7612
Location: Germany
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.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: DotBot [Bot] and 31 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group