Calculator Community > General Calculator Help |
How To Write an OS |
(1/7) > >> |
SirCmpwn:
Hello! Several people may want to write their own OSes, but I know from experience that it is very hard finding out where to start. I have put together a small tutorial and a basic kernel so that anyone who wants to can get started building their own OSes. If anyone wants to skip the struggle of simply getting something to boot, I have attached KnightKernelBasic, which is what I gave to Eeems to build Rouge on. It requires ZDS, and I recommend using TI Developer with it as well. Every OS needs these, just to boot: *Page 00 *A valid OS header But if you want it to actually do anything useful, it needs to: *Initialize the LCD *Set up memory *Initialize the stack You should have some other stuff, but that's all you really *need.* In order to boot and display something pretty, you really just need to have page 00, the stack, LCD, and a header. A basic OS header looks like this: --- Code: (OS) --- jr Boot db 0,0,0,0,0,0 db 0, 0 ; rst 08h db 0,0,0,0,0 db 0, 0 ; rst 10h db 0,0,0,0,0 db 0,0 ; rst 18h db 0,0,0,0,0 db 0, 0 ; rst 20h db 0,0,0,0,0 db 0,0 ; rst 28h db 0,0,0,0,0 db 0,0 ; rst 30h db 0,0,0,0,0,0,0 db 0, 0 ; rst 38h / System Interrupt db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 db 0,0,0,0,0,0,0,0,0 jp Boot dw 0A55Ah Boot: ; This executes at boot --- End code --- You could copy this into a document and start coding at Boot: and have an OS. This is also valid and signable, and may be sent to a calculator. It is worth noting that you need to have an interrupt or risk crashing the calculator. Add it at rst 38h: --- Code: ---; System Interrupt Routines SysInterrupt: exx ex af, af' in a, (04h) bit 0, a jr nz, HandleON bit 1, a jr nz, HandleTimer1 bit 2, a jr nz, HandleTimer2 bit 4, a jr nz, HandleLink jr InterruptDone HandleON: in a, (03h) res 0, a out (03h), a set 0, a out (03h), a ; ON interrupt jr InterruptDone HandleTimer1: in a, (03h) res 1, a out (03h), a set 1, a out (03h), a ; Timer one interrupt (might be best to merge with timer 2) jr InterruptDone HandleTimer2: in a, (03h) res 2, a out (03h), a set 2, a out (03h), a ; Timer two interrupt jr InterruptDone HandleLink: in a, (03h) res 4, a out (03h), a set 4, a out (03h), a ; Link interrupt InterruptDone: ex af, af' exx ei ret --- End code --- This is a basic interrupt with blank spots to put your code. In order to actually compile and test your OS, you need to sign it. It may also be useful to convert it to a ROM for testing. TI Developer will do this for you automatically, but if you don't want to use ZDS or TI Developer, you can use os2tools. Simple code to set up the LCD so you can draw on it: --- Code: --- ld a, 40h out (10h), a ld a, 05h call LCDDelay out (10h), a ld a, 01h call LCDDelay out (10h), a ld a, 3 call LCDDelay out (10h), a ld a, 0F6h call LCDDelay out (10h), a --- End code --- And to set up memory (ROM 00\ROM 01\RAM 01\RAM 00): --- Code: --- ld a, 1 ; Set flash page 1 in bank 1. out (6), a in a, (2) ;get calc version rlca ;Roll bit 7 into carry. ld a, 41h ; Set ram page 1 in bank 2. jr nc, LowerModel HigherModel: out (5),a ld a,81h out (7),a jr Done LowerModel: out (6), a out (7),a Done: --- End code --- Now go build some OSes! |
qazz42:
O_o woah do we have to use ZDS? I find ZDS very confusing (of course, I dont think I will be writing OSes very soon XD ) |
SirCmpwn:
You don't have to use ZDS. I just recommend it. |
meishe91:
I added this to the tutorial thread. It looks great. What are TI-Developer, ZDS, and os2tools though? |
qazz42:
ah, ok now, how would the .bin be turned into a .8xu? |
Navigation |
Message Index |
Next page |