8 bits, 256 bytes
8 bits, 256 bytes is an esolang by User:ChuckEsoteric08 inspired by Chip-8.
Description
It has 8-bit Program Counter, allowing programs to have 256 bytes at most, it has 16 8-bit internal registers, R0-RF, last one used only as a flag for other instructions, and a 8-bit Stack Pointer for the call stack. Program uses the same store for both program and data. There is also a 64x64 screen and a 16-key keyboard similar to Chip-8. Sprites are encoded as a series of 1 to 16 bytes similar to Chip-8.
Commands
Each command is dtored as 2 bytes, so each program can store only 128 commands. For the following commands it uses this values:
n, x or y - nybble, a single hex value b - a single byte
It has following commands, written in hex:
Hex | Assembly | Description |
---|---|---|
0000 | CLS | Clears the screen |
0001 | RET | Returns from subroutine |
01b | CALL b | Call subroutine at address b |
02b | JMP b | Jumps to instruction b |
1nb | SE n, b | Skips next instructuon if Rn = b |
2nb | SN n, b | Skips next instruction if Rn != b |
03xy | EQ x, y | Skips next instruction if Rx = Ry |
04xy | NE x, y | Skips instruction if Rx != Ry |
4nb | SB n, b | Sets Rn to b |
5nb | LD n, b | Loads a value from address b to Rn |
6nb | ST n, b | Stores a value of Rn to address b |
05xy | SR x, y | Sets Rn = Ry |
7nb | ADD n, b | Set Rn += b |
8nb | SUB n, b | Set Rn -= b |
06xy | ADR x, y | Set Rx += Ry |
07xy | SUR x, y | Set Rx -= Ry |
08xy | AND x, y | Set Rx = Rx AND Ry |
09xy | OR x, y | Set Rx = Rx OR Ry |
0Axy | XOR x, y | Set Rx = Rx XOR Ry |
0B0n | RS n | If least significant bit is 1, Set RF to 1, else set it to 0. Then divide Rn by 2 |
0B1n | LS n | If most significant bit is 1, Set RF to 1, else set it to 0. Then multiply Rn by 2 |
0B2n | SP n | Skip next command if key n is pressed |
0B2n | NP n | Skip next command if key n is pressed |
0B3n | SK n | Wait for key press, and set Rn to the value of pressed key |
9xyn | DR x, y, n | Draw n-byte sprite at coordinates Rx, Ry |
Each time after addition or subtraction wraps around RF is set to 1, if after an operation was performed it didn't wrap RF is set to 0