-
-
Notifications
You must be signed in to change notification settings - Fork 1
SAP1Emu Binary File Format
Bob Baker edited this page Oct 5, 2020
·
27 revisions
A lot of this is outdated. Documentation is slowly moving over to sap1emu.net/Docs/Docs
The SAP1Emu Binary File has some pretty simple requirements.
- All Binary Files must end with the ".b" file extension
- Each binary file must have exactly 16 lines of code
- Each line of code must contain only 1's and 0's with no nibbles-spaces or trailing end-spaces
- Each line of code must be terminated with a newline (CR LF for Windows and LF for Linux/macOS)
- Each line of code must be 8-bits wide
- The Binary File cannot have any extra newline characters after the 16th line of code
LDA == 0000
ADD == 0001
SUB == 0010
STA == 0011
JMP == 0100
JEQ == 0101
JNQ == 0110
JLT == 0111
JGT == 1000
JIC == 1001
...
OUT == 1110
HLT == 1111
NOP == 0000 // Must come after HLT
NOP == 0000 // Must come after HLT
LDA == 0001
ADD == 0010
SUB == 0011
STA == 0100
LDI == 0101 // Not yet implemented
JMP == 0110
JIC == 0111
JEQ == 1000
...
OUT == 1110
HLT == 1111
NOTE: The following examples will use the SAP1Emu Instruction Set
On the Assembly File page, the example used the following program:
LDA 0xD
ADD 0xE
ADD 0xF
OUT 0x0
HLT 0x0
...
0x2 0x8
0x0 0xF
0x0 0xD
If this program was assembled it would look like the following:
00001101
00011110
00011111
11100000
11110000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00101000
00001111
00001101
Remember the "..." will fill the area between the end of the program section and the beginning of the data section with NOP's.
When the SAP1Emu Engine starts, the first thing it does is loads the given program into the RAM of the SAP1Emu Emulator.
If the above binary file was loaded into the RAM, it would look like the following:
--------------------------
| Address | Value |
|-----------|------------|
| 0x0 | 00001101 |
| 0x1 | 00011110 |
| 0x2 | 00011111 |
| 0x3 | 11100000 |
| 0x4 | 11110000 |
| 0x5 | 00000000 |
| 0x6 | 00000000 |
| 0x7 | 00000000 |
| 0x8 | 00000000 |
| 0x9 | 00000000 |
| 0xA | 00000000 |
| 0xB | 00000000 |
| 0xC | 00000000 |
| 0xD | 00101000 |
| 0xE | 00001111 |
| 0xF | 00001101 |
--------------------------
© Bob Baker 2020