What does your OS look like? (Screen Shots..)

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
User avatar
AndrewAPrice
Member
Member
Posts: 2297
Joined: Mon Jun 05, 2006 11:00 pm
Location: USA (and Australia)

Re: What does your OS look like? (Screen Shots..)

Post by AndrewAPrice »

That's really cool Bender. I went with a stack machine because it was incredibly easy to generate from an AST, moving some of the complication to the VM.

Actually, interpreting stack byte code is simple (albiet possibly slower because stack machines generally require more instructions to represent the same operation), I want to eventually do JIT compilation. But, being a dynamic language I'd have to do polymorphic inline caching, and that starts to complicate things (for example I can't JIT "add" without knowing if it's a float, int, string, object with a custom operator, etc.)
Last edited by AndrewAPrice on Mon Jun 09, 2014 2:41 pm, edited 1 time in total.
My OS is Perception.
User avatar
AndrewAPrice
Member
Member
Posts: 2297
Joined: Mon Jun 05, 2006 11:00 pm
Location: USA (and Australia)

Re: What does your OS look like? (Screen Shots..)

Post by AndrewAPrice »

A lot of work went into this seemingly simple 'Hello World'.
VM running Hello World
VM running Hello World
helloworld.png (4.28 KiB) Viewed 6786 times
This is the first ever program written in my language Shovel that runs flawlessly on my VM (codenamed Turkey):

Code: Select all

var console = require("console");
var a = 0;
var incrementA = function() {
	a++;
};

while(a < 10) {
	incrementA();
	console.log("Hello world #" + a);
}
Function calls, closures, string manipulation, and calling native code!

Here it is the generated assembly before it assembled into bytecode:

Code: Select all

