0% found this document useful (0 votes)
102 views86 pages

Important Topics in Computer Organization and Architecture

The document discusses important topics in computer organization and architecture, focusing on assembly language and addressing modes. It outlines the characteristics, advantages, and disadvantages of assembly language, as well as various addressing modes used in programming, providing real-life examples and programming instructions for each mode. The content is authored by Ms. Shruti Tiwari from Bhopal University.

Uploaded by

Shruti Tiwari
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)
102 views86 pages

Important Topics in Computer Organization and Architecture

The document discusses important topics in computer organization and architecture, focusing on assembly language and addressing modes. It outlines the characteristics, advantages, and disadvantages of assembly language, as well as various addressing modes used in programming, providing real-life examples and programming instructions for each mode. The content is authored by Ms. Shruti Tiwari from Bhopal University.

Uploaded by

Shruti Tiwari
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/ 86

IMPORTANT TOPICS IN COMPUTER ORGANIZATION AND ARCHITECTURE

ASSEMBLY ADDRESSING INSTRUCTION TYPES OF


LANGUAGE MODES SET INSTRUCTIONS

-By Ms. Shruti Tiwari


-Assistant Professor,
-Department of Computer Applications
-Bhopal University,
- Bhopal, Madhya Pradesh"
ASSEMBLY LANGUAGE
-By Ms. Shruti Tiwari
-Assistant Professor,
-Department of Computer Applications
-Bhopal University,
- Bhopal, Madhya Pradesh"
• Assembly language is a low-level programming
language that uses symbolic codes, such as
"MOV" and "JMP", to represent machine-
specific instructions. It is translated into
machine code using an assembler.
An assembly language program instruction consists of two parts
Characteristics
• Low-level language: Assembly language is a low-level
language that directly accesses hardware components.
• Symbolic representation: Assembly language uses
symbolic codes to represent machine-specific
instructions.
• Machine-specific: Assembly language is specific to a
particular computer architecture.
• Translated to machine code: Assembly language is
translated into machine code using an assembler.
Advantages
1. Fast execution: Assembly language programs execute
quickly because they are translated directly into
machine code.
2. Low-level control: Assembly language provides direct
access to hardware components, allowing for low-level
control.
3. Efficient use of resources: Assembly language programs
can be optimized for efficient use of resources.
Disadvantages
1. Difficult to learn: Assembly language is difficult to learn
because it requires a deep understanding of computer
architecture.
2. Machine-specific: Assembly language is specific to a
particular computer architecture, making it non-
portable.
3. Error-prone: Assembly language programs are error-
prone because they require manual management of
resources.
Common Assembly Languages
1. MASM (Microsoft Macro Assembler): A
popular assembler for Microsoft Windows.
2. NASM (Netwide Assembler): A free and open-
source assembler.
3. GAS (GNU Assembler): A free and open-
source assembler.
Applications
1. Operating systems: Assembly language is used to
write low-level code in operating systems.
2. Embedded systems: Assembly language is used
to write code for embedded systems.
3. Device drivers: Assembly language is used to
write device drivers.
4. Games: Assembly language is used to write high-
performance game code.
Addressing Modes
IN COA
-By Ms. Shruti Tiwari
-Assistant Professor,
-Department of Computer Applications
-Bhopal University,
- Bhopal, Madhya Pradesh"
ADDRESSING MODES ?
• "Each instruction is divided into two parts: the first part
is the opcode and the second part is the operand. The
opcode specifies the type of operation to be
performed, and the operand is the data on which the
operation is performed. The method by which the
operand is specified in an instruction is called the
addressing mode.”
• Addressing modes are ways in which a computer
accesses and manipulates data in memory.
IMP TERMS
• Starting address of memory segment.
• Effective address or Offset: An offset is
determined by adding any combination of three
address elements: displacement, base and index.
– Displacement: It is an 8 bit or 16 bit immediate value
given in the instruction.
– Base: Contents of base register, BX or BP.
– Index: Content of index register SI or DI.
1. Immediate Addressing Mode:

