0% found this document useful (0 votes)
43 views

csc225 Lecture Notes-1

Computer Science 225 note

Uploaded by

longjiwokdima4
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
43 views

csc225 Lecture Notes-1

Computer Science 225 note

Uploaded by

longjiwokdima4
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 56

CSC 225: Introduction to

Computer Systems (2 CU)

 Course Lecturer: Prof. L.P. Damuut


 Assessment: 40:60
 Passmark:40%

1
Course Outline
 The structure of the Computer System
 Representation of numbers in computers

 Basic assembly language instruction sets, addressing

modes, stacks and procedures


 low level I/O concepts and examples of
microprogramming and logic circuits.
(Students will be expected to design, implement and debug
programs in an assembly language)

2
Course Objectives
At the end of this course each student should be able to:
1. Describe what a computer system is
2. Explain at least 4 components of a computer system
3. Differentiate between computer software and hardware
4. Give at least five examples each of input and output
devices respectively
5. Enumerate at least 4 categories of application software
6. Demonstrate how integer numbers are stored in the
computer memory
7. Perform basic binary arithmetic
8. Define assembly language and explain its basic syntax
9. State at least 4 advantages of assembly language
programs
10. Explain sample assembly language mnemonics

3
What is a computer
System?
A computer system can be defined as an
electronic device, operating under the control
of instructions stored in its own memory, that
can accept data (input), process the data
according to specified rules (process), produce
results (output) and stores the results
(storage) for future use. Generally, the term
computer system is used to describe a
combination of electro-mechanical
components known as hardware and a suite
of programs and data referred to as software.

4
printer
(output device)

monitor
(output device)

system unit
(processor, memory,
mouse
and storage devices)
keyboard (input device)
(input device)

USB flash drive


(storage device)
scanner
(input device)

modem
(communications
device)

memory cards
(storage device) external hard disk
(storage device)

Fig. 1 Computer hardware

5
The Components of a Computer
System
There are six primary components of a computer
system namely; input devices, the processor
(control unit and arithmetic/logic unit), memory,
output devices, storage devices, and
communications devices.
The processor, memory, and storage devices are
housed in a box-like case called the system unit or
Central Processing Unit (CPU) as shown in Fig. 1.
A peripheral is a device that connects to the system
unit and is controlled by the processor in the
computer. Peripherals can include input and output
devices, as well as some storage and communications
devices.

6
Input devices
An input device is any hardware component that allows the
user to feed data and instructions into the computer.
Depending on the program requirements, the input device
used may vary. Five commonly used input devices are
keyboard, mouse, microphone, scanner, and Web
cam. For PCs, the two primary input devices used are the
keyboard and the mouse.
A keyboard is an input device that contains keys users
press to enter data and instructions into the computer. All
desktop computer keyboards have a typing area that
includes the letters of the alphabet, numbers, punctuation
marks, and other basic function keys. Many desktop
computer keyboards also have a numeric keypad on the
right side of the keyboard

7
The System Unit

The system unit is a case that contains electronic


components of the computer used to process data (Fig 2).
System units are available in a variety of shapes and
sizes. The case of the system unit, also called the
chassis, is made of metal or plastic that protects the
internal components from damage. The motherboard,
sometimes called a system board, is the main circuit
board of the system unit. Many electronic components
are attached to it while others are built into it. The sound
and video cards are examples of adapter cards, which
are circuit boards that provide functions and capabilities
not built into the motherboard but are integrated into the
motherboard using expansion slots.

8
sound card

system unit

video card

memory module
processor

Fig 2 Components of the system unit

9
The Processor

The processor, also called the Central Processing Unit


(CPU), interprets and carries out the basic instructions
that operate the computer. Processors contain a control
unit and an arithmetic/logic unit. The control unit directs
and coordinates most of the operations in the computer.
The arithmetic/logic unit (ALU) performs arithmetic,
comparison, and other operations.
In a typical personal computer, all functions of the
processor are usually on a single chip. A computer chip is
a small piece of semi-conducting material that contains
many microscopic pathways capable of carrying electrical
current. Today’s processors can perform operations in
less than the time it takes to blink one’s eye.

