Skip to content

Program Development

Jacob Bates edited this page Dec 26, 2020 · 1 revision

Program Development

House-DOS commands and programs are written in x86 real-mode assembler. It is required knowledge to have at least a basic understanding of assembler in order to be successful in making a House-DOS program. There is no need to deal with segmentation, as the kernel abstracts that away, and a command can only occupy space in segment 0x4000.

Using System Calls

Typically, a program will contain at least one system call, a call to the kernel to perform a specific task, such as loading a file or printing a bit of text.

A system call is set up by setting the function number in AH (and sometimes AL as well), and also certain parameters in other registers (most of the time). Then, the kernel is invoked using INT 0x7E. Depending on the system call, there could be no output, there could be an output contained within a register (including FLAGS), or output could be given to a place in memory. Besides this, the registers should all be preserved in their original states.

Many system calls can produce errors, and when this happens, CF is set. Thus it is important to perform error checking wherever necessary.

Ending a Program

A program is stopped whenever a handback is issued. A handback is like any normal system call, except it doesn't require any parameters and it won't return to the code when it's done. It can be performed with system call INT 0x7E/AH = 0xFF. Alternatively, a program can exit with an error through system call INT 0x7E/AH = 0xFE, where SI points to a string to be used as an error message.

Metadata Headers

A metadata header is used by the kernel whenever a metadata parameter is passed in. It is eight bytes long, and structured in this way:

header:
    jmp main

h_creator   dw creator_addr     ; Point this address at a string with your name
h_desc      dw desc_addr        ; A basic description of the program
h_usage     dw desc_usage       ; Basic program usage info

main:
    ; Main code

It is entirely optional, and doesn't affect program execution in any way.

Clone this wiki locally