L-Language WebAssembly Runner

Separate inputs with commas: 3, 5 means X1 = 3 and X2 = 5.

Loading Wasm...

How to use it

  1. Write your program in the text box.
  2. Enter the input values in Inputs, separated by commas. The first value goes to X1, the second to X2, and so on: 3, 5 starts the program with X1 = 3 and X2 = 5.
  3. Click Run Trace. The last line of the trace shows the final values, and OutputVar is the result.

Inputs must be whole numbers of 0 or higher. Any variable without a value starts at 0, so with 3 as input, X2 is 0, and with an empty field, every variable is 0.

Inputs don't go in the program itself: X1 <- 20 is not valid, because programs can only add or subtract 1.

The example computes Y = 2 * X1. It uses Z1 to make unconditional jumps, and jumps to the unused label E to halt. It takes 6 * X1 + 3 steps, so raise Max steps for inputs above 82.

Constraints

Each trace line shows the next instruction number and every variable in the program or the inputs: OutputVar is Y, InputVar 1 is X1 and LocalVar 1 is Z1.

Disclaimer

This is not the full L language as Martin Davis defines it. There, variables hold arbitrarily large natural numbers and a program can run forever. This runner is finite: every run stops after Max steps, which is limited to the 32-bit maximum of 2147483647, and all values have to fit in the browser's memory. A trace that stops at Max steps doesn't tell you whether the program would have halted.