10
Memory
The Memory consists of electronic components
that store instructions waiting to be executed and
data needed by those instructions. Most memory
keeps data and instructions temporarily, which
means its contents are erased when the
computer is off.
This type of memory is referred to as RAM. RAM
(Random Access Memory) consists of memory
chips that can be read from and written into by
the processor and other devices.

11
These chips are placed on a memory module that
fits in a slot on the motherboard.
The memory in computers is measured in
kilobytes, megabytes, gigabytes, or terabytes. A
byte usually stores one character, such as the
letter A.
One kilobyte (KB or K) equals exactly 1,024
bytes, and one megabyte (MB) is about one
million bytes. One gigabyte (GB) is
approximately one billion bytes, and one
terabyte (TB) is approximately one trillion bytes.

12
Output devices
Output devices are hardware components that convey
information from the computer system to one or more
end users.

Commonly used output devices include display units;


printers; speakers, headphones, earbuds;
projectors; and interactive whiteboards. When a
computer is used for processing tasks such as creating
documents, the two output devices commonly used are
the printer and a display unit (e.g. VDU). A display
device is an output device that visually conveys text,
graphics, sound and video information. A monitor is a
display device that is packaged as a separate peripheral.

13
Storage Devices

A storage device is a computer hardware that


records and/or retrieves items to and from storage
media. A storage is the physical material on which a
computer keeps data, instructions, and information.
Three common types of storage media are hard
disks, flash drives and optical discs. A hard disk
is a storage device that contains one or more
inflexible, circular platters that use
magnetic particles to store data, instructions and
other information. The system unit on most personal
computers contains at least one hard disk.

14
Communications Devices

A communications device is a hardware component that


enables a computer to send (transmit) and receive data,
instructions and information to and from one or more
computers or mobile devices. A widely used
communications device is modem .

Communications occur over transmission media such as


cables, telephone lines, cellular radio networks, and
satellites. Some transmission media, such as satellites and
cellular radio networks are wireless, which means they have
no physical lines or wires. People around the world use
computers
and communications devices to communicate with each
other using one or more transmission media.

15
Computer Software
Computer software, also called a program, consists of a
series of instructions, organized for a common purpose,
that tells the computer what tasks to perform and how to
perform them.
A user interacts with a program through its user
interface. The user interface controls how data and
instructions are entered and how information is displayed
on the screen. Software nowadays comes with a
graphical user interface. With a Graphical User Interface
(GUI) one can interact with the software using text,
graphics and visual images such as icons. Computer
software can be categorised into two broad classes
namely system software and application software.

16
a. System Software

System software consists of programs that control


the operations of the computer and its devices. Two
types of system software are operating systems
and utility programs.
An operating system is a set of programs that
coordinates all the activities among computer
hardware devices. It provides a means for users to
communicate with the computer and other software.
When a user starts a computer, portions of the
operating system are copied into memory (i.e.,
RAM) from the computer’s hard disk. These parts of
the operating system remain in memory while the
computer is on.

17
A utility program allows a user to perform
maintenance-type tasks usually related to
managing a computer, its devices, or its
programs. For example, you can use a
utility program to burn digital photos on an
optical disc. Most operating systems include
several utility programs for managing disk
drives, printers, and other devices and
media.

18
b. Application Software

Application software consists of programs


designed to make users more productive
and/or assist them with personal tasks. These
include personal information management,
note taking, project management, accounting,
document management, computer-aided
design, desktop publishing, paint/image
editing, audio and video editing, multimedia
authoring, Web page authoring, personal
finance, legal, tax preparation, home
design/landscaping, travel and mapping,
education and entertainment (e.g., games).
19
The following categories of application
software are commonly used:
1. Word Processing (e.g. MS Word)
2. Desktop Publishing (e.g. Quark Xpress)
3. Spreadsheets (e.g. MS Excel)
4. Databases (e.g. MS Access)
5. Graphics (e.g. Coreldraw)
6. E-mail (e.g. MS Mail)
7. Internet Browsers (e.g. Firefox, Explorer)
8. Entertainment (i.e., games) such as Spider
Solitaire

