Composite

From Esolang
Jump to navigation Jump to search

Composite is an esolang created by User:ArthroStar11 All of it's commands are prime numbers (yes the name of the language is a pun)

Data Structure

  • 26 registers (32 bit signed integers) 1-index
  • data stack (32 bit signed integers, max size of 1000)
  • boolean cell

Syntax

Composite's program structure resembles assembly, you hard code in opcode n by typing in the nth prime. You type in the command followed by space separated args (if any exist). One line contains a command and all of its arguments

Composite's two means of flow control are while loops and subroutines. Subroutine calls are unconditional, loops will run as long as the boolean cell is true. The main routine starts at the beginning of the program and ends at the first defined subroutine or the end of the program, whichever is first.

Command list

PLEASE NOTE: the commands are listed as the opcodes, to use the commands you'll use the nth prime for opcode n

  • 1: define subroutine (0 args)
    • self explanatory
  • 2: gosub (1 arg)
    • jump to the subroutine <arg1>
  • 3: return (0 args)
    • returns from the subroutine, can also just let the subroutine end naturally. Ends program if reached in the main routine
  • 4: start loop (0 args)
    • defines the start point of the loop. Loops can be nested.
  • 5: end loop (0 args)
    • defines the end point of the loop
  • 6: greater than (2 args)
    • sets boolean cell to true if(reg[<arg1>] > reg[<arg2>])
  • 7: equal to (2 args)
    • sets boolean cell to true if(reg[<arg1>] == reg[<arg2>])
  • 8: not (0 args)
    • inverts boolean cell
  • 9: add (2 args)
    • reg[<arg1>] += reg[<arg2>]
  • 10: subtract (2 args)
    • reg[<arg1>] -= reg[<arg2>]
  • 11: multiply (2 args)
    • reg[<arg1>] *= reg[<arg2>]
  • 12: integer division (2 args)
    • reg[<arg1>] /= reg[<arg2>]
  • 13: modulo (2 args)
    • reg[<arg1>] %= reg[<arg2>]
  • 14: push(1 arg)
    • pushes reg[<arg1>] onto the stack
  • 15: pop(1 arg)
    • pops the stack and stores into reg[<arg1>]
  • 16: move (3 args)
    • if <arg1> is 1 sets reg[<arg2>] to <arg3>
    • if <arg1> is 2 sets reg[<arg2>] to reg[<arg3>]
  • 17: character input (1 arg)
    • takes user input as an ASCII character and stores it in reg[<arg1>]
  • 18: integer input (1 arg)
    • takes user input as an integer and stores it in reg[<arg1>]
  • 19: character output (1 arg)
    • prints reg[<arg1>] as an ASCII character
  • 20: character output (1 arg)
    • prints reg[<arg1>] as an integer

sample programs

Prints HI

53 2 2 359
53 2 3 367
67 2
67 3

prints 99 to 1

53 2 2 523
53 2 3 2
53 2 5 131
19
7
13 2 3
71 2
67 5
29 2 3
11

truth machine (shows subroutines)

53 2 2 2
29 2 2
61 3
13 3 2
71 3
7
3 2
11
2
71 3

Implementation

ArthroStar11's Interpreter (C source)