GPRX 3000

From Esolang
Jump to: navigation, search

GPRX 3000 is an esoteric programming language invented by xfix in 2016 implemented on non-existent GPRX 3000 CPU with three arbitrary precision registers and no external memory support.

Overview

GPRX 3000 programs are ran from beginning to end. All three general purposes registers and program counter are initialized to zero at program start. CPU implements the following commands.

Command Description
+ Adds contents of register B to register A.
- Subtracts contents of register B from A, and assigns the result to A. Throws an exception if a result is negative, as GPRX 3000 CPU doesn't support negative integers.
* Multiplies contents of register A and B, and sets the result to A.
/ Divides contents of register A by B, and sets the result to A.
% Performs modulo operation of register A using B, and assigns the result to A.
g Sets the program counter to contents of register A. This instruction doesn't cause program counter to increment after a jump. Throws an exception if program counter would be outside of program.
p Sends a current byte from register A to I/O port, which on emulator means standard output.
r Reads a byte from I/O port, increments it by 1, and sets it to register A. On error, 0 is returned. On emulator reading means reading from standard input.
x Sets register A to be register C, register B to be register A, register C to be register B.

Additionally, you can type in decimals in order to assign them to register A.

All other characters including whitespace throw an exception when executed, due to programs being supposed to be ran on CPU (subject to change).

Examples

Those programs assume themselves ending with a newline, as language throws an exception when GOTO instruction goes beyond the end of a program.

Hello, world!

72p101p108pp111p44p32p119p111p114p108p100p33p10p51g

cat

rx1+x1/x5*xx+xx2x-xx24+gxp0g

External resources