Protogen

From Esolang
Jump to navigation Jump to search

By Joseppi1

Protogen uses the bytes of a file, grouped together into lines of width bytes. Each line does an instruction unless the first byte does not have any instruction assigned, which is treated like a comment. The lines' first byte is for determining what is done, and the bytes after are the parameters for the instruction. Additionally, there are four registers. The A and B registers are used as input for various instructions, and the C and E registers are for output. The E register is reserved for overflows and other special or error-like information. Before you do anything, note that the first line is special. The first byte from it is used to determine the width. The width will be set to 2**byte, so 01 will make the width 2, 02 is 4, 04 is 16 and so on. This line isn't run unless you decide to jump to it for some odd reason.

First byte Byte as hex Instruction
A 41 The second byte (first of the param bytes) is put into register A.
B 42 The second byte (first of the param bytes) is put into register B.
a 61 Using little-endian formatting, the param bytes are used as an address in the code to find a byte, and that byte is put into register A.
b 62 Using little-endian formatting, the param bytes are used as an address in the code to find a byte, and that byte is put into register B.
c 63 Using little-endian formatting, the param bytes are used as an address in the code to find a byte, and register C replaces that byte.
e 65 Using little-endian formatting, the param bytes are used as an address in the code to find a byte, and register E replaces that byte.
+ 2b Adds together registers A and B and stores the result in register C. If no overflow occurs, register E is 0. If there is overflow, register E is 1.
- 2d Subtracts register B from A and stores the result in register C. If no underflow occurs, register E is 0. If there is underflow, register E is 255.
& 2b The bitwise and of registers A and B is stored in register C. Register E is set to 0.
| 7c The bitwise or of registers A and B is stored in register C. Register E is set to 0.
^ 5e The bitwise xor of registers A and B is stored in register C. Register E is set to 0.
j 6a Jumps, or moves the current execution, to the provided address as represented by little-endian bytes.
> 3e Jumps if the A register is greater than the B register.
= 3d Jumps if the A register is equal to the B register.
< 3c Jumps if the A register is less than the B register.
r 72 Jumps, then when a NULL is hit, jumps to the line after this one. (r for return)
NULL 00 Indicates the end of a code block or the program
, 2C Takes a character as input, putting it in register C. Register E is set to 0 unless this is the last character inputted, in which case register E is set to 1. Also, typing an empty line makes the C and E registers 0 and 1 respectively.
. 2E Outputs register A as a character
; 3B Takes an unsigned 8 bit integer as input, putting it in register C
: 3A Outputs register A as a unsigned integer
? 3F Picks a random number between register A and B (inclusive) and puts the choice in register C.

That's pretty much everything about Protogen. I'm new to making esolangs, so sorry if this one is bad. By the way, you'll probably want to get something like HxD or some other Hex editor. This will be hard to use otherwise.

Examples

While the link to my github below has some examples, here's the same examples as hexadecimal (It's hard to type the code properly):

  • Here's a hello world program:
02 00 00 00
41 48 00 00
2E 00 00 00
41 65 00 00 
2E 00 00 00 
41 6C 00 00
2E 00 00 00
2E 00 00 00
41 6F 00 00
2E 00 00 00
41 2C 00 00
2E 00 00 00
41 20 00 00
2E 00 00 00
41 57 00 00
2E 00 00 00
41 6F 00 00
2E 00 00 00
41 72 00 00
2E 00 00 00
41 6C 00 00
2E 00 00 00
41 64 00 00
2E 00 00 00
41 21 00 00
2E 00 00 00
00 00 00 00
  • Here's a 99 bottles of pop on the wall program:
02 00 00 00 
41 63 00 63 
42 01 00 00 
72 18 00 00 
72 A0 00 00 
6A 08 01 00 
61 07 00 00 
3A 00 00 00 
41 20 00 00 
2E 00 00 00 
41 62 00 00 
2E 00 00 00 
41 6F 00 00 
2E 00 00 00 
41 74 00 00 
2E 00 00 00 
2E 00 00 00 
41 6C 00 00 
2E 00 00 00 
41 65 00 00 
2E 00 00 00 
41 73 00 00 
2E 00 00 00 
41 20 00 00 
2E 00 00 00 
41 6F 00 00 
2E 00 00 00 
41 66 00 00 
2E 00 00 00 
41 20 00 00 
2E 00 00 00 
41 70 00 00 
2E 00 00 00 
41 6F 00 00 
2E 00 00 00 
41 70 00 00 
2E 00 00 00 
41 20 00 00 
2E 00 00 00 
00 00 00 00 
41 6F 00 00 
2E 00 00 00 
41 6E 00 00 
2E 00 00 00 
41 20 00 00 
2E 00 00 00 
41 74 00 00 
2E 00 00 00 
41 68 00 00 
2E 00 00 00 
41 65 00 00 
2E 00 00 00 
41 20 00 00 
2E 00 00 00 
41 77 00 00 
2E 00 00 00 
41 61 00 00 
2E 00 00 00 
41 6C 00 00 
2E 00 00 00 
2E 00 00 00 
41 2E 00 00 
2E 00 00 00 
41 0A 00 00 
2E 00 00 00 
00 00 00 00 
72 18 00 00 
61 07 00 00 
2D 00 00 00 
63 07 00 00 
41 0A 00 00 
2E 00 00 00 
41 54 00 00 
2E 00 00 00 
41 61 00 00 
2E 00 00 00 
41 6B 00 00 
2E 00 00 00 
41 65 00 00 
2E 00 00 00 
41 20 00 00 
2E 00 00 00 
41 6F 00 00 
2E 00 00 00 
41 6E 00 00 
2E 00 00 00 
41 65 00 00 
2E 00 00 00 
41 20 00 00 
2E 00 00 00 
41 64 00 00 
2E 00 00 00 
41 6F 00 00 
2E 00 00 00 
41 77 00 00 
2E 00 00 00 
41 6E 00 00 
2E 00 00 00 
41 0A 00 00 
2E 00 00 00 
41 50 00 00 
2E 00 00 00 
41 61 00 00 
2E 00 00 00 
41 73 00 00 
2E 00 00 00 
2E 00 00 00 
41 20 00 00 
2E 00 00 00 
41 69 00 00 
2E 00 00 00 
41 74 00 00 
2E 00 00 00 
41 20 00 00 
2E 00 00 00 
41 61 00 00 
2E 00 00 00 
41 72 00 00 
2E 00 00 00 
41 6F 00 00 
2E 00 00 00 
41 75 00 00 
2E 00 00 00 
41 6E 00 00 
2E 00 00 00 
41 64 00 00 
2E 00 00 00 
41 0A 00 00 
2E 00 00 00 
72 18 00 00 
72 A0 00 00 
41 0A 00 2E 
2E 00 00 00 
2E 00 00 00 
2E 00 00 00 
61 07 00 00 
3C 28 02 00 
6A 0C 00 00 
00 00 00 00
  • Here's a truth-machine:
02 00 00 00 41 3E 00 00 2E 00 00 00 41 20 00 00 2E 00 00 00 2C 00 00 00 63 17 00 00 61 17 00 00 42 30 00 00 3D 30 00 00 2E 00 00 00 6A 28 00 00 2E 00 00 00 00 00 00 00

How to run

If you want to try Protogen for yourself, I made a couple of Protogen runners here.