;VERY SIMPLE 6502 OPERATING SYSTEM
NUMDRV = $00 ;number of installed drivers
; holding spots to preserve registers
TEMP1 = $01; TEMP2 = $02; TEMP3 = $03; TEMP4 = $04
VECTORL = $05 ;used to indirect jump to specific driver
VECTORH = $06
DRVTABL = $20 ;beginning of driver pointer table, low bytes
DRVTABH = $40 ;beginning of driver pointer table, high bytes
MAXDRV = $20 ;maximum number of drivers supported
REGDRV ;Registers a driver
;pointer to driver .X high byte, .A low byte
PHP
STY TEMP1
LDY NUMDRV
CPX #MAXDRV
BEQ REGDRVE
STA (DRVTABL),Y
TXA
STA (DRVTABH),Y
INC NUMDRV
LDY TEMP
REGDRVZ PLP
RTS
REGDRVE SEC
JMP REGDRVZ
DRVCALL ;Calls a driver
;.Y is the specific driver number
;.A is specific operation, implemented by driver
;.A can be the following:
; 0-init device, 1-get device info, 2-get device state
; 3-open, 4-read, 5-write, 6-close
LDA (DRVTABL),Y
STA VECTORL
LDA (DRVTABH),Y
STA VECTORH
JMP (VECTORL) ; tail call optimization; borrow driver RTS
>>38 es is a computer operating system developed originally by Nintendo and since 2008 by Google. The operating system runs natively on x86, and includes a kernel written in C++.