SAS

From Esolang
Jump to navigation Jump to search

SAS /sæs/ or Simple Assembly is an assembly language invented by User:None1 to be easy to implement and compile to another language, it is possible to write a C compiler to it.

Memory

There are infinite dialects of SAS: SAS-1, SAS-2, ... The number is the architecture number: the number of bits in a machine word. The most commonly-used ones are SAS-8, SAS-16, SAS-24 and SAS-32.

The memory in SAS-x consists of 2x machine words, each machine word is x bits. Each machine word is addressed 0 to 2x-1. At start of the program, the addresses 0 to x-1 store 2i, where i is the address, the addresses 2x-1 to 2x-x store 2x-22x-i-1, where i is the address, while other addresses are zero.

Machine words wrap ((2x-1)+1=0).

Basic Commands

ADD x y

Add address y to address x.

JMP x y

If address x is nonzero, jump to line y (line numbers start from 0).

REF x y

Let x be the value addressed the value of address y.

Commands are case insensitive.

That's it.

I/O Extensions (optional)

OUT x

Print address x modulo 256 as ASCII.

INP x

Input address x as ASCII.

Example Programs

Hello, World!

The following works in SAS-8.

ADD 8 3
ADD 8 6
OUT 8
ADD 9 0
ADD 9 2
ADD 9 5
ADD 9 6
OUT 9
ADD 10 2
ADD 10 3
ADD 10 5
ADD 10 6
OUT 10
ADD 11 2
ADD 11 3
ADD 11 5
ADD 11 6
OUT 11
ADD 12 0
ADD 12 1
ADD 12 2
ADD 12 3
ADD 12 5
ADD 12 6
OUT 12
ADD 13 2
ADD 13 3
ADD 13 5
OUT 13
ADD 14 5
OUT 14
ADD 15 0
ADD 15 1
ADD 15 2
ADD 15 4
ADD 15 6
OUT 15
ADD 16 0
ADD 16 1
ADD 16 2
ADD 16 3
ADD 16 5
ADD 16 6
OUT 16
ADD 17 1
ADD 17 4
ADD 17 5
ADD 17 6
OUT 17
ADD 18 2
ADD 18 3
ADD 18 5
ADD 18 6
OUT 18
ADD 19 2
ADD 19 5
ADD 19 6
OUT 19
ADD 20 0
ADD 20 5
OUT 20

Cat program

INP 0
OUT 0
JMP 0 0

Truth Machine

INP 8
ADD 9 8
ADD 8 251
ADD 8 250
OUT 9
JMP 8 4

Computational class

When the architecture number is near infinity, the esolang is Turing complete, but the architecture number cannot be infinity. Also the esolang is not Turing complete when architecture number is infinity.

Implementations