Σniac II

The Σniac II (pronounced "Zee-niac") is a minimal processor. There is only one user-accessible register, the accumulator A. The Σniac operates on 8-bit words, and has a 5-bit address space. There are 6 regular instructions, as well as a special "halt" instruction that indicates the end of computation. Each instruction is encoded in one byte: 3 bits opcode, and 5 bits address. The 5-bit instruction counter IC is reset to 0 upon a reset, so that instruction always starts at address 0.

The memory is organized as follows:
ROM: addresses 0x00 .. 0x17 (24 bytes) - for program and constants
RAM: addresses 0x18 .. 0x1f  (8 bytes)  - for memory variables

Σniac II instruction set and opcodes

    opcode        mnemonic        meaning
    
0   000 aaaaa     ld    A, adr    A = Mem[adr]
1   001 aaaaa     sub   A, adr    A = A - Mem[adr]
2   010 aaaaa     add   A, adr    A = A + Mem[adr]
3   011 aaaaa     st    A, adr    Mem[adr] = A
4   100 aaaaa     b     adr       IC = adr           (goto adr)
5   101 aaaaa     bneg  adr       if A7==1, IC = adr (if A<0 goto adr)

7   111 11111     halt            stop execution
The Σniac II is a slight modification of the Σniac, a computer designed by a group of students in a J-term course in 1999. It is small enough that its complete circuit can be constructed and simulated (which we will do later in the semester).

 

Sample programs

Here is a small program to compute 3+10-1 and store the result in RAM. Note that labels are used for all addresses.
address            instruction   opcode            comments
hex binary label   (mnemonic)    binary     hex    
00  00000          ld   A, C3    000 00101  05     // constant 3 is stored at address C3 == 5
01  00001          add  A, C10   010 00110  46
02  00010          sub  A, C1    001 00111  27
03  00011          st   A, X     011 11000  78
04  00100          halt          111 11111  FF
05  00101  C3:     3             0000 0011  03
06  00110  C10:    10            0000 1010  0A
07  00111  C1:     1             0000 0001  01

18 11000 X:                                        // variable X is stored in Ram at address 0x18

Here is a program to sum the numbers from 1 to N and load the result into the accumulator. Addresses are given in hex. Again, labels are used for all addresses (constants, variables, and branch targets)
address    instruction   opcode    
   
00         ld   A, N     ; 000 01100  0C
01         st   A, sum   ; 011 11001  79
02  loop:  sub  A, C1    ; 001 01011  2B
03         bneg end      ; 101 01001  A9
04         st   A, i     ; 011 11000  78
05         add  A, sum   ; 010 11001  59
06         st   A, sum   ; 011 11001  79
07         ld   A, i     ; 000 11000  18
08         b    loop     ; 100 00010  82
09  end:   ld   A, sum   ; 000 11001  19
0A         halt          ; 111 11111  FF
0B  C1:    1             ; 0000 0001  01
0C  N:     5             ; 0000 0101  05

18  i:
19  sum:
Use the formatting of the above program as a model when you write your own programs. After a bit of practice you can omit the binary opcode column.