0% found this document useful (0 votes)
48 views17 pages

A Level Extra CS Notes (CH-1,3,4,8)

The document discusses hexadecimal, binary, bytes, character sets, graphics file types, sound recording and storage, and data compression. It provides information on why hexadecimal is used, defines common binary terms, describes bitmap and vector graphics with their advantages and disadvantages, explains how sound is recorded and stored digitally, and discusses benefits and disadvantages of data compression.

Uploaded by

ultimisticfest
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
48 views17 pages

A Level Extra CS Notes (CH-1,3,4,8)

The document discusses hexadecimal, binary, bytes, character sets, graphics file types, sound recording and storage, and data compression. It provides information on why hexadecimal is used, defines common binary terms, describes bitmap and vector graphics with their advantages and disadvantages, explains how sound is recorded and stored digitally, and discusses benefits and disadvantages of data compression.

Uploaded by

ultimisticfest
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 17

CH1

Why hexadecimal is used over binary: Easier to read and remember/understand for programmers
and takes up lesser space on screen during debugging, thus makes debugging easier. Also faster to
write for programmers such as when using hexadecimal color codes to mention colors on a
webpage.

Bit: Smallest addressable binary digit, that can either be value 1 (ON) or value 0 (OFF).

4 consecutive bits are called a nibble, and 8 consecutive bits are called a byte.

103n series of bytes: Kilobyte (KB), megabyte (MB), gigabyte (GB), terabyte (TB), petabyte (PB), etc.
for every integer n≥1
210n series of bytes: Kibibyte (KiB), mebibyte (MiB), gibibyte (GiB), tebibyte (TiB), pebibyte (PiB), etc.
for every integer n≥1
Most significant bit (MSB): The bit which, when changed, changes the value with the maximum
possible magnitude, and is usually the leftmost bit.
Least significant bit (LSB): The bit which, when changed, changes the value with the least possible
magnitude, and is usually the right-most bit.
The number of unique combinations possible with n bits is 2n whereas the highest integer number
possible is 2n-1. The magnitude of change by the MSB in an unsigned byte is 2n-1.
Word size: The number of bits allocated to any singular object such as an integer of a floating-point
number in the memory. For example, 64-bit processors have a word size of 64 bits.
Signed number: A number that can represent positive and negative values in binary, for example a
two’s complement byte.
Unsigned number: A number that only represents a positive value in binary.
[LEAVING OUT ALL CALCULATIONS]

Text encoding:
Character Set: A specified set of characters referenced to their binary forms called character
codes, that are used to display letters and characters in a computer. They are important as a
computer only understands their binary form, but when data needs to be shown to us, it shows the
data in characters so that we can read and understand it. There are three character sets in the
syllabus:
a) American Standard Code for Information Interchange (ASCII): A character set that uses 7
bits and contains a maximum number of 128 characters. First standardized character set.
b) Extended ASCII: An extension on ASCII that uses 8 bits and contains 128 more characters in
the character set that can be displayed. ASCII and Extended ASCII can only represent a
certain number of characters, mostly localized to the country. When the internet came
around, this made it difficult to communicate long distances with different languages. The
limited character set also meant that languages with thousands of characters such as
Chinese could not display all their characters within the 8 bits.

Written by Mithani
c) Unicode: Created to solve the issues of ASCII and Extended ASCII. Unicode can have 8 bits,
16 bits or 32 bits to display each character, which depends on the encoding type of the set
of characters. This means it can store up to 4 billion characters, and thus has enough space
for different font styles to show simultaneously as well as custom characters and emojis to
be added within the character set.
Each character, even numbers, are stored as their character codes within the text files.

Graphics:
Bitmap Graphic: An image file comprised of color values of every pixel, that can show a complete
image as a grid of several pixels together.

Vector Graphic: An image file comprised of shapes that have their position mathematically
calculated, and are thus rendered in real-time, and so can be scaled to any size with no pixel
popping/pixelation.

Advantages of bitmap images/disadvantage of vector images: Can store a constantly varying


amount of color as pixels and thus can contain nearly any image possible within a grid of pixels. The
image will also appear the exact same in different software and screens. The drawing can be of any
type without needing to be in the form of shapes and can be edited on a per-pixel basis. Vector
graphics, meanwhile, cannot show a constantly varying amount of color that does not follow any
trend or shape, nor can have each pixel individually edited, and so is not suitable for things like
photos of a digital camera or photo editing. They are also rendered by every software independently
of how the artist originally created the file, and thus must have a renderer available on the end
user’s computer to be visible, plus, due to different implementations in different renderers, the
color and shapes may not be reproduced correctly to what the artist had originally intended. The
shapes are also limited to several shapes and are thus limited. For intricate details, vector graphics
are not preferable.

