Computer Notes
Computer Notes
Denary Numbers
Denary numbers, also known as decimal numbers, are base-10 numbers.
They use ten symbols (0-9) to represent digits. The value of a denary
number is determined by the place value of each digit.
10
2
= 100 3 300
10
1
= 10 4 40
10
0
= 1 6 6
Binary Numbers
Binary numbers are base-2 numbers. They use two symbols (0 and 1),
called bits. Similar to denary numbers, the value is determined by place
values, but the place values are powers of 2.
Page 1
Created by Turbolearn AI
2
5
= 32 1 32
2
4
= 16 0 0
2
3
= 8 1 8
2
2
= 4 1 4
2
1
= 2 1 2
2
0
= 1 0 0
The sum of the products (32 + 8 + 4 + 2 = 46) gives the denary equivalent.
Hexadecimal Numbers
Hexadecimal numbers are base-16 numbers. They use sixteen symbols
(0-9 and A-F, where A-F represent 10-15). The value is determined by
place values, which are powers of 16.
Adding these products (512 + 160 + 6) gives the denary (base-10) equivalent: 678.
00001010 0A 10
11111111 FF 255
Page 2
Created by Turbolearn AI
Leading zeros are omitted when converting binary to hexadecimal on paper, but in
actual binary code, all positions in a byte must contain either a 0 or a 1. This
consistency is reflected in the hexadecimal representation.
Binary-Denary Conversions
Method 1: Summing Place Values
To convert a binary number to a denary number, add the place values of all digits
with a value of 1 (as illustrated in Table 1.02 - not included in this provided text).
Start with the most significant bit. Successively multiply by two and add the next
digit to the result. For example, converting 11001 to denary:
1. 64 (2⁶) → 1000000
2. 78 - 64 = 14
3. 8 (2³) → 1001000
4. 14 - 8 = 6
5. 4 (2²) → 1001100
6. 6 - 4 = 2
7. 2 (2¹) → 1001110
8. 2 - 2 = 0
Page 3
Created by Turbolearn AI
Successively divide the denary number by 2, recording the remainder at each step.
The binary equivalent is the sequence of remainders in reverse order.
246 / 2 123 0
123 / 2 61 1
61 / 2 30 1
30 / 2 15 0
15 / 2 7 1
7/2 3 1
3/2 1 1
1/2 0 1
To check an 8-bit binary result, remember that 7 bits can hold values up
to 127 (2⁷ - 1), while 8 bits can hold values up to 255 (2⁸ - 1).
Hexadecimal Conversions
Hexadecimal to Denary: Convert to binary first, then to denary.
Hexadecimal to Binary: Convert each hexadecimal digit to its 4-bit binary equivalent
(e.g., F → 1111, E → 1110).
Binary to Hexadecimal: Group the binary digits into sets of four, starting from the
least significant bit, and convert each group to its hexadecimal equivalent.
Task 1.01
Convert the following:
Question 1.01
Do computers ever use hexadecimal numbers?
Page 4
Created by Turbolearn AI
23,567 m
23.567 x 10³ m
23.567 km
Decimal Prefixes:
kilo k 10³
mega M 10⁶
giga G 10⁹
tera T 10¹²
In computing, these prefixes were historically used with slightly different meanings
(e.g., kilo often meant 1024 instead of 1000). This ambiguity is now resolved by
using binary prefixes:
Binary Prefixes:
kibi Ki 2¹⁰
mebi Mi 2²⁰
gibi Gi 2³⁰
tebi Ti 2⁴⁰
For readability, use one denary digit before the decimal point when presenting
numbers.
Number Representation
Page 5
Created by Turbolearn AI
When dealing with numerical results from calculations (e.g., file sizes), the initial
answer might not have the ideal number of digits before the decimal point. To fix this,
we use a magnitude factor.
For example:
If calculations involve values with different magnitude factors, convert them to the
same factor first. For instance, to find how many 2.4 MiB files fit on a 4 GiB memory
stick:
Computers store integers for various purposes. Sometimes, a simple positive integer
is stored as a binary number; the only decision is how many bytes to use. Using two
bytes (16 bits) allows representing values from 0 to (216 - 1) = 65,535.
However, twos complement form is more commonly used. Here are the definitions:
A faster method to find the twos complement: Start at the least significant bit and
move left, ignoring zeros until the first 1 (also ignore this 1). Invert the remaining bits.
Page 6
Created by Turbolearn AI
1. Convert to binary.
2. Add a leading 0.
Method 1:
Method 2:
Page 7
Created by Turbolearn AI
Binary Arithmetic
Recall denary addition: Start with the least significant digits, and if the sum exceeds
9, carry-over 1.
0+0=0
0+1=1
1 + 1 = 0 (carry 1)
1 + 1 + 0 = 0 (carry 1)
1 + 1 + 1 = 1 (carry 1)
Binary Addition
The addition of binary numbers follows these rules, performed from right to left
(least significant bit to most significant bit):
1 + 0 = 1 (no carry)
1 + 1 = 0 (carry 1)
0 + 1 + (carried 1) = 0 (carry 1)
1 + 1 + (carried 1) = 1 (carry 1)
Example: Adding the binary equivalents of denary 14 (1110) and denary 11 (1011):
Binary Subtraction
Binary subtraction also starts from the rightmost digit and proceeds left. A key
difference is "borrowing":
Page 8
Created by Turbolearn AI
0-0=0
0 - 1 = 1 (after borrowing 1 from the next position)
1-0=1
1-1=0
Example: Adding denary 63 (+63) to denary 63 (+63) using 8 bits (one byte):
One BCD digit per byte: Uses one byte, leaving four bits unused.
Packed BCD: Packs two 4-bit BCD codes into a single byte.
Page 9
Created by Turbolearn AI
BCD Arithmetic: Simple binary addition of BCD values can lead to incorrect results if
the result exceeds 9 in a nibble. A correction value (0110) is added when an invalid
BCD value (greater than 9) is produced.
ASCII Code
ASCII (American Standard Code for Information Interchange): A
character encoding standard for electronic communication.
The 7-bit version (US ASCII) was standardized by ANSI. Codes are usually presented
in tables (see example below). The most significant bit is often set to zero.
Page 10
Created by Turbolearn AI
Extended ASCII: Uses all eight bits of a byte, often referred to as ISO
Latin-1, including accented characters from European languages.
Variations also exist for this standard.
Question 1.02
Many years ago, a byte was defined as six bits. If a character was represented by one
byte, only 2 = 64 characters would be representable. Many characters would be
6
unavailable.
Unicode
Page 11
Created by Turbolearn AI
ASCII doesn't cover all characters; hence, Unicode was developed (alongside
Universal Character Set (UCS), ISO/IEC 10646). The goal is to represent any text,
including all languages. UTF-8 is a popular version using 1, 2, 3, or 4 bytes.
1 0??????? 7
2 110????? 10?????? 11
3 1110???? 10?????? 10?????? 16
4 11110??? 10?????? 10?????? 10?????? 21
The number of available codes depends on free bits. For example, the 2-byte format
has 11 free bits, allowing 2 = 2048 codes.
11
Images
Images are stored for display or printing. They can be created using graphics
packages or captured via photography/scanning.
Vector Graphics
In vector graphics (e.g., from drawing or CAD packages), each component is a
drawing object. The image is stored as a vector graphic file containing a drawing list
with commands and attributes for each object. Attributes include geometric data
(e.g., circle center, radius) and properties (line thickness, style, color, fill color).
Page 12
Created by Turbolearn AI
Task 1.05: Construct a partial drawing list for a given vector graphic. (This would
involve defining a format and listing commands for the image's objects based on
measurements.)
Image Representation
Vector Graphics
Vector graphic files represent images using geometric shapes.
Calculations are performed to avoid image distortion when the image is
displayed.
They can only be displayed directly on a graph plotter.
Conversion to a bitmap is often necessary for other display types.
Bitmaps
A bitmap is a digital image composed of a grid of pixels. Each pixel has a
specific color and position. The smallest identifiable component of a
bitmap image is a pixel.
Color Representation
Page 13
Created by Turbolearn AI
Bit depth: Number of bits to store each primary color (RGB). Often used
interchangeably with color depth, but more precisely describes bits per color
channel.
Resolution
Image resolution: Number of pixels per row × number of rows (in the bitmap
file).
Screen resolution: Resolution of the monitor displaying the image. Both must
be considered for screen displays.
A bitmap file doesn't define pixel or image physical size. Scaling doesn't change
pixel count. Magnification reveals individual pixels.
File Size
Larger files use more memory and take longer to display/transmit.
Vector graphics usually use less memory than bitmaps.
Bitmap file size calculation: (number of pixels per row) × (number of pixels per
column) × (color depth in bits) = total bits. Divide by 8 to get bytes.
Bit depth: 8 (24 bits per pixel since 8 bits per RGB component)
Resolution: 72 dpi (dots per inch), 5 inches × 3 inches
Pixels per row: 5 inches × 72 pixels/inch = 360 pixels
Pixels per column: 3 inches × 72 pixels/inch = 216 pixels
Total pixels: 360 × 216 = 77,760 pixels
Total bits: 77,760 pixels × 24 bits/pixel = 1,866,240 bits
Total bytes: 1,866,240 bits / 8 bits/byte = 233,280 bytes
Size in kibibytes: 233,280 bytes / 1024 bytes/KiB = 227.8 KiB
Page 14
Created by Turbolearn AI
Sound Representation
Natural sound: Variations in pressure detected by the ear. Contains many waves
with defined frequencies. Amplitude varies in a continuous, irregular pattern.
Electronic storage/transmission: Analog sound converted to binary code.
Sound Encoding
Sound encoder: Converts analog sound to digital data. Has two components:
Band-limiting filter: Removes high-frequency components undetectable
by the human ear.
Analog-to-digital converter (ADC): Samples the sound wave's
amplitude at regular intervals. Approximates amplitude using defined
amplitude levels. Accuracy depends on how closely the sample aligns
with an amplitude level.
Page 15
Created by Turbolearn AI
Compression Techniques
Two categories of compression exist:
Lossless compression: Reduces file size without information loss. The original
file can be recreated.
Lossy compression: Reduces file size with some information loss. The original
file cannot be perfectly recovered. Often, a combination of lossless and lossy
methods are used.
Page 16
Created by Turbolearn AI
Code Character
10 e
01 t
111 o
110 h
0001 l
0000 p
0011 w
0010 z
Exam-Style Questions
Question 1: A file contains binary coding. Two successive bytes are 10010101 and
00110011.
Page 17
Created by Turbolearn AI
Question 3: An audio encoder creates a song recording; the questions explore the
encoder's components.
Page 18
Created by Turbolearn AI
MP3 Compression
How music quality is retained: MP3 uses lossy compression techniques that
discard parts of the audio signal that are less perceptible to the human ear. This
significantly reduces file size without a major perceived loss in audio quality.
Network Evolution
Page 19
Created by Turbolearn AI
Modern LAN: Typically owned by the organization, uses twisted pair cables or
WiFi, contains a device for connecting to other networks, and includes directly
connected end-systems.
Internetworking
1990s: The widespread use of the Internet (internetworking) started.
Client-Server Model
Page 20
Created by Turbolearn AI
Early Use: In large organizations with internal networks, often using a powerful
central server.
Modern Use: The client is typically a web browser, and the server is a web
server hosting applications.
Thin Client: Sends input and receives output from the server.
Thick Client: May perform some processing locally before sending to or after
receiving data from the server; may even download and run the application
locally.
File Sharing
Client-Server: Files are stored on a server and accessed by clients.
Peer-to-Peer: Files are distributed among multiple peers, each acting as both
client and server. Advantages include avoiding network congestion.
Network Topologies
Five Requirements:
1. Sender
2. Receiver
3. Transmission medium (air or cables)
4. Message
5. Protocol
Page 21
Created by Turbolearn AI
Transmission Modes:
Message Types:
Network Topologies:
Transmission Media
Cable Types:
Twisted pair: Uses copper; lowest cost, lowest bandwidth, most susceptible to
interference and attenuation.
Coaxial: Uses copper; higher cost and bandwidth than twisted pair, less
susceptible to interference and attenuation.
Fiber-optic: Uses fiber optics; highest cost and bandwidth, least susceptible to
interference and attenuation.
Page 22
Created by Turbolearn AI
Twisted
Lowest Lowest Affected Worst More often
Pair
Coaxial Higher Higher Most affected Less affected More often
Fiber- Least
Highest Much higher Least affected Less often
Optic affected
Wireless Transmission:
(Figure 2.05, 2.06, and 2.07 would be included here if they were available.)
Question 2.01
Twisted pair cable can be shielded or unshielded. What are the options for this? How
does shielding affect the use of the cable?
Page 23
Created by Turbolearn AI
Satellite Communication
Satellite Altitudes:
GEO (Geostationary Earth Orbit): Highest altitude, over the equator;
used for long-distance communication; three satellites needed for global
coverage.
MEO (Medium-Earth Orbit): Used for GPS; ten satellites needed for
global coverage.
LEO (Low-Earth Orbit): Supplement mobile phone networks; fifty
satellites needed for full coverage (hundreds currently in orbit).
Van Allen Belts: Areas with high levels of charged particles that interfere with
satellites.
Transmission Delays: Greater distances with satellites cause transmission
delays.
Applications: GPS, internet access in remote areas. High-speed fiber optics
have reduced the reliance on satellites for general internet communication.
Page 24
Created by Turbolearn AI
Task 2.01: Calculate the approximate time taken for a transmission from the Earth's
surface to a medium-Earth-orbit satellite. (Assume the speed of light is 300,000
km/s). This calculation requires knowing the distance to the MEO satellite, which was
not provided in the lecture transcript.
LAN Hardware
Wired LANs
Early LANs: Used coaxial cables.
Current LANs: Primarily use twisted pair cables, with fiber-optic cables
becoming increasingly common.
Bus Configuration: Series of sockets linked by cables; terminators prevent
signal reflection; each end-system connects via an RJ-45 connector.
Star Configuration: Each end-system connects to a central device (hub, switch,
or router); cables are longer than in a bus configuration.
Repeaters: Used to extend bus networks by amplifying signals over long
distances.
Bridges: Connect two segments of a bus network; store network addresses of
end-systems in each segment.
Network Interface Card (NIC): Has a unique network address identifying the
end-system.
Central Devices: Hubs, switches, and routers; switches are the most common in
modern star networks.
Ethernet Ethernet
Page 25
Created by Turbolearn AI
Internet Infrastructure
The Internet is a massive, organically evolved internetwork, not a centrally
designed entity.
Its structure lacks a formal definition but exhibits a hierarchical nature.
Page 26
Created by Turbolearn AI
Routers
A router is a device at connection points (nodes) in the internet's mesh
network, responsible for selecting the optimal transmission route. Details
on router functionality are in Chapter 17, Section 17.05.
The Internet's core is a mesh of fiber-optic cables, with routers at each node.
Question 2.02
How near are you to an under-the-sea Internet fibre-optic cable?
Internet Applications
Page 27
Created by Turbolearn AI
Cloud Computing
Cloud computing provides computing services usually via the internet.
Options include private clouds (managed on-site or outsourced) and
public clouds (managed by third-party providers).
Bit Streaming
Bit streaming transmits compressed media (audio, video) as a sequence
of bits for efficient delivery. It's used in "on-demand" streaming, where
playback begins before the entire file is downloaded.
Streaming Media
Page 28
Created by Turbolearn AI
Two categories:
Buffer: Delivers data at the correct bit rate. Data sent to the buffer at a higher
rate to account for delays.
Media player: Monitors buffer fullness, controlling bit rate based on high and
low-water marks. Buffer size must be large enough to prevent overflow.
Page 29
Created by Turbolearn AI
Time (seconds) Data input (KiB) Data output (KiB) Buffer content (KiB)
Estimation: Buffer fills to high-water mark (900 KiB) between 8 and 10 seconds.
IP Addressing
TCP/IP: Standard protocol suite for internet communication, including IP
addressing.
IPv4 Address Classes: Original scheme with classes A, B, and C, each with a
different netID and hostID bit allocation.
A 0 7 24
B 10 14 16
C 110 21 8
Page 30
Created by Turbolearn AI
Problems with the original scheme: Insufficient Class B netIDs and too few
hostIDs in Class C addresses.
Method: 8-bit suffix added to specify the number of bits used for netID.
Example: Suffix 21 means 21 bits for netID, 11 bits for hostID (211 =
2048 hosts).
Sub-netting
Sub-netting improves host ID efficiency by structuring it. For example, a medium-
sized organization with 150 employees across seven LANs (six departments + head
office) could use sub-netting.
Page 31
Created by Turbolearn AI
This leaves only 106 unused addresses, which is reasonable for future expansion.
The other six unused netIDs remain available for other organizations.
Each address can be simultaneously used by many networks. The NAT box's
software examines each transmission, optionally including security checks.
IPv6 Addressing
IPv6 uses a 128-bit addressing scheme (2128 addresses), enabling more complex
address structures. Addresses are written in colon-hexadecimal notation, broken into
16-bit parts represented by four hexadecimal characters. Abbreviations are allowed.
Page 32
Created by Turbolearn AI
Domain Names
The Domain Name System (DNS), created in 1983, allocates readable domain
names for internet hosts and translates them to IP addresses. It's a hierarchical,
distributed database on numerous domain name servers. The hierarchy includes root
servers (replicated) at the top, with zones and primary/secondary name servers
below. There are over 250 top-level domains.
Page 33
Created by Turbolearn AI
LAN Topology: The most common topology for a Local Area Network (LAN) is
the star topology.
Transmission Media:
The World Wide Web: A distributed application accessible via the Internet.
Page 34
Created by Turbolearn AI
Portable:
Hard drive
Memory stick
Memory card (usually flash memory, but floppy disks or optical discs are
alternatives) Often used for personal backups.
Cloud storage
Magnetic tape
RAID (Redundant Arrays of Independent Disks)
SAN (Storage-Area Network) Often used for backups.
Page 35
Created by Turbolearn AI
Screen display
Hardcopy (printer or plotter)
Virtual headset display
Speaker
Writing to storage devices (listed above)
Network transmission
Data Input:
Keyboard/keypad
Screen interaction (icons, menus, pointing devices, touchscreens)
Game controller
Scanner
Microphone (with voice recognition)
Reading from storage devices (listed above)
Network transmission
Embedded Systems
Embedded systems are prevalent in manufactured items with mechanical or electrical
parts. They contain a processor, memory, and I/O capabilities.
Input/Output: Can range from internal-only to full user interfaces (e.g., mobile
phones).
Memory Components
Page 36
Created by Turbolearn AI
ROM Types:
1. Data installed during manufacturing.
2. PROM (Programmable ROM): Programmed by the system builder.
3. EPROM (Erasable PROM): Data erased with UV light; reprogrammable
but requires removal from the circuit.
4. EEPROM (Electrically Erasable PROM): Data erased electrically;
reprogrammable without removal.
Buffers
Buffers are used to manage data transfer speed mismatches between sender and
receiver. They function as queues, ensuring data order. Typically located in computer
memory.
Page 37
Created by Turbolearn AI
Magnetic Media
Magnetic tape: The first storage device, predating computers.
Hard disk: Specifically invented for computer storage, using magnetization to
write data.
Read/write head: Uses the principle that magnetization affects electrical
properties (read) and vice-versa (write). The two heads are often combined.
Binary representation: Two states of magnetization are interpreted as 1 or 0.
Optical Media
Optical storage evolved from non-computing technologies (like the
compact disc). Technologies include CD-ROM, CD-RW, DVD, and Blu-ray.
Page 38
Created by Turbolearn AI
Solid-State Media
Solid-state storage uses flash memory (semiconductor technology with
no moving parts).
Page 39
Created by Turbolearn AI
Storage Technologies
An extension question encourages research into current storage
technologies, comparing cost, capacity, and access speed for both laptop
internal storage and peripheral devices. The goal is to identify viable,
uncompetitive, and emerging technologies.
Output Devices
Screen Displays
Pixel Concept: Screen displays use pixels, each composed of three sub-pixels
(red, green, blue). Varying light emission from sub-pixels creates a range of
colors.
Cathode Ray Tube (CRT): Original technology where the inner screen surface
(coated in phosphor) emits light when electrons hit it. Pixels are lit by
controlling the electron beam direction.
Liquid Crystal Display (LCD): Dominant flat-screen technology with individual
cells containing liquid crystals. Backlighting illuminates the pixel matrix; each
pixel controls light transmission. LEDs typically provide the backlighting. The
manipulation of liquid crystal molecule alignment via voltage changes the
polarization of light, thus altering the display.
Page 40
Created by Turbolearn AI
Input Devices
The Keyboard
Functionality: Keyboard input (text or actions) is converted into character codes
and transmitted to the processor. The processor, controlled by the operating
system, displays the character or performs the action.
Internal Components: The keyboard contains electrical circuitry.
Keyboard Operation
Page 41
Created by Turbolearn AI
The keyboard contains a key matrix consisting of rows and columns of wires.
Pressing a key closes a circuit at the intersection of a row and column wire. The
microprocessor continuously checks for closed circuits. Upon detecting a closed
circuit, the microprocessor uses data in the ROM (Read-Only Memory) to identify the
corresponding character code and sends it to the screen.
Screen Interaction
Early computer systems relied solely on keyboards for input, often
navigating menus via numerical input.
The advent of Graphical User Interfaces (GUIs) in the 1980s revolutionized screen
interaction. GUIs use icons controlled by pointing devices like a mouse, transforming
the screen into both an input and output device.
In all types, the processor uses measurements to calculate the touch position and
initiate the requested action.
Inputting Graphics
Several methods exist for inputting graphic data:
Page 42
Created by Turbolearn AI
Page 43
Created by Turbolearn AI
Capacitive Touchscreen
This technology is only applicable for use with flat screens. It detects the change in
capacitance caused by a finger's touch.
Storage Devices
Page 44
Created by Turbolearn AI
Boolean Operators
Page 45
Created by Turbolearn AI
X = A OR B OR (C AND D)
Truth Tables
Truth tables visually represent the outputs of logic expressions for all possible input
combinations. For example, the truth table for AND:
Page 46
Created by Turbolearn AI
A B X = A AND B
0 0 0
0 1 0
1 0 0
1 1 1
This circuit can be constructed using four AND gates and two OR gates. (See
Figure 4.03 in the textbook).
Page 47
Created by Turbolearn AI
Logic Circuits
If the thermometer reading is in range (1), but either or both the fan and light are not
working (0), a warning light should activate. A logic circuit would need to be
designed to represent this fault condition.
Page 48
Created by Turbolearn AI
The outcome of a logic expression or circuit can be shown in a truth table. A logic
expression can be derived from a truth table using the rows that result in a 1 output.
Exam-Style Questions
Several exam-style questions are provided, covering topics such as:
A processor (CPU).
Direct processor access to memory.
Memory containing a stored program (replaceable) and data.
A stored program made of individual instructions.
Sequential instruction execution by the processor.
CPU Architecture
To understand the Von Neumann model's practical application, we need to know the
CPU's hardware components and their functions. A simplified schematic shows a
processor with the minimum necessary components.
Page 49
Created by Turbolearn AI
The active components are the Arithmetic Logic Unit (ALU) and the
control unit. The ALU handles arithmetic and logic processing. The control
unit manages data flow throughout the system, ensures correct
instruction handling, and uses clocks for synchronization (internal and
system clocks). Clock speed, defined by frequency, determines the
minimum time between successive activities.
Registers are storage components near the ALU, enabling fast access.
They have limited storage capacity (e.g., 16, 32, or 64 bits) and are either
general-purpose or special-purpose. A single general-purpose register is
called an Accumulator.
Page 50
Created by Turbolearn AI
Page 51
Created by Turbolearn AI
Address Bus: Carries addresses from the MAR to memory or I/O controllers
(one-way).
Data Bus: Carries data (instructions, addresses, values) between the CPU,
memory, and I/O devices (two-way). The direction of data flow (CPU to
memory, memory to CPU, I/O to CPU/memory) can vary depending on the
computer system's architecture.
Control Bus: Transmits signals between the control unit and other components
(two-way). Typically has eight wires and carries timing signals synchronized by
the system clock to coordinate data transmission.
Page 52
Created by Turbolearn AI
The Universal Serial Bus (USB) revolutionized peripheral connection, enabling the
plug-and-play concept. It supports a hierarchy of up to 127 devices, allowing hot-
swapping and automatic configuration. USB 3.2 is the latest version.
USB is a bus. A USB drive stores data; its USB port enables data
transmission.
Discussion Point: Research storage devices connected via USB, noting the USB
technology and data transfer speeds. Compare these to internal hard drive access
speeds.
Assuming a running program, the program counter (PC) holds the next instruction's
address.
Fetch Stage:
Page 53
Created by Turbolearn AI
The system clock controls the cycle, allowing one memory transfer per
cycle. The PC increment is by 1, unless it's a jump instruction, which
updates the PC after decoding.
Decode Stage: The control unit decodes the CIR instruction, sending signals to
appropriate components for execution.
; ; ;
M AR ← [P C] P C ← [P C] + 1 M DR ← [[M AR]] CI R ← [M DR]
The arrow (←) shows data transfer. Square brackets [] indicate register
contents. Double brackets [[]] denote the content at a given address.
Semicolons separate simultaneous operations.
Interrupt Handling
Interrupts are triggered by various events:
Program errors
Hardware faults
I/O requests
User interaction
Timer signals
Page 54
Created by Turbolearn AI
Page 55
Created by Turbolearn AI
Instruction Handling
Fetch-execute cycle: The process by which the CPU retrieves and executes
instructions.
Register Transfer Notation: A shorthand way of describing data transfers
between registers and memory. For example: MAR ← [PC] means "the contents
of the Program Counter (PC) are copied to the Memory Address Register
(MAR)".
Interrupts: Signals that halt the normal execution of the program to handle
exceptional events. When an interrupt is detected, control is transferred to an
interrupt-handling routine.
Page 56
Created by Turbolearn AI
a. Bus Explanations:
Data Bus: Transfers data between the CPU, memory, and I/O devices.
Address Bus: Specifies the memory location or I/O device being accessed.
Control Bus: Coordinates the actions of all components; signals for
read/write, interrupts etc.
b. Bus Width:
Page 57
Created by Turbolearn AI
a. Explanation of Statements:
MAR ← [PC]: The contents of the PC (holding the address of the next
instruction) are copied to the MAR.
PC ← [PC] + 1: The PC is incremented to point to the next instruction.
MDR ← [[MAR]]: The contents of the memory location addressed by the
MAR are fetched and placed in the MDR.
CIR ← [MDR]: The instruction from the MDR is loaded into the CIR for
decoding and execution.
Definitions:
b. Bus Usage:
MAR ← [PC]: The address on the address bus is the contents of the PC,
sent to the memory.
MDR ← [[MAR]]: The data from memory is transferred on the data bus into
the MDR.
Page 58
Created by Turbolearn AI
b. Sequence of operations:
c. Execution of Instruction LDD 35: This would load the data at memory location
35 into the accumulator.
d. Interrupts:
Page 59
Created by Turbolearn AI
b. Handling an Interrupt:
Page 60
Created by Turbolearn AI
This section discusses the differences between symbolic, relative, and absolute
addressing used by assemblers to convert assembly language into machine
code. The details of these addressing modes are not provided in the transcript.
Page 61
Created by Turbolearn AI
SUB #48: This subtracts 48 from the accumulator's contents. This converts the
ASCII code to its binary equivalent.
STO MAX: The value in the accumulator is stored at the memory location labeled
MAX.
LDM #0: Loads the value 0 into the accumulator.
STO TOTAL: Stores the value in the accumulator (0) at the memory location
labeled TOTAL.
STO COUNT: Stores the value in the accumulator (0) at the memory location
labeled COUNT.
STRTLP: IN: Inputs a number from the keyboard (ASCII code to accumulator).
SUB #48: Converts the ASCII code to binary.
ADD TOTAL: Adds the value at TOTAL to the accumulator; the sum is stored in the
accumulator.
STO TOTAL: Stores the updated sum back into TOTAL.
LDD COUNT: Loads the value from COUNT into the accumulator.
INC ACC: Increments the accumulator's value by 1.
CMP MAX: Compares the accumulator's value with the value at MAX.
JPN STRTLP: If the values are unequal, the program jumps to the instruction
labeled STRTLP.
END: Program termination.
Symbolic Addressing: Using labels (like MAX, TOTAL, COUNT, STRTLP) to refer
to memory locations instead of their numerical addresses. This improves
code readability and maintainability.
Relative Addressing: Uses an offset from a base register (BR) to locate memory
addresses. No labels are used.
Absolute Addressing: Specifies the exact memory address for each instruction and
data. Again, no labels are used.
Base Register (BR): A special register holding a base address used for
calculating memory addresses in relative addressing.
Page 62
Created by Turbolearn AI
Two-Pass Assembler
A two-pass assembler is necessary to handle programs with forward references
(using labels before they are defined).
Pass 1: Creates a symbol table, recording labels and their corresponding memory
addresses.
Pass 2: Uses the symbol table and an opcode lookup table (mapping opcodes to
binary representations) to translate the assembly code into machine code.
Symbol Offset
MAX +15
TOTAL +16
COUNT +17
STRTLP +7
Symbol Table: A table that stores labels and their corresponding memory
addresses within the program. This helps resolve forward references.
IN 0001 0000
SUB 0110 0001
STO 0100 0100
LDM 0010 0001
ADD 0100 0101
LDD 0010 0101
INC 0101 0101
CMP 1000 0100
JPN 1010 0100
END 1111 1111
Page 63
Created by Turbolearn AI
Addressing Modes
Different ways of specifying the location of an operand (data) for an instruction:
Addressing Modes
Four different addressing modes can be defined in a machine code instruction:
Addressing
Description Example
Mode
Immediate The operand is the value to be used in the instruction. SUB #48
The operand is the address which holds the value to be
Direct ADD TOTAL
used in the instruction.
The operand is an address that holds the address which
Indirect
has the value to be used in the instruction.
The operand is an address to which must be added the
Indexed
value currently in the index register (IX).
For immediate addressing, there are three options for defining the value:
Data Movement
These instructions load data into a register or store data in memory.
Page 64
Created by Turbolearn AI
Opcode
Instruction Explanation
Operand
The mnemonic defines the instruction type, including the register involved
and, where appropriate, the addressing mode. ACC indicates the
accumulator.
Page 65
Created by Turbolearn AI
Opcode
Instruction Explanation
Operand
JMP
Jump to the given address.
<address>
CMP Compare the contents of ACC with the contents of
<address> .
CMP #n Compare the contents of ACC with the number n.
CMI Indirect addressing. Compare the contents of ACC with
<address> the contents at the address specified at the given address.
JPE Following a compare instruction, jump to
<address> if the compare was True.
JPN Following a compare instruction, jump to
<address> if the compare was False.
Arithmetic Operations
Opcode
Instruction Explanation
Operand
ADD <address> Add the contents of the given address to the ACC.
ADD #n Add the denary number n to the ACC.
Subtract the contents of the given address from the
SUB <address>
ACC.
SUB #n Subtract the denary number n from the ACC.
INC
Add 1 to the contents of the register (ACC or IX).
<register>
DEC Subtract 1 from the contents of the register (ACC or
<register> IX).
Shift Operations
LSL #n: Logically shifts bits in the accumulator n places to the left.
LSR #n: Logically shifts bits in the accumulator n places to the right.
Page 66
Created by Turbolearn AI
Shift Instructions ️
More complex processors may offer a cyclic shift, where a bit moves from one end to
the carry bit and then re-enters at the other end, preserving all original bit values.
Left and right arithmetic shifts are also common, similar to logical shifts but
designed for multiplying or dividing signed integers by two. The sign bit remains
unchanged after the shift.
Instruction Explanation
The instruction is in the CIR, and only the 16-bit address is needed to locate the data
in memory, which is then transferred to the accumulator.
Page 67
Created by Turbolearn AI
Computer arithmetic can produce incorrect results due to overflow. The Status
Register helps identify such issues.
Worked Example 6.02: A trace table is used, showing changes in the accumulator
and memory locations based on user inputs (15, 27, 31).
Page 68
Created by Turbolearn AI
Exam-Style Questions
(b) Completes a trace table for a given assembly language program, showing the
memory contents and accumulator value at each step. The program uses instructions
like LDD, INC, STO, LDI (indirect addressing), DEC, ADD, and END.
Page 69
Created by Turbolearn AI
This question analyzes a simple assembly language program that takes input,
performs a calculation, and outputs a result. It requires explaining the program's
input, output, and completing a symbol table generated by the first pass of a two-
pass assembler.
(a) Determine the accumulator's contents after executing LDX 60, given memory
contents and the index register value. This tests understanding of indexed
addressing.
(b) Determine the index register's contents after executing DEC IX. This tests
understanding of the DEC instruction.
Monitoring Systems
A monitoring system records the condition of a system over time, often to
detect when a property goes outside a desired range (e.g., CPU
temperature). Sensors, like thermocouples (measuring temperature via
voltage output), are used to collect data. Sensors lack built-in intelligence;
they only measure and transmit data. The computer interprets this data
and takes action. Many types of sensors exist, measuring various
properties (pressure, humidity, etc.)
Control Systems
Page 70
Created by Turbolearn AI
These flags can be represented by individual bits within a byte in machine code. The
following assembly language code snippets illustrate how to manipulate these bits:
Page 71
Created by Turbolearn AI
Toggling a bit:
Setting a bit to 1:
Bitwise logic operations act on each bit individually; all bits in the
accumulator are processed simultaneously.
Page 72
Created by Turbolearn AI
Exam-Style Question
A farmer uses a barn to house poultry. The barn environment affects egg-laying.
Traditionally, the farmer manually checked the barn's conditions and made
adjustments if necessary. More recently, the farmer has considered using a
monitoring and control system to automatically maintain optimal conditions.
Page 73