actorartathleteauthorbizcrimecrosspostcustomerservicedirectoredufoodgaminghealthjournalistmedicalmilmodpostmunimusicnewsworthynonprofitotherphilpolretailscispecialisedspecializedtechtourismtravelunique

I've spent 4 years making a free operating system for calculators (in assembly). AMA!

Oct 6th 2014 by sircmpwn • 12 Questions • 624 Points

KnightOS is a free, open source operating system for Texas Instruments calculators. I've been working on it for over 4 years now. (begin nerdy stuff) It's over 25,000 lines of assembly code (which is arguably a pretty tough language to write things with), and it's built with its own toolchain, which is mostly written from scratch in C. It's a passable Unix-like enviornment with multitasking, dynamic memory management, etc (end nerdy stuff) In the past year or so, the project has picked up steam and now there are over a dozen talented people helping me out with it. Maybe some people here will want to get involved, too!

My Proof: http://www.knightos.org/reddit.txt

AMA!

Q:

Any other projects you have been working on? Or ones you would like to start?

A:

Thanks for asking! I work on a ton of open-source projects, here are a few:

I also contribute code to projects like RES and ImageMagick, but KnightOS is definitely my favorite project.


Q:

Was there a reason you decided to stick with assembly for the whole is instead of bootstrapping to c like most other current os'es?

A:

TI calculators run on z80s. These processors have C compilers, but they don't work very well - they produce rather bloated code, and often slow code. It's unfortunately unacceptable for a kernel on such limited systems to be written in C.


Q:

Wouldn't it have been easier to rewrite the c compiler than write an entire os in assembly?

A:

Probably not. The compilers aren't poorly written, it's just that we're really resource starved here. Hand-optimized assembly is the way to go.


Q:

I remember back when it was just the basics. The good old days

Nowadays... Delay slots and register renaming make me want to kill myself

A:

You could make it work. I believe in you.


Q:

How old are you and why did you decide to skip higher education?

A:

I'm 21 and I skipped it because i don't consider it worthwhile for my own needs.


Q:

has Texas Instruments ever contacted you?

A:

Nope.


Q:

How hard would it be to get it working for a TI-86? It has the same CPU as the 83+, and more RAM, but a non-upgradeable 256k ROM, which I think is probably a barrier here.

A:

Impossible. You hit the nail right on the head.


Q:

Hey! This is an awesome project. I would love to work on something like this. I'm still in school but systems and low level projects like this really interesting. A few questions! Did you find the instruction set for the z80 limiting in any way and what was your debugging process like? Id imagine there arent a lot of helpful tools out there for a project like this. Thanks!

A:

The z80 has a generous instruction set which isn't too limiting. It's got support for a lot of nice things that are less common on 8 bit CPUs, like good bit manipulation.

For debugging I've mostly used emulators. On the 84+ CSE, however, there were no emulators when I got started. I couldn't even get the screen to turn on at first and I ended up wiring an LED into the link port and making it blink to communicate debugging information to the outside world.


Q:

How useful is it for someone interested in programming to learn Assembly? I am a physics/maths undergrad, but I like programming and know my way around C++. Would learning Assembly give me some sort of deeper understanding (as I've often heard)? Are there any (other) benefits?

A:

You probably won't find it practical unless you have a specific constraint that demands it (like I do). Learning it, however, can be very valuable to come to a deeper understanding with how your computer works. I suggest you do so.


Q:

Why is the calculator so expensive

Also how should I start coding assembly (I know there's no point), I'm on a debian variant.

A:

Because TI has a monopoly.

You can start writing assembly for calculators by installing our WIP SDK and genkfs, then heading over to our documentation.


Q:

What, may I ask, does your OS do for a calculator? I have a TI 84 plus and it does pretty much everything I need it to, except surf the web but it doesn't have the memory for that and has a black and white screen and it would be terribly awkward to view websites. So please explain why I would need a different OS on my calculator.

A:

The features are described on the home page: http://www.knightos.org, along with an emulator so you can see for yourself. To quote the download page, though: "KnightOS isn't done, and you may be underwhelmed."


Q:

Thanks for posting this, actually, it's very motivating, have to ask: 1-How & where did you start learning assembly? and good resources? 2-How did you learn writing OSes? also any good resources you recommend? 3-Is writing an OS for calculator is different than writing an OS for PCs?

A:
  1. http://tutorials.eeems.ca/ASMin28Days/lesson/toc.html, years ago
  2. I just wrote one and learned as I went along
  3. I haven't written an OS for PCs so I can't say for sure.