Advantages of vector images/disadvantages of bitmap images: As they only need to store lines of
code as drawing lists that determine the shapes that must be rendered, they are usually of much
lesser file size than bitmap images and so are preferable in webpages. They are also very flexible in
terms of resolution, as they can be rescaled to any size without any issues of pixelation. They have
shapes and so can be decomposed, and their shapes individually modified without affecting the
other shapes. This is, thus, preferable in places such as webpages and logos, due to the flexibility in
rescaling and lower file size. Bitmaps, on the other hand, take up more physical pixels per logical
pixel when rescaled to a higher resolution, and so, each pixel is visible as square blobs that way,
and scaling in between set sizes may cause smearing due to linear scaling filling in the gaps by
guessing the pixels in the middle. To edit bitmaps, though, each individual pixel may need to be
changed, modifying the whole image.

How a camera shoots a photo and creates a bitmap image: Light from the surrounding reflects off
the object to capture and hits the CCD, which is the sensor inside the camera. The color data is
recorded as a series of varying electrical signals generated by photons. The camera then stores the
color data for those signals captured at each point in the CCD in their respective positions in a 2D
grid of pixels, and this makes up the complete bitmap image that we see.

Written by Mithani
Drawing List: A set of instructions/commands that contains the list of objects and how to draw
them inside a vector image file. Examples: color, fill, stroke thickness, dimensions, etc.

Pixel: The smallest addressable part of a display or an image that may show color with different
brightness values.

Color depth: The number of bits used to show the color information for each pixel in an image.

Color palette: The total number of colors that can be shown by each pixel in an image. It is normally
2n where n is the color depth.

Resolution: The number of rows and columns of pixels making up an image or a display.

File header: A small section at the start of the file that contains metadata about the file that has
additional information for the programs.

Things in a photo file header (using Exchangeable Image File [EXIF] format):

a) Location.
b) Lens information.
c) Color depth.
d) Resolution.
e) File type/encoding.

Sound
How are sound waves recorded: Back and forth vibrations of sound particles cause the diaphragm
in a microphone to vibrate a magnet back and forth between a copper coil. This rapid back and forth
movement of the magnet induces current in the copper coil and these analog vibrations are
digitized using an ADC and the modulated wave is stored as binary.

Sample: One singular record of the amplitude of sound in binary form.

Sampling resolution: The number of bits used to represent the varying degrees of amplitude that a
microphone can record in each sample.

Sampling rate: The number of samples recorded per second.

Higher of all 3 means better quality but less file size. Reducing all three may introduce quantization
error.

How are sound waves stored: The recorded sound waves are converted into their loudness value
based on the sampling resolution to be able to record sounds of all loudness possible. This is done
many times per second, with the frequency being equal to the sampling rate. These amplitudes are
then stored in a sequential binary form where they can be read and output through a DAC and a
speaker to make a sound.

Mono audio: Storing only one track for all audio channels. The sound output thus cannot be made
to differentiate between sounds coming from the right or left.

Written by Mithani
Stereo audio: Storing two tracks, one per audio channel. The sound output can be made to be
directional in left or right that way.

Nyquist Theorem: we must use a sampling frequency that is at least double to what a human can
hear so that little to no useful sound is missed in the recording. Since a human can hear sounds up
to 22KHz, we must use at least a 44.1KHz frequency to record audio.

Compression
How compression is beneficial:

a) Uses less bandwidth to transfer data over the internet, which can also mean lower data
costs for users and the server.
b) It helps download stuff faster.
c) Uses less storage space on the device and allows to store more data in the same space
than through downloading an uncompressed file.
d) Does not lose enough detail to make the photo/music look/sound largely different from the
real deal (in case of lossy)
e) No detail is lost as the file can be uncompressed at any time to get back the original data (in
case of lossless).

Disadvantages of compression:

a) Additional CPU processing is required to compress the file (and decompress it for lossless).
b) While there is little difference in quality, algorithms are not perfect and may cause you to
lose data that you may want [lossy compression only].
c) It destroys the original file such that you cannot restore it to the original version (for lossy
compression only).
d) Programs and text files cannot undergo [lossy compression only] lossy compression as it
may lose important data in the files themselves, rendering them useless.
e) [Lossless only] Some compression algorithms like RLE may not work well on a file such as a
photo with fast varying colors, as it requires repeated patterns to work effectively, and may
instead have the opposite effect of increasing file size if the image, for example, does not
have repeated sections of the same color.

Lossy compression ways:

a) Reduce bit depth of the sound/photo file.


b) Reduce photo resolution/Reduce sampling rate for sound files.
c) Remove useless metadata from a file header.
d) Reduce audio tracks.
e) Similar colors that are not distinctly differentiable by the naked eye can be made into the
same color, and these bits can be stored as blocks in a JPEG.
f) If there are two sounds, one louder and the other lesser in an audio file, the lesser one can
be discarded as it will be inaudible anyways.

Written by Mithani
How does RLE work (in images): It counts the number of continuous color pixel values and assigns
this count to the color values counted, telling the software that that specific color value appeared
<count> many times repeatedly.

Example of RLE: If in denary 0 meant black and 1 meant white, and there was a pattern of bits
`1111000`, this would be stored in denary as `14 03` which uses 3 less denary digits, saving file
size by almost 50%.