In this mode, the operand is


specified directly in the instruction.
Example: MOV A, #10
Real-Life Examples
• 1. Withdrawing Money from an ATM: When you withdraw
money from an ATM, you instruct the machine to dispense
a specific amount of cash. Here, the amount of money is an
immediate operand.
• 2. Making a Phone Call: When you make a phone call, you
instruct your phone to dial a specific number. Here, the
phone number is an immediate operand.
• 3. Opening a File on a Computer: When you open a file on
your computer, you instruct the operating system to open a
specific file. Here, the file name is an immediate operand.
Programming Examples
• 1.MOV Instruction: MOV A, #10 This instruction stores
the value 10 in register A. Here, #10 is an immediate
operand.
• 2. LOAD Instruction: LOAD A, #100 This instruction
loads the value 100 into register A. Here, #100 is an
immediate operand.
• 3. JMP Instruction: JMP #LABEL This instruction jumps
to the label specified. Here, #LABEL is an immediate
operand.
ADVANTAGES AND DISADVANTAGES
Advantages:
1. Fast execution, as the operand is already available.
2. No memory access required.
3. Simplifies programming.
Disadvantages:
1. Limited to small, constant values.
2. Cannot be used for large data or variables.
2. Direct Addressing Mode:
• In this mode, the operand is stored in a
memory location, and its address is specified
in the instruction.
• Example: MOV A, 1000H
Real-Life Examples
• 1.Finding a book in a library: When you search for a book
in a library, you look for it by its title or author's name.
Here, the book's address is specified directly.
• 2. Visiting a specific address: When you visit a specific
address, you provide the address directly. Here, the address
is specified directly.
• 3. Opening a specific file on a computer: When you open a
specific file on a computer, you provide the file's name or
address directly. Here, the file's address is specified directly.
Programming Examples
• MOV instruction: MOV A, 1000H This instruction stores
the value at address 1000H in register A. Here, the
address 1000H is specified directly.
• 2. LOAD instruction: LOAD A, 2000H This instruction
loads the value at address 2000H into register A. Here,
the address 2000H is specified directly.
• 3. JMP instruction: JMP 3000H This instruction jumps
to the address 3000H. Here, the address 3000H is
specified directly.
ADVANTAGES AND DISADVANTAGES
Advantages:
1. Fast access to memory locations.
2. Efficient use of memory.
3. Simplifies programming.
Disadvantages:
1. Limited to a specific range of addresses.
2. May require additional memory accesses.
3. Indirect Addressing Mode:
• In this mode, the
operand's address is
stored in another
memory location, and
its address is specified
in the instruction.
• Example: MOV A,
[1000H]
Real Life Examples
• 1. Sending a Letter: When you send a letter, you
address it to a location specified in a separate
document.
• 2. Visiting a Website: When you visit a website, you
enter its URL into a browser, which stores the website's
address.
• 3. Opening a File: When you open a file, you enter its
name or address into an operating system, which
stores the file's address.
Programming Examples
• 1.MOV Instruction: MOV A, (1000H) This
instruction stores the value stored at address
1000H in register A.
• 2. LOAD Instruction: LOAD A, (2000H) This
instruction loads the value stored at address
2000H into register A.
• 3. JMP Instruction: JMP (3000H) This instruction
jumps to the address stored at address 3000H.
ADVANTAGES AND DISADVANTAGES
• Advantages:
 Allows for dynamic memory allocation.
 Enables access to large data structures.
 Flexible and efficient.
• Disadvantages:
 Slower execution due to additional memory accesses.
 More complex programming required.
