Module2 Fc
Module2 Fc
S2 CSE
NUMBER SYSTEMS
The decimal system is the most commonly used number system in everyday life and is
based on 10 digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, and 9.
Each place value in a decimal number is a power of 10.
For example, in the number 235:
• 2×10^2=200
• 3×10^1=30
• 5×10^0=5 Total: 200+30+5=235
The decimal system is positional, meaning the value of each digit depends on its position
in the number.
Binary Number System
The binary system is used internally by almost all modern computers and computer-based devices
because it is straightforward to implement with digital electronic circuitry.
It uses only two digits: 0 and 1.
These two symbols represent two states: 0 for off, and 1 for on.
Binary numbers are written using powers of 2. For example, the binary number 1011 represents:
• 1x2^3-8
• 0x2^2-0
• 1×2^1-2
• 1×2^0-1
• Total: 8+0+2+1=11in decimal.
Octal Number System
The octal system is a base-8 number system that uses digits from 0 to 7.
Each digit represents a power of 8.
It is sometimes used in computing as a shorthand for binary numbers because every octal
digit corresponds to exactly three binary digits.
For example, the octal number 157 represents:
1×8^2=64
5x8^1=40
7x8^0=7
Total: 64+40+7=111 in decimal.
Hexadecimal Number System
The hexadecimal system is a base-16 number system that uses 16 symbols: the digits 0 to 9 and
the letters A to F (or a to f) to represent values from 10 to 15.
Hexadecimal is often used in computing and digital electronics as a more compact representation
of binary numbers.
One hexadecimal digit corresponds to 4 binary digits (bits).
For example, the hexadecimal number 1F3 represents:
o 1×16^2=256
o F(15)×16^1=240
o 3×16^0=3
o Total: 256+240+3=499 in decimal.
DATA STORAGE UNITS
Data storage units are standardized measurements used to quantify digital information.
Storage capacity is typically measured using various units, each representing different
scales of data.
The most common units used to measure digital storage are:
1. Bits
Bits are the basic building blocks of not only data storage, but all computers.
Computers work in binary digits, combining 0's and 1's in countless patterns.
These binary digits are known as bits, and are the smallest possible unit for data storage.
2. Byte
A byte consists of 8 bits and is the standard unit of storage used to measure file sizes and
memory capacity in most systems.
For one character of text typically takes up one byte.
All example, memory storage is expressed in terms of bytes, so although bits might be
the foundation upon which data storage is built, bytes are the building blocks that truly
denote the usability of any one storage solution.
3. Kilobyte (KB)
1 KB = 1,024 bytes (in binary systems). In decimal (SI system), 1 KB is often considered
1,000 bytes. Kilobytes are used to measure small files such as text documents.
4. Megabyte (MB)
1 MB = 1,024 KB = 1,048,576 bytes (binary). In the SI decimal system, 1 MB =
1,000,000 bytes. Megabytes are used to measure the size of larger files like images, audio
files, and software applications.
4. Gigabyte (GB)
1 GB = 1,024 MB = 1,073,741,824 bytes (binary).
In the decimal system, 1 GB = 1,000,000,000 bytes. Gigabytes are commonly used to
measure the storage capacity of devices like smartphones, SSDs, and hard drives.
Data Storage Units
BINARY REPRESENTATION OF DATA
AND NUMBERS
Binary Representation of Data and Numbers is the use of the binary number system (base-
2) to represent data in computing.
In binary, only two digits are used: 0 and 1. This is because computers use electrical
signals that can be in one of two states, typically represented as off (0) and on (1).
The base-2 system is the positional notation with 2 as a radix.
The binary system is applied internally by almost all latest computers and computer-based
devices because of its direct implementation in electronic circuits using logic gates. Every
digit is referred to as a bit.
Converting Decimal to Binary
To convert a decimal number to binary, we can repeatedly divide the number by 2 and
record the remainders.
To convert 13 to binary
1. Divide 13 by 2. The quotient is 6, and the remainder is 1.
2. Divide 6 by 2. The quotient is 3, and the remainder is 0.
3. Divide 3 by 2. The quotient is 1, and the remainder is 1.
4. Divide 1 by 2. The quotient is 0, and the remainder is 1.
5. Now, take the remainders from bottom to top: 1101.
2. To convert 47 to binary
1. Divide 47 by 2. The quotient is 23, and the remainder is 1.
2. Divide 23 by 2. The quotient is 11, and the remainder is 1.
3. Divide 11 by 2. The quotient is 5, and the remainder is 1.
4. Divide 5 by 2. The quotient is 2, and the remainder is 1.
5. Divide 2 by 2. The quotient is 1, and the remainder is 0.
6. Divide 1 by 2. The quotient is 0, and the remainder is 1.
7. Now, take the remainders from bottom to top: 101111.
To convert 0.54 to binary
Convert 10110 to binary
Convert 0.1101 to decimal
Integer Representation
An unsigned integer can only represent non-negative whole numbers (0 or positive numbers).
It uses all its bits to represent the magnitude of the number.
For example: 8-bit unsigned integer can represent numbers from 0 to 255 (since 2^8 = 256 possible
values)
10101010 (binary)- 1x27+0x26+ 1x25+0x24+1x23+0x22+1×21 +0×20-128 +32 +8 +2 = 170 (decimal)
Thus, 10101010 in binary= 170 in decimal
Signed Integer Representation
A signed integer can represent both positive and negative whole numbers.
There are a few different methods for encoding signed integers in binary.
1. Sign and Magnitude Representation:
In sign and magnitude representation, the most significant bit (MSB) is used to represent
the sign of the number: 0 indicates a positive number and 1 indicates a negative number.
The remaining bits represent the magnitude(absolute value) of the number.
For example, using 8 bits:+5 is represented as: 00000101 (binary) and
-5 is represented as: 10000101 (binary) (MSB = 1 indicates the negative sign)
• The limitation of sign and magnitude is that there are two representations for zero: +0 (00000000) and -
0 (10000000), which is inefficient.
2. Two's Complement Representation
In two's complement representation, negative numbers are represented by inverting the bits of the
number's absolute value and then adding 1 to the result.
This method is widely used because it simplifies arithmetic operations and avoids having two
representations for zero.
For example, using 8 bits:+5 is represented as: 00000101 (binary) and-5 is represented as:Invert
00000101 → 11111010Add 1-11111011 (binary)
Two's complement works because of the way it handles overflow and it allows for simpler hardware
implementation of addition and subtraction.
For example, to convert a positive number to its negative counter part in two's
complement:
1. Write the number in binary.
2. Invert all the bits.
3. Add 1 to the result.
Convert +5 to binary (8-bit): +5=00000101.
Now, to convert -5:
• 1. Invert 00000101 → 11111010
• 2. Add 1-11111011 (binary)Thus, -5 is represented as 11111011 in two's complement.
Binary Arithmetic
Binary Addition
In binary arithmetic, the process of adding two binary numbers is called binary addition.
Binary numbers consist of only 0 and 1. In the binary addition, a carry is generated when
the sum is greater than 1.
Rules:
Example
Binary Subtraction
Binary subtraction is a mathematical operation used to find the difference between two binary
numbers.
In binary subtraction, each bit of the binary numbers is subtracted, starting from the rightmost
bit.
The Borrowing process happens when subtracting 1 from 0.
Rules:
0–0=0
1–0=1
1–1=0
0 – 1 (requires borrowing, becomes 10 – 1=1)
Example
10110
- 1101
-----------------------
1001
2. Subtract 101 from 1111
Binary multiplication is the process of multiplying two binary numbers and obtain their
product.
In binary multiplication, we multiply each bit of one binary number by each bit of another
binary number and then add the partial products to obtain the final product.
Rules:
0x0=0
1x0=0
0x0=0
1x1=1
Example
Binary division is one of the basic arithmetic operations used to find the quotient and
remainder when dividing one binary number by another.
Example :
Divide 110011 by 11.
Procedure
• Start dividing from the leftmost bits of the dividend by the divisor.
• Multiply the quotient obtained by the divisor and subtract from the dividend.
• Bring down the next bits of the dividend and repeat the division process until all the bits
of given divided are used.
9’s Complement
The 9's complement of a number is found by subtracting each digit in the number from 9. It is commonly
used in subtraction operations in digital electronics and computer systems.
Steps to Find 9's Complement:
1. Write the given number.
2. Subtract each digit of the number from 9.
Example:
Let's calculate the 9's complement of the number 4567.
1. Write the number:
4567
2. Subtract each digit from 9:
o9-4=5
o9-5=4
o9-6=3
o9-7=2
3. Resulting 9's complement: 5432
Steps for Subtraction Using 9's
Complement:
The CPU uses a cycle known as the Instruction cycle to process all of these instructions
and operations.
The instruction cycle is the time it takes a CPU to execute and retrieve a complete
instruction . While this cycle can vary from CPU to CPU, they typically consist of the
following stages:
1. Fetch: When we power on our computers, the CPU is ready to process instructions. As
instructions are received, a register in the CPU known as the Program Counter (PC) holds the
memory address of the next instruction to be processed. When it comes time to begin
processing the instruction, the CPU copies the memory location and stores the duplicated data
in another register on the CPU known as the Instruction Register (IR). Decoding occurs once
the instruction's memory is available.
2. Decode: The next step in the cycle is to decode the instruction. During this stage, the
Control Unit determines what the instruction recorded in the IR implies.
3. Execute: In this phase, the instruction is carried out!
4. Memory Access: The memory access step retrieves any data required to perform an
instruction. This stage is only activated if the instruction demands data from memory.
5. Registry Write-Back: If the execution of the instruction has any effect on data, the
registry write-back step is used. This is another stage that may or may not occur during
the cycle.
key components
Program Counter (PC): Keeps track of the address of the next instruction.
Memory Address Register (MAR): Holds the address of the instruction or data to be
accessed.
Memory Buffer Register (MBR): Holds the instruction or data that has been fetched from
or will be written to memory.
Instruction Register (IR): Holds the currently decoded instruction.
Control Unit (CU): Decodes the instruction and generates the necessary control signals.
Arithmetic Logic Unit (ALU): Performs mathematical and logical operations.
Advantages
1. Standardization: The instruction cycle provides a standard way for CPUs to execute
instructions, which allows software developers to write programs that can run on multiple
CPU architectures.
2. Efficiency: By breaking down the instruction execution into multiple steps, the CPU can
execute instructions more efficiently.
3. Pipelining: The instruction cycle can be pipelined, which means that multiple instructions
can be in different stages of execution at the same time. This improves the overall
performance of the CPU, as it can process multiple instructions simultaneously.
Disadvantages
1. Overhead: The instruction cycle adds overhead to the execution of instructions, as each
instruction must through multiple stages before it can be executed. This overhead can
reduce the overall performance of the CPU.
2. Complexity: The instruction cycle can be complex to implement, especially if the CPU
architecture and instruction set are complex. This complexity can make it difficult to
design, implement, and debug the CPU.
3. Limited parallelism: While pipelining can improve the performance of the CPU, it also
has limitations. For example, some instructions may depend on the results of previous
instructions, which limits the amount of parallelism that can be achieved.
Fetch – Execute Instruction Cycle
It is the basic operation cycle of a computer (also known as the fetch decode execute
cycle).
During the fetch execute cycle the computer retrieves a program instruction from its
memory. It then establishes and carries out the actions that are required for that
instruction.
The cycle of fetching, decoding, and executing an instruction is continually repeated by
the CPU whilst the computer is turned on.
1. Fetch Stage:
During the fetch phase, the CPU retrieves an instruction from memory (RAM) to execute.
Step 1: Program Counter (PC) provides the address of the next instruction.
Step 2: The instruction is fetched from memory.
CPU uses the memory address in the PC to access the instruction memory. The memory
address is loaded into the Memory Address Register (MAR). Then, the instruction is fetched
from the memory and placed into the Memory Buffer Register.
Step 3: Increment the Program Counter.
Step 4: The instruction is loaded into the Instruction R(IR)
2.Execute Stage
During the execute phase, the CPU performs the action specified by the instruction.
Step 5: Decode the instruction: The Control Unit (CU) decodes the instruction stored in the
Instruction Register (IR) to determine the operation to perform.
Step 6: Operate on data (if needed): If the instruction involves an operation, such as an
arithmetic or logical operation, the Arithmetic Logic Unit (ALU) performs the operation.
Step 7: Write back results (if necessary): If the instruction produces a result (for example, a
calculation), the result is written back into a register or memory location.
3. Repeat the cycle
Once the instruction has been executed, the CPU returns to the fetch phase and retrieves
the next instruction using the updated Program Counter (PC).
This cycle repeats until the program completes or a halt condition is encountered.
Simple assembly language instruction:
MOV RI, R2
This instruction copies the contents of register R2 into register R1.
In the Fetch phase, the CPU retrieves the instruction from memory.
Step 1: The Program Counter (PC) holds the address of the next instruction to be fetched.
Assume the address of the MOV R1, R2instruction is 0x2000.
Step 2: The address 0x2000 is copied to the Memory Address Register (MAR). The instruction
stored at address 0x2000 (which is MOV R1, R2) is fetched from memory and placed into the
Memory Buffer Register (MBR).
Step 3: After fetching the instruction, the Program Counter (PC) is incremented to point to the
next instruction (for example, to address 0x2004).
Step 4: The instruction in the MBR is transferred to the Instruction Register (IR). The IR now
holds MOV R1, R2.
In the Decode phase, the CPU decodes the instruction to determine what action needs to
be taken.
Step 5: The Control Unit (CU) examines the instruction in the IR. It determines that the
instruction is a Move (MOV) operation, which means the contents of register R2 need to
be copied into register R1.
Step 6: The Control Unit (CU) sends signals to:
Read the data from register R2.
Write the data into register R1.
In the Execute phase, the CPU performs the operation specified by the instruction.
Step 7: Since this is a Move instruction, the CPU doesnot need to perform a calculation.
It simply copies the data from R2 to R1.
Step 8: The contents of R2 are written into R2.
Step 9:The Program Counter (PC) is already updated during the fetch stage, CPU is ready
to fetch the next instruction from memory.
. Complete Instruction Cycle
(Fetch-Decode-Execute-Store)
Central Processing Unit (CPU) is the brain of a computer, responsible for executing instructions and
performing calculations. It follows a structured architecture that allows it to process data efficiently.
Major Components of a CPU
1. Arithmetic Logic Unit (ALU):
o Performs arithmetic (addition, subtraction, multiplication, division) and logical (AND, OR, NOT, XOR) operations.
2. Control Unit (CU):
o Directs operations by fetching, decoding, and executing instructions.
o Manages the flow of data between the CPU, memory, and input/output devices.
3. Registers:
o Small, high-speed storage units inside the CPU for temporary data storage.
o Examples of registers:
Program Counter (PC): Holds the address of the next instruction.
Instruction Register (IR): Stores the current instruction.
Accumulator (ACC): Temporarily holds intermediate results.
4. Memory (RAM) :
O CPU interacts with memory (RAM) to fetch instructions and store intermediate data during processing.
Functions:
Stores instructions and data that the CPU needs for execution.
Provides fast access to data that the CPU can retrieve and manipulate.
5. Bus System:
O It is used for communication between the CPU and other parts of the computer such as memory and input/output
devices..
o Types:
▪ Data Bus: Transfers actual data.
▪ Address Bus: Transfers memory addresses.
▪ Control Bus: Sends control signals.
CPU Instruction Cycle (Fetch-Decode-
Execute Cycle)
The Arithmetic Logic Unit (ALU) is a key component of the CPU responsible for
performing
all arithmetic and logical operations. It operates as the computational core of the
processor.
Functions of ALU
The ALU is responsible for:
1. Arithmetic Operations: Addition, subtraction, multiplication, and division.
2. Logical Operations: AND, OR, NOT, XOR, NAND, NOR, XNOR.
3. Bitwise Operations: Bit shifting (left shift, right shift) and bit manipulation.
4. Comparison Operations: Checking if values are equal, greater than, or less than.
5. Increment/Decrement Operations: Increasing or decreasing values by one.
Components of ALU
The ALU consists of various subcomponents that work together to perform computations:
(i) Operand Registers
● Temporarily store the input values for an operation.
● Examples: Accumulator (ACC), General Purpose Registers (R1, R2, etc.)
(ii) Arithmetic Unit
● Performs mathematical calculations like addition, subtraction, multiplication, and division using circuits like adders and
multipliers.
(iii) Logic Unit
● Executes logical operations such as AND, OR, XOR, and NOT using logic gates.
(iv) Status Flags
● Stores information about the result of an operation.
● Example flags:
o Zero (Z) Flag: Set if the result is zero.
o Carry (C) Flag: Set if there is a carry from an addition operation.
o Sign (S) Flag: Set if the result is negative.
Working of ALU
Registers are small, high-speed storage units located inside the CPU, used to
store temporary
data, instructions, and addresses.
Characteristics of Registers:
● Faster than cache and main memory.
● Store data temporarily for quick processing.
● Used in the fetch-decode-execute cycle for efficient execution.
Types of Registers:
1. General-Purpose Registers (GPRs)
o Used for general data storage during execution.
o Example: AX, BX, CX, DX (in x86 architecture).
2. Special-Purpose Registers
o Designed for specific tasks, such as holding memory addresses, flags, or counters.
Special-Purpose Registers in a CPU:
Register Function
Program Counter (PC) Holds the address of the next instruction to be
executed.
Instruction Register (IR) Stores the current instruction being executed.
Memory Address Register Holds the address of the memory location being
(MAR) accessed.
Memory Data Register Temporarily stores data read from or written to
(MDR) memory.
Accumulator (ACC) Holds intermediate arithmetic and logical results.
Stack Pointer (SP) Points to the top of the stack in memory.
The Control Unit (CU) is a critical component of the CPU that directs the
execution of instructions by coordinating data flow between the CPU,
memory, and input/output devices.
Functions of the Control Unit:
1. Instruction Fetching – Retrieves instructions from memory.
2. Instruction Decoding – Interprets the instructions to determine required operations.
3. Generating Control Signals – Directs other CPU components, such as the ALU and
registers.
4. Managing Data Flow – Ensures proper movement of data between registers, memory,
and I/O devices.
Types of Control Units:
CISC (Complex Instruction Set Computing) is a type of microprocessor architecture that aims to
reduce the number of instructions per program, at the cost of using more complex instructions.
Single instruction can execute multiple low- level operations (such as loading from memory,
performing an arithmetic operation, and storing the result back to memory) in a single
instruction cycle.
Reduce the number of instructions required to perform a task, thus potentially improving
performance for certain applications.
key characteristics of CISC architecture
1.Complex Instructions: CISC processors have a large number of instructions, many of which can
perform operations in a single instruction (e.g., load from memory, complex perform arithmetic, and store
back in one instruction).
2. Variable-Length Instructions: CISC instructions can vary in length, depending on the operation and
operands involved.
3. Fewer Instructions: Since CISC allows for complex operations in a single instruction, fewer
instructions may be required to complete a task compared to other architectures like RISC.
4. Memory-to-Memory Operations: CISC processors can perform operations directly on memory
without needing to load data into registers first.
5. Backward Compatibility: CISC architectures, especially in the case of x86 processors, often maintain
backward compatibility with older programs, allowing software written for older processors to run on
newer ones.
Advantages of CISC:
Reduced Instruction Count: Complex instructions mean that fewer instructions
are needed for a given task, potentially reducing the overall program size.
Improved Performance for Specific Tasks: For certain applications that
require complex operations (like mathematical calculations or string processing),
CISC can outperform simpler architectures.
Disadvantages of CISC:
Slower Clock Speeds: The complexity of each instruction may lead to slower
execution compared to simpler instructions.
Complex Decoding: The need to decode variable-length instructions adds
complexity to the processor design.
Reduced Instruction Set Computing (RISC)
Architecture
The primary goal of RISC is to simplify the design and operation of processors by limiting the
number of instructions and making each instruction execute in a single clock cycle (or a minimal
number of cycles).
RISC architectures are designed to increase performance through simplicity, efficiency, and
parallelism.
Key Characteristics of RISC Architecture
1. Simplified Instructions: RISC processors use a small set of instructions, each designed to execute in a single cycle (or as few cycles as
possible). These instructions tend to be simple and perform a single, well-defined task.
2. Fixed-Length Instructions: Unlike CISC, where instruction lengths can vary, RISC instructions are typically of fixed length (e.g., 32
bits), making instruction decoding faster and simpler.
3.Load/Store Architecture: RISC processors separate memory access and arithmetic operations. Memory can only be accessed through
specific load and store instructions, and all other operations are performed on registers.
4. Registers as the Primary Data Storage: RISC processors use a large number of general-purpose registers.
5. Fewer Addressing Modes: RISC architectures typically have simpler, fewer addressing modes compared to CISC, which makes the
processor easier to design and implement.
6. Instruction Pipeline: The simplicity and regularity of RISC instructions for make them well-suited pipelining. Instruction pipelining
allows multiple instructions to be processed simultaneously at different stages, improving performance.
7. Compiler-Dependent Optimization: RISC relies heavily on the compiler to optimize code and make use of the simple instruction set.
Since the instructions are simple, the compiler has to generate efficient code that takes advantage of the architecture.
Advantages
Faster Execution
Simpler Hardware Design
Better Pipelining
Energy Efficiency
Disadvantages
Larger Code Size
More Work for Compiler
Memory Traffic
RISC vs CISC architecture
RISC CISC
Focus on software Focus on hardware
Uses only Hardwired control unit Uses both hard wired and microprogrammed
control unit
Transistors are used for more registers Transistors are used for storing complex
Instructions
Fixed sized instructions Can perform only Variable sized instructions Can perform REG
Register to Register Arithmetic operations to REG or REG to MEM or MEM to MEM
Code size is large Code size is small
An instruction executed in a single clock Instruction takes more than one clock cycle
cycle
The no. of instructions is less as compared to The no. of Instructions is more as compared
CISC to RISC.
VLIW Vs Superscalar Processor
Depending on the processor's design, instructions can vary, but they generally fall into
these categories:
CISC (Complex Instruction Set Computing): CPUs with a large number of complex
instructions, often involving multiple operands or addressing modes in a single
instruction.
Example: x86 architecture.
RISC (Reduced Instruction Set Computing): CPUs with a smaller set of simpler
instructions, typically involving fewer operands and addressing modes.
Example: ARM, MIPS architectures.
Assembly Language
Definition:
Assembly Language is a low-level programming language that uses
human-readable mnemonics instead of binary machine code. It
provides direct control over CPU operations.
Features of Assembly Language:
● Uses mnemonics like MOV, ADD, SUB instead of binary codes.
● Requires an Assembler to convert assembly code into machine code.
● Allows direct memory and register manipulation.
● Faster than high-level languages but harder to code
Advantages of Assembly Language:
❖ Efficient and fast execution.
❖ Direct Hardware Control
❖ Suitable for system Programming (OS,drivers)
Disadvantages of Assembly Language:
❖ Difficult to learn compared to high-level languages.
❖ Machine-dependent (not portable).
Basic Assembly Language
Instructions
Conditional jump instructions transfer control based on the status of flags in the CPU (such as Zero
Flag, Carry Flag, etc.). These flags are affected by previous operations like ADD, SUB, CMP, etc.
1. JE destination or JZ destination - These instructions jump to a specified label if the Zero Flag (ZF)
is set,indicating that the last comparisonresulted in zero.
For example: JE label
2. JNZ destination –These instructions jump to the specified label if the Zero Flag (ZF) is clear,
meaning the result of the previous operation was not zero.
For example: JNE label; Jump if Zero Flag is not set (notequal)
3. JC destination - The JC instruction jumps if the Carry Flag (CF) is set, indicating that the previous
operation caused a carry (e.g., in an unsigned addition or subtraction).
For example, JC label
JL destination -The JL instruction jumps if the first operand is less than the second
operand, based on signed comparison.
For example:JL label
JGE destination -The JGE instruction jumps if the previous comparison indicated that
the first operand is greater than or equal to the second operand, considering signed values.
For example:JGE label
JLE destination -The JLE instruction jumps if the previous comparison showed that the
first operand is less than or equal to the second operand, considering signed values.
For Example:JLE label
Comparison Instructions
Comparison instructions in assembly language are used to compare two operands and set
the status flags (Zero Flag, Carry Flag, Sign Flag, etc.) based on the result of the
comparison
Example - CMP AX, BX
✓ If AX == BX, the Zero Flag (ZF) will be set.
✓ If AX> BX, the Carry Flag (CF) will be cleared.
✓ If AX < BX, the Carry Flag (CF) will be set.
Logical Instructions
Shift and rotate instructions are used to shift or rotate the bits of a register or memory
operand. These operations are used for arithmetic or logic operations such as division, and
bit manipulation.
1. SHL operand, count - The SHL (Shift Left) instruction shifts the bits of the operand to the
left by a specified number of positions. The vacant bit positions on the right are filled with
zeros.
For example: SHL AX, 1 ; Shift the bits of AX to the left by 1 position (multiply by 2)
2. SHR operand, count - The SHR (Shift Right) instruction shifts the bits of the operand to
the right by a specified number of positions. The vacant bit positions on the left are filled
with zeros.
Example : SHR AX, 1 ; Shift the bits of AX to the right by 1 position.
3. SAL operand, count
SAL (Shift Arithmetic Left) is essentially the same as SHL and shifts the bits of the operand
to the left.
For example: SAL AX, 1
4. SAR operand, count - The SAR (Shift Arithmetic Right) shifts the bits of the operand to
the right by a specified number of positions, but it preserves the sign bit for signed numbers.
SAR AX, 1 ; Shift AX right by 1 position
5. ROL operand, count
The ROL (Rotate Left) instruction rotates the bits of the operand to the left by a specified
number of positions. The leftmost bit is moved to the rightmost position.
For example: ROL AX, 1 ; Rotate the bits of AX to the left by 1 position
6. ROR operand, count
The ROR (Rotate Right) instruction rotates the bits of the operand to the right by a
specified number of positions.
Example- ROR AX,1
Example of Assembly Language Program