Example of RLE not working: If in denary 0 meant black and 1 meant white, and there was a pattern
of bits `0100010` this would be stored in denary as `01 11 03 11 01` which in fact increased the
denary digit count by 3 instead, and so would increase the file size by almost 50% rather than
decrease.

Huffman encoding: A technique that assigns short bit patterns to repeated characters and stores
the bit pattern in a dictionary linking them to the original repeated characters. This is particularly
useful with many repeated characters.

CH3
Input devices: Devices which can be used by a human to send signals to a system to perform
certain tasks. Examples: Mouse, keyboard, touchscreen, various sensors.

Output devices: Devices that a computer can use to translate computer data into a form that users
can understand. Examples: Display screen, speaker, LED indicator lights, etc.

Principle functions of devices:


Keyboard: A matrix of keys is arranged in rows and columns with each key having a circuit with a gap
underneath it. Each key has a different character code and has a conductive strip underneath the
key. When the key is pressed, the conductive strip closes the circuit and lets current flow. The
character code is identified by how much change is detected in the voltage by a microprocessor,
and that character is displayed on screen.

Mouse: There is an LED light underneath the mouse and a camera. The camera makes many
pictures per second of the surface, which is illuminated by an LED light. When the mouse is moved,
the difference of dots moved is calculated by the mouse, and this tells the mouse how much
position it has changed, which is reported to the system to move the on-screen cursor.

Touchscreen: There are two types of touchscreens in the syllabus:

a) Resistive touch screens: These are the cheapest touchscreens available. They have two
conductive plates separated by an insulating spacer, and a tiny voltage runs through the
screens. When the outer layer is touched, the plate bends and touches the other plate, thus
completing the circuit, and a voltage change is detected by a microprocessor that uses this
change to determine the coordinates of the touch. Resistive touchscreens have very
unreliable touch and do not even support multi-touch capabilities. They have very low
brightness and are not durable either. However, they are usable even with gloves and
objects between the hand and the screen.

Written by Mithani
b) Capacitive touch screens: These are only mildly expensive compared to resistive
touchscreens. It has a plate charged with many capacitors. Since our bodies are
conductive, touching the plate with bare hands causes the charge to transfer to our hands.
This change in electric charges is detected by sensors in the corners of the screen, and
depending on how much change of voltage is detected, the coordinates of touch points are
calculated that way. Capacitive touchscreens are much more durable and have better
visibility than resistive touchscreens, and even support multitouch, but require bare hands
to touch the screen, so cannot be used by some styluses and gloves.

Charge Couple Device (CCD): An array of photosensitive cells that have a current induced in them
when light hits the specific cell. This color is different for every combination of wavelength. The
color is calculated based on the voltage induced for all the cells in the grid of a CCD and a digital
representation is thus captured.

It is used in:

a) Flatbed Scanners: A CCD is placed in the center of the scanner. The page to be scanned is
put above a transparent panel. A light source moves under the transparent panel and some
of the light is absorbed whereas the rest reflects off the page and through some mirrors into
the CCD. The measured light intensity is then converted into pixel values by software to
form a digital representation of the page.
b) Digital Cameras: Light bounces off objects and into lenses that focus the image onto a CCD
(image sensor). There is a digital or a physical shutter to accurately control how much light
goes into the camera so that color values are of the correct brightness, as well as a physical
aperture that controls how much reflected light goes through the lens. The measured light
intensity is then turned into a grid of pixel values by software.

Microphones: Sound vibrations cause a thin film called the diaphragm back and forth, which moves
an attached magnet back and forth too, and this magnet is surrounded by a copper coil that has
different voltages created in it based on the vibrating magnet. An ADC converts the voltages into
binary.

Speakers: A DAC converts binary sound files into voltages that are induced in an iron core to create
rapid magnetic fields making it an electromagnet, and this causes a magnet inside the speaker to
repel and attract rapidly. The magnet is attached to a cone that also vibrates with the magnet. These
cones vibrate the air rapidly to create sound waves.

Liquid Crystal Displays (LCDs): Screens with a liquid crystal in each pixel that allow certain
wavelengths of light through depending on the voltage applied to them. They contain a backlight
(usually LED) as they do not emit their own light and can only show color if light goes through them.

Light Emitting Diodes (LED) Displays: Screens with individual pixels made up of a matrix of LEDs
that can output Red, Blue and Green colors. They do not need a backlight as each pixel can emit its
own light. They have many benefits over LCDs, but they are more expensive to manufacture.

Organic Light Emitting Diodes (OLED) Displays: LED displays made from organic materials that can
create flexible displays. Organic films are placed between charged plates, and when an electric

Written by Mithani
field is applied, the organic films release their own lights on the RGB spectrum, and thus do not
need backlights.

Printers:

