The TIS-100 runs at 50 Hz in RUN mode, 5,000 Hz in FAST mode, and 25 Hz when the STEP key (F6) is held down. (Holding the STEP button down only runs a single step.) Most assembly instructions run in a single cycle; MOV
takes two cycles under some circumstances.
The behavior of using ANY
as a destination suggests that nodes are evaluted starting at the upper left, moving left to right, and advancing down one row and returning to the left edge upon reaching the end of a row. This behavior is not guaranteed and may change.
The character # and any characters after it on a line are ignored. Comments may follow a label or opcode and arguments.
Characters following ## are treated as the program's title and are displayed in the menu. The ## does not need to be the start of comment. Spaces one the left and right side of the title are discarded. If multiple entries with ## are present, TIS-100 searches starting in the upper left node, searching from top to bottom inside of the node's assembly. If nothing is found, TIS-100 moves from left to right and repeats the search for the assembly in each node. Upon reaching the right edge, TIS-100 moves to the left of te next row down and repeats the procedure.
Title is "B":
# A ## B
Title is "#### C ####":
###### C ####
Title is "D":
##D
Title is "D":
## D
A label, if present, must be the first thing on the line. It is terminated with a : which must be immediately adjacent to the label. Valid characters for labels are the letters A through Z, the digits 0 through 9, and the punctuation in the set of ~`$%^&*()_-+={}[]|\;'"<>,.?/ . There are no limitations on which characters may be in which positions of the label. A line may only have a single label. A label must have at least one character before the colon. Labels may be up to 18 characters long, but the longest addressable label is 14 characters.
ACC
- Accumulator. Register. Can be used as a source or destination. Initialized to 0. Reads and writes are instantaneous.
BAK
- Backup. Register. Only SAV
and SWP
interact with BAK
. The identifier “BAK
” is never a valid identifier in a program.
NIL
- Nothing. Register. Can be used as a source, in which case “0” is returned. Can be used as a destination, which which case the value is discarded.
UP
, DOWN
, LEFT
, RIGHT
- Connections to adjacent nodes. Ports. Can be used as a source or a destination. When used as a destination, the value cannot be read by the adjacent node in the same cycle that it was written to. Blocks until a destination value is used as a source by the adjacent node or a source is used as a destination by an adjacent node.
ANY
- Port. Can be used as a source, in which case the value will be read from the first port with a waiting value, as searched in the order LEFT, RIGHT, UP, DOWN. Can be used as a destination, in which case the value is available to all ports; it will be cleared from all ports as soon as any adjacent node reads it. Assuming all adjacent points try to read simulataneously, the winner will be selected in the order UP, LEFT, RIGHT, and DOWN. The search order is not formally part of the TIS-100 description, so it may change in future releases.
LAST
- Port. Refers to the same port used by the last reference to ANY
, either in read or write. If ANY
has not been used, attempts to use LAST
as a source will return 0, while attempts to use LAST
as a destination will block forever.
source can be ACC, NIL, UP, DOWN, LEFT, RIGHT, ANY, LAST, or an integer from −999 through 999, inclusive. If the value is an integer, it is used directory. Otherwise the register or port is read for the value to use.
destination can be ACC, NIL, UP, DOWN, LEFT, RIGHT, ANY, or LAST.
Each opcode has 0, 1, or 2 arguments. The opcode and arguments must be separated by at least one space or comma, but may be separated by any number of spaces or commas. The following are all equivalent:
MOV 1 ACC
MOV,1 ACC
MOV 1,ACC
MOV,,,,1,,,,ACC
MOV , ,1, , ACC
Syntax: NOP
Does nothing.
Syntax: MOV
source destination
Reads a value from source and write it to destination. If source is a port, blocks until a value is present. If destination is a port, blocks until the value is received.
1 cycle when writing ACC or NIL.
2 cycles when writing to UP, DOWN, LEFT, or RIGHT, assuming the neighboring node is willing to retrieve the value on the second cycle. The data is not yet in the port until the end of the first cycle. This prevents a single value from travelling multiple nodes in a single cycle.
Syntax: SWP
Swaps the values of ACC and BAK
Syntax: SAV
Copies the value of ACC to BAK
Syntax: ADD
source
The source value is added to the value in ACC, and the result placed in ACC. Results greater than 999 are limited to 999. Results less than −999 are limited to −999.
Syntax: SUB
source
The source value is subtracted to the value in ACC, and the result placed in ACC. Results greater than 999 are limited to 999. Results less than −999 are limited to −999.
Syntax: NEG
The value in ACC is negative (swapped between positive and negative) and written back into ACC. 0 is left unchanged.
Syntax: JMP
label
Transfer execution to the first instruction after label.
Syntax: JEZ
label
If the ACC is 0, transfer execution to the first instruction after label.
Syntax: JNZ
label
If the ACC is not 0, transfer execution to the first instruction after label.
Syntax: JGZ
label
If the ACC is greater than 0, transfer execution to the first instruction after label.
Syntax: JLZ
label
If the ACC is greater than 0, transfer execution to the first instruction after label.
Syntax: JRO
source
Transfer execution to the offset specified by source. Offset is measured in instructions. Negative offsets can be used to move jump backward, positive offsets to jump forward, or 0 to execute the JRO instruction again.
Syntax: HCF
Causes the game to restart. Halt and Catch Fire. As execution of this instruction terminates the active run, it cannot be used in a puzzle solution.
Copyright Copyright 2015 Alan De Smet. This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License. Fork this on GitHub!