假想電腦
有 XE 版本,為進階版
SIC/XE 可相容 SIC 的指令 (upward compatible)
Mnemonic | Number | Special use |
---|---|---|
A | 0 | Accumulator |
X | 1 | Index register |
L | 2 | Linkage register |
PC | 8 | Program counter |
SW | 9 | Status word |
Mode | Indication | TA |
---|---|---|
Direct | x=0 | = address |
Indexed | x=1 | = address+ (X) |
Mnemonic | Number | Special use |
---|---|---|
A | 0 | Accumulator |
X | 1 | Index register |
L | 2 | Linkage register |
PC | 8 | Program counter |
SW | 9 | Status word |
B | 3 | Base |
S | 4 | General working |
T | 5 | General working |
F | 6 | Floating-point |
Format 1 : 1 byte
Format 2 : 2 bytes
Format 3 : 3 bytes
Format 4 : 4 bytes
定址模式
Two-pass assembler
OPTAB
SYMTAB
Label | Addr |
---|---|
FIRST | 1000 |
CLOOP | 1003 |
ENDFIL | 1015 |
… | … |
LOCCTR
Intermedia file
見課本
更多定址模式 & instruction formats
Program Relocation
SIC/XE 指令對應
Immediate | op #c |
Indirect | op @m |
PC-relative/Base-relative | op m |
Extended format | +op m |
Indexed | op m,x |
Register-to-register instructions
Large memory
PC-relative : -2048 ~ 2047
Base-relative : 0 ~ 4095
Assembler 會先試 PC-relative, 失敗才試 Base-relative
如果還不夠用就用 format 4,有20 bit
ex 1 :
disp = RETADR - (PC) = 30 - 3 = 2Dh
opcode = 00010100b
nixbpe = 110010
ex 2 :
disp = 6 - 1A = -14 = -(0000 0001 0100)b = (1111 1110 1100)b = (FEC)b
opcode = 00111100
nixbpe = 110010
ex 3 :
disp = 0036 - 104E(PC) = -1018 <- 超過了
disp = 0036 - 0033(B) = 3
__不用處理 X __
nixbpe = 111100
ex 4 :
有變數操作,要用relative
disp = 0033 - 0006 = 02D
nixbpe = 010010
ex 5 :
COPY START 0
M 000007 05
#define
,可以定義很多東西symbol EQU value
把變數宣告和程式碼本身分開,讓 assembler 自行排列,可避免存取過遠的位置及增加讀取效率
預設為 default block
USE CBLCK
每個 block 都有自己的 LOCCTR
Pass 1 :
Pass2 :
計算 object code
對於 abslute symbol (非相對),沒有 block number
107 1000 MAXLEN EQU BUFEND-BUFFER
ex :
LENGTH = (block 1 start)+0003 = 0066+0003=0069
LOCCTR = (block 0 start)+0009 = 0009
PC-relative : disp = 0069 - 0009 = 0060
Object code 沒有被動到
USE
的時候 Text record 會開新的一行(個)
CSECT
tag 可供全域跳躍