a) Inkjet printers: Preferable if the quality of the print matters to you, as it has excellent detail
and color reproduction. However, ink runs out rapidly and may be expensive. They are also
very slow to print with.
i. Thermal bubble printers: The print head has ink inside a nozzle. It moves across a
page and uses a coil to heat up the ink, making it expand to form a bubble and out of
the nozzle. This transfers the ink to the paper. A vacuum is created in the nozzle to
draw more ink into the nozzle.
ii. Piezoelectric printers: A crystal is located within the ink reservoirs of the printers
that vibrate rapidly to cause some ink to get transferred out of the nozzle and onto
the page.
b) Laser printers: Preferable if the quality of the print is not as important to you, rather, the
speed of the print is. Their initial cost is high, but their ink lasts longer. A charge is induced in
specific places by a laser onto a drum that rotates. A toner scatters ink powder on the
paper, and the paper then is charged oppositely and so sticks to the drum where there is a
charge present, and a heating element in the drum causes the powder between the parts in
contact to fuse. The unfused ink is cleared off and the page is rolled out.

Always talk about “Data is sent to the printer driver that turns the data into a readable format, and
once the printer is not busy, sends the data to the printers memory buffer.” as the first sentence of
all such questions asking how any printer works, and end with “The print head/drum charge is reset
and the printer checks to see if a new page is needed to be printed.”

c) 3D printers: A model of the object that has to be printed is either 3D scanned or modelled in
CAD. The object is sent to the printer driver which divides the object into tiny slices and
sends the printer each slice sequentially, which is printed one by one layer by layer on top of
itself. A nozzle has a filament that heats up to melt and moves it in the shape it must for
making the said shape as the molten material extrudes out and cools to make a solid layer.
The next layer data is fetched, and the steps repeat.
i. Binder 3D printing: Adds a binding agent after every layer runs to act as a glue when
the next layer is printed on top of it. It also uses powder instead of molten plastic.
ii. Direct 3D printing: Prints each layer after another directly by moving up and down.
This must use molten plastic or resin, though, to be able to stick each layer to each
other automatically.

Computer components:
Primary storage:

a) Random Access Memory (RAM): Very fast volatile memory that can be written to and read
from at blazingly high speeds. It can be accessed directly by the CPU, and thus all data or
instructions must be present in the RAM before the CPU can access them. It loses data as
soon as the power is pulled. It has memory addresses, which are the physical locations for

Written by Mithani
all the available or filled locations for data to be stored in the RAM. There are two types of
RAM:
i. Static RAM (SRAM): Faster than DRAM but more expensive to produce. Is typically
used in CPU cache, where high speed is critical. Use flip flops to store each bit.
Need to be refreshed much less than DRAM.
ii. Dynamic RAM (DRAM): Slower than SRAM but relatively much less expensive to
produce. They are used as system RAM as they are still much faster than secondary
storage. They use capacitors to store bits, with a charged state meaning 0 and an
uncharged state meaning 1 for the capacitor. They need to be refreshed constantly
so that the capacitors may not leak charge.
b) Read Only Memory (ROM): Non-volatile flash memory on the motherboard itself. It can not
be erased or rewritten to (unless it’s EPROM or EEPROM), only read from. It usually contains
the BIOS of a system, as well as the startup sequence for the device. Traditionally, ROMs
can only be created by the manufacturer and cannot be written to. However, new
technologies have brought other types of ROMs too.
i. Programmable ROM (PROM): ROM which can be manufactured as chips in bulk by
an outsourced company and can be written to by the manufacturer themselves. This
way the manufacturers can save on needing to invest in machines to manufacture
ROM chips themselves.
ii. Erasable Programmable ROM (EPROM): ROM which can not only be written to but
can also be erased and rewritten to. However, these need UV light to be erased
completely before being written to again. This requires special tools though.
iii. Electrically Erasable Programmable ROM (EEPROM): ROM which can not only be
written to, but it can also be erased electronically, and can be reprogrammed
without needing to erase the entire contents of the EEPROM. This allows computers
to have upgradable BIOSes.

Both primary storage devices are required for a computer to function at all.

Secondary storage devices:

a) Hard Disk Drives (HDDs): Has platters coated with a magnetic substance. The platters spin
several thousands of times per second on a spindle motor, and a read write head on an arm
moves back and forth that is controlled by an electronic circuit. When reading the hard
drive, any magnetized part is a 1 whereas a non-magnetized part is a 0. Current in the write
head can induce a magnetic field on to any part of the platter, and magnetic fields from the
disk can induce a current into the read head.
A hard drive is divided into many sectors and tracks which have data stored on them
sequentially. After many writes and overwrites, there may not be enough contiguous space
in one track, and so data may need to be split up over multiple tracks, which increases
access times for the data, and so the data can be slow to read and write. Disk
defragmentation helps with this somewhat by bringing contiguous data blocks togethers in
tracks, thus allowing for faster read times. HDDs also have moving parts that are affected by
vibrations and even nearby magnetic fields, and so are not very reliable, but if left
unaffected, have extremely high write endurance, making them the best choice for things
like off-site backups where high speeds are not the concern, rather, storage size is.