20
Representation of numbers in computers

Bit
– Single Binary Digit
– Can have value 0 or 1, and nothing else
– A bit is the smallest possible unit of information in a
computer
- Groups of bits can represent data or information
– 1 bit – 2 alternatives 0 or 1
– 2 bits – 4 alternatives 01, 00, 10 or 11
– 3 bits –8 alternatives 000, 001, 010, 011, 100, 101,110, 111
– 4 bits – 16 alternatives 0000, 0001, 0010, 0011, 0100, 0101,
0110, 0111, 1000, 1001,1010, 1011,1100, 1101, 1110, 1111
– 8 bits -28 = 256 alternatives
– n bits – 2n alternatives
– a group of 8 bits is called a byte

21
- 1kbyte = 210 = 1024 bytes
– 1Mbyte = 220= 1048,576 bytes
- 1Gbyte = 230 = 1,073,741,824 bytes

22
Binary Number Representation
of Integers
If we save one bit to signify positive (+) or
negative (-), then an n-bit binary word can
represent integers in the range
-2n-1 -1 .. +2n-1
For example, a 16-bit binary word can
represent integers in the range
-216-1 -1 .. +216-1 = -215 -1 .. +215
-32,767 .. +32,768

23
Exercise 1
Convert the 16-bit binary number 0 0 0 0 0 0
0 11 0 0 1 1 1 1 1 to a decimal number:
Solution:
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 (power)
0 0 0 0 0 0 0110011111
= 1 x 2 8 + 1 x 2 7 + 1 x 2 4 +1 x 2 3 + 1 x 2 2
+1x21+1x20
= 256 + 128 + 16 + 8 + 4 + 2 + 1
= 415

24
Let the most significant bit (MSB) signify
positive or negative numbers (1 for negative;
0 for positive)
Exercise 2: Sum -9 and +9 in 16-bits
+9 = 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 1
-9 = 1 0 0 0 0 0 0 0 0 0 0 0 1 0 0 1
Summing the two gives us:
+9 + (-9) = 1 0 0 0 0 0 0 0 0 0 0 1 0 0 1 0

The result is NOT zero!


How can this problem be solved?

25
In order to solve the problem in Exercise 2, we
need a different representation for negative
numbers called 2s-complement
Step 1: Take the 1s-complement of the positive
binary number, 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 1
Gives us: 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 0 (Hint:
flip each bit)
Step 2: Add 1 to the result
1111111111110110+
1
__________________________
1111111111110111
(this is the 2s compliment)

26
Step 3:Add the positive binary number to
the 2s compliment as follows:
0000000000001001+
1111111111110111
_____________________________
0000000000000000
This is the correct answer!

Exercise 3: Add the binary equivalence of


+5 and -5

27
Hexadecimal (Hex) Notation

In Hex notation, each group of 4 bits represents


a number in the range 0 – 15 as follows:
0000=0 1000=8
0001=1 1001=9
0010=2 1010=A
0011=3 1011=B
0100=4 1100=C
0101=5 1101=D
0110=6 1110=E
0111=7 1111=F

28
Consequently:

Binary: HEX:
0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 1 = 0009
1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 = FFF7

 Note that Hex is used as a notation for any


sequence of bits (e.g. ASCII characters
require only two hex digits)

29
Assembly Languages
Assembly Languages belong to the family of Low-level
programming languages that provide little or no abstraction
from a computer's Instruction Set Architecture(ISA).
Commands or functions in the language map closely to
processor instructions. These languages let the programmer
have direct access to the resources of the machine (e.g., CPU
Registers, Memory and I/O ports). Although they are machine-
dependent, assembly languages have the following
advantages:
 They are easier to understand and use than machine

