% PRIMA - Die PRImitive MAschine


Architektur:   8-bit Akkumulatormaschine
               256 Worte Hauptspeicher, je 8-bit
               nur direkte Adressierung

Zwei Befehlsformate: 

   Klasse 0 (Arithmetische Operationen, Laden, Speichern)

                  bit:   7   6    5  4  3  2  1  0
                        [0] [WR] [opcode          ] 
                        [address                  ]

   Klasse 1 (Sprungbefehle)

                  bit:   7   6    5  4  3  2  1  0
                        [1] [      opcode         ] 
                        [address                  ]


Befehlszyklus ("instruction cycle"):

  state=0:   Befehl lesen,    BR = MEM[ PC ], PC = PC + 1

  state=1:   Adresse lesen,   AR = MEM[ PC ], PC = PC + 1

  state=2:   Befehl ausführen

             if (KL == 1) then         // dies ist ein Sprungbefehl
                if (condition) then    // Bedingung prüfen
                   PC = AR             // Sprungbefehl ausführen
                endif
             else                      // ALU oder Speicherzugriff
                if (WR == 1) then
                   MEM[ AR ] = AKKU    // Speichern
                else  
                   AKKU = ALU( AKKU, OV, MEM[AR] ) // ALU Operation
                endif
             endif



Liste der Befehle ("instruction set"):

Mnemonic   dezimal   binär        Operation

ADD              0   00000000            AKKU = AKKU + MEM[ AR ], 
ADD*            32   00100000     OV=0,  AKKU = AKKU + MEM[ AR ]
SUB              1   00000001            AKKU = AKKU - MEM[ AR ]
SUB*            33   00100001     OV=0,  AKKU = AKKU - MEM[ AR ]

AD1             10   00001010            AKKU = AKKU + 1   (increment)
AD1*            42   00101010     OV=0,  AKKU = AKKU + 1   (increment)
SB1             12   00001100            AKKU = AKKU - 1   (decrement)
SB1*            44   00101100     OV=0,  AKKU = AKKU - 1   (decrement)

OR               2   00000010            AKKU = AKKU OR  MEM[ AR ], 
OR*             34   00100010     OV=0,  AKKU = AKKU OR  MEM[ AR ], 
AND              3   00000011            AKKU = AKKU AND MEM[ AR ], 
AND*            35   00100011     OV=0,  AKKU = AKKU AND MEM[ AR ], 
XOR              4   00000100            AKKU = AKKU XOR MEM[ AR ], 
XOR*            36   00100100     OV=0,  AKKU = AKKU XOR MEM[ AR ], 

NOP              8   00001000            AKKU = AKKU       (no operation)
NOP*            40   00101000     OV=0,  AKKU = AKKU       (clear OV)

SL               5   00000101            AKKU = AKKU << 1  (shift left)
SL*             37   00100101     OV=0,  AKKU = AKKU << 1  (shift left)
SR               6   00000110            AKKU = AKKU >>> 1 (shift right)
SR*             38   00100110     OV=0,  AKKU = AKKU >>> 1 (shift right)
RR               7   00000111            AKKU[i] = AKKU[i-1%8] (rotate right)
RR*             39   00100111     OV=0,  AKKU[i] = AKKU[i-1%8] (rotate right)

Laden und Speichern ("load", "store"):

LD               9   00001001            AKKU = MEM[ AR ]  (load)
LD*             41   00101001     OV=0,  AKKU = MEM[ AR ]  (load)
LDI             11   00001011            AKKU = MEM[ AR ] + 1 
LDI*            43   00101011     OV=0,  AKKU = MEM[ AR ] + 1  
LD0             14   00001110            AKKU = 0
LD0*            46   00101110     OV=0,  AKKU = 0
LD1             15   00001111            AKKU = 1
LD1*            47   00101111     OV=0,  AKKU = 1

ST              72   01001000            MEM[ AR ] = AKKU  (store)
ST             104   01101000     OV=0,  MEM[ AR ] = AKKU  (store)

Sprungbefehle ("branches"):

BU             128   1x0xxxx0     PC = AR     (jmp / branch unconditional)
BU*            160   1x1xxxx0          
BZ             131   10000011     if (AKKU == 0) PC = AR   (branch if zero)
BZ*            163   10100011     
BCY            133   10000101     if (AKKU[8]==1) PC = AR  (branch if carry)
BCY*           165   10100101      
BOD            193   11000001     if (AKKU[0]==1) PC = AR  (branch if odd)
BOD*           225   11100001     
BLS            137   10001001     if (AKKU[7]==1) PC = AR  (branch if less)
BLS*           169   10101001
BOV            ---   --------
BOV*           161   10100001     if (OV==1) PC = AR       (branch if overflow)
BSW            145   10010001     if (SW==1) PC = AR       (branch if switch)
BSW*           177   10110001