Written by Mithani
b) Solid State Drives (SSDs): Use NAND gates inside to store electrons in cells that can be
used to represent bits. The electron gates, however, wear out over time if they are written to
repeatedly and may cause that NAND flash to work incorrectly, causing the SSD to die after
a lifespan called the write endurance. SSDs are also relatively more expensive to
manufacture than HDDs. However, they are more reliable as they have no moving parts and
are thus unaffected by vibrations. They are also much faster than traditional HDDs and are
also unaffected by disk fragmentation as the NAND chips can be read at any time.

Optical storage: Storage mediums that use light physics to read and write data to and from a disc.
The most common types are Compact Disks (CDs), Digital Versatile Discs (DVDs) and Blu-rays.
They are made with a set of layers with a thin reflective layer on the surface. Lasers are bounced off
the surface and are detected within a sensor. Each disc has a continuous track of data arranged in a
spiral form and data is stored as pits and valleys, where light reflects differently and the sensor
detects this change and counts it as a bit. The disc is spun at very high speeds and the laser moves
back and forth to read the disc file.

Embedded system: A self-contained system with a microcontroller and input and output devices
that can only process what has been programmed into the microcontroller. They may be a
monitoring device or a control device.

a) Monitoring system: A device that and displays data to the human supervisor and sends
alerts once any value goes beyond a certain value so that the human supervisor may
correct it.
b) Control system: A device that can do the same things as a monitoring system but can also
take actions on its own, such as automatically sending a signal to any device to perform a
certain function once any measurement goes beyond a specified threshold. It is automated
and does not need a human supervisor to run, but the latter can still override a control
system.

[LEAVING LOGIC GATES TOPIC]

CH4
Computer architecture: The structure and components that make up a computer system and how
they are interconnected.

Von Neumann architecture: A computer architecture modelled by Sir John Von Neumann in the
early 1940s that specified how a stored program computer system would work. This model is still
used today, with some modifications. The Von Neumann architecture had the following:

a) Central Processing Unit (CPU): The main computational processor of a computer that is
responsible for executing all the instructions of programs. The CPU was further divided into:
i. Arithmetic and Logic Unit (ALU): Responsible for arithmetic calculations, logical
operations, Boolean operations, and binary shifts.
ii. Control Unit (CU): A component in the computer that is responsible for sending
control signals to different components of a computer to perform different

Written by Mithani
operations. It also decodes the instructions of a program and enables the circuits in
the ALU required to perform on the decoded instructions.
iii. System Clock: Generates pulses on the control bus as timing signals, with a rising
edge and falling edge, to keep different components of a computer synchronous
with each other. If the components are out of sync, the computer can crash if it does
not receive a response from any component in time or too quickly (and can also
lead to race conditions).
iv. Immediate Access Store (IAS): Basically RAM. It is not within the CPU. It has all the
programs and instructions and data that the CPU needs to access. When a program
must be run, it must be loaded from the backing store (secondary storage) onto the
IAS and then each instruction must be run one at a time.
v. Registers: Extremely high-speed memory cache directly on the CPU die itself. It has
the data that needs to be modified quickly, and also the data that the CPU is
currently working on. There are two types of registers:
1. General purpose registers: Registers that the ALU uses to store
intermediate calculations and data. The only one that we have in the
syllabus is the Accumulator.
2. Special purpose registers: Registers that have specific jobs as to what
exactly they must contain. These are vital to the fetch-decode-execute
cycle. They are:
a. Program Counter (PC): Holds the address of the next
instruction/data that the processor must fetch from the memory or
write to memory. This address is sent to the MAR and the PC is then
incremented to point to the next address that must be executed.
b. Memory Address Register (MAR): Holds the address of the current
instruction/data that must be fetched from the memory or has to be
written to memory. The data/instruction found at the memory
address found in the MAR is loaded into the MDR.
c. Memory Data Register (MDR): The MDR is the register that holds the
instruction/data itself that has been read from memory or must be
written to memory. The instruction in the MDR is then copied into the
CIR.
d. Current Instruction Register (CIR): The CIR is the register that
contains the instruction that must be decoded and executed by the
CU in the same cycle.
e. Status Register (SR): Each bit is a certain flag that indicates to other
components the status of useful things. For example, the interrupt
flag may tell the control unit that an interrupt must be handled after
each fetch-decode-execute cycle.
f. Index Register (IX): Used for indexed addressing.
b) Memory: The CPU would be able to access the memory directly. The memory could store
program instructions as well as data. The program instructions would be in sequential order
so that they could be executed in the correct order.

Written by Mithani
c) Buses: Sets of wires that connect different components together. Buses may be
unidirectional or bidirectional. There are three types of buses in the syllabus:
i. Address Bus: A unidirectional bus that links the MAR to the RAM. It sends the
location where the data must be fetched from the memory through it. The size of the
address bus determines the amount of RAM that a computer can address
simultaneously.
ii. Data Bus: A bidirectional bus that links the registers to the RAM. It carries data to
and from the CPU. The width of the data bus determines how much data can be
transported per cycle.
iii. Control Bus: A bidirectional bus that links the CU to every other component. Timing
signals to coordinate components are sent through this, and so are other types of
control signals such as status signals or command signals. The CU uses the control
bus to enable the circuit for an operation after decoding an instruction.