languages
 Assembly language codes are relatively easy to debug

 They are easier to modify than machine language

 Assembly language programs are generally the fastest

programs
 Assembly language programs are often the smallest in size
30
Assembly Language
Syntax
Each assembly line begins with either a label, a blank
(tab), an asterisk, or a semicolon
Each line has four fields namely:
{label[:]} mnemonic {operand list} {;comment}

Note the label and comment fields are optional


Example: loop: mov #COUNT,r5 ; get counter

loop: = label
mov = mnemonic
#COUNT,r5 = operand list
; get counter = comment

31
Label Field
- Labels are symbols
– Labels must begin in column 1
– A label can optionally be followed by a
colon – The value of a label is the current
value of the Location Counter (address within
program)
– A label on a line by itself is a valid
statement – Labels used locally within a
program file must each be unique

32
Mnemonic Field
The Mnemonic Field:
– Follows the label field
– The mnemonic field cannot start in column
1; if it does, it is interpreted as a label
– The mnemonic field contains one of the
following items:
◦ Instruction mnemonic (I.e. ADD, MOV, JMP)
◦ Assembler directive (i.e. .data, .list, .equ)
◦ Macro directive (i.e. .macro, .var, .mexit)
◦ Macro call

33
Operand Field
The operand field follows the mnemonic field
and contains one or more operands
– The operand field is not required for all
instructions or directives
– An operand may consist of:
1. Symbols
2. Constants
3. Expressions (combination of constants and
symbols)
– Operands are separated by commas

34
Machine Language Instruction Set
Category Example
Arithmetic ADD, SUBTRACT, MULTIPLY,
DIVIDE
Logic AND, OR, NOT, EXCLUSIVE OR
Program Control BRANCHING, SUBROUTINES
Data Movement MOVE, LOAD, STORE
Input/Output READ, WRITE

35
Example:
C ++ Language code:
C= A + B;
An equivalent Assembly language code:
ADD r1, r2
where r1 and r2 are registers holding data A
and B respectively

36
Information System
– A system that takes data, stores and processes it,
and provides information as an output
– An IS is a computer in use
– The amount of data can be vast
Communication: the transfer of meaningful
Information. Communication Comprises of the
following:
» the sender (transmitter)
» the channel over which to send the data and
» the receiver
The communication protocol is also very important
for effective communication to take place

37
User interfaces:
– Software which is responsible for passing
information to and from the person using the
computer program
– Communicates with and controls the computer
– There are three common types of user interfaces
namely:
1. Graphic user interfaces: This uses pictures,
graphic symbols (icons) to represent commands
2. Menu driven interfaces: Pull-down menu are
used for user choices
3. Command driven interfaces:User types in
single letter, word or line on a prompt which is
translated into an instruction for the computer

38
Digital Logic Circuits
Design
At the logic level, there are two categories of digital
systems namely:
1. Combinational - digital systems without
memory
2. Sequential - digital systems with memory
For the purpose of this course, emphasis will be
placed on combinational digital circuit systems.
Note that digital signals can only have a fixed
number of values within certain tolerances. In
digital circuitry, these values can only be of two
distinct states namely TRUE or FALSE (i.e., High or
Low).

39
Boolean Algebra
Definition: a logical variable x can have only
one of two possible values or states :
x = TRUE
x = FALSE
In binary notation, we can say
x = TRUE = 1
x = FALSE = 0
This is called positive logic or high-true logic. We could
also say
x = TRUE = 0
x = FALSE = 1
This is called negative logic or low-true logic
Note that the positive logic is conventionally used instead.

40
Logic Gates
Logic gates are switching circuits that
perform certain simple operations on binary
Signals. These operations are chosen to
facilitate the implementation of useful
functions:
a. The AND Logic Operation: Consider the
following circuit diagram. The bulb lights on
when both A and B switches are ON or TRUE.
If any only one is ON or TRUE, the circuit is
still broken implying that the bulb won’t light.

