[ Class Overview ] [ CGA Screen ] [ Keyboard ]
Task 1: Input/Output functionality for OOStuBS
Learning objectives
- Familiarize with the development environment
- Refreshing the programming language C++
- Programming close to the hardware (CGA screen and keyboard)
Task description
For test outputs and to simplify debugging, the OOStuBS exercise operating system should first be equipped with output functionality.
These are supposed to be used similar to the C++ Standard Input / Output Streams (iostream) library and implemented with the help of the classes IO_Port, CGA_Screen, Stringbuffer, O_Stream and CGA_Stream. From these classes, the provided template code already contains IO_Port.
In order to use the output functionality everywhere in OOStuBS, you should create a global CGA_stream object kout.
In order to allow interactive applications, you should additionally complete class Keyboard_Controller, which is included in the template together with class Key.
When handing in the task, you should be able to demonstrate the functionality
of the mentioned classes with the help of a meaningful test program.
For this purpose, use the kout object for differently
formatted outputs in the main()
function of OOStuBS, like this:
kout << "Test <stream result> -> <expected>" << endl; kout << "zero: " << 0 << " -> 0" << endl; kout << "decimal: " << dec << 42 << " -> 42" << endl; kout << "binary: " << bin << 42 << dec << " -> 0b101010" << endl; kout << "octal: " << oct << 42 << dec << " -> 052" << endl; kout << "hex: " << hex << 42 << dec << " -> 0x2a" << endl; kout << "uint64_t max: " << ~((unsigned long)0) << " -> 18446744073709551615" << endl; kout << "int64_t max: " << ~(1l<<63) << " -> 9223372036854775807" << endl; kout << "int64_t min: " << (1l<<63) << " -> -9223372036854775808" << endl; kout << "some int64_t: " << (-1234567890123456789) << " -> -1234567890123456789" << endl; kout << "some int64_t: " << (1234567890123456789) << " -> 1234567890123456789" << endl; kout << "pointer: " << reinterpret_cast<void*>(1994473406541717165ul) << " -> 0x1badcafefee1dead" << endl; kout << "smiley: " << static_cast<char>(1) << endl;For the test of the keyboard input, you should create a KeyboardController object. Use it to poll characters from the keyboard in a loop and print them with kout.
Note: In later tasks, application and test code should be implemented
in the Application
class (also in the template) and not in main()
.
If you want, you can of course do this already in task 1.
Implementation notes
The task essentially consists of the two parts "outputs" and "inputs", whereby the test of the "inputs" is not possible without "outputs". The subtask "outputs" can also be divided into three independent parts, which can be solved and tested individually. Therefore, we recommend the following workflow:
Outputs
- The class CGA_Screen and a small test application.
- The classes Stringbuffer and O_Stream and a small test application.
- The classes CGA_Stream and a small test application.
Inputs
- Completion of the Keyboard_Controller class and the final test application.
You should be especially careful when implementing set_repeat_rate
and set_led
. It is quite possible that bugs in these functions
will only lead to problems in task 2 and following – which might complicate
troubleshooting there.
Template code
The provided Git repository already contains some code, tools, assembler files and a Makefile, which you can use to compile your program, to test it in QEMU, or to write it to a USB stick.
Additional information
- Information on the CGA screen
- Information on the keyboard