Fetch Execute (F-E) Cycle:


On every instruction, the processor cycles through three stages:

a) Fetching the data: The PC points to the address of the next instruction to be executed. This
address is copied into the MAR and the address in the PC is incremented to point to the next
instruction. The data in the memory at the address found in the MAR is copied into the MDR.
If it is an instruction, it is copied into the CIR.
b) Decoding the instruction: The CU decodes the instruction and makes certain circuits ready
in the ALU for running the specific instruction.
c) Executing the instruction: The instruction is executed by the ALU, and the cycle starts again.

A computer must do multiple tasks together. If it was just running instructions for one program
before starting the next, there could be no multitasking. That’s where interrupts come into play.
Interrupts allow the CPU to run processes of different programs together to appear as if they are
happening simultaneously, like downloading something in the background while watching a video.
It also allows the computer to respond to critical situations just as the problems arise. Examples of
interrupts: printer jam, CTRL + ALT + DELETE, program crash, hardware fault, server timeouts, etc.

How are interrupts handled: At the end of a fetch-execute cycle, the processor checks if the
interrupt flag in the status register is turned on and checks the priority of the interrupt. If it’s on and
the interrupt has a priority greater than the current process, the data in the registers currently is put
into a stack, and after identifying the interrupt, an appropriate Interrupt Service Routine (ISR) (A
software that is made to handle that certain interrupt. Not handling the interrupt can cause a
computer to crash.) is called to handle the interrupt. Once the interrupt is handled by the ISR, an
interrupt is checked for if there is any to be handled, and its priority. If there are no more interrupts
or the priority is lower than that of the current program, the data of the registers is pulled out of the
stack and the fetch-execute cycle continues.

Factors affecting CPU performance:


Clock speeds: The higher the clock speeds, the more the number of instructions that can be
executed per second, allowing for faster performance. However, increasing clock speeds may

Written by Mithani
cause the CPU to overheat and shorten its lifespan, and may also cause crashes due to other
components being unable to keep up with the increased timing signals and going out of sync.

Core count: Each core has its own dedicated control unit, buses, ALU, etc. and can run in parallel
with other cores, which allows for more processes to happen simultaneously, and reduces the
need for interrupts, allowing for faster performance. However, the cores must communicate with
each other to synchronize the instructions that each of them is individually executing, which may
introduce latency as more cores are added.

Cache: This is small amount of blazing fast memory on the CPU die. Sending signals and retrieving
data from the RAM is relatively slow due to the distance that the signals must travel, and so CPUs
come with some amount of L1, L2 and L3 cache where they can store the data that is being
frequently accessed (using branch prediction), reducing the amount of latency, increasing
performance. However, this is relatively expensive to manufacture in larger quantities, as well as fit
on the constricted space in a CPU itself.

Data bus width: The wider the data bus, the more the data that can be simultaneously transferred
by the CPU to the memory and the registers in one F-E cycle. This usually correlates with better
performance. The width of the data bus gives us the word size of the computer.

RAM size and address bus: As everything that a CPU needs to run must be present in the RAM, data
that is not accessed much is often “paged” to the slower hard disk to make space for other
programs. However, this is slow and may cause a lot of latency when a CPU requests any data and
can cause the performance to reduce. To prevent this, increasing the amount of available system
RAM can help increase performance as less paging will be required due to already having enough
space in the system memory to be able to load additional programs. However, there is no point
increasing RAM if the CPU cannot address it. For this reason, the computer must have a large
enough address bus to be able to address that RAM too. Thus, RAM must be increased in
compliance with the address bus for it to benefit the processor speed.

Ports
Universal Serial Bus (USB): A standard protocol as well as a physical port that transfers data in
serial. It offers plug and play support, which means it allows the identification of the device from
the computer which allows the computer to search for and download the appropriate driver for the
device. USB devices are detected by the change in voltage caused by inserting a USB into a port,
after which the handshake is performed.

Video Graphics Array (VGA): A port that outputs display video from the computer to the monitor in
analog form. It is a very old standard and uses pins on the front. The original standard was very
limited and unreliable which caused other standards to be formed.

High-Definition Multimedia Interface (HDMI): A port that outputs display video from a computer to a
monitor in a binary/digital stream. It can support much larger displays in terms of resolution, at
higher refresh rates and more colors, and also has built in piracy protection in the form of High
Bandwidth Copy Protection (HDCP), which allows Digital Rights Management (DRM) authentication
protocols on certain movies and videos to block any software or hardware that tries to record the
movie for piracy.

Written by Mithani
Languages:
Low-level languages: Code that is closer to machine code. These are hardware dependent
languages and cannot be reused with different types of hardware. Examples are like assembly
language, which needs to be translated to machine code using an assembler. They run processes
on the CPU by using instructions in the CPUs instruction set. It is much more complex to
understand and debug, compared to high level languages, but it gives more control of the specific
hardware and can be more optimized than high level code. Low-level programs also can not make
use of libraries to speed up the development of the program.

Instruction set: The set of instructions set by the manufacturer that a programmer can use to
perform functions in a certain processor.

