0e18958341ad87e310c7693ed8be7cbc9169b4c0
5150 stuff
Layout of a bootable polOS floppy disk
The floppy disk is FAT12 formatted. It must contain at least the following items:
- fat12boot.bin: the boot sector. It loads polio.com from a FAT12-formatted drive 0 to address 0x0600 and jumps to it.
- polio.com: the basic OS functions. It serves all interrupt 0x80 functions (see below) and loads polmon.com to address 0x1200, then jumps to it.
- polmon.com: a barebones memory utility. See below for all it can do.
polOS int 0x80
- function in AH
- optional argument in AL
- other arguments on the stack
- return value in AX
AH | AL | stack arguments | return | description |
---|---|---|---|---|
0x01 | addr, c, h, s | error code in AH | readsector: reads 1 floppy sector at c/h/s into 0000:addr | |
0x02 | addr, c, h, s | error code in AH | writesector: writes 1 floppy sector at c/h/s from 0000:addr | |
0x03 | c, h | error code in AH | formattrack: formats 1 track at c/h | |
0x04 | fname, addr | non-zero if error | readfile: reads file with name at ds:fname into ds:addr | |
0x05 | addr, size | bytes received, < 0 if error | recvpara: receive at most size bytes from parallel port into ds:addr | |
0x06 | addr, size | bytes sent, < 0 if error | sendpara: send at most size bytes to parallel port from ds:addr | |
0x07 | until-idle | 0 if idle | runpara: run a round of parallel comms if AL=0, keep going until idle if AL!=0 | |
0x08 | fname, addr, size | error code in AH | writefile: writes size bytes from ds:addr into file with name at ds:fname |
polmon commands
Commands are a single letter followed by an optional space and arguments, with optional spaces between them. A command can be prefixed with up to 4 hex digits, which will then change the current address.
- (no command): dumps 16 bytes at the current address. If no address is given, also increments the current address by 16.
w bytes:[u8]*
: writes bytes in hex to the current address.k src:u16 size:u16
: copy size bytes of memory from cur-seg:src to cur-seg:cur-addrs seg:u16
: changes the current segmentj
: calls a function at the current address. ABI calling conventions below.l file:str
: loads a program with given name into the current segment, address 0x0100.r args:[u16]*
: runs the program in the current segment with arguments.i ax:u16 args:[u16]*
: call an int 0x80 function with given AX and stack args. See section above.
The r, j and i commands display the value of the AX register after returning to polmon.
ABI convention for (j)umping to functions
- AX, BX, CX, DX are caller-saved, all others are callee-saved
- first 3 arguments passed in AX, DX and CX, others are pushed in reverse order (former argument in lower memory)
- return value in AX
ABI for programs
See example in hello.com
Examples
Launching mushroom client
s 200
l mushroom.com
r
FTP a file and store it to the floppy disk
s 200
l ftpget.com
- switch to segment 0x200
- load file ftpget.com to cur-seg:0100
Here you need to run this on the host:
python ftpserve.py src/hello.com
Then on polOS:
r f000 200
s 0
6000
w 48454c4c4f202020434f4d
i 0800 6000 f000 200
- run previously loaded
ftpget.com
: store up to 0x200 (512) bytes to address 0000:f000 - set cur-seg to 0x0000
- set cur-add to 0x6000
- write file name in ascii:
HELLO COM
to 0000:6000 - call int 0x80 0x08 (writefile) with args: fname, addr, size
We can now test that the program got transferred correctly:
s 300
l hello.com
r
But where is my ls
command?
You can just inspect memory at 0000:1c00, that's the root directory. Each entry is 0x20 (32) bytes long and starts with 11 characters that constitute the file name.
Useful stuff
Description
Languages
C++
40.1%
C
29.4%
Assembly
21.8%
Python
4.6%
Makefile
3.5%
Other
0.6%