FOC Mod2 Notes
FOC Mod2 Notes
1
GXEST203 Foundations of Computing: From Hardware Essentials to Web Design
2
GXEST203 Foundations of Computing: From Hardware Essentials to Web Design
3
GXEST203 Foundations of Computing: From Hardware Essentials to Web Design
4
GXEST203 Foundations of Computing: From Hardware Essentials to Web Design
5
GXEST203 Foundations of Computing: From Hardware Essentials to Web Design
A binary number is converted to decimal equivalent simply by summing together the weights of
various positions in the binary number
Example: 00001001
To compute a number in this system, you would multiply the digit value by the place
value, then add them all together: (1*8)+(0*4)+(0*2)+(1*1) = 9
6
GXEST203 Foundations of Computing: From Hardware Essentials to Web Design
EXAMPLE : n = 110.101
7
GXEST203 Foundations of Computing: From Hardware Essentials to Web Design
1’s Complement of Binary Number is computed by changing the bits 1 to 0 and the
bits 0 to 1. For example,
1’s complement of 101 is 010
1’s complement of 1011 is 0100
1’s complement of 1101100 is 0010011
2’s Complement of Binary Number is computed by adding 1 to the 1’s complement of
the binary number. For example,
2’s complement of 101 is 010 + 1 = 011
2’s complement of 1011 is 0100 + 1 = 0101
2’s complement of 1101100 is 0010011 + 1 = 0010100
8
GXEST203 Foundations of Computing: From Hardware Essentials to Web Design
magnitude. The left most bit, also called the Most Significant Bit (MSB) is the sign bit. The
remaining n-1 bits denote the magnitude of the number
In signed binary numbers, the sign bit is 0 for a positive number and 1 for a negative number. For
example, 01100011 is a positive number since its sign bit is 0, and, 11001011 is a negative number
since its sign bit is 1. An 8–bit signed number can represent data in the range −128 to +127 (–27to
+27−1). The left-most bit is the sign bit.
FRACTIONAL NUMBERS.
Fractional numbers, such as 12.34 and −0.001275, can also be represented in binary by using the
signed-integer techniques we have just described. To do that, however, first convert the number to
scientific notation:
where M is the mantissa, B is the exponent base (usually 2), and E is the exponent.
Example:Represent the decimal quantity 15.75.
Use 16 bits to represent the number, with 10 bits allocated for representing the mantissa and 6 bits for
the exponent. (The exponent base B is assumed to be 2 and is not explicitly stored.) Both the mantissa
and the exponent are signed integer numbers, so we can use either the sign/magnitude or two’s
complement notations that we just learned to represent each of these two fields. (In all the following
examples, we have chosen to use sign/magnitude notation.) In binary, the value 5 is 101. To represent
the fractional quantity 0.75
0.75 = 0.11
5.75 = 101.11
9
GXEST203 Foundations of Computing: From Hardware Essentials to Web Design
MEMORY REPRESENTATION
10
GXEST203 Foundations of Computing: From Hardware Essentials to Web Design
● The computer memory stores different kinds of data like input data, output data, intermediate
results, etc., and the instructions. Binary digit or bit is the basic unit of memory. A bit is a single
binary digit, i.e., 0 or 1.
● A bit is the smallest unit of representation of data in a computer. However, the data is handled by
the computer as a combination of bits.
● A group of 8 bits form a byte.
● One byte can store 28, i.e., 256 different combinations of bits, and thus can be used to represent
256 different symbols. In a byte, the different combinations of bits fall in the range 00000000 to
11111111. A group of bytes can be further combined to form a word. A word can be a group of 2,
4 or 8 bytes.
11
GXEST203 Foundations of Computing: From Hardware Essentials to Web Design
● Text: Characters are encoded as binary numbers using standards like ASCII or
Unicode. Example: ○ A=01000001 in binary (ASCII).
● Images: Stored as a grid of pixels, each represented in binary (e.g., grayscale uses
8 bits per pixel).
● Audio: Sampled and quantized into binary values during analog-to-digital
conversion.
• ASCII is a 7-bit character encoding standard used to represent text in computers, communication
systems, and other devices. It assigns numerical values to letters, digits, punctuation marks, and
control characters.
• The American Standard Code for Information Interchange (ASCII) is widely used in computers of
all types.
• ASCII codes are of two types—ASCII−7 and ASCII−8.
• ASCII-7 is a 7-bit standard ASCII code. In ASCII-7, the first 3 bits are the zone bits and the next
4 bits are for the digits. ASCII-7 allows 27 = 128 combinations. 128 unique
• ASCII-8 is an extended version of ASCII-7.
• ASCII-8 is an 8-bit code having 4 bits for zone and 4 bits for the digit.
• ASCII-8 allows 28 = 256 combinations. ASCII-8 represents 256 unique symbols. ASCII is
used widely to represent data in computers.
• The ASCII-8 code represents 256 symbols.
• Codes 0 to 31 represent control characters (non−printable), because they are used for
actions like, Carriage return (CR), Bell (BEL), etc.
• Codes 48 to 57 stand for numeric 0−9. o
• Codes 65 to 90 stand for uppercase letters A−Z.
• Codes 97 to 122 stand for lowercase letters a−z.
• Codes 128 to 255 are the extended ASCII codes.
12
GXEST203 Foundations of Computing: From Hardware Essentials to Web Design
EXAMPLE 1: Encode the word “DATA” and convert the encoded value into binary
values which can be understood by a computer.
Answer:
ASCII value of D is 68 and its equivalent 7-bit binary code = 1000100
ASCII value of A is 65 and its equivalent 7-bit binary code = 1000001
ASCII value of T is 84 and its equivalent 7-bit binary code = 1010100
ASCII value of A is 65 and its equivalent 7-bit binary code = 1000001
EXAMPLE 2: Encode the string data “Good” into its binary representation using
ASCII/UTF-8.
Ans: 01000111 01101111 01101111 01100100
13
GXEST203 Foundations of Computing: From Hardware Essentials to Web Design
EXAMPLE 3: Encode the string data “Hello” into its binary representation using
ASCII/UTF-8.
Ans: 01001000 01100101 01101100 01101100 01101111
EXAMPLE 4: Decode the binary data “01101000 01100001 01101001” into its text
representation using ASCII/UTF-8.
Ans: hai
EXAMPLE 5: Decode the binary data “01101000 01100101 01101100 01101100
01101111” into its text representation using ASCII/UTF-8.
Ans: hello
• It is an 8-bit character encoding system developed by IBM. It was primarily used on IBM
mainframes and midrange computers.
• EBCDIC codes are mainly used in the mainframe computers.
• 256 unique symbols are represented using EBCDIC code.
• It represents decimal numbers (0−9), lower case letters (a−z), uppercase letters (A−Z), Special
characters, and Control characters (printable and non−printable, e.g., for cursor movement,
printer vertical spacing, etc.).
Unicode
• Unicode is a universal character encoding standard for the representation of text which includes
letters, numbers and symbols in multi−lingual environments.
• The Unicode Consortium based in California developed the Unicode standard.
• Unicode uses 32 bits to represent a symbol in the data.
• Unicode allows 232 = 4164895296 (~ 4 billion) combination
• Unicode can uniquely represent any character or symbol present in any language like Chinese,
Japanese, etc. In addition to the letters; mathematical and scientific symbols are also represented
in Unicode codes.
• An advantage of Unicode is that it is compatible with the ASCII−8 codes. The first 256 codes in
Unicode are identical to the ASCII-8 codes.
14
GXEST203 Foundations of Computing: From Hardware Essentials to Web Design
• Unicode is implemented by different character encodings. UTF-8 is the most commonly used
encoding scheme. UTF stands for Unicode Transformation Format. UTF-8 uses 8 bits to 32 bits
per code
• Multiple Encoding Forms:
• UTF-8 (1-4 bytes per character) – Most widely used on the web.
• UTF-16 (2 or 4 bytes per character).
• UTF-32 (4 bytes per character)
ASCII Vs Unicode
Practice Questions :
1. What is the value of the 8-bit binary quantity 10101000 if it is interpreted
(a) as an unsigned integer and
(b) as a signed integer represented in sign/magnitude notation?
2. What does the unsigned decimal value 99 look like in binary using 8 bits?
3. What do the signed integers −300 and 1254 look like in binary using 10 bits and
sign/magnitude integer representation?
15
GXEST203 Foundations of Computing: From Hardware Essentials to Web Design
4. What is the value of the 8-bit binary quantity 10010111 when it is interpreted as a
sign/magnitude integer?
5. Using 4 bits and two’s complement representation, what is the binary
representation of the following signed decimal values:
a. +6
b. −3
6. Using 10 bits to represent the mantissa (sign/magnitude) and 6 bits for the exponent
(also sign/magnitude), show the internal representation of the following two values:
a. + 0.25
b. − 32 1/16
16
GXEST203 Foundations of Computing: From Hardware Essentials to Web Design
CPU ARCHITECTURE
Central Processing Unit (CPU) controls, coordinates and supervises the operations of the computer. It
is responsible for processing of the input data. The CPU is the brain of the computer, responsible
for executing instructions. A simplified conceptual block diagram of a CPU with memory is shown
in Figure
17
GXEST203 Foundations of Computing: From Hardware Essentials to Web Design
● ALU performs arithmetic and logic operations, and uses registers to hold the data that is being
processed.
● Performs arithmetic operations (addition, subtraction, multiplication, division).
● Executes logical operations (AND, OR, NOT, XOR) for decision-making.
● Works directly with data fetched from registers or memory.
● The control unit of a computer does not do any actual processing of data. It organizes the
processing of data and instructions. It acts as a supervisor and, controls and coordinates the
activity of the other units of computer.
● Directs and coordinates the activities of the computer.
● Decodes instructions fetched from memory and sends control signals to other components
(ALU, memory, I/O).
● Ensures instructions are executed in the correct sequence.
• Registers:
Memory
18
GXEST203 Foundations of Computing: From Hardware Essentials to Web Design
Memory stores data and instructions that the CPU needs to execute tasks. It is divided into:
• Secondary Memory:
o Non-volatile storage like hard drives, SSDs, and external storage for long-term data
retention.
• Cache Memory:
o A small, fast memory inside or near the CPU.
o Holds frequently accessed data to speed up processing.
Registers
Why are Registers Important?
Registers are crucial because they reduce the time the CPU spends accessing data from slower memory
types. By keeping data close to the CPU, they enhance performance and efficiency.
• Speed: Registers offer significantly faster access times compared to main memory (RAM),
leading to quicker instruction execution.
• Efficiency: By keeping frequently used data readily available, registers minimize the need to
constantly fetch data from slower memory locations.
19
GXEST203 Foundations of Computing: From Hardware Essentials to Web Design
• Registers are high-speed storage areas within the CPU, but have the least storage capacity.
Registers are not referenced by their address, but are directly accessed and manipulated by the
CPU during instruction execution.
• Registers store data, instructions, addresses and intermediate results of processing. Registers
are often referred to as the CPU’s working memory.
• The data and instructions that require processing must be brought in the registers of CPU before
they can be processed. For example, if two numbers are to be added, both numbers are brought
in the registers, added and the result is also placed in a register
20
GXEST203 Foundations of Computing: From Hardware Essentials to Web Design
• The output from the memory address register is passed to an address decoder.
• The output from the address decoder consists of a series of lines, each of which can light up the
bulbs in a single row of cells.
• Only one line at a time can be activated—specifically, the one corresponding to the decoded
address.
• The active line will light the bulbs that correspond to “1s”, leaving the “0s” dark.
The viewer therefore will see only the single group of cells that i
21
GXEST203 Foundations of Computing: From Hardware Essentials to Web Design
22
GXEST203 Foundations of Computing: From Hardware Essentials to Web Design
• Every instruction must be fetched from memory before it can be executed. Therefore, the first step
in the instruction cycle always requires that the instruction must be fetched from memory.
• The address of the current instruction to be executed is identified by the value in the program
counter register
• The first step will be to transfer that value into the memory address register, so that the computer can
retrieve the instruction located at that address
• Following notation to indicate the transfer of a data value from one register to another:
Step 1: Transferred from the Program counter to the Memory Address Register.
Step 2: Transferred from the Memory Data Register to the Instruction Register.
The instruction register will hold the instruction through the rest of the instruction cycle.
Step 3: The remaining steps are instruction dependent. Let us consider the steps required to complete
a load instruction
The notation IR [address] is used to indicate that only the address part of the contents of the instruction
register is to be transferred.
Step 4: This step prepares the memory module to read the actual data that will be copied into the
accumulator
Step 5: The CPU increments the program counter, and the cycle is complete and ready to begin the
next instruction
23
GXEST203 Foundations of Computing: From Hardware Essentials to Web Design
The load instruction requires only five steps. Four of the steps simply involve the movement of data
from one register to another. and the new value is returned to the same register.
The fifth step is nearly as simple. It requires the addition of the value 1 to the contents of a register
Assume that the following values are present just prior to execution of this segment:
24
GXEST203 Foundations of Computing: From Hardware Essentials to Web Design
25
GXEST203 Foundations of Computing: From Hardware Essentials to Web Design
INSTRUCTION SET
Classification of Instructions
Data Movement Instructions: Move data between registers, memory, and input/output
devices.
• MOV – Transfer data from one location to another
• LOAD – Load data from memory into a register
There may be a load byte instruction, a load half-word (2 bytes), a load word (4
bytes), and a load double word (8 bytes) within the same instruction set.
Eg: LOAD 1 --Load the contents of memory cell 1 into register R
• STORE – Store data from a register to memory
Eg: STORE A --Store the result into A
• PUSH/POP – Move data to/from the stack
Arithmetic Instructions
26
GXEST203 Foundations of Computing: From Hardware Essentials to Web Design
• The content of operand are added to the content of the accumulator and the result is stored in
accumulator .
• ADD A,B
subtraction.
• Any 8 bit data or the contents of a register or contents of a memory location can be subtracted
from the contents of the accumulator.
• SUB A,B
27
GXEST203 Foundations of Computing: From Hardware Essentials to Web Design
DEC AX ; AX = AX - 1
28
GXEST203 Foundations of Computing: From Hardware Essentials to Web Design
29
GXEST203 Foundations of Computing: From Hardware Essentials to Web Design
30
GXEST203 Foundations of Computing: From Hardware Essentials to Web Design
ASSEMBLY LANGUAGE
Disadvantages of machine language
• It uses binary. There are no natural language words, mathematical symbols, or other
convenient mnemonics to make the language more readable.
• It allows only numeric memory addresses (in binary). A programmer cannot name an
instruction or a piece of data and refer to it by name.
• It is difficult to change. If we insert or delete an instruction, all memory addresses following
that instruction will change.
• It is difficult to create data. If a user wants to store a piece of data in memory, he or she
must compute the internal binary representation for that data item. These conversion algorithms
are complicated and time consuming.
31
GXEST203 Foundations of Computing: From Hardware Essentials to Web Design
Inorder to overcome the short comings of machine language, the programmers developed a
new language,called assembly language.
● Assembly languages created a more productive, user-oriented environment.
● Today, assembly languages are more properly called low-level programming
languages, which means they are closely related to the machine language.
● Each symbolic assembly language instruction is translated into exactly one binary
machine language instruction.
● A program written in assembly language is called the source program.
● The source program must be translated into a corresponding machine language
program,called the object program.
● This translation is carried out by a piece of system software called an assembler.
● Translators for high-level languages are called compilers.
There are three major advantages to writing programs in assembly language rather than
machine language:
• Use of symbolic operation codes rather than numeric (binary) ones
• Use of symbolic memory addresses rather than numeric (binary) ones
• Pseudo-operations that provide useful user-oriented services such as data generation
32
GXEST203 Foundations of Computing: From Hardware Essentials to Web Design
The comment field, preceded in our notation by a double dash (--), is not really part of the instruction.
It is a helpful explanation added to the instruction by a programmer and intended for readers of the
program. It is ignored by the machine during translation and execution.
Assembly languages allow the programmer to refer to op codes using a
symbolic name, called the op code mnemonic, rather than by a number. We can write op codes using
meaningful words like LOAD, ADD, and STORE rather than obscure binary codes like 0000, 0011,
and 0001.
we can attach a symbolic label to any instruction or piece of data in the program. The label then
becomes a permanent identification for this instruction or data, regardless of where it appears in the
program or where it may be moved in memory. A label is a name (followed by a colon to identify it as
a label) placed at the beginning of an instruction.
Example Program
.BEGIN
LOAD R1, VALUE ; Load VALUE into Register R1