High-level languages: Code that is closer to normal English and is easier to write, understand and
debug. These can be made to work on a wide variety of devices. However, they need to be compiled
or interpreted to translate them to machine code. Most programming languages like Python,
JavaScript, C#, Rust, etc. are all high-level programming languages. They can use libraries to speed
up the development of programs.

Machine code: Binary code that a computer can understand and execute. It is extremely difficult for
a human to read, write, understand, and debug this. Translators are required to turn languages into
machine code.

Instructions are divided into:

a) The Opcode: The instruction that must be decoded and executed by the computer.
b) The Operand: The data value on which the instruction must be executed.

Differences between different translators:

a) Compiler: Compiles a high-level language and creates an executable file that can be
executed on any device. However, if any changes are made to the program, it must be
recompiled. Compilers show all errors in a program together, and if some errors are based
on other tiny errors, a huge error stack is given during the compiling process that is difficult
to sift through. This makes development of programs using a compiler more difficult.
However, once compiled, the machine code is relatively quick to execute as it does not
need to be retranslated again.
b) Interpreter: Executes a high-level language line by line. This gives the errors while reading
each line and thus is easier to debug as you can find out where exactly the original mistake
happens causing all errors. This allows for easier program development. However, on every
run, an interpreter must be available for reading the code file, and so if you share your code
with anyone else, the end-user’s system must have an interpreter for that language on their
system too. It is relatively slower than compiled executables as each line must be read and
executed one by one, which takes up more overhead than a pre-translated file that is
already in machine code.
c) Assembler: Turns each low-level instruction into machine code for the program
sequentially, where each assembly instruction correlates to one machine code instruction.

Written by Mithani
There are two types of addressing for operands:

a) Absolute addressing: Addressing memory by using the physical memory addresses


themselves.
b) Symbolic addressing: Addressing memory by using symbols that are referenced to the
absolute memory addresses.

There are five modes of addressing for opcodes:

a) Direct addressing: Operand is the final address.


b) Indirect addressing: Operand points to the memory address that contains the final address.
c) Relative addressing: Operand + current instruction address is the final address.
d) Indexed addressing: The contents of the memory location found in the index register (or the
value of the index register itself, depends on the question) are added to the memory
address in the operand which is the final address.
e) Immediate addressing: Operand is the data that must be modified by the instruction.

There are two types of assemblers:

a) One-pass assemblers: One-pass assemblers directly turn assembly into machine code in
one pass.
b) Two-pass assemblers: Slower than one-pass assemblers but are more flexible. Allow for
comments and symbolic addressing in the code. They remove comments and whitespaces
and use a symbol table to reference symbolic addresses to physical addresses in the first
pass. In the second pass, the code from the first pass is turned into machine code.

Types of instructions in 9618 assembly language (read your question for the exact opcodes
available in the question):

a) Data movement: Load, store, move.


b) Arithmetic operations: Addition, subtraction, increment and decrement.
c) Input and output instructions.
d) Unconditional and conditional instructions: Jump conditions, END operation.
e) Comparison instructions.

Masks: Binary strings that can be used with logical bitwise operators to modify bits in the
accumulator in a certain way. These may be used to check if certain bits are of certain form.

AND operations are used with binary strings with 0s to turn off certain bits and leave the ones with 1
as they were before.

OR operations are used with binary strings with 1s to turn on certain bits and leave the ones with 0
as they were before.

XOR operations can be used with binary strings with 1s to toggle the values (0 → 1, 1 → 0) of certain
bits and leave the ones with 0 as they were before.

AND B00000000 (or AND #0) can clear a byte.

OR B11111111 (or OR #255) can turn make all the bits 1 in a byte.

Written by Mithani
[Logical shifts, assembly trace tables and mask calculations have been left out]

CH8
Database: An organized collection of data.

Table: A collection of objects with their assigned attributes stored in rows and columns.

Database Management System (DBMS): A software that is used to manage a database as well as
the data within it and can also be used to run queries on a database. It has tools such as the
developer interface, that allows the creation of reports and forms from or for the data in the
database. It also has a query processor that allows running queries with complex conditions to
obtain data in the format exactly as you want it.

Query: a command to the database in the form of a line of SQL code that tells the database what
data to modify or extract or how to change the structure of the database. There are two types of
queries:

a) Data Definition Language (DDL): All the commands used to define, modify, and delete the
structure of a database and the tables within. These commands are not designed to change
any data inside a table (except where the data must be deleted by deleting a column or
table) and that is why it’s called “Definition” language, only defining the structure of how
data should be inserted. Command examples: CREATE, ALTER.
b) Data Manipulation Language (DML): All the commands used to insert, extract, modify, or
remove data itself within a database itself, thus called “Manipulation” language. These
cannot modify the structure of a database or the tables inside it. Command examples:
SELECT, UPDATE, INSERT, DELETE

Flat file: A text file with all the data in a single file as a single table that must be shared with other
people if multiple people want to use it.

Problems with a flat file approach:

