We are currently working on new rules for what content should and shouldn't be allowed on this website, and are looking for feedback! See Esolang:2026 topicality proposal to view and give feedback on the current draft.

Nadleq

From Esolang
Jump to navigation Jump to search

Nadleq is an OISC where the one instruction is "Negate and ADd and branch if Less-than or EQual to zero", conventionally abbreviated to nadleq.

Of course, this is derived from the famous Subleq.

Overview

Subleq is a simple one instruction language. Each Subleq instruction has 3 memory address operands. Since Subleq has only one instruction, the opcode itself is conventionally omitted, so each instruction is three addresses long.

Given three operands,

A B C

The execution of an instruction of this form subtracts the value in memory address B from the value in memory address A (the only difference from Subleq!), storing the result into memory address B. If the result stored into memory address B is less than or equal to zero, the execution jumps to the memory address C; otherwise it continues to the next instruction.

For example, in

3 4 6
7 7 7
3 4 0

the first instruction, at address zero, subtracts 7 (address 3) from 7 (address 4). The result in address 4 is 0, so jump to 6. Starting at address 6 is the instruction 3 4 0 which again subtracts now 0 from 7 and halts because the result 7 is larger than zero. Here is a trace of execution (leftmost column is program counter; A and B are shown after subtraction)

0: 3 4 6 A=7 B=0
6: 3 4 0 A=7 B=7
9: Halts

Assembly Syntax

Unlike Subleq, a standard for the assembly syntax exists.

We'll allow program points to be labelled, and for labels to be used in place of addresses, like so:

X Y 6
X:7 Y:7 7
X Y 0

On the first line X refers to a memory cell defined somewhere else. On the second line the address of X is actually defined, by X:7, which means that this address that initially holds 7 has name X.

$ io 256
H=72 io ->
i=105 io ->
halt

On the first line, we created an alias of 256 called io. On the second line, we created a new cell with value 72, prints it. -> refers to the next command. halt compiles to 0 0 -1

NoraTtempt

Nadleq will be used in a cellular-automaton computer called NoraTtempt, which I am currently building.

It's 16-bit, and can theoretically contain 65536 words, but I designed to let it have only 0.5kb RAM which is actually enough for small programs.

The 256th pin is interactive, where you can enter a number in the numpad and see the output with a decimal display.

Implementation

Not yet.