4. Register Addressing Mode:
• In this mode, the operand is stored in a
register.
• Example: MOV A, B
REAL LIFE EXAMPLE
• Calculator: When you perform calculations on a
calculator, the numbers are stored in registers,
and the operations are performed on those
registers.
• Bank Account: When you perform transactions
on your bank account, the account balance is
stored in a register (or a memory location), and
the transactions are performed on that register.
PROGRAMMING EXAMPLES
• MOV Instruction: MOV A, B This instruction
moves the value stored in register B to register A.
• ADD Instruction: ADD A, B This instruction adds
the value stored in register B to the value stored
in register A.
• SUB Instruction: SUB A, B This instruction
subtracts the value stored in register B from the
value stored in register A.
ADVANTAGES AND DISADVANTAGES
• Advantages:
 Fast access to data
 Reduced memory access time.
 Improved performance.
• Disadvantages:
 Limited number of registers available.
 Data must be loaded into registers before processing.
5.Register Indirect Addressing Mode:
• In this mode, the operand's address is stored
in a register.
• Example: MOV A, [BX]
REAL LIFE EXAMPLE
• POSTMAN ‘s Example
• A postman has a register that stores the
addresses of the packages he needs to deliver. He
also has another register that stores the package
information. When he needs to deliver a new
package, he writes the address in the first register
and the package information in the second
register.
Other Examples
1. Bank Account: In a bank account, the account number is like a register that
stores the account information. When you want to access your account
information, you use your account number.
2. Phonebook: In a phonebook, names are like registers that store phone
numbers. When you want to find someone's phone number, you look up
their name.
3. Computer File System: In a computer file system, file names are like registers
that store file information. When you want to access a file, you use its file
name.
4. Library Catalog: In a library catalog, book titles are like registers that store
book information. When you want to find a book, you look up its title.
5. Database: In a database, keys are like registers that store data records. When
you want to access a data record, you use its key.
Programming Example
• MOVBX, 1000H ; Load address 1000H into
register BX
• MOV AX, [BX] ; Load data from address 1000H
into register
Advantages
• 1. Flexible memory access: Register indirect addressing
mode allows for flexible memory access, as a register can
store a memory address, and then be used to access the
data at that address.
• 2. Efficient use of registers: This mode uses registers
efficiently, as a single register can store a memory address.
• 3. Simplified programming: Register indirect addressing
mode simplifies programming, as the programmer does not
need to directly specify the memory address.
Disadvantages
• 1. Complexity: Using register indirect addressing mode can
increase programming complexity, as the programmer
needs to load a memory address into a register.
• 2. Slow execution: Execution may be slower in this mode,
as the program needs to load a memory address into a
register and then use that register to access the data.
• 3. Limited flexibility: Register indirect addressing mode has
limited flexibility, as the programmer needs to load a
memory address into a register
6. Auto increment Addressing Mode:
• In this mode, the memory address is
automatically incremented after accessing the
operand.
• Example: MOV A, (R1)+
• Auto increment and Auto decrement modes
are useful for implementing “Last-In-First-Out”
data structures.
Real-Life Example
• A cashier at a grocery store uses a scanner to
scan the barcodes of items being purchased.
Each time an item is scanned, the scanner
automatically increments the count of items
purchased.
Programming Example
• MOVAX, [SI] ; Load the value at the address
pointed to by SI into AX
• INC SI ; Increment the value of SI
• MOV [SI], AX ; Store the value in AX at the
address pointed to by SI
ADVANTAGES AND DISAVANTAGES
• Advantages
• 1. Efficient use of memory and registers.
• 2. Simplifies programming for arrays and data structures
• 3. Fast execution
• Disadvantages
• 1. Limited flexibility
• 2. Can lead to errors if not used carefully3. May require
additional memory accesses
7. Auto decrement Addressing Mode:
• In this mode, the memory address is
automatically decremented after accessing
the operand.
• Example: MOV A, (R1)-
• Auto increment and Auto decrement modes
are useful for implementing “Last-In-First-Out”
data structures.
Real-Life Example
• A stack of plates in a cafeteria. When a plate is
removed from the stack, the stack pointer (the
person taking the plate) decrements the stack
(removes the plate from the top of the stack).
Programming Example
• MOV AX, [SI] ; Load the value at the address
pointed to by SI into AX
• DEC SI ; Decrement the value of SI
• MOV [SI], AX ; Store the value in AX at the
address pointed to by SI
ADVANTAGES AND DISADVANTAGES
Advantages
1. Efficient use of memory and registers
2. Simplifies programming for stacks and recursive data
structures
3. Fast execution
Disadvantages
1. Limited flexibility
2. Can lead to errors if not used carefully
3. May require additional memory accesses
8. Base Register Addressing Mode:
• In this mode, the operand's address is
calculated using a base register and an offset.
• Example: MOV A, 1000H(BX)
Real-Life Example
• A librarian uses a catalog system to locate
books on shelves. The catalog system serves
as a base register, providing the starting point
for locating books on specific shelves.
Programming Example
• MOV AX, [BX+10] ; Load the value at the
address pointed to by BX+10 into AX
• MOV [BX+10], AX ; Store the value in AX at the
address pointed to by BX+10
ADVANTAGES & DISADVANTAGES
Advantages
1. Efficient use of memory and registers
2. Simplifies programming for arrays and data structures
3. Fast execution
Disadvantages
1. Limited flexibility
2. Can lead to errors if not used carefully
3. May require additional memory accesse
9. Indexed Addressing Mode
• In this mode, the operand's address is
calculated using an index register and an
offset.
• Example: MOV A, 1000H(R1, R2)
Real-Life Example
• A librarian uses a catalog system to locate
books on shelves. The catalog system has an
index that points to the location of each book
on the shelf. The librarian uses the index to
quickly locate the desired book.
Programming Example
• MOV AX, [BX+SI] ; Load the value at the
address pointed to by BX+SI into AX
• MOV [BX+SI], AX ; Store the value in AX at the
address pointed to by BX+SI
ADVANTAGES AND DISADVANTAGES
Advantages
1. Efficient use of memory and registers.
2. Simplifies programming for arrays and data structures
3. Fast execution.
4. Flexible addressing mode
Disadvantages
1. Can lead to errors if not used carefully.
2. May require additional memory accesses.
3. Can be complex to implement
10. Relative Addressing Mode:
• In this mode, the operand's address is
specified relative to the current instruction.
• Example: JMP LABEL
Real-Life Example
• A tourist guide taking a group on a city tour.
The guide can say, "We'll move 5 blocks ahead
and then take a left turn." Here, the guide
uses relative addressing mode, describing a
location relative to the current position.
Programming Example
• MOV AX, [BP-10] ; Load the value at the
address pointed to by BP-10 into AX
• MOV [BP-10], AX ; Store the value in AX at the
address pointed to by BP-10In this example,
the BP (Base Pointer) register is used in
relative addressing mode.
ADVANTAGES AND DISADVANTAGES
Advantages
1. Efficient use of memory and registers
2. Simplifies programming for data structures and arrays
3. Fast execution
4. Flexible addressing mode
Disadvantages
1. Can lead to errors if not used carefully
2. May require additional memory accesses
3. Can be complex to implement
4. Limited flexibility in certain situations
11. Stack Addressing Mode:
• In this mode, the operand is stored on the
stack.
• Example: PUSH A
Real-Life Example
• A plate stack used in a cafeteria. When a plate
is placed on the stack, it goes on top. When a
plate is removed from the stack, it comes from
the top.
Programming Example
• PUSH AX ; Push the value of AX onto the stack
• POP AX ; Pop the value from the stack into AX
ADVANTAGES & DISADVANTAGES
Advantages
1. Efficient use of memory and registers
2. Simplifies programming for data structures and arrays.
3. Fast execution
Disadvantages
1. Can lead to errors if not used carefully
2. May require additional memory accesses
12. Indirect Stack Addressing Mode:
• In this mode, the operand's address is stored
on the stack, and its address is specified
indirectly.
• Example: MOV A, [SP]
Real-Life Example
• A courier service that delivers packages. When
a package is delivered, the courier service
gives the customer a receipt. The receipt
contains information about the package.
Programming Example
• MOV AX, [SP] ; Load the value at the address
pointed to by the stack pointer (SP) into AX
• MOV [SP], AX ; Store the value in AX at the
address pointed to by the stack pointer (SP)
ADVANTAGES AND DISADVANTAGES
Advantages
1. Efficient use of memory and registers
2. Simplifies programming for data structures and arrays
3. Fast execution
Disadvantages
1. Can lead to errors if not used carefully
2. May require additional memory accesses
13. Implied Addressing Mode:
• In this mode, the operand's address is implied
by the instruction itself.
• Example: INC A
REAL LIFE EXAMPLE
• An ATM machine. When you use an ATM
machine, you need to enter your PIN. The
ATM machine automatically accesses your
account information without needing explicit
instructions.
Programming Example
• NOP ; No operation is performed
• CLC ; The carry flag is cleared
Advantages
1. Fast execution
2. Low memory and register usage
3. Simplified programming
Disadvantages
1. Limited flexibility
2. Can lead to errors if not used carefully
INSTRUCTION SET
-By Ms. Shruti Tiwari
-Assistant Professor,
-Department of Computer Applications
-Bhopal University,
- Bhopal, Madhya Pradesh"
Instruction Set
• The instruction set is the set of instructions that a
computer's processor can understand and execute.
• An instruction set, also known as an instruction set
architecture (ISA), is a set of commands that a
microprocessor can understand and execute. These
instructions tell the processor what operations to
perform, such as arithmetic, data manipulation, and
input/output operations.
Components of an Instruction Set
1. Instruction Format:
The format of an instruction, including opcode, operands, and
addressing mode.
2. Opcode: A code that specifies the type of instruction, such
as ADD, SUB, MUL, DIV, etc.
3. Operands: The data used by the instruction.
4. Addressing Mode:
A method of accessing operands, such as immediate, register,
or memory addressing.
Types of Instruction Sets
1. CISC (Complex Instruction Set Computing): A complex
instruction set that allows for multiple operations to be
performed in a single instruction.
2. RISC (Reduced Instruction Set Computing): A simple
instruction set that performs one operation per
instruction.
3. EPIC (Explicitly Parallel Instruction Computing): An
instruction set that supports parallel execution of
instructions
Examples of Instruction Sets
1. x86 Instruction Set: Used by Intel and AMD
processors.
2. ARM Instruction Set: Used by ARM
processors.
3. MIPS Instruction Set: Used by MIPS
processors.
Importance of Instruction Set
1. Processor Design: Instruction Set is crucial for
processor design.
2. Software Development: Instruction Set is
important for software development.
3. Performance: Instruction Set affects processor
performance.
TYPES OF INSTRUCTIONS
-By Ms. Shruti Tiwari
-Assistant Professor,
-Department of Computer Applications
-Bhopal University,
- Bhopal, Madhya Pradesh"
Types of Instructions
Instructions can be classified into three main categories:
1. Data Transfer Instructions: These instructions transfer data from one
location to another.
Example: MOV A, B
2. Data Processing Instructions: These instructions perform arithmetic
and logical operations on data.
Example: ADD A, B
3. Control Flow Instructions: These instructions control the flow of
execution of instructions.
Example: JMP LABEL
Data Transfer Instructions
1. MOV (Move)
MOV destination, source- Copies data from source to destination.
2. LOAD (Load)LOAD destination, source- Copies data from memory
location source to register destination.
3. STORE (Store)STORE destination, source- Copies data from register
source to memory location destination.
4. PUSH (Push)PUSH source- Copies data from register source to stack.
5. POP (Pop)POP destination- Copies data from stack to register
destination.
Data Transfer Instructions
6. LEA (Load Effective Address)LEA destination, source- Copies address
of source to register destination.
7. LDS (Load Segment Register)LDS destination, source- Copies
segment selector from source to segment register destination.
8. LES (Load Extra Segment Register)LES destination, source- Copies
extra segment selector from source to extra segment register
destination.
9. LFS (Load FS Register)LFS destination, source- Copies FS segment
selector from source to FS register destination.
10. LGS (Load GS Register)LGS destination, source- Copies GS segment
selector from source to GS register destination.
Data Transfer Instructions
11. LSS (Load SS Register)LSS destination, source- Copies SS segment
selector from source to SS register destination.1
2. MOVS (Move String)MOVS destination, source- Copies string from
source to destination.
13. MOVSB (Move Byte String)MOVSB destination, source- Copies byte
string from source to destination.
14. MOVSW (Move Word String)MOVSW destination, source- Copies
word string from source to destination.
15. MOVSD (Move Doubleword String)MOVSD destination, source-
Copies doubleword string from source to destination.
Data Processing Instructions
ADD (Add)- ADD destination, source- Adds source and destination.
SUB (Subtract)- SUB destination, source- Subtracts source from
destination.
MUL (Multiply)- MUL destination, source- Multiplies source and
destination.
DIV (Divide)- DIV destination, source- Divides destination by source.
INC (Increment)- INC destination- Increments destination by one.
DEC (Decrement)- DEC destination- Decrements destination by one.
NEG (Negate)- NEG destination- Negates destination.
AND (Bitwise AND)- AND destination, source-
Performs bitwise AND operation on destination
and source.
OR (Bitwise OR)- OR destination, source- Performs
bitwise OR operation on destination and source.
XOR (Bitwise XOR)- XOR destination, source-
Performs bitwise XOR operation on destination
and source.
NOT (Bitwise NOT)- NOT destination- Performs
bitwise NOT operation on destination.
SHL (Shift Left)- SHL destination, count- Shifts destination
left by count bits.
SHR (Shift Right)- SHR destination, count- Shifts
destination right by count bits.
SAL (Shift Arithmetic Left)- SAL destination, count- Shifts
destination left by count bits, maintaining sign bit.
SAR (Shift Arithmetic Right)- SAR destination, count-
Shifts destination right by count bits, maintaining sign
bit.
Control flow instructions are used to control the flow of execution of
instructions. There are several types of control flow instructions:

