System Software Module 1
System Software Module 1
System Software:
An Introduction to Systems Programming
Leland L. Beck
3rd Edition
1
System Programming
Chapter 1: Background
Chapter 2: Assemblers
Chapter 3: Loaders and Linkers
Chapter 4: Macro Processors
Chapter 5: Compilers
Operating Systems
Other System Software
Software Engineering Issues
3
Mr. Prashant Ankalkoti, Faculty, MCA Dept., JNNCE
Outline
Introduction
System Software and Machine Architecture
The Simplified Instructional Computer (SIC)
SIC Machine Architecture
SIC/XE Machine Architecture
SIC Programming Examples
Traditional (CISC) Machines
RISC Machines
Text editor
To create and modify the program
Compiler and assembler
You translated these programs into machine language
Loader or linker
The resulting machine program was loaded into
memory and prepared for execution
Debugger
To help detect errors in the program
Application Program
Utility Program
Debugger Macro Processor Text Editor
(Library)
OS
Memory Process Device Information
Management Management Management Management
Machine independent
Machine Dependent
Computer
Fetch Fetch
Decoder Computation Store Result
Instruction Operand
Addressing Modes
There are two addressing modes available
Indicated by x bit in the instruction
(X) represents the contents of reg. X
1 11 36
S exponent fraction
Addressing mode
Direct b=0, p=0 TA=disp
Format 4 e=1
Memory address
00000
(0000 0000 0000 0000 0000)
~FFFFF (Byte)
(1111 1111 1111 1111 1111)
UltraSPARC architecture:
Memory:
Memory consists of 8 bit-bytes. Two consecutive bytes form a
halfword, four bytes form a word, eight bytes form a doubleword.
UltraSPARC programs operates on Virtual Address
Space (264 bytes). Virtual Address Space is divided into pages and
these pages are stored in the physical memory or on disk.
Data Formats : Integers are stored as 8-, 16-, 32-, or 64-bit Binary
numbers.
Characters are represented using 8-bit ASCII codes.
Floating points are represented using three different formats namely
single-precision format, double-precision format, quad-precision
format.
Source Object
Program Assembler Code Linker
Executable
Code
Loader
50
2.1 Basic Assembler Functions
Assembler directives (pseudo-instructions)
START – specify name and starting addr of program
END – indicate the end of the source program and the
first executable instruction in the program.
BYTE – Generate character or hexadecimal constant,
occupying many bytes as needed to represent the
constant.
WORD- Generate one word integer constant
RESB - Reserve the indicated number of bytes
RESW – Reserve the indicated number of words
These statements are not translated into machine
instructions.
Instead, they provide instructions to the assembler itself.
51
2.1 Basic Assembler Functions
Data transfer (RD, WD)
A buffer is used to store record
Buffering is necessary for different I/O rates
The end of each record is marked with a null character
(0016)
Buffer length is 4096 Bytes
The end of the file is indicated by a zero-length record
Subroutines (JSUB, RSUB)
RDREC, WRREC
Save link (L) register first before nested jump
52
2.1 Basic Assembler Functions
Figure 2.1 shows an assembler language program
for SIC.
The line numbers are for reference only.
Indexing addressing is indicated by adding the modifier
“X”
Lines beginning with “.” contain comments only.
Reads records from input device (code F1)
Copies them to output device (code 05)
At the end of the file, writes EOF on the output device,
then RSUB to the operating system
53
Mr. Prashant Ankalkoti, Faculty, MCA Dept., JNNCE 54
Mr. Prashant Ankalkoti, Faculty, MCA Dept., JNNCE 55
2.1.1 A simple SIC Assembler
Figure 2.2 shows the generated object code for
each statement.
Loc gives the machine address in Hex.
Assume the program starting at address 1000.
Translation functions
Translate STL to 14.
Translate RETADR to 1033.
Build the machine instructions in the proper format (,X).
Translate EOF to 454F46.
Write the object program and assembly listing.
56
Mr. Prashant Ankalkoti, Faculty, MCA Dept., JNNCE 57
Mr. Prashant Ankalkoti, Faculty, MCA Dept., JNNCE 58
Mr. Prashant Ankalkoti, Faculty, MCA Dept., JNNCE 59
2.1.1 A simple SIC Assembler
Assembler’s Functions
Convert mnemonic operation codes to their machine
language equivalents
STL to 14
Convert symbolic operands (referred label) to their
equivalent machine addresses
RETADR to 1033
Build the machine instructions in the proper format
Convert the data constants to internal machine
representations
Write the object program and the assembly listing
60
2.1.1 A simple SIC Assembler
Example of Instruction Assemble
Forward reference
STCH BUFFER, X
8 1 15
549039
opcode x address
m
(54)16 1 (001)2 (039)16
61
2.1.1 A simple SIC Assembler
Forward reference
Reference to a label that is defined later in the program.
62
2.1.1 A simple SIC Assembler
The functions of the two passes assembler.
Pass 1 (define symbol)
Assign addresses to all statements (generate LOC).
Save the values (address) assigned to all labels for Pass
2.
Perform some processing of assembler directives.
Pass 2
Assemble instructions.
Generate data values defined by BYTE, WORD.
Perform processing of assembler directives not done
during Pass 1.
Write the OP (Fig. 2.3) and the assembly listing (Fig. 2.2).
63
2.1.2 Assembler Algorithm & Data Structures
Our simple assembler uses two internal data structures : The
OPTAB (operation code table )and SYMTAB (symbol table).
OPTAB is used to look up mnemonic operation codes and translate
them to their machine language equivalents.
LDA→00, STL→14, …
SYMTAB is used to store values (addresses) assigned to labels.
FIRST→1000, COPY→1000, …
64
2.1.2 Assembler Algorithm & Data Structures
The Operation Code Table (OPTAB)
Contain the mnemonic operation & its machine
language equivalents (at least).
Contain instruction format & length.
During Pass 1, OPTAB is used to look up and validate
operation codes.
During Pass 2, OPTAB is used to translate the operation
codes to machine language.
In SIC/XE, assembler search OPTAB in Pass 1 to find
the instruction length for incrementing LOCCTR.
Organized as a hash table, with mnemonic operation
code as the key (Static table).
65
2.1.2 Assembler Algorithm & Data Structures
The Symbol Table (SYMTAB)
Include the name and value (address) for COPY 1000
FIRST 1000
each label. CLOOP 1003
Include flags to indicate error conditions ENDFIL 1015
Contain type, length. EOF 1024
THREE 102D
Pass 1, labels are entered into SYMTAB, ZERO 1030
along with assigned addresses (from RETADR 1033
LOCCTR). LENGTH 1036
BUFFER 1039
Pass 2, symbols used as operands are look RDREC 2039
up in SYMTAB to obtain the addresses.
Organize as a hash table (static table).
The entries are rarely deleted from table.
66
2.1.2 Assembler Algorithm & Data Structures
Pass 1 usually writes an intermediate file.
Contain source statement together with its assigned
address, error indicators.
This file is used as input to Pass 2.
Figure 2.4 shows the two passes of assembler.
Format with fields LABEL, OPCODE, and OPERAND.
Denote numeric value with the prefix #.
#[OPERAND]
67
Mr. Prashant Ankalkoti, Faculty, MCA Dept., JNNCE 68
Mr. Prashant Ankalkoti, Faculty, MCA Dept., JNNCE 69
Mr. Prashant Ankalkoti, Faculty, MCA Dept., JNNCE 70
Mr. Prashant Ankalkoti, Faculty, MCA Dept., JNNCE 71
Mr. Prashant Ankalkoti, Faculty, MCA Dept., JNNCE 72
Mr. Prashant Ankalkoti, Faculty, MCA Dept., JNNCE 73
Mr. Prashant Ankalkoti, Faculty, MCA Dept., JNNCE 74
Mr. Prashant Ankalkoti, Faculty, MCA Dept., JNNCE 75
Mr. Prashant Ankalkoti, Faculty, MCA Dept., JNNCE 76
Mr. Prashant Ankalkoti, Faculty, MCA Dept., JNNCE 77
Mr. Prashant Ankalkoti, Faculty, MCA Dept., JNNCE 78
Mr. Prashant Ankalkoti, Faculty, MCA Dept., JNNCE 79
Mr. Prashant Ankalkoti, Faculty, MCA Dept., JNNCE 80
Mr. Prashant Ankalkoti, Faculty, MCA Dept., JNNCE 81
Mr. Prashant Ankalkoti, Faculty, MCA Dept., JNNCE 82
Mr. Prashant Ankalkoti, Faculty, MCA Dept., JNNCE 83
Mr. Prashant Ankalkoti, Faculty, MCA Dept., JNNCE 84
Mr. Prashant Ankalkoti, Faculty, MCA Dept., JNNCE 85
Mr. Prashant Ankalkoti, Faculty, MCA Dept., JNNCE 86
Mr. Prashant Ankalkoti, Faculty, MCA Dept., JNNCE 87
SIC / XE Program
ABC = ALPHA * 10 – 50
LDA #10 //ALPHA
ABC RESW 1