28z is a simple VM loosely inspired by the RPL environment on the HP-28 calculator.
go build .
./28z
All values are assumed to be floating point by default.
String values are identified by a single preceeding quotation mark (').
Sequence values contain a sequence of instructions created dynamically through the define and reduce sequence instructions.
Reference values are identified by a preceeding dollar sign ($) and are replaced with the corresponding register or variable value either when input, or in storing mode when evaluated.
References can also be specified with a preceeding percent sign (%) in interactive input to have the reference be resolved and immediately evaluated.
- Description: Evaluate x
- Arg count: 1
- Result count: 0
- Usage:
- Description: Drop x
- Arg count: 1
- Result count: 0
- Usage: drop ⤶
- Description: List availabel files in ROM
- Arg count: 0
- Result count: 0
- Usage: files ⤶ [files]⥱Console
- Description: Define sequence
- Arg count: 0
- Result count: 0
- Usage: > ⤶
- Description: Store y into x, preserving y
- Arg count: 2
- Result count: 1
- Usage: 2 ⤶ 'a ⤶ put ⤶ ⤒2; y⥗a
- Description: Clear stack
- Arg count: 0
- Result count: 0
- Usage: clear ⤶
- Description: Write a raw object to file
- Arg count: 1
- Result count: 0
- Usage:
- Description: Render RAM as buffer
- Arg count: 0
- Result count: 0
- Usage: render ⤶
- Description: Prompt the user for a value
- Arg count: 1
- Result count: 1
- Usage: 'Enter x ⤶ prompt ⤶
- Description: Apply x to renderable RAM
- Arg count: 1
- Result count: 0
- Usage:
- Description: y modulus by x
- Arg count: 2
- Result count: 1
- Usage: 6 ⤶ 2 ⤶ / ⤶ ⤒0
- Description: cos of x
- Arg count: 1
- Result count: 1
- Usage:
- Description: Derefernce x, replacing x
- Arg count: 1
- Result count: 1
- Usage: 'a ⤶ deref ⤶ ⤒a
- Description: Collect x and y into x
- Arg count: 2
- Result count: 1
- Usage: 1 ⤶ 2 ⤶ collect ⤶ ⤒[2]:1,2
- Description: Decrement the loop register
- Arg count: 0
- Result count: 0
- Usage: dec
- Description: Evalue x against all entries in y to modify y
- Arg count: 2
- Result count: 1
- Usage: apply ⤶
- Description: Exchange y and the value in var x
- Arg count: 2
- Result count: 1
- Usage: 3 ⤶ 'a ⤶ exchange ⤶ ⤒a 3⥗a
- Description: Purge x
- Arg count: 1
- Result count: 0
- Usage: 'a ⤶ purge ⤶ undefined⥗a
- Description: Execute x repeatedly
- Arg count: 1
- Result count: 0
- Usage: 0 ⤶ < ⤶'f ⤶ repeat ⤶
- Description: Inverts x
- Arg count: 1
- Result count: 1
- Usage:
- Description: Store y into x
- Arg count: 2
- Result count: 0
- Usage: 2 ⤶ 'a ⤶ asref ⤶ y⥗a
- Description: Collect stack into x
- Arg count: 1
- Result count: 1
- Usage: 1 ⤶ 2 ⤶ collect ⤶ ⤒[2]:1,2
- Description: Render and pause
- Arg count: 0
- Result count: 0
- Usage:
- Description: Set the result flag to 1 if y >= x
- Arg count: 2
- Result count: 0
- Usage:
- Description: Sleep for x ms
- Arg count: 1
- Result count: 0
- Usage:
- Description: Graph a sequence
- Arg count: 3
- Result count: 0
- Usage: graph ⤶
- Description: Display status
- Arg count: 0
- Result count: 0
- Usage:
- Description: Addition for all permuations of x and y
- Arg count: 2
- Result count: 1
- Usage:
- Description: Pop from this stack and push to previous
- Arg count: 1
- Result count: 0
- Usage: produce ⤶
- Description: Set the result flag to 1 if y <= x
- Arg count: 2
- Result count: 0
- Usage:
- Description: Subtract x from y
- Arg count: 2
- Result count: 1
- Usage: 6 ⤶ 2 ⤶ - ⤶ ⤒4
- Description: Halt execution
- Arg count: 0
- Result count: 0
- Usage: halt ⤶
- Description: Expand x into the stack
- Arg count: 1
- Result count: -1
- Usage: ⤒[2]:1,2 | expand ⤶ ⤒1 ⤒2
- Description: Print x
- Arg count: 1
- Result count: 0
- Usage: 'Hello world ⤶ print ⤶ Hello world⥱Console
- Description: Sets the result flat to 0
- Arg count: 0
- Result count: 0
- Usage:
- Description: Multiply y by x
- Arg count: 2
- Result count: 1
- Usage: 6 ⤶ 2 ⤶ * ⤶ ⤒12
- Description: Divide y by x
- Arg count: 2
- Result count: 1
- Usage: 6 ⤶ 2 ⤶ / ⤶ ⤒3
- Description: Refer to the current sequence
- Arg count: 0
- Result count: 1
- Usage: this ⤶
- Description: Zero RAM
- Arg count: 0
- Result count: 0
- Usage:
- Description: Set the result flag to 1 if x = y
- Arg count: 2
- Result count: 0
- Usage:
- Description: Conditionally evaluate x if result flag is 1
- Arg count: 1
- Result count: 0
- Usage: ⤒ | ceval ⤶
- Description: Return from function
- Arg count: 0
- Result count: 0
- Usage: end ⤶
- Description: Clear the output buffer
- Arg count: 0
- Result count: 0
- Usage:
- Description: Map a file to RAM
- Arg count: 1
- Result count: 0
- Usage: 'rom/file.raw ⤶ mmap ⤶ file.byes⥱RAM
- Description: sin of x
- Arg count: 1
- Result count: 1
- Usage:
- Description: Define sequence
- Arg count: 0
- Result count: 0
- Usage: < ⤶
- Description: Evaluate x against all entries in y
- Arg count: 2
- Result count: 0
- Usage:
- Description: Set loop counter to x
- Arg count: 1
- Result count: 0
- Usage: 5 ⤶ setloop ⤶
- Description: Execute x if the loop counter is not zero
- Arg count: 0
- Result count: 0
- Usage: 5 ⤶ setloop ⤶ ⤒ | loop ⤶
- Description: Stop the current loop
- Arg count: 0
- Result count: 0
- Usage:
- Description: Add x and y
- Arg count: 2
- Result count: 1
- Usage: 6 ⤶ 2 ⤶ + ⤶ ⤒8
- Description: Generate random between 0 and 1
- Arg count: 0
- Result count: 1
- Usage:
- Description: Use x to reduce y to a single value
- Arg count: 2
- Result count: 1
- Usage: reduce ⤶
- Description: Swap x and y
- Arg count: 2
- Result count: 2
- Usage: swap ⤶ ⤒x,y
- Description: Duplicates x on the stack
- Arg count: 1
- Result count: 2
- Usage:
- Description: Pop from previous stack and push to current
- Arg count: 0
- Result count: 1
- Usage: consume ⤶
- Description: Enter function
- Arg count: 0
- Result count: 0
- Usage: enter ⤶
- Description: Dereference x, preserving x
- Arg count: 1
- Result count: 1
- Usage: 'a ⤶ get ⤶ ⤒a
- Description: Set the result flag to 1 if x != y
- Arg count: 2
- Result count: 0
- Usage:
- Description: Conditionally evaluate y if result flag is 1, otherwise evaluate x
- Arg count: 2
- Result count: 0
- Usage: ⤒, ⤒ | ceval2 ⤶
- Description: Evaluate a pair where y is the last input and x is the generator
- Arg count: 1
- Result count: 1
- Usage: ⤒ ⤶ generate ⤶ ⤒, ⤒