8052 kernel
I wrote a kernel for my 8052 development board. It is written entirely in assembler, and can be used on the 8051 with minor adjustments. It uses the extra memory in the 8052, but can also run on the 8051 with less internal memory available.
The kernel has a large set of features, which can be individually included/excluded from compile, thus allowing for a small kernel with only the desired features
Kernel features
- Preemptive scheduler running on a timer interrupt. The registers and stack of the current process is swapped out, and the registers and stack of the next process to run is swapped in.
- Semaphores.
- Mutexes.
- List functions (push/pop/length).
- String-formatting of hex, decimal and floating-point numbers
- Interrupt-driven serial I/O.
- 32-bit integer math (addition, subtraction, multiplication, division).
- 32/8-bit floating point, 32-bit mantissa, 8-bit exponent (addition, subtraction, multiplication, division).
- Taylor-series demonstrating floating point precision (e^x, ln(x), x^y, sqrt(x), sin(x), cos(x)).
Microprocessor development boards like my 8052 board all have different hardware configurations. Therefore some constants in the kernel may be will be different on other boards.
Kernel source files
- krn2.asm - the main entry point, containing include statements referring to the other files.
- krn_constants.asm - symbolic constants and general macros.
- krn_data.asm - variable declarations.
- krn_hw.asm - hardware drivers.
- krn_printutil.asm - conversion between binary and ascii representation of numbers
- krn_functions.asm - kernel-related functions
- krn_intutil.asm - integer math functions
- krn_floatutil.asm - floating point math functions
- krn_float_taylor.asm - taylor series
- krn_programs.asm - user programs to be run by the kernel
All programs to be run by the kernel has the form: Init, then a do-forever-loop. Programs can interact with eachother using semaphores and locks.