單一指令計算機(英語:one instruction set computer,OISC)也稱最簡指令集計算機(ultimate reduced instruction set computer,URISC),它是一種抽象計算機,該計算機只有一條指令。巧妙地選取這一條指令,並且給予無限的資源,單一指令計算機就能成為和其他多指令計算機一樣的圖靈機。在教學上,這種計算機被推薦來幫助理解計算機架構,同時,也能用它來研究計算機的結構模型。
基本介紹
- 中文名:單一指令計算機
- 外文名:one instruction set computer
- 縮寫:OISC
- 又稱:最簡指令計算機
機器架構
- 位操縱機
- Transport Triggered Architecture機器
- 基於算術的圖靈完備機器
- 加法(addleq,如果小於或等於零則增加和分支)
- 減少(DJN,如果非零則減量和分支(跳躍))
- 增加(P1eq,如果等於另一個值則加1和分支)
- 減法(subleq,如果小於或等於則減法和分支)
指令類型
- 如果小於或等於零,則減去和分支
- 如果否定則減去並分支
- 如果借用,則反向減去並跳過
- 移動(用作傳輸觸發架構的一部分)
- 如果非零則減去和分支(SBNZ a,b,c,定義)
- Cryptoleq(異構加密和未加密計算)
如果不等於零減去並且分支
如果小於或等於零減去並且分支
subleq a, b, c ; Mem[b] = Mem[b] - Mem[a] ; if (Mem[b] ≤ 0) goto c
subleq2 a, b ; Mem[a] = Mem[a] - ACCUM ; ACCUM = Mem[a] ; if (Mem[a] ≤ 0) goto b
合成指令
subleq Z, Z, c
subleq a, Z subleq Z, b subleq Z, Z
subleq b, b subleq a, Z subleq Z, b subleq Z, Z
subleq b, Z, L1 subleq Z, Z, OUT L1: subleq Z, Z subleq Z, b, c OUT: ...
subleq2 tmp ; tmp = 0 (tmp = temporary register) subleq2 tmp subleq2 minus_one ; acc = -1 subleq2 a ; a' = a + 1 subleq2 Z ; Z = - a - 1 subleq2 tmp ; tmp = a + 1 subleq2 a ; a' = 0 subleq2 tmp ; load tmp into acc subleq2 a ; a' = - a - 1 ( = ~a ) subleq2 Z ; set Z back to 0
int memory[], program_counter, a, b, c program_counter = 0 while (program_counter >= 0): a = memory[program_counter] b = memory[program_counter+1] c = memory[program_counter+2] if (a < 0 or b < 0): program_counter = -1 else: memory[b] = memory[b] - memory[a] if (memory[b] > 0): program_counter += 3 else: program_counter = c
如果否定則減去並分支
subneg a, b, c ; Mem[b] = Mem[b] - Mem[a] ; if (Mem[b] < 0) goto c
subneg POS, Z, c ... c: subneg Z, Z
subneg4 s, m, r, j ; subtrahend, minuend, result and jump addresses ; Mem[r] = Mem[m] - Mem[s] ; if (Mem[r] < 0) goto j
如果借用則反向減去並跳過
例子
# First, move z to the destination location x. RSSB temp # Three instructions required to clear acc, temp [See Note 1] RSSB temp RSSB temp RSSB x # Two instructions clear acc, x, since acc is already clear RSSB x RSSB y # Load y into acc: no borrow RSSB temp # Store -y into acc, temp: always borrow and skip RSSB temp # Skipped RSSB x # Store y into x, acc # Second, perform the operation. RSSB temp # Three instructions required to clear acc, temp RSSB temp RSSB temp RSSB z # Load z RSSB x # x = y - z [See Note 2]