a) Data redundancy: A lot of the data is repeated within a database using a flat-file approach,
as there are no tables to link data together with foreign keys, and so all the data linked to an
attribute has to be repeated in any place where two records have that same attribute with
the same value. This increases storage use by a lot for the database to store all the data with
each record in the same line.
b) Data inconsistency: If the data is repeated, changing the data in one place to a certain value
will not change all the values dependent on that field, or will not change that field in other
places with the same value where the data must be consistent. There is no referential
integrity.
c) Data privacy: There is no User Access Control or user views to lock what the viewer can or
cannot see in a database, and so every user who has the flat-file database can see all the
data, even if it is sensitive data or data that the viewer does not need or has the possibility to
be misused.

Written by Mithani
d) Data dependency: Programs could be dependent on the exact structure and position of
certain data values in a flat-file, and any modification of the structure would cause the
program to read the incorrect data from the file as despite the structure being changed, the
program would still be expecting data to be arranged the same way as the previous
structure.

Relational databases: A relational database uses a series of tables with records and attributes
linked together and can be connected to remotely at a centralized location while being normalized
and is made to solve all the problems found with the flat-file approach.

Solutions to:

a) Data redundancy: normalization and primary-foreign key links, using much less storage
than flat-files.
b) Data inconsistency: normalization and referential integrity
c) Data privacy: User Access Control and User Views
d) Data dependency: Using a query system which can allow the program to query the data in
the exact structure it needs using the attribute names no matter how the data is actually
arranged on disk.

Primary key: A field in a table that uniquely identifies records in that table. It can never be NULL.

Composite key: Multiple fields in a table that act as one primary key by having unique combinations
in the table.

Foreign key: A field in a table that has values to link records to values in another table, where the
field is the primary key in the other table. This may be a one-to-one relation or a one-to-many
relation. Many-to-one is not possible as many primary keys can not be present as one foreign key in
another table, and many-to-many relation is a wrong database since it, just like many-to-one does
not make logical sense.

Candidate keys: All fields that are unique throughout a table and could possibly be primary keys.

Secondary key: A candidate key that can be used in indexing to speed up finding data in a certain
database.

Indexing: Using extra information of a table along with secondary keys to allow for searching data
based on criterion faster in a table.

Database Administrator: The person who manages a database and assigns access views for users.
He also controls the functionality and the backups of the database.

Referential integrity: Enforcing integrity in relational databases by not allowing foreign key links to
be made to non-existent primary keys. Whenever a foreign key value is being added to the table, the
system checks if the primary key with that value exists in the table its being linked to, and if not, it
errors out the query. Similarly, it will not let you delete a field or change the primary key of it if all its
referenced foreign keys are not removed, i.e. if any foreign key reference to that primary key exists in
the database, and if so, the system will not let allow deleting the primary key.

Written by Mithani
Normalization: A technique used to solve data duplication issues and improve data integrity as well
as optimize the structure of a database. It solves most issues of data redundancy.

In the syllabus, there are only three steps to normalizing a database, called the three Normal
Forms. You can only normalize a database by working your way up the Normal Forms, starting with:

a) First Normal Form (1NF): Make sure each table has a primary key field for all records. Make
sure the data is atomic (cannot be broken down simpler) e.g. Full Name can be broken
down into First Name and Last Name. Most importantly, there must be no repeating groups
of attributes such as if there are fields that have certain values only since certain other
fields have certain values, and this trend is visible in the entire database. This is not
necessarily the same thing as non-key dependencies though.
b) Second Normal Form (2NF): Make sure the database is already in 1NF. Make sure there are
no partial dependencies. This majorly only applies to databases with tables using
composite keys. No field must be dependent on data in one field of a composite key only
throughout the entire database.
c) Third Normal Form (3NF): Make sure the database is already in 2NF. There must be no non-
key dependencies. There must not be any dependency of any field throughout a table in a
database on another field that’s not a primary key or part of a composite key.

Dependency: A value that varies in line with another value in the same record.

Data dictionary: Metadata about the database such as field names, primary keys, data types, etc.

The database concept has three levels:

a) The Internal Level: The arrangement of data on the actual physical disk itself.
b) The Conceptual Level: The organized arrangement of data from the internal level as rows
and columns with tables and relationships. This contains a universal view of the database
that is controlled by the database administrator.
c) The External Level: The views for every user and the details about the security, provisions,
and access rights for who or what can access how much of the data.

Structured Query Language (SQL):


A language used by programmers to query data from a relational database.

SQL types of commands are listed in the “Queries” section.

SQL data types: “VARCHAR”, ‘CHAR’, #DATE#, #TIME#, INT, REAL, BOOLEAN

Table constraints: Specify the rules the data must follow to be inserted within a table. Examples:
UNIQUE, NOT NULL, CHECK, PRIMARY KEY, FOREIGN KEY

When extracting data based on criterion of multiple tables, you use INNER JOIN or SELECT FROM
table1, table2;

If this is useful for you, please keep me in your prayers. Good luck with your exams! Let me know if
there are any errors.

Written by Mithani

You might also like