41
A B

+
-

The truth table of the AND operation is as


follows: A B F= A AND B
0 0 0
0 1 0
1 0 0
1 1 1

42
The circuit diagram of the AND gate is as
shown below:

A
F=A.B
B

b. The OR logic operation: In the following


diagram, the light bulb is switched on when
ether of the two switches A and B is ON.

43
A
B
+
-

The truth table of the OR operation is as


follows:
A B F= A OR B
0 0 0
0 1 1
1 0 1
1 1 1

44
The circuit diagram of the OR gate is as
shown below:

A
F=A+B
B

Note that A and B are input variables


c. The NOT Logic Operation: This is a
single input logic operation also called a
toggle when the output signal is the reverse
of the input signal.

45
The truth table of the NOT logic operation is
given below:

A F= NOT A
0 1
1 0

The circuit diagram of the NOT gate is as


shown below:

A F=Ä

46
d. The NAND Logic Operation: This is a
combination logic comprising of both AND
and NOT operations. The truth table of the
NAND logic is as shown below:
A B F= A NAND B
0 0 1
0 1 1
1 0 1
1 1 0

The circuit diagram for the NAND gate is as


follows:

47
A
____
F=A.B
B

e. The NOR Logic operation: The NOR is


also a combination logic comprising of the
NOT and the OR logical operations. The truth
table of the NOR logic operation is as follows:
A B F= A NOR B
0 0 1
0 1 0
1 0 0
1 1 0

48
The NOR logic gate is as shown below:
A
____
F=A+B
B

f. The Exclusive OR /XOR logic operation. This


logic is similar to the OR logic but the output
is only TRUE if and only if one of the input
variables is TRUE.
The truth table of the XOR logic is as follows”
A B F= A XOR B
0 0 0
0 1 1
1 0 1
1 1 0 49
The XOR logic gate is as shown below:

A
F=A⊕B
B

50
Rules and Laws of Boolean Algebra
Operations on Boolean variables are defined
and governed by laws, the most important of
which are presented as follows:
1. Commutative Law: This law states that
the order of the variables is not important.
E.g.;

A.B=B.A
A+B=B+A

51
2. Associative Law: This law states that the
grouping of the variables is unimportant.
Example:

A . (B . C) = A . (B . C)
A + (B + C) = A + (B + C)
3. Distributive Law: This law states that we
can remove the parenthesis by ‘multiplying
through’. For example:
A . (B + C) = A . B + A . C
The above laws are the same as in algebra,
where ‘+’ and ‘.’ are interpreted as addition
and multiplication respectively.
52
DeMorgan’s Laws of Boolean
Algebra
Law (1): ____ __ __
A+B=A.B
The law reads as follows:
“NOT (A OR B) = NOT A AND NOT B”.
The truth table below provides prove for the
law:
____ _ _ _ _
A B A+B A+B A B A. B
0 0 0 1 1 1 1
0 1 1 0 1 0 0
1 0 1 0 0 1 0
1 1 1 0 0 0 0

53
Law(2): ____ _ _
A.B=A+B
The second law reads :
“NOT (A AND B) = NOT A OR NOT B”
The truth table below provide the proof.
___ _ _ _ _
A B A.B A.B A B A+ B
0 0 0 1 1 1 1
0 1 0 1 1 0 1
1 0 0 1 0 1 1
1 1 1 0 0 0 0

Note that these laws are true for any number of


variables.
54
Exercises
1 Write an assembly language subroutine to
sum ten positive integer numbers (i.e., 1 to 10).
2 Produce the truth table and circuit diagram
for the following Boolean algebra :
___
a. XY+KZ
______
b. BC+DE +FGH
3 Produce the Hex equivalents of the following
decimal numbers i. 100 ii. 204 iii. 55

55
4 Show how an 8-bit computer system would
carry out the following binary arithmetic
a. -6 + 9
b. 12 – 8

5 State and prove DeMorgan’s second law of


Boolean Algebra using truth table

56

You might also like