1. Unconditional Branch: This instruction always transfers


control to the target instruction.
Example: JMP LABEL
2. Conditional Branch: This instruction transfers control to the
target instruction only if a specified condition is true.
Example: JEQ LABEL
3. Loop: This instruction repeats a sequence of instructions
until a specified condition is true.
Example: LOOP LABEL
Control Flow Instructions
• 1. JMP (Jump) - Transfers control to a new location.
• 2. JE (Jump if Equal) - Transfers control to a new
location if two operands are equal.
• 3. JNE (Jump if Not Equal) - Transfers control to a new
location if two operands are not equal.
• 4. JG (Jump if Greater) - Transfers control to a new
location if one operand is greater than another.
• 5. JL (Jump if Less) - Transfers control to a new location
if one operand is less than another.
Control Flow Instructions
• 6. JGE (Jump if Greater or Equal) - Transfers control to a
new location if one operand is greater than or equal to
another.
• 7. JLE (Jump if Less or Equal) - Transfers control to a
new location if one operand is less than or equal to
another.
• 8. LOOP (Loop) - Transfers control to the beginning of a
loop.
• 9. RET (Return) - Returns control from a function.
-By Ms. Shruti Tiwari
-Assistant Professor,
-Department of Computer Applications
-Bhopal University,
- Bhopal, Madhya Pradesh"

THE END

You might also like