RSSB

From Esolang
Jump to: navigation, search

RSSB is an esoteric programming language which implements a Turing Complete single instruction computer.

Overview[edit]

RSSB stands for Reverse Subtract and Skip if Borrow, taking the principles of RISC to the extreme. The specification defines one instruction, RSSB. Each instruction has one operand, a pointer into memory. There are two registers, IP the instruction pointer, and ACC the accumulator.

The reverse subtract and skip if borrow operation subtracts the accumulator from the contents of memory. The result is stored in both memory and the accumulator. If the result was below zero, the next instruction will be skipped. The instruction pointer is mapped to memory location 0 and the accumulator is mapped to location 1. The complete list of special memory locations is as follows:

Location Description
0 instruction pointer
1 accumulator
2 always contains 0
3 character input
4 character output

Example[edit]

Hello, World[edit]

This program prints out the words Hello, World!:

; RSSB Hello World, John Metcalf

loop    rssb   acc       ; acc = character from ptr
ptr     rssb   hello        

        rssb   out       ; display character

        rssb   zero      ; acc = -acc

        rssb   zero      ; always skipped

        rssb   sum       ; subtract acc from sum

        rssb   ip        ; skipped if sum is <0
                         ; otherwise jump to 0

        rssb   acc       ; subtract 1 from ptr
        rssb   one
        rssb   ptr

        rssb   acc       ; jump to loop
        rssb   loopoff
        rssb   ip
loopoff rssb   $-loop

sum     rssb   -1116

one     rssb   1

        rssb   33        ; '!'
        rssb   100       ; 'd'
        rssb   108       ; 'l'
        rssb   114       ; 'r'
        rssb   111       ; 'o'
        rssb   87        ; 'W'
        rssb   32        ; ' '
        rssb   44        ; ','
        rssb   111       ; 'o'
        rssb   108       ; 'l'
        rssb   108       ; 'l'
        rssb   101       ; 'e'
hello   rssb   72        ; 'H'

See also[edit]

External resources[edit]