Professional Documents
Culture Documents
CS303 M1-Ktunotes - in PDF
CS303 M1-Ktunotes - in PDF
Memory
8-bit bytes
3 consecutive bytes form a word
Addressed by the lowest number byte
S . I N
T U N OTE
215 (32768) bytes in the computer memory
K
A word (3 bytes)
…
32768 = 215 bytes
S . I N
instruction stores the return address
T U N OTE
in this register
PC 8
K Program counter; contains the address of the next
instruction to be fetched for execution
SW 9 Status word; contains a variety of information,
including a Condition Code (CC)
SIC does not have any stack. It uses the linkage register to store the
return address.
It is difficult to write the recursive program. A programmer has to
maintain memory for return addresses when he write more than one
layer of function call.
Data formats
Characters
8-bit ASCII codes
Integers
S . I N
OTE
24-bit binary numbers
T U N
2’s complement for negative values
K-N ⇔ 2 – N
n
e.g., if n = 4, -1 ⇔ 24 – 1 = (1111)2.
. I N
Note that the memory size of SIC is 215 bytes
S
U N OTE
X is to indicate index-address mode
T
K
Addressing modes
Mode Indication Target address calculation
S . I N
test CC and jump accordingly
E
SubroutineU N O
linkage T
instructions
K
JSUB
T
jumps and places the return address in register
L
RSUB
returns to the address in L
.
ONE WORD 1 ONE-WORD CONSTANT
. ONE-WORD VARIABLES
ALPHA RESW 1
BETA RESW 1
GAMMA RESW 1
DELTA RESW 1
INCR RESW 1
WORD/BYTE
Reserve one word/byte of storage
RESW/RESB
S . I N
Reserve one or more words/bytes of storage
Example
T U N OTE
K
ALPHA RESW 1
FIVE WORD 5
CHARZ BYTE C`Z’
C1 RESB 1
Registers S and T are only for storing data. They can not use
for accumulator
Ex: ADDR S, A A ← A+S
COMPR X, T
S . I N
OTE
sign bit s (0: +, 1: -)
T U N
fraction f: a value between 0 and 1
K
exponent e: unsigned binary number between 0 and 2047
value: s * f * 2 (e-1024)
Ex: 5 = 22+20=(2-1+2-3)*23= (2-1+2-3)*21027-1024
0,10000000011,1010000….0
S . I N
Extend the address field to 20 bits
E
SIC/XE instruction O
U N T
formats
K T
! " #! "
! " #! " ! " ! "
! " #! " $ # #! "
! " #! " $ # ! "
% & %
When base N
U O T
KT integer
relative mode is used, disp is a 12-bits
unsigned
When program-counter relative mode is used, disp
is a 12-bits signed integer
2’s complement
Direct addressing for formats 3 and 4 if b=p=0
These two addressing mode can combine with index
addressing if x=1
Addressing modes
Bits x,b,p,e: how to calculate the target address
relative, direct, and indexed addressing
modes
S . I N
Bits i and n: how to use the target address (TA)
U N TE Operand value
OIndication
Mode
T
K addressing
Immediate i=1, n=0 TA: TA is used as the operand
value, no memory reference
Indirect addressing i=0, n=1 ((TA)): The word at the TA is
fetched. Value of TA is taken as
the address of the operand value
Simple addressing i=0, n=0 Standard SIC
i=1, n=1 (TA):TA is taken as the address of
the operand value
S . I N
OTE
3600 103000
.
.
.
. K T U N
. .
6390 00C303
. .
. .
. .
C303 003030
. .
. .
. .
T U N
+op m,X OTE (PC)+disp+(X)
(B)+disp+(X)
(TA)
(TA)
4DA
4DA
000---
001---
K +op m
+op m,X
b/p/e/disp
b/p/e/disp+(X)
(TA)
(TA)
4DAS
4DAS
Indirect 100000 +op @c disp ((TA)) 4D
100001 +op @m addr ((TA)) 4D
100010 +op @m (PC)+disp ((TA)) 4DA
100100 +op @m (B)+disp ((TA)) 4DA
Immediate 010000 +op #c disp TA 4D
010001 +op #m addr TA 4D
010010 +op #m (PC)+disp TA 4DA
010100 +op #m (B)+disp TA 4DA
Instruction set
Refer to Appendix A for all instructions (Page 496)
Notations for appendix
A ← (m..m+2): move word begin at m to A
S . I N
OTE
P: privileged instruction
T U N
X: instruction available only in SIC/XE
K
C: condition code CC
ALPHA
.
T
RESWK 1
U N ONE-WORD VARIABLE
C1 RESB 1 ONE-BYTE VARIABLE
. K
STR1 BYTE C’TEST STRING’ 11-BYTE STRING CONSTANT
STR2 RESB 11 11-BYTE VARIABLE
1
Downloaded from Ktunotes.in
Intro
Introduces the design & implementation of
system software
S . I N
2 types T U N OTE
K
Application software
System software
2
Downloaded from Ktunotes.in
Application Software (1/2)
3
Downloaded from Ktunotes.in
Application Software (2/2)
Types
Word processing S/W
Database S/W
Oracle, MS Access E S . I N
U N O T
Spreadsheet
T
KS/W
Excel, Lotus, Apple Numbers
Multimedia S/W
MS PowerPoint
Downloaded from Ktunotes.in
4
System Software (1/7)
5
Downloaded from Ktunotes.in
System Software (2/7)
Examples
Text Editor
Compiler
E S . I N
U N OT
Loader / Linker
T
K
Debugger
Assembler
Interpreter
6
Downloaded from Ktunotes.in
System Software (3/7)
Text Editor
Allows user to create/modify a file having only plain
text
S . I N
T U OTE
Edit contents to get an immediate visual feedback
N
K
Emacs (Unix)
Notepad (Microsoft)
SimpleText, TextEdit (Mac OS)
7
Downloaded from Ktunotes.in
System Software (4/7)
Compiler
Higher language to assembly language
Translates source code into data, that computer can
I N
S .
understand
T U N OTE
K
Source code to object code
ADA, BASIC, Fortran, Pascal
C, C++, C#
Open Source, Research
8
Downloaded from Ktunotes.in
System Software (5/7)
Linker
Object code from compiler is turned into executable
program
Gathers 1 or more objects generated by the compiler
& combines into a single EXE
S . I N
T U OTE
In IBM OS/360 termed as linkage editor
N
Loader K
Loads programs from executables into memory &
executes
9
Downloaded from Ktunotes.in
System Software (6/7)
Debugger
Breakpoint
K T U N
DEBUG – Microsoft DOS built-in debugger
Ups – Fortran, C
Xdebug – PHP
10
Downloaded from Ktunotes.in
System Software (7/7)
Assembler
Assembly language to machine language
Mnemonics to machine code
S . I N
T U OTE
Produces executable machine code
N
K
Pattern of bits
Interpreter
High level language to machine language
Executes immediately
11
Downloaded from Ktunotes.in
S . I N
T U N OTE
K
Application software is
System software is used for operating
1. used by user to perform
computer hardware.
specific task.
System softwares are installed on the Application softwares are
2. computer when operating system is installed according to
installed. user’s requirements.
S . I N
3.
N OTE
In general, the user does not interact with
system software because it works in the
T U
In general, the user
interacts with application
K
background. sofwares.
Application software can’t
System software can run independently. It run independently. They
4. provides platform for running application can’t run without the
softwares. presence of system
software.
Some examples of
application softwares are
Some examples of system softwares are
5. word processor, web
compiler, assembler, debugger, driver, etc.
browser, media player,
etc.
14
Downloaded from Ktunotes.in
System S/W & Machine Architecture (2/2)
System program
Supports the operation & use of computer
Focus on system
S . I N
Machine dependent
T U N OTE
Machine K
Independent
Some aspects of system software, do not directly
depend upon the type of computing system
general design & logic of an assembler
general design & logic of a compiler
code optimization techniques
15
Downloaded from Ktunotes.in
The Simplified Instructional Computer
(SIC) (1/2)
S . I N
Hypothetical
T U N OTE
computer that includes the
K
hardware features most often found on real
machines
16
Downloaded from Ktunotes.in
The Simplified Instructional Computer
(SIC) (2/2)
Two versions of SIC
SIC
S . I N
T U N OTE
SIC/XE (extra equipments or extra expensive)
K
SIC program can be executed on SIC/XE (upward
compatible)
Upward compatible
Object program for the standard SIC machine will execute
properly on SIC/XE system
17
Downloaded from Ktunotes.in
SIC Machine Architecture (1/7)
Memory
Registers
Data formats
E S . I N
U N O T
Instruction
K Tformats
Addressing Modes
Instruction Set
Input & Output
18
Downloaded from Ktunotes.in
SIC Machine Architecture (2/7)
Memory
215 bytes memory
32,768 bytes I N
S .
8-bit bytes
T U N OTE
K
3 consecutive bytes form a word (24 bits)
Little endian
addressed by location of lowest numbered byte
19
Downloaded from Ktunotes.in
SIC Machine Architecture (3/7)
Registers
5 registers – each of length 24 bits
E S . I N
Register Number
U O
Function
N T Use
A 0 KT Accumulator Arithmetic operations
X 1 Index register Addressing
L 2 Linkage register Storing return address for
subroutine jumps (JSUB)
PC 8 Program counter Address of next instruction to be
fetched
SW 9 Status word Flags, other information
including Condition Code (CC)
20
Downloaded from Ktunotes.in
SIC Machine Architecture (4/7)
Data Formats
Integers are stored as 24-bit binary numbers
2’s complement for negative values
I N
S .
T U OTE
8-bit ASCII for characters
N
K
No floating point hardware in standard SIC
Instruction Formats
24-bit format
x indicates indexed addressing mode
8 1 15
opcode X address
21
Downloaded from Ktunotes.in
SIC Machine Architecture (5/7)
Addressing modes
2 addressing modes available
Indicated by x bit in the instruction
S . I N
Mode T U N
Indication
OTETarget address calculation
K
Direct x=0 TA = address
Indexed x=1 TA = address + (x)
22
Downloaded from Ktunotes.in
SIC Machine Architecture (6/7)
Instruction Set
Load and store: LDA, LDX, STA, STX etc
Integer arithmetic operations: ADD, SUB, MUL, DIV
All arithmetic operations involve register A and a word in memory, with
the result being left in the register
Comparison: COMP I N
instruction sets aK
N
TU code CC to indicate the result
condition
Conditional jump instructions: JLT, JEQ, JGT
these instructions test the setting of CC and jump accordingly
Subroutine linkage: JSUB, RSUB
JSUB jumps to the subroutine, placing the return address in register L
RSUB returns by jumping to the address contained in register L
23
Downloaded from Ktunotes.in
SIC Machine Architecture (7/7)
24
Downloaded from Ktunotes.in
SIC/XE Machine Architecture (1/12)
Memory
Larger Memory
220 bytes (1 megabyte) in the computer memory
. I N
Leads to change in instruction formats & addressing modes
S
OTE
Registers
K T U N
Additional registers provided
Data Formats
Floating-point data type: frac*2(exp-1024)
fraction: 0~1
exponent: 0~2047
S . I N
OTE
s
1 11
K T U
exponent
N 36
fraction
26
Downloaded from Ktunotes.in
SIC/XE Machine Architecture (3/12)
Addressing modes
Base relative (n=1, i=1, b=1, p=0)
Program-counter relative (n=1, i=1, b=0, p=1)
I N
S .
T U OTE
Direct (n=1, i=1, b=0, p=0)
N
K
Immediate (n=0, i=1, x=0)
Indirect (n=1, i=0, x=0)
Indexing (both n & i = 0 or 1, x=1)
Extended (e=1)
Note: Indexing cannot be used with immediate or indirect
addressing
28
Downloaded from Ktunotes.in
SIC/XE Machine Architecture (5/12)
n i x b p e
opcode 1 0 0 disp
U N OTE
The word at the location given by the target address is
T
fetched K
The value contained in this word is then used as the address
of the operand value
Simple addressing mode
The target address is taken as the location of the operand
(n = 1, i = 1) used by SIC/XE
(n = 0, i = 0) used by SIC
Indexed addressing cannot be used with immediate or indirect modes.
33
Downloaded from Ktunotes.in
SIC/XE Machine Architecture (10/12)
4: Format 4 instruction
D: Direct-addressing instruction (i.e.,)non-relative addressing b=0 & p=0
A: Assembler selects either program-counter relative or base- relative mode
S: Compatible with instruction format for standard SIC
S . I N
T U N OTE
K
S . I N
T U N OTE
K
Instruction Set
new registers: LDB, STB, etc.
floating-point arithmetic: ADDF, SUBF, MULF, DIVF
register move: RMO S . I N
OTE
K T U N
register-register arithmetic: ADDR, SUBR, MULR, DIVR
supervisor call: SVC
generates an interrupt for OS
Input / Output
SIO, TIO, HIO
start, test, halt the operation of I/O device
36
Downloaded from Ktunotes.in
Complete Instruction Set (1/5)
P: privileged
instruction
X: available
only on XE
S . I N
T U N OTE F: floating-
point
K Instruction
C: condition
code CC set
to indicate
result of
operation
37
Downloaded from Ktunotes.in
Complete Instruction Set (2/5)
S . I N
T U N OTE
K
38
Downloaded from Ktunotes.in
Complete Instruction Set (3/5)
S . I N
T U N OTE
K
S . I N
T U N OTE
K
40
Downloaded from Ktunotes.in
Complete Instruction Set (5/5)
S . I N
T U N OTE
K
41
Downloaded from Ktunotes.in
SIC & SIC/XE Programming Examples(1/10)
Immediate addressing
makes the program
S . I N run faster because it
S . I N
T U N OTE
K
S . I N
T U N OTE
K
S . I N
T U N OTE
K
• Same as TIX. Value for comparison is taken form another register, not
from memory
• Loop efficient, b’coz value not fetched from memory each time the
loop is executed
S . I N
T U N OTE
K
S . I N
T U N OTE
K
S . I N
T U N OTE
K
49
Downloaded from Ktunotes.in
SIC & SIC/XE Programming Examples(9/10)
• Read operation placed in a subroutine
• Subroutine called from main using JSUB
• At end of subroutine, RSUB, returns control to instruction following
JSUB
• READ subroutine consists of loop
• TD, CC, then RD
S . I N
T U N OTE
K
Fig: Subroutine
Downloaded callKtunotes.in
from & record input operations SIC/XE 51