Foc m2 Notes
Foc m2 Notes
1. Data Representations
1. Numbers
Numbers are typically represented in binary format by converting each digit to binary equivalents.
Example: Representing the decimal number 5 in binary.
o 5 in decimal is 101 in binary.
Example: Representing 10 in binary.
o 10 in decimal is 1010 in binary.
2. Text (Characters)
Text characters are represented using standardized encoding schemes, like ASCII (American Standard Code for
Information Interchange) or Unicode.
Example: Representing the character 'A' in ASCII.
o In ASCII, 'A' is represented by the decimal number 65.
o 65 in binary is 01000001.
Example: Representing the character 'a'.
o In ASCII, 'a' is represented by 97.
o 97 in binary is 01100001.
3. Images
Images are represented in binary by breaking down each pixel into binary values that represent color information. In
grayscale images, each pixel might be represented by an 8-bit binary number, while in color images (like RGB), each
color channel (Red, Green, Blue) may use 8 bits, giving a total of 24 bits per pixel.
Example: A grayscale pixel with an intensity value of 200.
o 200 in binary is 11001000.
Example: An RGB pixel with values (Red=255, Green=0, Blue=127).
o Red: 11111111, Green: 00000000, Blue: 01111111.
4. Sound
Sound is represented as a sequence of binary values that correspond to sample amplitudes of the audio signal at each
point in time. These samples are often stored as 8-bit, 16-bit, or 32-bit binary numbers.
Example: A sound sample with an amplitude of 128 in 8-bit audio.
o 128 in binary is 10000000.
5. Instructions
Machine instructions are represented in binary and are specific to the processor. Each instruction consists of an
"opcode" (operation code) and possibly some additional data (like an address or value).
Example: An imaginary instruction ADD R1, R2 (add the contents of register R2 to register R1).
o This might be encoded in binary as something like 0001 0001 0010 (specific to the processor
architecture).
These examples show how computers represent different data types in binary. The binary system enables efficient
data storage and processing due to its compatibility with digital circuits
Converting between decimal and binary is a fundamental process in computer science. Let's go over each conversion
method with examples.
2. Number Systems
1. Converting Decimal to Binary
To convert a decimal number to binary, repeatedly divide the number by 2, recording the remainder at each step. The
binary number is formed by reading the remainders in reverse order (from bottom to top).
Steps:
1. Divide the decimal number by 2.
2. Record the remainder (0 or 1).
3. Use the quotient (result of division) as the new number to divide by 2.
4. Repeat until the quotient is 0.
5. The binary number is the sequence of remainders read in reverse.
Example: Convert 25 to binary
1. 25÷2=12 with a remainder of 1.
2. 12÷2=6 with a remainder of 0.
3. 6÷2=3 with a remainder of 0.
4. 3÷2=1 with a remainder of 1.
5. 1÷2=0 with a remainder of 1.
Reading the remainders from bottom to top, 25 in decimal is 11001 in binary.
Another Example converting decimal number 17 to binary
2. Octal (Base-8)
Octal uses eight digits: 0 through 7. It is useful as a shorthand representation of binary because each octal digit
corresponds to exactly three binary bits.
Example:
o Binary: 101011 can be grouped into three bits from the right as 000 101 011.
o Octal: 000 is 0, 101 is 5, and 011 is 3, so the octal number is 053.
o Decimal Equivalent: 0×82+5×81+3×80=0+40+3=43
3. Hexadecimal (Base-16)
Hexadecimal uses sixteen symbols: 0 to 9 and A to F (where A represents 10, B represents 11, and so on up
to F which represents 15). It’s another shorthand for binary, where each hex digit represents four binary bits.
Example:
o Binary: 11011011 can be grouped into four bits from the right as 1101 1011.
o Hexadecimal: 1101 is D, and 1011 is B, so the hexadecimal number is DB.
o Decimal Equivalent: D×161+B×160=13×16+11=208+11=219
Binary Addition
The binary system consists of only two digits, 1 and 0. Most of the functionalities of the computer system use
the binary number system.
Before attempting the binary addition process, we should have complete knowledge of how the place works in
the binary number system.
Rules of Binary Addition
0+0=0
0+1=1
1+0=1
1 + 1 =10
How To Do Binary Addition?
Now, look at the example of the binary addition:101 + 101
Procedure for Binary Addition of Numbers:
101
(+) 101
Step 1: First consider the 1’s column, and add the one’s column,( 1+1 ) and it gives the result 10 as per the
condition of binary addition.
Step 2: Now, leave the 0 in the one’s column and carry the value 1 to the 10’s column.
1
101
(+) 101
————–
0
Step 3: Now add 10’s place, 1+( 0 + 0 ) = 1. So, nothing carries to the 100’s place and leave the value 1 in the
10’s place
1
101
(+) 101
————-
10
Step 4: Now add the 100’s place ( 1 + 1 ) = 10. Leave the value 0 in the 100’s place and carries 1 to the 1000’s
place.
1
101
(+) 101
————-
1010
So, the resultant of the addition operation is 1010.
When you cross-check the binary value with the decimal value, the resultant value should be the same.
The binary value 101 is equal to the decimal value 5
So, 5 + 5 = 10
The decimal number 10 is equal to the binary number 1010.
Example 1: 10001 + 11101
Solution:
1
10001
(+) 1 1 1 0 1
———————–
101110
Example 2: 10111 + 110001
Solution:
111
10111
(+) 1 1 0 0 0 1
———————–
1001000
Register Function
Program Counter (PC) Holds the address of the next instruction to be executed.
Memory Address Register (MAR) Holds the address of the memory location being accessed.
Register Function
Memory Data Register (MDR) Temporarily stores data read from or written to memory.
Status/Flag Register Stores flags indicating CPU status (e.g., Zero Flag, Carry Flag, Overflow Flag).
A bus is a set of physical connections (cables, circuits, etc.) that can be shared by multiple hardware
components to communicate with one another.
Memory and input/ output devices are connected to the Central Processing Unit through a group of
lines called a bus. These lines are designed to transfer data between different components.
Data Bus: The data bus is responsible for the actual transfer of data between the CPU, memory,
and peripheral devices. It carries the data that the system reads from or writes to memory or I/O
devices. The data bus is bidirectional.
Control Bus: carries control signals that manage and synchronize the operations of the CPU, memory,
and peripheral devices. The control bus is unidirectional.
9. Addressing in Computers
Addressing refers to the method of specifying the location of data or instructions within the computers
memory.
Types of addressing modes:
1. physical addressing: This is the most common addressing mode. In this address is directly mapped to
a specific physical memory location in the RAM.
2. Logical addressing:
3. Immediate addressing
4. Direct addressing:
5. Indirect Addressing:
6. Register Addressing:
7. Indexed addressing:
8. Base – Register Addressing:
9. Relative Addressing
ADD A, B A = A + B