DCIT 101
Introduction to Computer Science
Session 5:
Computer Software Fundamentals
Contact Information: saadingo@[Link]
College of Education
School of Continuing and Distance Education
Topics
• Assembly Language
Programming
– Machine Code Instructions
– Assembly language
– Addressing Modes
– Assembly Language
Instructions
• System Software
Fundamentals
– System Software
– Operating System
Activities
– Utility Programs
DCIT101_DE-20232024 Slide 2
– Library Programs
What is Assembly Language
Programming?
• An assembly language is a type of low-level programming
language that is intended to communicate directly with a
computer's hardware.
• Unlike machine language, which consists of binary and
hexadecimal characters, assembly languages are designed to
be readable by humans.
• An assembly language is a programming language that allows
a programmer (a human) to tell the microprocessor (the chip)
in the computer exactly what to do, in terms of the specific
operations the processor knows how to perform.
DCIT101_DE-20232024 Slide 3
What is Assembly Language
Programming?
• In assembly language, the instructional codes have been made
more user-friendly in such a manner that by looking at a program
written in assembly language one can understand some steps more
easily than a sequence of 0s and 1s.
• The computer instructions are written in easily understandable
short words which are called mnemonics. For example, MOV stands
for moving the data, SUB stands for subtraction, ADD stands for
addition, etc.
• All instructions are written in capital letters. A program in assembly
language needs software known as an assembler which converts
the program consisting of mnemonics and data into machine
language.
DCIT101_DE-20232024 Slide 4
Assembly language
• Machine code programming:
– Allows you the programmer to take control of the processor
– Yields optimum efficiency in program
– Can be time consuming
– Subject to errors
• Assembly language
– For each machine code instruction you have an equivalent assembly
language instruction
– Mnemonic (A symbolic abbreviation)
– A character representation of the operand
• Assembler
– Is a program that translates an assembly language program into
machine code
DCIT101_DE-20232024 Slide 5
Advantages of Assembly Language
– How programs interface with OS, processor, and BIOS;
– How data is represented in memory and other external
devices;
– How the processor accesses and executes instruction;
– How instructions access and process data;
– How a program accesses external devices.
DCIT101_DE-20232024 Slide 6
Advantages of Assembly Language
• Other advantages of Assembly Language
– It requires less memory and execution time;
– It allows hardware-specific complex jobs in an easier way;
– It is suitable for time-critical jobs;
– It is most suitable for writing interrupt service routines and
other memory resident programs.
DCIT101_DE-20232024 Slide 7
Features of an Assembly language
program
– Comments
– Symbolic name for constants
– Labels for addresses These help the programmer write
the program
– Macros
– Subroutines
– Directives This will be converted into binary code
– System calls
Sequence of instructions
that are used more than
once
These are instructions to the assembler as to how
it must construct the final executable machine
code
DCIT101_DE-20232024 Slide 8
Assembly Language Statements
• Assembly language programs consist of three types
of statements −
– Executable instructions or instructions,
– Assembler directives or pseudo-ops, and
– Macros.
DCIT101_DE-20232024 Slide 9
Setting up an Assembler Environment
• For this course, you will need
– An IBM PC or any equivalent compatible computer
– A copy of Linux operating system
– A copy of the Edsim simulator/NASM assembler program
• There are many good assembler programs, such as −
– Microsoft Assembler (MASM)
– Borland Turbo Assembler (TASM)
– The GNU assembler (GAS)
– The Edsim simulator/NASM
• [Link]
DCIT101_DE-20232024 Slide 10
Installing NASM
• To check whether you already have NASM installed, take the following steps −
– Open a Linux terminal.
– Type whereis nasm and press ENTER.
– If it is already installed, then a line like, nasm: /usr/bin/nasm appears. Otherwise, you
will see just nasm:, then you need to install NASM.
• To install NASM, take the following steps −
• Check The netwide assembler (NASM) website for the latest version.
• Download the Linux source archive [Link], where [Link] is the NASM
version number in the archive.
• Unpack the archive into a directory which creates a subdirectory nasm-X. XX.
• cd to [Link] and type ./configure. This shell script will find the best C compiler
to use and set up Makefiles accordingly.
• Type make to build the nasm and ndisasm binaries.
• Type make install to install nasm and ndisasm in /usr/local/bin and to install the
man pages.
DCIT101_DE-20232024 Slide 11
Installing NASM
• To install NASM, take the following steps −
– Check The netwide assembler (NASM) website for the latest version.
– Download the Linux source archive [Link], where [Link] is the
NASM version number in the archive.
– Unpack the archive into a directory which creates a subdirectory nasm-X.
XX.
– cd to [Link] and type ./configure. This shell script will find the best C
compiler to use and set up Makefiles accordingly.
– Type make to build the nasm and ndisasm binaries.
– Type make install to install nasm and ndisasm in /usr/local/bin and to
install the man pages.
DCIT101_DE-20232024 Slide 12
Machine Code Instructions
DCIT101_DE-20232024 Slide 13
Machine Code Instructions
• Instruction Set
– The set of basic machine operations the processor can perform.
• Machine code
– It is the only language the machine (CPU) understands
– Different processors have different instruction sets
– The structure of the code will be similar for different processors
• Opcode (Operation Code)
– This is a code that tells the computer which basic operation it must perform
• Machine code Instructions
– It is a binary code with a defined number of bits that comprises an opcode
and very often one operand
DCIT101_DE-20232024
Slide 14
Syntax of Assembly Language Statements
[label] mnemonic [operands] [;comment]
• The fields in the square brackets are optional
DCIT101_DE-20232024 Slide 15
Machine Code Instructions
• Instruction Format
– This is a binary format which specifies a computer instruction. It specifies the address
of the operand, the opcode and the addressing mode of the instruction
• Format of Machine code Instructions
– The total number of bits or bytes for the whole instruction
– The number of bits that define the opcode
– The number of operands that define the remaining bits
– Whether the opcode occupies the most significant bit or the LSB
operation Address mode Register addressing operand
4 bits 2 bits 2 bits 16 bits
Opcode
DCIT101_DE-20232024 Slide 16
Addressing Data in Memory
• Fetch-decode-execute cycle
– Fetching the instruction from memory
– Decoding or identifying the instruction
– Executing the instruction
– 0725H. This number will require two bytes of memory
DCIT101_DE-20232024 Slide 17
Addressing Modes
• When an instruction requires a value to be loaded into a
register, there are different ways of identifying the value and
these different ways is described as the addressing modes
operation Address mode Register addressing operand
4 bits 2 bits 2 bits 16 bits
Opcode
With two bits used for the addressing mode you
can have as many as four different types of
addressing mode
DCIT101_DE-20232024 Slide 18
Addressing Modes
• Immediate
– The value to be used is in the instruction
• Direct
– An address which holds the value to be used in the instruction
• Indirect
– An address which holds the address which holds the value to be
used is in the instruction
• Indexed
– An address to which must be added what is currently in the
index register (IX) to get the address which holds the value in the
instruction
DCIT101_DE-20232024 Slide 19
Instructions for data movement
Instruction Opcode Instruction Explanation
Opcode binary operand
LDM 0000 0001 #n Immediate addressing loading n to
ACC
LDR 0000 0111 #n Immediate addressing loading n to IX
LDD 0000 0010 <address> Direct addressing, loading to ACC
LDI 0000 0101 .<address> Indirect addressing, loading to ACC
LDX 0000 0110 <address> Indexed addressing, loading to ACC
STO 0000 1111 <address> Storing the contents of ACC
opcode operand
LDM #33 0000 0001 0010 0001
Assembly language
DCIT101_DE-20232024 Machine code Slide 20
Instructions for arithmetic operations
Opcode operand Opcode binary Explanation
ADD <address> 0000 1010 Add the contents of the address to ACC
INC <register> 0000 1011 Increase the value stored in the register by 1
DEC <register> 0000 1100 decrease the value stored in the register by 1
DCIT101_DE-20232024 Slide 21
Instructions for comparisons and
jumps
Opcode operand Opcode binary Explanation
JMP <address> 10000 0010 Jump to specified address, unconditional
CMP <address> 10000 0011 Compare the contents of ACC with contents of
address
CMP #n 1000 0100 Compare the contents of ACC with number n
JPE <address> 1000 0000 Jump to the address if result of the previous
comparison was TRUE
JPN <address> Jump to the address if result of the previous
comparison was FALSE
DCIT101_DE-20232024 Slide 22
Instructions for input and output
Opcode operand Opcode binary explanation
IN 1001 1001 Used to store in ACC the ASCII value of
character typed at the keyboard
OUT 0000 1000 Used to display on the screen the character for
which the ASCII code is stored in ACC
DCIT101_DE-20232024 Slide 23
Examples
• LDM #39
– Opcode : load the number which follows into the ACC
– Operand (number) 39
• ADD 67
– Opcode: Load the contents of the address which follows to
the ACC
– Operand: (address) 67
DCIT101_DE-20232024 Slide 24
Symbolic and Absolute Addressing
300 LDI 309 StartProg: LDI Here
301 CMP 394 CMP Value
302 JPE 308 JPE EndProg
303 OUT OUT
304 LDD 309 LDD Here
305 INC ACC INC ACC
396 STO 309 STO Here
307 JMP 300 JMP StartProg
308 End EndProg: End
309 500 Here: 500
310 65 65
311 74 74
312 65 65
313 90 90
314 32 Value: 32
DCIT101_DE-20232024 Slide 25
DCIT101_DE-20232024 Slide 26
System Software Fundamentals
• Objectives
– Describe why a computer needs an OS
– Explain the Key management tasks carried out by the OS
– Show an understanding of the need for typical utility software
– Show understanding that software under development is often
constructed using existing code from program libraries
– Describe the benefits to the developer of software constructed using
library files including DLL
– Show an understanding of the for assembler software
– Explain the benefits of using either a compiler or an interpreter
– Show an understanding that high level language programs may be
partially compiled and partially interpreted eg Java
DCIT101_DE-20232024 Slide 27
System Software Fundamentals
– System Software
– Operating System
Activities
– Utility Programs
– Library Programs
– Language Translators
DCIT101_DE-20232024 Slide 28
Application Software
• Examples of Application software
are the following −
– Payroll Software
– Student Record Software
– Inventory Management
Software
– Income Tax Software
– Railways Reservation
Software
– Microsoft Office Suite
Software
– Microsoft Word
– Microsoft Excel
– Microsoft PowerPoint
DCIT101_DE-20232024 Slide 29
Application Software
• Features of application software are as follows −
– Close to the user
– Easy to design
– More interactive
– Slow in speed
– Generally written in high-level language
– Easy to understand
– Easy to manipulate and use
– Bigger in size and requires large storage space
DCIT101_DE-20232024 Slide 30
System Software
1. Enter machine room with deck of punched cards and
punched paper tape reel
2. Switch on the computer
3. Put deck of cards into the card reader and press button
4. Put paper tape into tape reader and press button
5. Press button to run program, entered into memory from
punched cards, which uses data entered into memory
from tape
6. Press button to get output printed on the line printer
7. Switch off computer
8. Leave machine room with deck of cards, paper tape and
line printer output Slide 31
DCIT101_DE-20232024
Features of a system software
• Close to the system
• Fast in speed
• Difficult to design
• Difficult to understand
• Less interactive
• Smaller in size
• Difficult to manipulate
• Generally written in low-level language
DCIT101_DE-20232024 Slide 32
Operating System
• Operating System(OS):
– This is a software platform that provides facilities for
programs to be run which are of benefit to the user.
• The computer hardware is completely unusable without the
OS as it provides the visual interface that enables the user to
communicate with the computer system.
• The OS is an example of a ‘system software’ as opposed to an
application software.
• System Software are programs that help run the computer
system.
DCIT101_DE-20232024 Slide 33
Operating System
DCIT101_DE-20232024 Slide 34
Operating System Objectives
– To make the computer system convenient to use in an efficient
manner.
– To hide the details of the hardware resources from the users.
– To provide users a convenient interface to use the computer system.
– To act as an intermediary between the hardware and its users,
making it easier for the users to access and use other resources.
– To manage the resources of a computer system.
– To keep track of who is using which resource, granting resource
requests, and mediating conflicting requests from different programs
and users.
– To provide efficient and fair sharing of resources among users and
programs.
DCIT101_DE-20232024 Slide 35
Operating Systems Features
• Characteristic features of Operating Systems −
– Memory Management
– Processor Management
– Device Management
– File Management
– Security
– Job Accounting
– Control Over System Performance
– Interaction with the Operators
– Error-detecting Aids
– Coordination Between Other Software and Users −
DCIT101_DE-20232024 Slide 36
Operating System Activities
• The computer has various resources which must be managed;
– Main memory: Do we have enough memory to load
another program?
– Secondary storage: is there sufficient hard disk space to
save a file download?
– Processor: if a number of processes are concurrently
loaded, how does the OS decide which process gets the
next use of the processor
– Input/Output: are they working? Are they recognized by
the various application programs in use?
DCIT101_DE-20232024 Slide 37
Operating System Activities
• User-System interface
– A command line interface
– A graphical user interface
DCIT101_DE-20232024 Slide 38
Operating System Activities
• User-System interface
– A command line interface
– A graphical user interface
• Do you have any experience of using a command line
interface?
• Find out how to run commands from a command line
interface and list all the directories on your computer
• List all the files on the computer
• Create a new directory
DCIT101_DE-20232024 Slide 39
Operating System Activities
• Program-hardware interface
– Programmers write software users run the software
– The OS has to ensure that the hardware does what the software wants
it to do
– Program development tools associated with a programming language
allow a programmer to write a program without worrying about how
the processor/hardware works. The OS then provides a mechanism for
executing the program developed
DCIT101_DE-20232024 Slide 40
Operating System Activities
• Resource Management
– A process is an instant of a program in execution
– Processes don’t run to completion without interruption
– At any one time there will be many processes running on the computer
system and each process needs access to resources provided by the
computer system
• Resource management is about:
– Scheduling of processes
– Resolution of conflicts when two processes require the same resource
DCIT101_DE-20232024 Slide 41
Operating System Activities
• Memory Management
– Memory protection: ensures that one program does not try
to use the same memory locations as another program
– Memory organization scheme: is chosen to achieve
optimum usage of a limited memory size, eg virtual
memory, paging or segmentation
– Memory usage optimization involves decisions about which
processes should be in main memory at any one time and
where they are stored in this memory
DCIT101_DE-20232024 Slide 42
Operating System Activities
• Device Management
– Every computer system has a variety of components that
are categorized as devices eg monitor screen, keyboard,
printer, webcam etc. their management requires
– Installation of the appropriate device driver software
– Control of usage by processes
DCIT101_DE-20232024 Slide 43
Operating System Activities
• File Management
– File naming conventions
– Directory (folder) structure
– Access control mechanism
• Security Management
– Provision of recovery when data is lost
– Prevention of intrusion
– Ensuring data privacy
DCIT101_DE-20232024 Slide 44
Operating System Activities
• Error detection and recovery
• Errors can arise due to many reasons
• Badly written program
• Wrong data
• Device not working properly
– The OS should be able to
• Interrupt a running process and provide error
diagnostics
• In extreme cases should be able to shut down the
system in an organized fashion without loss of data.
DCIT101_DE-20232024 Slide 45
Utility Programs
• Utility Program
– A program that performs a very specific task, usually
related to managing system resources, supporting users
and developers in their work.
– It might be provided by the OS or installed separately
– It is not executed as part of the normal routine of the OS
– Utility programs are run as and when needed
DCIT101_DE-20232024 Slide 46
Utility Programs
• Examples of Utility Programs
– Hard disk formatter and checker
• Removing existing data from a disk that has been used previously
• Setting up the file system based on table of contents, this allows file
recognized by the OS to be associated with specific physical part of disk
• Partitioning the disk into logical drives
– Hard disk defragmenter
– Virus checker
– Backup software
– File compression
– Disk contents analysis/disk repair software
DCIT101_DE-20232024 Slide 47
Library Programs
• Library program:
– A program contained in a program library that the program can make
use of in his own software development
– Examples include built in functions, Numerical algorithmic group (NAG)
library (since 1971)
– Dynamic Link Library (DLL): provides a mechanism for code sharing. A
DLL file is executable code which is only loaded into main memory
when required.
DCIT101_DE-20232024 Slide 48
Language Translators
• Assembler software
– This is a software which translates a program written in an assemble
language into machine code.
– A two pass assembler may be required.
– First pass
• Removal of comments
• Creation of symbolic table containing the binary codes for symbolic names
and labels
• Creation of a literal table if programmer has used constants in the program
• Expansion of macros
• Identification of system calls and subroutines
– Second pass
• If no errors in first pass assembler generates object code. This involves
replacing symbolic addresses with absolute addresses.
DCIT101_DE-20232024 Slide 49
Language Translators
• Compiler software
– A compiler translates a source code program written in a high level
language into a machine code file. If there are syntax errors these are
reported to the developer. Changes are made and the program
recompiled. In the absence of errors an object code is produced which
can be executed many times over.
• Interpreter software
– An interpreter also converts a program written in a high level language
into machine code.
– The interpreter will analyse the first statement, if error is found it
executes that statement. The second statement is also analysed and
executed executed until the end.
DCIT101_DE-20232024 Slide 50
Language Translators
• Compilation steps
1. Source code is loaded into compiler (no data is required at this stage)
2. Compiler program begins execution
3. The first line of source code is read
4. The line is analysed
5. If an error is found it is recorded
6. If no error is found the line of source code is converted to an
intermediate code
7. The next line of source code is read and steps 4-7 are repeated
8. When the whole of the source code has been dealt with one of the
following happens
a. If no error is found in the whole source code the complete intermediate code
is converted into object code
b. If any errors are found a list of these is output and no object code is produced
DCIT101_DE-20232024 Slide 51
Language Translators
• Interpreter steps
1. The interpreter program, the source code and the data to be used are
all loaded
2. The interpreter begins execution
3. The first line of source code is read
4. The line is analysed
5. If an error is found this is reported and the program halts execution
6. If no error is found the line of source code is converted into an
intermediate code
7. The interpreter uses the intermediate code to execute the required
action
8. The next line of source code is read and steps 4-8 are repeated
DCIT101_DE-20232024 Slide 52
Language Translators
• Benefits and drawbacks of compilers and Interpreters
– Benefits of a compiler
• A compiler creates object code – that is an executable file
• Compiled programs execute faster than interpreted code
• Compiler software is not needed at runtime once compiled, no further
translation is required
• If the program contains loops the compiler will need to translate this
section of code only once
DCIT101_DE-20232024 Slide 53
Language Translators
• Benefits and drawbacks of compilers and Interpreters
– Benefits of an interpreter
• Interpreted code makes for easier debugging
• An interpreter allows an attempted execution of the program at any stage
in its development
• An interpreter allows for testing parts of a program before all the code is
written
• Java
– Platform independent language. You can run a java program on any
platform (hardware and OS) without any modification
– Java uses a 2 step compilation process
• Java source code is compiled (using javac compiler) to java byte code
• The byte code is executed by the JVM which is installed on every machine
DCIT101_DE-20232024 Slide 54
Language Translators
Differences Between Compiler and Assembler
Compiler Assembler
An assembler converts the assembly level
Compiler converts the high-level language source
language code into the machine level language
code into machine level language code.
code.
The input of a compiler is high-level language
Where as, its input is low level assembly code.
source code.
Compiler converts the whole source code to
Assembler does not convert the code in one go.
machine code at once.
It has the following phases: lexical analysis, syntax
analysis, semantic analysis, intermediate code
An assembler completes the task in two passes.
generation, code optimization, code generation
and error handling.
It produces a machine code in form of
It produces binary code in form of 0s and 1s.
mnemonics.
Examples are Java, C, C++ etc. compilers. Examples of assemblers are GAS, GNU etc.
DCIT101_DE-20232024 Slide 55
Assignment 4:
QUESTION ONE:
• One of the reasons for having an OS is to provide a
user interface to a computer system
– Name two different types of interface that an OS should
provide
– Identify for each type of interface a device that could be
used to enter data
– Identify and explain briefly three other management tasks
carried out by an OS
DCIT101_DE-20232024 Slide 56
Assignment 4:
QUESTION TWO:
• A PC OS will make available to a user a number of utility
programs
– Identify two utility programs that might be used to deal with a
hard disk problem
– For each of these utility programs explain why it might be
needed and explain what it does
– Identify two other utility programs for a PC user
• Library programs are made available for programmers
– Explain why a programmer should use library programs
– Identify two examples of a library program
DCIT101_DE-20232024 Slide 57
Assignment 4:
QUESTION THREE:
• Assemblers, compilers and interpreters are examples of translation
programs
– State the difference between an assembler and a compiler or interpreter
– A ‘two-pass’ assembler is usually used. Give two examples of what might
be done in the first pass
– State what will be produced in the second pass
• A programmer can choose to use an interpreter or a compiler.
– State three differences between how an interpreter works and how a
compiler works
– Discuss the advantages and disadvantages of an interpreter compared to a
compiler
– If a programmer chooses java, a special approach is used. Identify one
feature of this special approach.
DCIT101_DE-20232024 Slide 58
END
Referece:
• All material presented
in this course is based
on the book by D.
Dalcher and L. Brodie
Thank you Successful IT projects
DCIT101_DE-20232024 Slide 59