three states, no bits

A balanced ternary computer, specified and running in your browser

Every digit is -1, 0, or +1. Six of them make one word. This site documents the architecture and gives you a working machine to write for.

word
6 trits
states per word
729
range
-364 .. 364
memory
729 words
registers
R0 .. R7, PC, SP, FLAGS
instruction
3 words, fixed width

word dial

set each switch to - 0 +
243
81
27
9
3
1
reads000+0-9 -1 =8

Numbers, without a sign bit

Negative values fall out of the notation itself: flip every trit and you have the negation. Leading zero trits are dimmed so the significant part of a word reads first.

decimalwordweights
-364-------243 - 81 - 27 - 9 - 3 - 1
-13000----9 - 3 - 1
-100000--1
00000000
100000+1
8000+0-9 - 1
1210+++++81 + 27 + 9 + 3 + 1
364++++++243 + 81 + 27 + 9 + 3 + 1

A program, end to end

add.tas
START:
    MOV   R1, +0-      ; R1 = 8
    MOV   R2, 5
    ADD   R1, R2       ; R1 = 13
    STORE [100], R1
    HALT

Load this and six other example programs — including Fibonacci with visible overflow — in the playground, where the assembler reports errors by line and the machine can be stepped one instruction at a time.