Ss 1
Ss 1
Ss 1
TCS 501
UNIT I INTRODUCTION
UNIT II ASSEMBLERS
Machine Dependent
Machine Independent
MACHINE INDEPENDENT
◦ comparison:
COMP - compares the value in
register A with a word in memory,
this instruction sets a condition code
CC to indicate the result
INSTRUCTION SET
BYTE0
CHARZ 5A Hexadecimal 0f Z
BYTE0
C1
EXAMPLE PROGRAMS (SIC)
BYTE0 BYTE1 BYTE2
ALPH
A
BYTE0 BYTE1 BYTE2
FIVE 00 00 05
BYTE0
CHARZ 5A Hexadecimal 0f Z
BYTE0
C1
BYTE0
CHARZ 5A Hexadecimal 0f Z
BYTE0
C1
BYTE0
CHARZ 5A Hexadecimal 0f Z
BYTE0
C1
BYTE0
CHARZ 5A Hexadecimal 0f Z
BYTE0
C1 5A
- - - -
EXAMPLE PROGRAMS (SIC) Example 2
Label Mnemoni Operand
cs
1000 LDX ZERO
1001 MOVECH LDCH STR1, X
0101 0000 1 001 0000 0001 0000
1002 STCH STR2, X
1003 TIX ELEVEN
1004 JLT MOVECH
- - -
- - -
1010 STR1 BYTE C TEST
STRING
1011 STR2 RESB 11
1012 ZERO WORD 0
- - - -
EXAMPLE PROGRAMS (SIC) Example 2
Label Mnemoni Operand
cs
1000 LDX ZERO
1001 MOVECH LDCH STR1, X
0101 0000 1 001 0000 0001 0000
1002 STCH STR2, X
0101 0100 1 001 0000 0001 0001
1003 TIX ELEVEN
1004 JLT MOVECH
- - -
- - -
1010 STR1 BYTE C TEST
STRING
1011 STR2 RESB 11
1012 ZERO WORD 0
- - - -
EXAMPLE PROGRAMS (SIC) Example 2
Label Mnemoni Operand
cs
1000 LDX ZERO
1001 MOVECH LDCH STR1, X 0101 0000 1 001 0000 0001 0000
- - - -
EXAMPLE PROGRAMS (SIC) Example 2
Label Mnemoni Operand
cs
1000 LDX ZERO
1001 MOVECH LDCH STR1, X 0101 0000 1 001 0000 0001 0000
- - - -
EXAMPLE PROGRAMS (SIC) Example 2
T E S T S T R I N G
TIX ELEVEN
JLT MOVECH 0 1 2 MEMORY ZERO
- - ZERO 00 00 00
- -
0 1 2 MEMORY- ELEVEN
STR1 BYTE C TEST ELEVEN 00 00 0B
STRING
STR2 RESB 11
ZERO WORD 0
ELEVEN WORD 11
0 1 2 3 4 5 6 7 8 9 10
T E S T S T R I N G
STR1 54 45 53 54 20 53 54 52 49 4E 47
0 1 2 3 4 5 6 7 8 9 10
STR2
0 1 2
ELEVEN
ELEVEN- MEMORY
00 00 0B
0 1 2 ZERO- MEMORY
ZERO 00 00 00
0 1 2
Load in Index register of content ZERO
X 00 00 00
0 1 2 3 4 5 6 7 8 9 10
T E S T S T R I N G
STR1 54 45 53 54 20 53 54 52 49 4E 47
0 1 2 3 4 5 6 7 8 9 10
STR2
0 1 2 0 1 2
ELEVEN 00 00 0B ZERO 00 00 00
ZERO- MEMORY
ELEVEN- MEMORY
0 1 2
X 00 00 00
Loaded (STR1(0)+X)=54
0 1 2
A 00 00 54
0 1 2 3 4 5 6 7 8 9 10
T E S T S T R I N G
STR1 54 45 53 54 20 53 54 52 49 4E 47
0 1 2 3 4 5 6 7 8 9 10
STR2 54
0 1 2 0 1 2
ELEVEN 00 00 0B ZERO 00 00 00
ZERO- MEMORY
ELEVEN- MEMORY
0 1 2
X 00 00 00
0 1 2
A 00 00 54
0 1 2 3 4 5 6 7 8 9 10
T E S T S T R I N G
STR1 54 45 53 54 20 53 54 52 49 4E 47
0 1 2 3 4 5 6 7 8 9 10
STR2 54
0 1 2 0 1 2
ELEVEN 00 00 0B ZERO 00 00 00
ZERO- MEMORY
ELEVEN- MEMORY
0 1 2
X 00 00 01
0 1 2
A 00 00 54
Increment the value of X by 1 and
compare the value of X with ELEVEN
IF X<ELEVEN
Set the value of CC=JLT
0 1 2 3 4 5 6 7 8 9 10
T E S T S T R I N G
STR1 54 45 53 54 20 53 54 52 49 4E 47
0 1 2 3 4 5 6 7 8 9 10
STR2 54
0 1 2 0 1 2
ELEVEN 00 00 0B ZERO 00 00 00
ZERO- MEMORY
ELEVEN- MEMORY
0 1 2
X 00 00 01
0 1 2
A 00 00 45
0 1 2 3 4 5 6 7 8 9 10
T E S T S T R I N G
STR1 54 45 53 54 20 53 54 52 49 4E 47
0 1 2 3 4 5 6 7 8 9 10
STR2 54 45
0 1 2 0 1 2
ELEVEN 00 00 0B ZERO 00 00 00
ZERO- MEMORY
ELEVEN- MEMORY
0 1 2
X 00 00 01
0 1 2
A 00 00 45
Example 3
LDA APLHA
ADD INCR
SUB ONE
STA BEETA
ONE WORD 1
ALPHA RESW 1
BEETA RESW 1
INCR RESW 1
JSUB READ
INDEV F1
-
-
.
READ LDX ZERO
TD INDEV
JEQ RLOOP
RD INDEV
STCH RECORD, X
TIX K100
JLT RLOOP
RSUB
-
-
INDEV BYTE X’F1’
RECORD RESB 100
.
ZERO WORD 0
K100 WORD 100
JSUB READ
INDEV F1
-
B0 B1.........................B99
-
RECORD
.
READ LDX ZERO
TD INDEV
JEQ RLOOP
RD INDEV
STCH RECORD, X
TIX K100
JLT RLOOP
RSUB
-
-
INDEV BYTE X’F1’
RECORD RESB 100
ZERO WORD 0
K100 WORD 100
JSUB READ
INDEV F1
-
B0 B1.........................B99
-
RECORD
.
READ LDX ZERO B0 B1 B2
TD INDEV ZERO 00 00 00
JEQ RLOOP
RD INDEV
STCH RECORD, X
TIX K100
JLT RLOOP
RSUB
-
-
INDEV BYTE X’F1’
RECORD RESB 100
ZERO WORD 0
K100 WORD 100
JSUB READ
INDEV F1
-
B0 B1.........................B99
-
RECORD
.
READ LDX ZERO B0 B1 B2
TD INDEV ZERO 00 00 00
JEQ RLOOP B0 B1 B2
RD INDEV K100 00 00 64
STCH RECORD, X
TIX K100
JLT RLOOP
RSUB
-
-
INDEV BYTE X’F1’
RECORD RESB 100
ZERO WORD 0
K100 WORD 100
JSUB READ INDEV F1
-
B0 B1.........................B99
- RECORD
. B0 B1 B2
READ LDX ZERO ZERO 00 00 00
TD INDEV
B0 B1 B2
JEQ RLOOP K100 00 00 64
RD INDEV B0 B1 B2
STCH RECORD, X X 00 00 00
TIX K100
JLT RLOOP
RSUB
-
-
INDEV BYTE X’F1’
RECORD RESB 100
ZERO WORD 0
K100 WORD 100
JSUB READ TEST DEVICE FOR READY
INDEV F1
IF YES CC= JLT
- ELSE CC= JEQ
B0 B1.........................B99
- RECORD
. B0 B1 B2
READ LDX ZERO ZERO 00 00 00
RLOOP TD INDEV
B0 B1 B2
JEQ RLOOP K100 00 00 64
RD INDEV B0 B1 B2
STCH RECORD, X X 00 00 00
TIX K100
JLT RLOOP
RSUB
-
-
INDEV BYTE X’F1’
RECORD RESB 100
ZERO WORD 0
K100 WORD 100
JSUB READ INDEV F1
-
B0 B1.........................B99
- RECORD
. B0 B1 B2
READ LDX ZERO ZERO 00 00 00
RLOOP TD INDEV
B0 B1 B2
JEQ RLOOP K100 00 00 64
RD INDEV B0 B1 B2
STCH RECORD, X X 00 00 00
TIX K100
JLT RLOOP
RSUB
-
-
INDEV BYTE X’F1’
RECORD RESB 100
ZERO WORD 0
K100 WORD 100
JSUB READ INDEV F1
- INPUT DEVICE
B0 B1.........................B99
- RECORD
. B0 B1 B2
READ LDX ZERO ZERO 00 00 00
RLOOP TD INDEV
B0 B1 B2
JEQ RLOOP K100 00 00 64
RD INDEV B0 B1 B2
STCH RECORD, X X 00 00 00
TIX K100
JLT RLOOP NOW LEST ASSUME THAT THE DEVICE IS
RSUB READY.
-
-
INDEV BYTE X’F1’
RECORD RESB 100
ZERO WORD 0
K100 WORD 100
JSUB READ
-
B0 B1.........................B99
- RECORD 71
. B0 B1 B2
READ LDX ZERO ZERO 00 00 00
RLOOP TD INDEV
B0 B1 B2
JEQ RLOOP K100 00 00 64
LET THE
RD INDEV B0 B1 B2 CHARACTER
STCH RECORD, X X 00 00 00 READ BY THE
TIX K100 DEVICE IS
INDEV F1 'GEU’
JLT RLOOP
RSUB Read the character from INDEV and store
- into accumulator A
-
A xx xx 71
INDEV BYTE X’F1’
RECORD RESB 100
ZERO WORD 0
K100 WORD 100
JSUB READ INDEV F1
-
B0 B1.........................B99
- RECORD 71
. B0 B1 B2
READ LDX ZERO ZERO 00 00 00 LET THE
RLOOP TD INDEV
B0 B1 B2 CHARACTER
JEQ RLOOP READ BY THE
K100 00 00 64
DEVICE IS
RD INDEV B0 B1 B2 'GEU'
STCH RECORD, X X 00 00 00
TIX K100
JLT RLOOP
A xx xx 71
RSUB
-
- STORE THE CONTENT OF THE Accumulator in
RECORD BY PERFORMING THE INDEXED (X)
INDEV BYTE X’F1’
ADDRESSING MODE.
RECORD RESB 100
ZERO WORD 0
K100 WORD 100
JSUB READ INDEV F1
-
B0 B1.........................B99
- RECORD 71
. B0 B1 B2
READ LDX ZERO ZERO 00 00 00 LET THE
RLOOP TD INDEV
B0 B1 B2 CHARACTER
JEQ RLOOP READ BY THE
K100 00 00 64
DEVICE IS
RD INDEV B0 B1 B2 'GEU'
STCH RECORD, X X 00 00 01
TIX K100
A xx xx 71
JLT RLOOP
RSUB
COMPARE THE VALUE OF X WITH K100,
- AFTER INCREMENT IN X.
- 64>1
SET CC=JLT
INDEV BYTE X’F1’
RECORD RESB 100
ZERO WORD 0
K100 WORD 100
JSUB READ INDEV F1
-
B0 B1.........................B99
- RECORD 71
. B0 B1 B2
READ LDX ZERO ZERO 00 00 00 LET THE
RLOOP TD INDEV
B0 B1 B2 CHARACTER
JEQ RLOOP READ BY THE
K100 00 00 64
DEVICE IS
RD INDEV B0 B1 B2 'GEU'
STCH RECORD, X X 00 00 01
TIX K100
A 00 00 71
JLT RLOOP
RSUB
COMPARE THE VALUE OF X WITH K100,
- AFTER INCREMENT IN X.
- 64>1
SET CC=JLT
INDEV BYTE X’F1’
RECORD RESB 100
ZERO WORD 0
K100 WORD 100
JSUB READ INDEV F1
-
B0 B1.........................B99
- RECORD 71
. B0 B1 B2
READ LDX ZERO ZERO 00 00 00 LET THE
RLOOP TD INDEV
B0 B1 B2 CHARACTER
JEQ RLOOP READ BY THE
K100 00 00 64
DEVICE IS
RD INDEV B0 B1 B2 'GEU'
STCH RECORD, X X 00 00 01
TIX K100
A 00 00 64
JLT RLOOP
RSUB
-
-
INDEV BYTE X’F1’
RECORD RESB 100
ZERO WORD 0
K100 WORD 100
JSUB READ INDEV F1
-
B0 B1.........................B99
- RECORD 71 69
. B0 B1 B2
READ LDX ZERO ZERO 00 00 00 LET THE
RLOOP TD INDEV
B0 B1 B2 CHARACTER
JEQ RLOOP READ BY THE
K100 00 00 64
DEVICE IS
RD INDEV B0 B1 B2 'GEU'
STCH RECORD, X X 00 00 01
TIX K100
A 00 00 64
JLT RLOOP
RSUB
-
-
INDEV BYTE X’F1’
RECORD RESB 100
ZERO WORD 0
K100 WORD 100
Cont…………….. JSUB READ
-
-
.
READ LDX ZERO
RLOOP TD INDEV
JEQ RLOOP
RD INDEV
STCH RECORD, X
TIX K100
JLT RLOOP
RSUB
-
-
INDEV BYTE X’F1’
RECORD RESB 100
ZERO WORD 0
K100 WORD 100
SIC/XE MACHINE ARCHITECTURE
•Memory
Maximum memory available on a SIC/XE
system is 1 Megabyte (220 bytes)
•Registers
Additional B, S, T, and F registers are
provided by SIC/XE, as compared to SIC.
REGISTERS
B 3 Base register
S 4 General working register
T 5 General working register
F 6 Floating-point accumulator (48
bits)
FLOATING-POINT DATA TYPE
• Same as SIC.
• There is a 48-bit floating-point data type
1 11 36
s exponent fraction
F*2(e-1024)
INSTRUCTION FORMATS
Format 1 (1 byte) 8
op
Eg-RSUB
8 4 4
Format 2 (2 bytes)
op r1 r2
Formats 1 and 2 are instructions that do not
reference memory at all
e.g. COMPR A, S
CONTINUED…
Format 3 (3 bytes)
6 1 11111 12
op n i xbpe disp
Displacement byte
Format 4 (4 bytes)
6 1 11111 20
op n i xbpe address
ADDRESSING MODES & FLAG BITS
•e - e = 0 means format 3, e = 1
means format 4
Format 3 or 4
ADDRESSING MODES
Format 3
Mode Indicatio Target address calculation
n
TA=(Base)+ disp
Base relative b=1,p=0 (0disp 4095) (disp can't be
-ve)
TA=(PC)+ disp
Program- (-2048disp 2047) (disp can
b=0,p=1
counter relative be -ve)
STX(10) LENGTH 6 1 1 1 1 1 1 12
(B)=0033 op n i x b p e disp
TA=0033
disp=TA-(B) 00010000 1 1 0 1 0 0 0000 0000 0000
Disp=0033-0033=0000 Direct addressing mode so n, i=1,
there is NO indexed addressing so x=0
0000- We discard the first bit, base relative so b=1, p=0
as we need to represent a total format 3 inst. so e=0
of 12 bits for displacement.
Note- In SIC/XE there always be opcode in such a way that no effect after
the last two-digit truncation.
2. Base relative Addressing Mode Example
6 1 1 1 1 1 1 12
op n i x b p e disp
STCH(54) BUFFER, X
(B)=0033
0101 0100 1 1 1 1 0 0 0000 0000 0011
TA=0036
disp=TA-(B) Direct addressing mode so n, & i=1,
Disp=0036-0033=0003 there is index addressing so x=1
base relative so b=1, p=0
format 3 inst. so e=0
1. PC relative Addressing Mode Example
6 1 1 1 1 1 1 12
op n i x b p e disp
6 1 1 1 1 1 1 12
op n i x b p e disp
A 00 00 05
EXAMPLE PROGRAMS (SIC/XE)
Example 1 BYTE0 BYTE1 BYTE3
LDA #5 ALPHA 00 00 05
STA ALPHA
LDCH #90
STCH C1
. BYTE0
. C1
ALPHA RESW 1
C1 RESB 1
A xx xx 5A
A xx xx 5A
Example 2 STR1
T
54
E
45 53
S T
54 20
S
53
T
54
R
52 49
I N
4E
G
47
LDT #11
LDX #0
MOVCH LDCH STR1, X 0 1 2 3 4 5 6 7 8 9 10
TIXR T
JLT MOVCH 0 1 2
- - ZERO 00 00 00
STR1 BYTE C’ TEST 0 1 2
STRING
T
STR2 RESB 11
0 1 2
X
0 1 2
A
Example 2 STR1
T
54
E
45 53
S T
54 20
S
53
T
54
R
52 49
I N
4E
G
47
LDT #11
LDX #0
MOVCH LDCH STR1, X 0 1 2 3 4 5 6 7 8 9 10
TIXR T
JLT MOVCH 0 1 2
- - ZERO 00 00 00
STR1 BYTE C’ TEST 0 1 2
STRING
T 00 00 0B
STR2 RESB 11
0 1 2
X 00 00 00
0 1 2
A XX XX
Example 2 STR1
T
54
E
45 53
S T
54 20
S
53
T
54
R
52 49
I N
4E
G
47
LDT #11
LDX #0
MOVCH LDCH STR1, X 0 1 2 3 4 5 6 7 8 9 10
TIXR T
JLT MOVCH 0 1 2
- - ZERO 00 00 00
STR1 BYTE C’ TEST 0 1 2
STRING
T 00 00 0B
STR2 RESB 11
0 1 2
X 00 00 00
0 1 2
A XX XX
Example 2 STR1
T
54
E
45 53
S T
54 20
S
53
T
54
R
52
I
49
N
4E
G
47
LDT #11
LDX #0
MOVCH LDCH STR1, X 0 1 2 3 4 5 6 7 8 9 10
TIXR T
JLT MOVCH 0 1 2
- - ZERO 00 00 00
STR1 BYTE C’ TEST 0 1 2
STRING
T 00 00 0B
STR2 RESB 11
0 1 2
X 00 00 00
0 1 2
A XX XX 54
Example 2 STR1
T
54
E
45 53
S T
54 20
S
53
T
54
R
52
I
49
N
4E
G
47
LDT #11
LDX #0
MOVCH LDCH STR1, X 0 1 2 3 4 5 6 7 8 9 10
TIXR T
JLT MOVCH 0 1 2
- - ZERO 00 00 00
STR1 BYTE C’ TEST 0 1 2
STRING
T 00 00 0B
STR2 RESB 11
0 1 2
X 00 00 00
0 1 2
A XX XX 54
Example 2 STR1
T
54
E
45 53
S T
54 20
S
53
T
54
R
52
I
49
N
4E
G
47
LDT #11
LDX #0
MOVCH LDCH STR1, X 0 1 2 3 4 5 6 7 8 9 10
TIXR T
JLT MOVCH 0 1 2
- - ZERO 00 00 00
STR1 BYTE C’ TEST 0 1 2
STRING
T 00 00 0B
STR2 RESB 11
0 1 2
X 00 00 01
0 1 2
A XX XX 54
Example 2 STR1
T
54
E
45 53
S T
54 20
S
53
T
54
R
52
I
49
N
4E
G
47
LDT #11
LDX #0
MOVCH LDCH STR1, X 0 1 2 3 4 5 6 7 8 9 10
TIXR T
JLT MOVCH 0 1 2
- - ZERO 00 00 00
STR1 BYTE C’ TEST 0 1 2
STRING
T 00 00 0B
STR2 RESB 11
0 1 2
X 00 00 01
0 1 2
A XX XX 54
DIFFERENT ARCHITECTURES
•Memory
•Registers
•Data Formats
•Instruction Formats
•Addressing Modes
•Instruction Set
•Input and Output
TRADITIONAL (CISC) MACHINES
•Immediate mode,
•register-direct mode,
•PC-relative,
•Register indirect with displacement,
•Register indirect indexed
INSTRUCTION SET
•Immediate mode,
•register-direct mode,
•PC-relative,
•Register indirect with displacement,
INSTRUCTION SET
LDT #200
LDX #0
CLOOP TD INDEV
JEQ CLOOP
To transfer two RD INDEV
hundred bytes of
data from input STCH RECORD, X
device to memory
TIXR T
JLT CLOOP
.
.
INDEV BYTE X ‘F5’
RECORD RESB 200
EXAMPLE PROGRAMS (SIC)
JSUB READ
.
READ LDX ZERO
CLOOP TD INDEV
Subroutine to
JEQ CLOOP
transfer two RD INDEV
hundred bytes of STCH RECORD, X
data from input TIX B200 : add 1 to index compare 200 (B200)
device to memory
JLT CLOOP
RSUB
.
INDEV BYTE X ‘F5’
RECORD RESB 200
ZERO WORD 0
B200 WORD 200
EXAMPLE PROGRAMS (SIC/XE)
JSUB READ
.
.
READ LDT #200
LDX #0
CLOOP TD INDEV
JEQ CLOOP
RD INDEV
Subroutine to STCH RECORD, X
transfer two
hundred bytes of TIXR T : add 1 to index compare T
data from input JLT CLOOP
device to memory RSUB
.
.
INDEV BYTE X ‘F5’
RECORD RESB 200