Function f0
-locals 3
-closures 1
PushString "console"
Require
Store 1
PushUnsignedInteger 0
StoreClosure 0
PushFunction f1
Store 2
Jump l1
.l0
Load 2
CallFunctionNoReturn 0
PushString "Hello world #"
LoadClosure 0
Add
PushString "log"
Load 1
LoadElement
CallFunctionNoReturn 1
.l1
LoadClosure 0
PushUnsignedInteger 10
LessThan
JumpIfTrue l0
.l2
Function f1
-locals 0
-closures 0
LoadClosure 0
Increment
StoreClosure 0
The executable file is 191 bytes (there's redundant metadata that could remove to shrink this.)

Right now, my VM is running as a userspace program in Windows (here's my userspace main.cpp that initialises the VM and runs the above file) - mostly for ease of testing, and porting to bare metal (my goal) should mainly involve re-implementing hooks.cpp.

Still to-do on the VM proper, before I start working on the kernel:
  • Garbage collection is not finished yet - string manipulation generates a lot of junk! Doesn't track when to invoke it.
  • Multithreading and multiple instances of the VM (essential for a multitasking OS.)
  • Standard library for the inbuilt types (like foreach loops over object properties, getting array sizes, etc.)
  • More compiler optimizations.
  • Port my compiler and assembler to Shovel to make a self-hosting tool chain.
I would love to have a JIT compiler one day - but I would rather make a functional OS first with a usable VM before I begin optimizing it.
Last edited by AndrewAPrice on Mon Jun 09, 2014 8:32 pm, edited 1 time in total.
My OS is Perception.
CelestialMechanic
Member
Member
Posts: 52
Joined: Mon Oct 11, 2010 11:37 pm
Location: Milwaukee, Wisconsin

Re: What does your OS look like? (Screen Shots..)

Post by CelestialMechanic »

Looks good, but how did the "hello world!" of the Shovel source get morphed into "Hello world #" that was pushed in bytecode?
Microsoft is over if you want it.
User avatar
AndrewAPrice
Member
Member
Posts: 2297
Joined: Mon Jun 05, 2006 11:00 pm
Location: USA (and Australia)

Re: What does your OS look like? (Screen Shots..)

Post by AndrewAPrice »

Oh - I'm sorry. I was experimenting with different code, and posted the wrong change. I've corrected it now.

Edit: If your curious, a simple recursive Fibonacci test shows my interpreted language is about 7x slower than unoptimized C: https://github.com/MessiahAndrw/Perception/tree/master/shovel/tests About 180x slower than optimized C - although I'm suspicious if my C compiler was able to resolve most of the calculation at compile time.
My OS is Perception.
User avatar
sortie
Member
Member
Posts: 930
Joined: Wed Mar 21, 2012 3:01 pm
Libera.chat IRC: sortie

Re: What does your OS look like? (Screen Shots..)

Post by sortie »

I ported the Mono virtual machine to Sortix. I can now execute .NET programs such as the C# compiler MCS which is written in C#. Here I compile and execute a C# hello world program under my operating system:

Image
User avatar
AndrewAPrice
Member
Member
Posts: 2297
Joined: Mon Jun 05, 2006 11:00 pm
Location: USA (and Australia)

Re: What does your OS look like? (Screen Shots..)

Post by AndrewAPrice »

Awesome sortie - you keep impressing me!
My OS is Perception.
User avatar
Bender
Member
Member
Posts: 449
Joined: Wed Aug 21, 2013 3:53 am
Libera.chat IRC: bender|
Location: Asia, Singapore

Re: What does your OS look like? (Screen Shots..)

Post by Bender »

Finally completed the compiler for my kernel, sample source code:

Code: Select all

class MainClass {
	int volume = 500
	int damage = 300
	string string1 = " Hello, World "
	proc Main {
		LOAD_R0 MainClass->string1
		CALLF MainClass->print
		VM_EXIT
	}
	proc print {
		PUSH R1
		PUSH R0
		.loop:
		LOAD_BYTE
		CMPR R1, 0
		JMPF_E .done
		VM_CALL 0
		JMPF .loop
		.done:
		POP R0
		POP R1
		RETF
	}
	
}
The compiler's crap for now (uses goto everywhere, hacks etc. and is just one cs file), you can get System.ArrayOutofRange exceptions everywhere if you're not careful, and it isn't really HLL yet just something like OO assembly. And in other news the VM can now use ROM disks :), currently it uses the JamesM initrd format, because I didn't bother create a new disk generator yet. :wink:
Screenshots:
Fibonacci Numbers and the hello world program above (first compiled to asm by the compiler, and then by fasm using macros)
Image
I've been thinking of using DynAsm for the JIT part of my VM, as it's also used in LuaJIT and is really easy to work with.
"In a time of universal deceit - telling the truth is a revolutionary act." -- George Orwell
(R3X Runtime VM)(CHIP8 Interpreter OS)
User avatar
Bender
Member
Member
Posts: 449
Joined: Wed Aug 21, 2013 3:53 am
Libera.chat IRC: bender|
Location: Asia, Singapore

Re: What does your OS look like? (Screen Shots..)

Post by Bender »

So today I taught my kernel about inverse trignometric functions (as if I understand them well :mrgreen: ), and here it is, calculating the value of PI using arctan(1 rad)* 4, and showing a bit more FPU instructions.
Image
"In a time of universal deceit - telling the truth is a revolutionary act." -- George Orwell
(R3X Runtime VM)(CHIP8 Interpreter OS)
emadrezvani
Posts: 7
Joined: Sun Jun 08, 2014 2:17 am

Re: What does your OS look like? (Screen Shots..)

Post by emadrezvani »

its our os:
Image
User avatar
Candy
Member
Member
Posts: 3882
Joined: Tue Oct 17, 2006 11:33 pm
Location: Eindhoven

Re: What does your OS look like? (Screen Shots..)

Post by Candy »

I've got DHCP working now. This is the log from within QEMU:

Code: Select all

iphlen = 20
dhcp: tag=53 len=1
dhcp: tag=50 len=4
dhcp: tag=54 len=4
bootp packet op=1 msgtype=3RTL8139: RxBufPtr write val=0x0248
RTL8139:  CAPR write: rx buffer length 8192 head 0x04b0 read 0x0258
RTL8139: receiver buffer data available 0x0258
RTL8139: ChipCmd read val=0x000c
pktstatus = 02522001
rx packet FFFFFD000428025C length 590
received udp packet from 10.0.2.2:67 to 255.255.255.255:68
ipaddr is now 0A00020F
dhcpserver is now 0A000202
netmask is now FFFFFF00
gateway is now 0A000202
dns0 is now 0A000203
validFor is now 00015180
DHCP: Got IP Address!!! I am now 10.0.2.15
RTL8139: RxBufPtr write val=0x04a0
RTL8139:  CAPR write: rx buffer length 8192 head 0x04b0 read 0x04b0
RTL8139: receiver buffer is empty
RTL8139: ChipCmd read val=0x000d
RTL8139: IntrStatus write(w) val=0x0005
RTL8139: Set IRQ to 0 (0000 e07f)
RTL8139: entered rtl8139_set_next_tctr_time
RTL8139: Set IRQ to 0 (0000 e07f)
I even have DNS, gateway and netmask ready, so I could theoretically start building a route table for TCP/UDP. I'm going to first try to get it to ping (ARP + ICMP) though. This does show that my Ethernet/IP/UDP stack is working far enough to do this, which is good :-D.

I could paste a screenie from the terminal, but it's not quite the showpiece... network internals rarely are.
User avatar
AndrewAPrice
Member
Member
Posts: 2297
Joined: Mon Jun 05, 2006 11:00 pm
Location: USA (and Australia)

Re: What does your OS look like? (Screen Shots..)

Post by AndrewAPrice »

Nice work Candy!
Candy wrote:I could paste a screenie from the terminal, but it's not quite the showpiece... network internals rarely are.
I understand. I want to boast about my JIT progress, but visually I have nothing to show. My fibonacci benchmark? "I could do that in C in 5 minutes!"
My OS is Perception.
ByteBit
Posts: 6
Joined: Mon Jun 16, 2014 2:40 pm

Re: What does your OS look like? (Screen Shots..)

Post by ByteBit »

Image
Right now you can just move the windows and bring them to the top.
It's a complete real mode OS for now.
User avatar
zhiayang
Member
Member
Posts: 368
Joined: Tue Dec 27, 2011 7:57 am
Libera.chat IRC: zhiayang

Re: What does your OS look like? (Screen Shots..)

Post by zhiayang »

After taking a break from actually coding my OS, I've decided to try my hand at a simple VM. Nothing too complex, it's mostly a register machine.
The following code does factorial recursively:

Code: Select all

@main
	move $0x0A -> %r01
	move $0x02 -> %r02
	call @factorial

	copy %rr -> %r03

.loop
	increment %r32
	jump -> .loop


@factorial
	cmpeq %r01, %r02
	branch -> .ret

	decrement %r01
	call @factorial

	increment %r01
	multiply %rr, %r01
	return

.ret
	move $0x2 -> %rr
	return
I would need to get the assembler to somehow link multiple source files together, then after that I can start work on the compiler proper. The VM implementation I have seems a little over-the-top; it can easily support (if I bother to implement it, that is) memory latency and caching... I mean, who intentionally slows down their VM? (I usually run it at 5 cycles/second for debugging)

Another problem is allowing immediate values directly inside opcodes; currently only a certain number of instructions handle immediate values, would be nice if I could cmpgt %r01, $0x2 instead of having to waste a register to store '2'.
crazyender
Posts: 2
Joined: Wed Jul 16, 2014 3:03 am

Re: What does your OS look like? (Screen Shots..)

Post by crazyender »

well, this is my os, it runs Linux binaries
Attachments
1.png
mateuszb
Member
Member
Posts: 32
Joined: Sun Jan 16, 2011 1:27 am

Thins are coming along together

Post by mateuszb »

SATA working, basic FAT32 working, native intel graphics also working. Time to work on displaying that mp4 movie :)
Attachments
image.jpg
Post Reply