Wrench Examples
[submit] [github] [isa_docs] [variants] [scratch]

/* Example programs from the repository. Source code is available [here]. */

/* acc32 */

  • [ok][Echo one char: 'ABCD']
    Same program with input "ABCD": only the first character is read and echoed, "BCD" stays in the input.
  • [ok][Echo one char: 'W']
    Reads one character from the input port 0x80 and writes it to the output port 0x84. Input: 'W' (87).
  • [ok][Factorial (loop)]
    Reads n = 5 from the input port 0x80, computes n! in a loop and writes 120 to the output port 0x84.
  • [ok][Hello world]
    Prints "Hello\n\0World" to the output port 0x84, one character at a time.
  • [ok][Logical NOT]
    Reads a boolean (0 is true, 1 is false) from the input port 0x80 and writes its negation to 0x84. Input: 1, output: 0.

/* f32a */

  • [ok][Factorial (loop)]
    Reads n = 4 from the input port 0x80, computes n! in a loop and writes 24 to the output port 0x84. Multiplication is done with +* steps, as f32a has no multiply instruction.
  • [ok][Hello world]
    Prints "Hello\n\0World" to the output port 0x84, one character at a time.
  • [ok][Logical NOT]
    Reads a boolean (0 is true, 1 is false) from the input port 0x80 and writes its negation to 0x84. Input: 1, output: 0.

/* m68k */

  • [ok][Echo one char: 'W']
    Reads one character from the input port 0x80 and writes it to the output port 0x84. Input: 'W' (87).
  • [ok][Factorial (loop)]
    Reads n = 5 from the input port 0x80, computes n! in a loop and writes 120 to the output port 0x84.
  • [ok][Factorial (recursive)]
    Computes 5! = 120 with a recursive subroutine (jsr/rts). Saves n on the stack with move.l D0, -(A7).
  • [ok][Factorial (recursive, link/unlk)]
    Computes 5! = 120 with a recursive subroutine. Keeps n in a stack frame made by link/unlk.
  • [ok][Hello world]
    Prints "Hello\n\0World" to the output port 0x84. Reads each character with move.b and writes it as a long word (move.l).
  • [ok][Hello world (byte writes)]
    Same as Hello world, but writes each character to the output port with move.b.
  • [ok][Logical NOT]
    Reads a boolean (0 is true, 1 is false) from the input port 0x80 and writes its negation to 0x84. Input: 1, output: 0.

/* risc-iv-32 */

  • [ok][Echo one char: 'ABCD']
    Same program with input "ABCD": only the first character is read and echoed, "BCD" stays in the input.
  • [ok][Echo one char: 'W']
    Reads one character from the input port 0x80 and writes it to the output port 0x84. Input: 'W' (87).
  • [ok][Factorial (loop)]
    Reads n = 5 from the input port 0x80, computes n! in a loop and writes 120 to the output port 0x84.
  • [ok][Hello world]
    Prints "Hello\n\0World" to the output port 0x84, one character at a time.
  • [ok][Huge report]
    A loop of 1 000 000 steps that hits the 600 000 step limit. Shows how a very long step-by-step report is cropped.
  • [ok][Logical NOT]
    Reads a boolean (0 is true, 1 is false) from the input port 0x80 and writes its negation to 0x84. Input: 1, output: 0.
  • [ok][Random memory init]
    Memory not set by the program is filled with random bytes on each run. The .word marker stays 0xDEADBEEF. Set seed: in the config to repeat a run.

/* vliw-iv */

  • [ok][Factorial (loop)]
    Reads n = 5 from the input port 0x80, computes n! in a loop and writes 120 to the output port 0x84.
  • [ok][Hello world]
    Prints "Hello\n\0World" to the output port 0x84, one character at a time.
  • [ok][Parallel slots and hazards]
    Runs several operations in one bundle: read-after-read, write-after-write and write-after-read. Change seed: in the config to see the write-after-write result change.

/* wasm32 */

  • [ok][Call frames]
    Nested calls with .frame locals. Stops inside the inner call to show the stack layout: frames, locals and the control stack.
  • [ok][Echo one char: 'ABCD']
    Same program with input "ABCD": only the first character is read and echoed, "BCD" stays in the input.
  • [ok][Echo one char: 'W']
    Reads one character from the input port 0x80 and writes it to the output port 0x84. Input: 'W' (87).
  • [ok][Factorial (loop)]
    Reads n = 5 from the input port 0x80, computes n! in a loop and writes 120 to the output port 0x84.
  • [ok][Factorial (recursive)]
    Computes 5! = 120 with a function that calls itself. Each call gets its own frame on the operand stack.
  • [ok][Hello world]
    Prints "Hello\n\0World" to the output port 0x84, one character at a time.
  • [ok][Logical NOT]
    Reads a boolean (0 is true, 1 is false) from the input port 0x80 and writes its negation to 0x84. Input: 1, output: 0.
/* 0.0.6.4 */