ReadWrite

From Esolang
Jump to navigation Jump to search

ReadWrite is an esoteric programming language written by User:Dominicentek. It only has 2 instructions. Reading from memory or writing to memory.

Instructions

Instruction Syntax Description
READ <address> Reads from a memory address and stores to the register
WRITE <address> Writes register's value to a memory address
WRITE <address> <value> Writes to a memory address directly without changing the register.

If a line contains a number without any instruction, the number is given to the register.

Special Addresses

-1 - When written to, it outputs to the console as an integer. When read from, it takes user's input as an integer.
-2 - Control flow. It is written to normally, however, when it's read from and the value is 0, next instruction is skipped.
-3 - Goto. When written to, it goes to a line number. Reading from gets the current line number.
-4 - When written to, it outputs to the console as an ASCII character. When read from, it takes user's input as an ASCII character.

Math

You can also do Math when changing the register or when writing to. Simply replace a number by a Math operation. # represents the register's value. Any number will be used as an address pointer to a value in memory. It cannot do complex Math operations. Valid Math operations are:

  • x + y - Add
  • x - y - Subtract
  • x * y - Multiply
  • x / y - Divide
  • x % y - Modulo (Division Remainder)
  • x ** y - Power
  • x & y - Bitwise AND
  • x | y - Bitwise OR
  • x ^ y - Bitwise XOR
  • ! x - Bitwise NOT
  • ~ x - Bitwise REVERSE
  • x << y - Bitshift to left
  • x >> y - Bitshift to right

Example Programs

Hello World

WRITE -4 72
WRITE -4 101
WRITE -4 108
WRITE -4 108
WRITE -4 111
WRITE -4 44
WRITE -4 32
WRITE -4 87
WRITE -4 111
WRITE -4 114
WRITE -4 108
WRITE -4 100
WRITE -4 33

Truth Machine

READ -1
WRITE -2
READ -2
WRITE -3 6
WRITE -3 8
WRITE -1 1
WRITE -3 6
WRITE -1 0

Calculator

1
WRITE 2
READ -1
WRITE 0
READ -1
WRITE 1
READ -1
# - 2
WRITE -2
READ -2
WRITE -3 13
WRITE -3 33
# - 2
WRITE -2
READ -2
WRITE -3 18
WRITE -3 35
# - 2
WRITE -2
READ -2
WRITE -3 23
WRITE -3 37
# - 2
WRITE -2
READ -2
WRITE -3 28
WRITE -3 39
# - 2
WRITE -2
READ -2
WRITE -3 42
WRITE -3 41
0 + 1
WRITE -3 42
0 - 1
WRITE -3 42
0 * 1
WRITE -3 42
0 / 1
WRITE -3 42
0 % 1
WRITE -1

Interpreter

Download