0% found this document useful (0 votes)
9 views19 pages

CPU-Memory Connection Explained

The document outlines the connection between a computer's processor (CPU) and memory, detailing components such as the CPU, RAM, cache, and the system bus that facilitates data transfer. It describes the workflow of instruction execution, including fetching, processing, and storing results, as well as the types of instructions like arithmetic, data transfer, and control instructions. Additionally, it explains instruction sequencing and branching for executing specific tasks in a structured manner.

Uploaded by

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

CPU-Memory Connection Explained

The document outlines the connection between a computer's processor (CPU) and memory, detailing components such as the CPU, RAM, cache, and the system bus that facilitates data transfer. It describes the workflow of instruction execution, including fetching, processing, and storing results, as well as the types of instructions like arithmetic, data transfer, and control instructions. Additionally, it explains instruction sequencing and branching for executing specific tasks in a structured manner.

Uploaded by

heyna2617
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

describe the connection between various components of a processor with the memory of a computer.

The connection between the processor (CPU) and the memory in a computer is a vital part of computer architecture. These components work together through a structured
system of buses and control units to enable data flow and processing. Here's a breakdown of the connection:

Components Involved:

1. Processor (CPU):

o Central unit for processing data.

o Contains subcomponents such as the Arithmetic and Logic Unit (ALU), Control Unit (CU), and Registers.

2. Memory:

o Primary Memory (RAM): Temporary, high-speed storage for data and instructions.

o Cache Memory: Small, fast memory located near or inside the processor for frequently accessed data.

o Secondary Memory: Permanent storage (e.g., HDD, SSD) connected indirectly via the memory hierarchy.

3. System Bus:

o Facilitates communication between CPU, memory, and other peripherals.

o Divided into three types:

 Data Bus: Transfers data between components.

 Address Bus: Transfers the addresses of memory locations.

 Control Bus: Sends control signals to manage data flow.

 Program is loaded into memory.

 PC points to the first instruction.

 The PC value is copied to the MAR.

 A Read signal is sent to memory.

 The instruction is sent to the MDR and then to the IR.

 The instruction is decoded and executed.

 If needed, the ALU gets operands from memory by:

 Sending the address to MAR.

 Fetching the operand to MDR.

 Sending it to the ALU for operation.

 The result is stored in MDR, and the address is sent to MAR for writing back to memory.

 The PC is incremented to the next instruction.

Here's a simplified list of steps needed to execute the machine instruction "Add LOCA, R0," using the transfer between components as described:

1. Transfer PC to MAR: Copy the contents of the Program Counter (PC) to the Memory Address Register (MAR).

2. Read from memory: Issue a Read command to memory and wait for the word to be transferred into the Memory Data Register (MDR).

3. Load instruction into IR: Transfer the instruction from MDR into the Instruction Register (IR) and decode it.

4. Transfer address LOCA to MAR: Transfer the address LOCA from IR to MAR.

5. Read operand from memory: Issue a Read command and wait until MDR is loaded with the value from LOCA.

6. Transfer operand from MDR to ALU: Transfer the contents of MDR to the Arithmetic Logic Unit (ALU).

7. Transfer contents of R0 to ALU: Transfer the contents of R0 to the ALU.

8. ALU operation: The ALU performs the addition of the two operands (LOCA and R0) and transfers the result back into R0.

9. Transfer PC to ALU: Transfer the contents of PC to the ALU.

10. Increment PC: Add 1 to the operand in the ALU and transfer the incremented address back to PC.

Connection Workflow:

1. Fetching Instructions:

o The Program Counter (PC) in the CPU holds the address of the next instruction.

o The Address Bus transfers this address to the Memory Address Register (MAR).

o A read signal is sent via the Control Bus to fetch the instruction from memory.

o The instruction is fetched into the Memory Data Register (MDR) and transferred to the Instruction Register (IR).

2. Fetching Data:

o If the instruction requires data (operands), the CPU sends a memory address (via the MAR and Address Bus).
o Memory responds by placing the data on the Data Bus.

o The data is transferred to the General Purpose Registers or ALU.

3. Processing Data:

o The ALU processes the data as per the instruction in the IR.

o Intermediate results are stored in registers for faster access.

4. Storing Results:

o If the result needs to be stored in memory:

 The result is moved to the MDR.

 The memory location address is placed in the MAR.

 A write signal is sent via the Control Bus to store the data in memory.

Key Features of the Connection:

1. Direct Connection via Cache:

o To improve speed, frequently used data is stored in cache memory, which is much closer to the CPU.

o Reduces the latency caused by accessing primary memory.

2. Clock Synchronization:

o CPU and memory operations are synchronized using a clock signal to ensure smooth data flow.

3. Hierarchy:

o A memory hierarchy (cache → RAM → secondary storage) ensures an efficient balance of speed, size, and cost.

Block Diagram:

The block diagram would include:

 CPU with its components (ALU, Control Unit, Registers).

 Memory (Primary and Cache).

 System Bus (Data Bus, Address Bus, Control Bus) connecting the CPU and Memory.

instructions and Instruction Sequencing

Instruction sequencing is the process of executing a sequence of machine instructions in a specific order to accomplish a desired computational task. Instructions are categorized
based on their functionality and the number of operands they work with.

Basic Instruction Types

Instructions are the commands given to a processor to perform specific operations, such as arithmetic, data transfer, or control. The basic types of instructions include:

1. Arithmetic Instructions:

o Perform mathematical operations, e.g., Add, Subtract, Multiply, Divide.

2. Data Transfer Instructions:

o Transfer data between memory and registers, e.g., Load, Store, Move.

3. Control Instructions:

o Control the execution sequence, e.g., Branch, Jump, Call.

4. Logic Instructions:

o Perform logical operations, e.g., AND, OR, NOT.

5. Shift and Rotate Instructions:

o Shift or rotate bits within a word.

Basic Instruction Types

Instructions in a processor are used to perform various operations such as arithmetic computations, data transfer, and control flow management. Here's a breakdown of the basic
instruction types with examples:

1. Arithmetic Instructions:

These instructions perform mathematical operations like addition, subtraction, multiplication, and division.

 Examples:

o ADD: Adds two values.

 ADD R1, R2: Adds the value in register R2 to the value in register R1 and stores the result in R1.

o SUB: Subtracts one value from another.


 SUB R3, R4: Subtracts the value in R4 from R3 and stores the result in R3.

o MUL: Multiplies two values.

 MUL R1, R2: Multiplies the values in R1 and R2, storing the result in R1.

o DIV: Divides one value by another.

 DIV R5, R6: Divides the value in R5 by the value in R6, storing the quotient in R5 and remainder in R6.

2. Data Transfer Instructions:

These instructions are used to move data between memory and registers, or between different registers.

 Examples:

o LOAD: Loads data from memory into a register.

 LOAD R1, 1000: Loads the value from memory address 1000 into register R1.

o STORE: Stores data from a register into memory.

 STORE R1, 2000: Stores the value in register R1 into memory location 2000.

o MOVE: Transfers data from one register to another.

 MOVE R2, R3: Copies the value in register R3 into register R2.

3. Control Instructions:

Control instructions manage the sequence of execution in a program, such as branching or calling subroutines.

 Examples:

o JUMP: Unconditionally jumps to a specific memory address.

 JUMP 5000: Jumps to memory address 5000 and starts executing from there.

o BRANCH: Conditional jump based on a condition (e.g., zero, carry flag).

 BRANCH ZERO, 2000: Jumps to memory location 2000 if the zero flag is set.

o CALL: Calls a subroutine and saves the return address.

 CALL 4000: Calls the subroutine starting at address 4000 and stores the return address.

4. Logic Instructions:

These instructions perform logical operations on binary values, such as AND, OR, and NOT.

 Examples:

o AND: Performs a bitwise AND operation.

 AND R1, R2: Performs a bitwise AND on the values in R1 and R2, storing the result in R1.

o OR: Performs a bitwise OR operation.

 OR R3, R4: Performs a bitwise OR on the values in R3 and R4, storing the result in R3.

o NOT: Performs a bitwise NOT (inversion).

 NOT R5: Inverts all bits in register R5.

5. Shift and Rotate Instructions:

These instructions manipulate bits within a word by shifting or rotating them.

 Examples:

o SHL (Shift Left): Shifts the bits of a value to the left, filling with zeroes or sign extension.

 SHL R1, 1: Shifts the value in R1 left by 1 bit, and stores the result back in R1.

o SHR (Shift Right): Shifts the bits of a value to the right.

 SHR R2, 2: Shifts the value in R2 right by 2 bits, and stores the result in R2.

o ROL (Rotate Left): Rotates the bits of a value to the left.

 ROL R3, 1: Rotates the value in R3 left by 1 bit.

o ROR (Rotate Right): Rotates the bits of a value to the right.

 ROR R4, 1: Rotates the value in R4 right by 1 bit.

Summary:

 Arithmetic Instructions: Perform calculations like addition and multiplication.

 Data Transfer Instructions: Move data between memory and registers or between registers.

 Control Instructions: Control the flow of execution (e.g., branching, jumping).

 Logic Instructions: Perform logical operations like AND, OR, and NOT.

 Shift and Rotate Instructions: Modify data at the bit level by shifting or rotating.
Example of Instruction Sequencing:

Consider a high-level statement:

C=A+B

The execution steps are as follows:

1. Fetch Operands:

o The contents of memory locations A and B are fetched into the processor.

2. Compute Result:

o The sum of the values of A and B is computed inside the Arithmetic Logic Unit (ALU).

3. Store Result:

o The computed sum is stored back into memory at location C.

Execution Using Three-Address Instructions: check book

1. Three-Address Instruction Format

A three-address instruction can be symbolically represented as:

Add A, B, C

 Operands:

o A and B: Source operands.

o C: Destination operand.

 Operation:

Operation :C [A] + [B]

o Add: Denotes the arithmetic operation to be performed.

Instruction Format:

Operation Source1, Source2, Destination

 Contains the memory addresses of three operands: Source1, Source2, and Destination.

Steps in Execution:

1. Fetch Operands:

o The processor retrieves the contents of memory locations A and B and loads them into temporary registers (e.g., R1 and R2).

2. Perform the Operation:

o The ALU performs the addition:


R3 = R1 + R2.

3. Store the Result:

o The result in R3 is stored back in memory location C.

Three-Address Instructions

 Format: ADD A, B, C

 Explanation: The instruction ADD A, B, C performs the operation [A] + [B] and stores the result in [C].

o Operands:

 A and B are source operands (from memory).

 C is the destination operand (where the result is stored).

 Challenge: Each operand (A, B, C) needs a memory address, which requires multiple bits for encoding, leading to a larger instruction size. This can exceed the word size
of the processor, requiring multi-word instructions.

2. Two-Address Instructions

 Format: ADD A, B

 Explanation: The instruction ADD A, B adds the contents of memory location A to the contents of B. Here, B serves as both a source and a destination.

o Sequence to achieve C = [A] + [B]:

 First, ADD A, B adds A to B and stores the result in B.

 Then, MOVE B, C moves the result from B to C.

 Challenge: Though more compact than three-address instructions, this approach still requires multiple instructions.

3. One-Address Instructions

 Format: ADD A

 Explanation: One-address instructions use an accumulator (a special register) for operations. For example, ADD A adds the contents of memory location A to the
contents of the accumulator.

o Sequence to achieve C = [A] + [B]:

1. LOAD A — loads A into the accumulator.


2. ADD B — adds the contents of B to the accumulator.

3. STORE C — stores the result in C.

 Challenge: While the instruction format is compact, the use of the accumulator for all operations can limit flexibility and performance in certain tasks.

4. Zero-Address Instructions (Stack-Based)

 Format: ADD

 Explanation: In a zero-address instruction set (typically used in stack-based architectures), operations are implicitly performed on values at the top of the stack. For
example, ADD would pop two values from the stack, add them, and push the result back onto the stack.

o Example for C = [A] + [B]:

 PUSH A — pushes A onto the stack.

 PUSH B — pushes B onto the stack.

 ADD — pops A and B, adds them, and pushes the result back.

Instruction Format Summary:

 Opcode: The operation to be performed (e.g., ADD, LOAD, STORE).

 Operands or Addresses: The locations or values involved in the operation (e.g., A, B, C).

 Different instruction formats provide various trade-offs between simplicity, flexibility, and performance.

Example for Evaluating Arithmetic:

To evaluate an expression like C = A + B, depending on the architecture:

 Three-Address: ADD A, B, C

 Two-Address: ADD A, B, then MOVE B, C

 One-Address: LOAD A, ADD B, STORE C

 Zero-Address (Stack-based): PUSH A, PUSH B, ADD

This sequence of instructions illustrates how different architectures can handle the same high-level operation in different ways.

Branching in instruction sequencing allows a program to execute a specific set of instructions repeatedly or conditionally, based on certain conditions. Here’s a breakdown of
how branching works, particularly in the context of creating loops.

Initial Setup and Registers

1. Number of Entries (n):


The number of entries in the list, 'n', is stored in memory location N.

2. Register Usage:

o R1: Used as a counter to keep track of how many numbers need to be added.

o R0: Holds the cumulative sum of the numbers as they are added.

o Program Counter (PC): Holds the address of the next instruction to be executed.

setup:

1. Store the number of entries in the list: The number of entries, n, is stored at memory location N.

2. Load the counter into R1: The value of N (the number of numbers to sum) is loaded into R1.

Loop Execution:

3. Start the Loop:

o The loop begins at location LOOP.

4. Determine Address:

o The address of the next number in the list is calculated.

5. Fetch and Add:

o The next number from the list is fetched and added to the running total in R0.

6. Decrement Counter:

o R1 is decremented by 1, indicating one number has been processed.

7. Branch Instruction:

o A conditional Branch > 0 is used to check if R1 is still greater than 0 (i.e., if more numbers need to be added).

o If R1 is still greater than 0, the program branches to the LOOP address and continues with the next iteration.

End of Loop:

8. Store Result:

o After all numbers are added, the total in R0 is moved to the SUM location in memory.
.

Conditional Branch:

 The Branch > 0 instruction checks if the value in R1 is greater than 0. If true, the program jumps back to LOOP to continue the addition.

 If R1 reaches 0, the branch is not taken, and the loop ends.

Summary of Instructions:

1. Move N, R1: Load the number of entries into R1.

2. Loop: Start a loop.

3. R0 = R0 + Next Number: Fetch the next number from memory and add it to R0.

4. Decrement R1: Reduce the counter by 1.

5. Branch > 0: If R1 > 0, branch back to LOOP.

6. Move R0, SUM: When the loop ends, store the result in SUM.

Explanation of Branching in Instruction Sequencing (as per your description):

1. Program Loop with a Branch Instruction:

o Instead of writing a long sequence of instructions (like multiple ADD instructions), you can place a single ADD instruction in a loop, which will be repeated as
necessary.

o The loop is a sequence of instructions executed multiple times depending on the condition.

2. Loop Control using a Counter:

o The number of times the loop should be executed is stored in memory location N.

o Register R1 is used as a counter to determine the number of times the loop is executed.

o At the beginning of the program, the value of N (the number of iterations) is loaded into register R1.

3. Decrementing the Counter:

o The Decrement instruction reduces the contents of R1 by 1 after each iteration.

o The loop continues as long as the contents of R1 are greater than 0.

o Once R1 becomes 0, the loop will stop, and the program will proceed with the next instruction.

4. Conditional Branching:

o Branch instructions change the normal flow of execution by loading a new address into the program counter (PC).

o This new address is called the branch target. When the branch occurs, the processor will fetch and execute the instruction at the new address, instead of
continuing with the next sequential instruction.

o A conditional branch occurs only if a specified condition is met (e.g., Branch > 0).

 For example: Branch > 0 LOOP causes a branch to the LOOP label if the value in R1 is greater than 0.

 If the condition is not met, the program will continue executing sequentially.

5. Instruction Flow (Branching in Action):

o Let's go through the loop execution step-by-step:

1. Initial Setup: Load the value of N (number of iterations) into register R1.

2. Loop Execution:

 Fetch the next list entry and add it to R0 (accumulator).

 Decrement R1 by 1.

 If R1 is greater than 0, the program will branch back to LOOP and repeat the process.

3. End of Loop:

 Once R1 reaches 0, the loop ends, and the program proceeds to the next instruction.

 The result stored in R0 is then moved to memory location SUM (final result).

impExample of Instructions for a Simple Loop:

1. LOAD N — Load the number of iterations into R1.

2. LOOP: ADD [memory], R0 — Fetch the next entry from memory and add it to R0.
3. DECREMENT R1 — Decrement the counter register (R1).

4. BRANCH R1 > 0, LOOP — If R1 is still greater than 0, go back to the LOOP label.

5. MOVE R0, SUM — Once the loop ends, store the result from R0 into the memory location SUM.

Condition Codes: Overview and Usage

In computer architecture, condition codes (or status flags) are special bits within a processor that store information about the results of various operations. These flags play a
crucial role in controlling the flow of execution, particularly for conditional branch instructions, which depend on specific conditions being met after operations like addition,
subtraction, etc.

Let's break down the details and usage of condition codes step by step:

1. What are Condition Codes?

 Condition codes are bits used by the processor to record the outcomes of operations.

 These flags provide information on whether the result of an operation (arithmetic, logic, or data transfer) meets specific criteria, such as being negative, zero, or causing
overflow.

 The processor maintains a special register, typically called the Condition Code Register (CCR) or Status Register, where these flags are stored.

2. Common Condition Flags

There are typically four important flags that are most commonly used:

1. N (Negative Flag)

 Purpose: The N flag indicates whether the result of an operation is negative.

 Behavior:

o Set to 1 if the result is negative.

o Cleared to 0 if the result is not negative (i.e., it’s either positive or zero).

2. Z (Zero Flag)

 Purpose: The Z flag indicates whether the result of an operation is zero.

 Behavior:

o Set to 1 if the result is zero.

o Cleared to 0 if the result is non-zero (positive or negative).

3. V (Overflow Flag)

 Purpose: The V flag indicates if arithmetic overflow has occurred.

 Behavior:

o Set to 1 if an overflow happens. This happens when the result of an operation exceeds the maximum value that can be represented by the given number of bits
(e.g., adding two large numbers that causes the result to go beyond the processor’s word size).

o Cleared to 0 if no overflow occurs.

4. C (Carry Flag)

 Purpose: The C flag indicates whether there was a carry-out from the most significant bit during an operation.

 Behavior:

o Set to 1 if a carry-out occurs during an arithmetic operation (e.g., during addition or subtraction).

o Cleared to 0 if no carry occurs.

Conditional Branch Instructions: Explanation

A conditional branch instruction checks the state of the condition code flags (N, Z, V, C) and, based on their values, determines whether to jump to a different part of the
program. The most common condition flags include:

 N (Negative Flag): Set to 1 if the result of the last operation was negative.

 Z (Zero Flag): Set to 1 if the result was zero.

 V (Overflow Flag): Set to 1 if an overflow occurred during the operation.

 C (Carry Flag): Set to 1 if there was a carry during an operation (used for operations on larger numbers).

Understanding the Example

From your input, I assume you have an example involving some bit values and status flags. You may want to evaluate a sequence of conditions and determine what happens with
the program's flow based on the flag states.

Let's Break Down the Given Flags

 C = 1: This means the Carry flag is set, indicating a carry-out occurred during an operation.

 N = 0: This means the Negative flag is not set, so the result of the last operation was non-negative (either zero or positive).
 V = 0: This means there was no overflow in the last operation. The result was within the allowable range of values for the operands.

 Z = 0: This means the Zero flag is not set, so the result of the operation was non-zero.

Overflow and the Overflow Flag (V)

Overflow occurs during an arithmetic operation when the result exceeds the range of values that can be represented using the available number of bits.

Example:

 Consider an 8-bit signed integer representation:

o The range of values is -128 to +127.

o If you add two positive numbers and the result exceeds +127, overflow occurs.

o Similarly, if you add two negative numbers and the result is less than -128, overflow occurs.

Overflow Flag (V)

 V = 1: Overflow has occurred.

 V = 0: No overflow occurred.

Key Points:

 Overflow is specific to signed arithmetic.

 It is determined by analyzing the signs of the operands and the result.

Logic for Overflow in Addition (Signed Numbers):

 If operands have the same sign (both positive or both negative) and the result has a different sign, overflow occurs.

Carry and the Carry Flag (C)

The Carry flag is used in unsigned arithmetic to indicate when a carry-out occurs from the most significant bit during an addition operation.

Example:

 Consider an 8-bit unsigned integer:

o The range is 0 to 255.

o If you add 200 + 100 = 300, the result cannot fit in 8 bits. The carry-out is generated from the most significant bit.

Carry Flag (C)

 C = 1: Carry occurred (the result does not fit in the word size).

 C = 0: No carry occurred.

Key Points:

 Carry is specific to unsigned arithmetic.

 It is crucial for performing multi-word arithmetic (e.g., adding 64-bit numbers on a 32-bit processor).

Condition Codes and Flags

Condition codes (status flags) provide information about the result of the last operation performed. These flags are stored in the Condition Code Register (CCR) or Status
Register (SR).

Common Flags:

1. N (Negative Flag):

o Set to 1 if the result of the operation is negative (for signed numbers).

o Cleared to 0 otherwise.

2. Z (Zero Flag):

o Set to 1 if the result is 0.

o Cleared to 0 otherwise.

3. V (Overflow Flag):

o Set to 1 if overflow occurs in signed arithmetic.

o Cleared to 0 otherwise.

4. C (Carry Flag):

o Set to 1 if a carry-out occurs in unsigned arithmetic.

o Cleared to 0 otherwise.

Conditional Branch Instructions

Branch instructions are used to alter the normal sequential flow of a program based on the condition flags.

Key Concepts:

 A conditional branch instruction tests one or more condition flags and branches (jumps) to a new instruction if the condition is met.

 If the condition is not met, the program continues executing the next sequential instruction.

Example: Branch>0
 This instruction causes a branch if:

o N = 0 (not negative).

o Z = 0 (not zero).

Logic Expression for Branch>0:

 Branch occurs if !(N | Z) (neither negative nor zero).

Conditional Branch Examples

1. Branch if Zero (BZ):

o Checks the Zero flag (Z).

o Branch occurs if Z = 1 (result is zero).

2. Branch if Negative (BN):

o Checks the Negative flag (N).

o Branch occurs if N = 1 (result is negative).

3. Branch if Carry (BC):

o Checks the Carry flag (C).

o Branch occurs if C = 1 (carry occurred).

4. Branch if Overflow (BV):

o Checks the Overflow flag (V).

o Branch occurs if V = 1 (overflow occurred).

5. Branch Greater Than Zero (BGT):

o Checks if the result is greater than zero.

o Branch occurs if !(N | Z) (neither negative nor zero).

Detailed Example of Conditional Branching

Let's assume an 8-bit signed arithmetic operation:

1. Operands:

o A = 50 (binary: 0011 0010).

o B = 80 (binary: 0101 0000).

2. Operation:

o A + B = 130.

3. Binary Addition:

0011 0010 (50)

+ 0101 0000 (80)

-------------

1000 0010 (Binary result: -126 in 8-bit signed representation)

4. Flags:

o N = 1: The result is negative.

o Z = 0: The result is not zero.

o V = 1: Overflow occurred (130 exceeds +127).

o C = 0: No carry occurred (specific to unsigned arithmetic).

5. Branching Instruction:

o Branch if Negative (BN):

 Branch occurs because N = 1.

o Branch if Overflow (BV):

 Branch occurs because V = 1.

o Branch if Zero (BZ):

 No branch because Z = 0.

Summary

 Overflow (V): Indicates signed arithmetic overflow.

 Carry (C): Indicates unsigned arithmetic carry.

 Condition Flags: Help guide conditional branching instructions like Branch>0, Branch Negative, and Branch if Zero.

 Conditional Branching allows dynamic control of program flow based on the results of operations.

Addressing Modes and Effective Address Calculations refer book


Addressing Modes Overview

Addressing modes define how the location of an operand is specified in an instruction. They offer different ways to access memory locations or registers for performing
operations. Here's a detailed explanation of the various addressing modes:

1. Register Mode

 Description: In this mode, the operand is stored in a register, and the instruction specifies the register.

 Example:

Move R1, R2 ; Copy the contents of register R1 into register R2

 Effective Address (EA): The address is directly the register being referenced (e.g., EA = Ri).

2. Absolute (Direct) Mode

 Description: The operand is located at a specific memory address, and the address is explicitly provided in the instruction.

 Example:

Move LOC, R0 ; Load the contents of the memory location LOC into register R0

 Effective Address (EA): The address is the specified location (e.g., EA = LOC).

3. Immediate Mode

 Description: The operand is explicitly specified in the instruction itself as a constant value.

 Example:

MOV #200, R0 ; Place the value 200 in register R0

 Effective Address (EA): The value is directly given in the instruction and does not refer to memory (e.g., EA = Immediate Value).

4. Indirect Mode

 Description: The operand is accessed through a memory location or register that contains the address of the operand.

 Subtypes:

o Register Indirect: The register contains the address of the operand.

o Memory Indirect: The memory location contains the address of the operand.

Example: Register Indirect

Move R1, (R2) ; Fetch data from the address contained in R2 and store it in R1

 Effective Address (EA): The address is the contents of the register (e.g., EA = [Ri]).

Example: Memory Indirect

Move (LOC), R0 ; Fetch the data at memory address LOC and load it into R0

 Effective Address (EA): The address is the content of the memory location at LOC (e.g., EA = [LOC]).

5. Indexing Mode

 Description: The effective address of the operand is calculated by adding a constant value (offset) to the value in a register. This is particularly useful for accessing
elements in an array or list.

 Example:

Add 20(R1), R2 ; Add the value at memory location R1 + 20 to R2

 Effective Address (EA): EA = X + [Ri], where X is the offset and Ri is the register.

8. Relative Mode

 Description: The effective address is calculated relative to the current value of the program counter (PC), commonly used for branch instructions.

 Example:

Branch >0 LOOP ; If condition is met, jump to location LOOP relative to the current PC

 Effective Address (EA): EA = PC + X, where X is the signed offset.

9. Auto-Increment Mode

 Description: The register value is used to fetch the operand, and after the operand is accessed, the register is automatically incremented to point to the next item in
memory.

 Example:

(R1)+ ; Use the value in R1 as the address, then increment R1

 Effective Address (EA): EA = [Ri], and after the operand is accessed, Ri is incremented.
10. Auto-Decrement Mode

 Description: The register value is decremented before being used to access the operand. This is typically used when accessing data in reverse order.

 Example:

-(R1) ; Decrement R1, then use it to access the operand

 Effective Address (EA): EA = [Ri], and then Ri is decremented.

Summary : Addressing Modes Overview

Addressing modes specify how the operand of an instruction is located. Here’s a summary of the key addressing modes discussed:

1. Register Mode (Direct Register)

o The operand is located in a specified register.

o Example: Move R1, R2 (Copy contents of R1 into R2).

o Effective Address (EA): The register's content is used directly.

2. Absolute (Direct) Mode

o The operand is located at a fixed memory address.

o Example: Move LOC, R0 (Load the value at memory location LOC into R0).

o EA: The address is given directly.

3. Immediate Mode

o The operand is explicitly provided in the instruction.

o Example: MOV #200, R0 (Load the immediate value 200 into R0).

o EA: Operand is the constant value provided in the instruction.

4. Indirect Mode

o The address of the operand is contained in a register or memory location.

o Register Indirect Mode:

 Example: Move R1, (R2) (Fetch the value at the address in R2 and store it in R1).

 EA: The content of the register R2 is the address.

o Memory Indirect Mode:

 Example: Move (LOC), R0 (The content at LOC points to the actual memory address, which is used to load data into R0).

 EA: The address is stored at a memory location (pointer).

5. Index Mode

o The effective address is the sum of a base register's content and a constant value (offset).

o Example: Add 20(R1), R2 (The operand's address is 20 + content of R1).

o EA: EA = X + [Ri] where X is the offset and Ri is the index register.

6. Base with Index Mode

o A combination of two registers (one holding the base and the other holding the offset) to compute the effective address.

o Example: Add (R1, R2) (The operand is at the address computed by adding the contents of R1 and R2).

o EA: EA = [Ri] + [Rj].

7. Base with Index and Offset Mode

o A combination of a base register, an index register, and a constant offset.

o Example: Add X(R1, R2) (The address is calculated by adding contents of R1, R2, and the offset X).

o EA: EA = X + [Ri] + [Rj].

8. Relative Mode

o The effective address is determined by the current value of the program counter (PC) plus an offset.

o Example: Branch >0 LOOP (Branch to the LOOP location if the condition is met).

o EA: EA = PC + X, where X is the signed offset relative to the current PC value.

9. Auto-increment Mode

o The operand is accessed via a register, and after accessing the operand, the register is incremented.

o Example: (R2)+, R0 (The address in R2 is used to fetch data, and then R2 is incremented to point to the next address).

o EA: The register is incremented automatically after accessing the operand.

10. Auto-decrement Mode

 The operand is accessed via a register, and before accessing the operand, the register is decremented.

 Example: (R2)-, R0 (Decrement R2 and then access the operand at the new address).

 EA: The register is decremented automatically before the operand is accessed.


1. Register Mode

 Description: The operand is stored in a register specified in the instruction.

 Effective Address (EA): Not applicable, as the data is directly in the register.

 Example:

Move R1, R2

o The contents of register R1 are copied to R2.

2. Absolute (Direct) Mode

 Description: The operand is located in a specific memory location explicitly mentioned in the instruction.

 Effective Address (EA): The memory address provided in the instruction.

 Example:

Move LOC, R2

o If LOC = 1000:

 EA = 1000.

 The contents of memory location 1000 are copied to register R2.

3. Immediate Mode

 Description: The operand value is directly specified in the instruction.

 Effective Address (EA): Not applicable, as the operand is part of the instruction itself.

 Example:

Move #200, R0

o The value 200 is placed directly into register R0.

4. Indirect Mode

 Description: The address of the operand (Effective Address) is stored in a pointer (register or memory location).

 Effective Address (EA): The value in the pointer register or memory location.

 Example:

Add (R1), R0

o If R1 = 1000 and memory location 1000 contains the value 50:

 EA = 1000 (value in R1).

 Operand = value at memory location 1000, i.e., 50.

5. Index Mode

 Description: The effective address is calculated by adding an offset (displacement) to the value in the index register.

o Effective Address (EA): EA=X+[Ri]

o X: Offset specified in the instruction.

 Ri: Index register.

 Example:

Add 20(R1), R2

o If R1 = 1000 and X = 20:

 EA = 1000 + 20 = 1020.

 Operand = value at memory location 1020.

6. Base with Index Mode

 Description: Combines two registers to calculate the effective address.

o Effective Address (EA): EA=[Ri]+[Rj]

o Ri: Base register.

 Rj: Index register.

 Example:

Add (R1, R2), R3

o If R1 = 1000 and R2 = 200:


 EA = 1000 + 200 = 1200.

 Operand = value at memory location 1200.

7. Base with Index and Offset Mode

 Description: Adds an offset to the sum of two registers to calculate the effective address.

o Effective Address (EA): EA=X+[Ri]+[Rj]

o X: Offset specified in the instruction.

o Ri: Base register.

  Rj: Index register.


  Example:
Add 10(R1, R2), R3

o If R1 = 1000, R2 = 200, and X = 10:

 EA = 10 + 1000 + 200 = 1210.

 Operand = value at memory location 1210.

8. Relative Mode

 Description: Calculates the effective address relative to the program counter (PC).

o Effective Address (EA EA=X+[PC]

o X: Offset specified in the instruction.

o PC: Current program counter value.

 Example:

Branch > 0 LOOP

o If PC = 3000 and X = 50:

 EA = 3000 + 50 = 3050.

 Branch target address = 3050.

9. Auto Increment Mode

 Description: Uses the current value of a register as the effective address and then increments the register.

 Effective Address (EA):

o Current value of Ri, then increment Ri

 Example:

Add (R1)+, R2

o If R1 = 1000:

 EA = 1000.

 After the instruction, R1 = 1000 + 1 = 1001.

10. Auto Decrement Mode

 Description: Decrements the value in a register first, and then uses the new value as the effective address.

 Effective Address (EA):

o Decrement Ri, then use the new value.

 Example:

Add -(R1), R2

o If R1 = 1000:

 Decrement R1: R1 = 1000 - 1 = 999.

 EA = 999.

Stack

Stack: Definition and Basic Operations

A stack is a data structure that organizes elements in a way that allows data to be added and removed only from one end, which is called the top. The other end of the stack
is called the bottom.

Stacks follow the Last In, First Out (LIFO) principle, which means that the last element added (pushed) to the stack is the first one removed (popped).

Example of Stack (LIFO)

Consider a stack of plates in a cafeteria:

You can only add plates to the top of the stack (push).
When you want to serve a plate, you take the one on top first (pop).

If plates are added in the order: Plate1, Plate2, Plate3 — Plate3 will be removed first (because it was added last).

Basic Operations of a Stack

Push:

This operation adds an item to the top of the stack.

The Stack Pointer (SP) is used to keep track of the current top of the stack.

Pop:

This operation removes the item from the top of the stack.

After the item is removed, the SP is updated to point to the new top of the stack.

Memory and Stack Pointer (SP)

The stack is stored in memory, and the Stack Pointer (SP) is a special register that holds the address of the current top item in the stack.

When an item is pushed, the SP is decremented (because stacks typically grow downwards in memory).

When an item is popped, the SP is incremented.

Push and Pop Operations (32-bit Word Length)

In byte-addressable memory, with a 32-bit word length, the operations can be implemented in assembly as follows:

Push Operation

To add a new item (NEWITEM) to the stack, we use:

Subtract #4, SP // Decrement the stack pointer by 4 (since each word is 4 bytes)

Move NEWITEM, (SP) // Store NEWITEM at the current top of the stack (address in SP)

This first decrements the stack pointer by 4 and then stores the new item at the new top of the stack.

Pop Operation

To remove the top item and store it in a variable (ITEM), we use:

Move (SP), ITEM // Retrieve the item from the current top of the stack (address in SP)

Add #4, SP // Increment the stack pointer by 4 (moving to the next item in the stack)

This retrieves the item at the top and then updates the stack pointer to the next item.

Autoincrement and Autodecrement Modes

Some processors have Autoincrement and Autodecrement addressing modes, which simplify the push and pop operations.

Push operation can be simplified to:

Move NEWITEM, -(SP) // Store NEWITEM at the address pointed by SP and decrement SP automatically

Pop operation can be simplified to:

Move (SP)+, ITEM // Retrieve the item at the current top and increment SP automatically

These modes help in optimizing the code and reduce the need for explicit increment or decrement instructions.

1. Stack Usage and Overflow

o The stack is allocated a fixed memory range.

o Example:

 Stack runs from 2000 (bottom) to 1500.

 SP starts at 2004, and the first item is stored at 2000.

o Overflow:

 Occurs if you push an item onto a full stack.

o Underflow:

 Happens if you pop an item from an empty stack.

Stack Frame and Its Operation

A stack frame is a portion of the stack used to store information related to a function or subroutine call, including parameters, local variables, and return addresses. It helps
manage the execution of subroutines and functions in a structured manner. Here’s a breakdown of the stack frame operations:

Components of a Stack Frame:

1. Frame Pointer (FP): Used to access the parameters passed to the subroutine and local variables. It remains fixed during the execution of the subroutine.

2. Stack Pointer (SP): Points to the top of the stack and changes as items are pushed or popped onto/from the stack. Unlike the FP, SP moves during the function's
execution.
Stack Frame Simplified

A stack frame is a part of the stack used to manage a function or subroutine call. It stores:

1. Parameters passed to the function.

2. Local variables used by the function.

3. The return address to go back to the calling program.

How It Works

1. Calling the Function:

o Push the parameters and the return address onto the stack.

2. Setting Up:

o Save the old frame pointer (FP).

o Set the frame pointer (FP) to the current top of the stack (SP).

3. During the Function:

o Use the stack to store local variables and registers (if needed).

4. Finishing the Function:

o Restore saved registers (if any).

o Remove local variables from the stack.

o Restore the old FP.

o Return to the calling program using the saved return address.

Example:

1. Push function parameters onto the stack.

2. Save the old FP and set the new FP.

3. Use stack space for local variables.

4. Clean up and return to the caller.

Key Points

 FP: Fixed pointer for accessing parameters and local variables.

 SP: Points to the top of the stack and changes during execution.

 Keeps everything organized for nested function calls.

Components of a Stack Frame

1. Frame Pointer (FP):

o A register pointing to the start of the stack frame.

o Used to access function parameters and local variables in a stable manner, even as the stack pointer changes.

2. Stack Pointer (SP):

o Points to the top of the stack.

o Moves up (decrements) or down (increments) as items are pushed or popped from the stack.

Stack Frame Setup and Cleanup

1. Calling the Subroutine:

 The calling function pushes the parameters onto the stack.

 The return address (the location to resume execution after the function completes) is pushed onto the stack.

 The stack pointer (SP) now points to the return address.

2. Setting Up the Stack Frame in the Subroutine:

 The old frame pointer (FP) is saved onto the stack.


Instruction: Push FP → Move FP, -(SP)

 The new frame pointer (FP) is initialized to the current value of the stack pointer (SP).
Instruction: Move SP, FP

3. Allocating Space for Local Variables:

 Space for the function’s local variables is reserved by adjusting the stack pointer (SP).
Example: Subtract #12, SP → Reserves 12 bytes for 3 local variables (4 bytes each).
4. Saving Registers (Optional):

 If the function needs to use processor registers (e.g., R0, R1), their values are saved onto the stack to avoid overwriting them.
Instruction: Push R0 or Push R1.

5. Executing the Function:

 During execution, the function accesses:

o Parameters using the frame pointer (e.g., FP+4, FP+8).

o Local variables using the frame pointer (e.g., FP-4, FP-8).

6. Cleaning Up After the Function:

 Restoring Registers: If any registers were saved, their original values are restored.
Instruction: Pop R1, Pop R0

 Deallocating Local Variables: Space allocated for local variables is freed by adjusting SP.
Example: Add #12, SP → Frees 12 bytes of local variables.

7. Restoring the Old Frame Pointer:

 The old frame pointer is restored from the stack.


Instruction: Pop FP → Move (SP), FP

8. Returning to the Caller:

 The return address is at the top of the stack.

 Instruction: RET → Jumps back to the return address, transferring control to the calling function.

 Steps for Setting Up a Stack Frame:

1. Calling the Subroutine:

o Initially, the stack pointer (SP) is pointing to the old top of the stack (oldTOS).

o The calling program pushes the parameters onto the stack.

o The CALL instruction is executed, pushing the return address (address to resume after function execution) onto the stack.

o SP points to the return address.

2. Setting Up the Stack Frame in the Subroutine:

o Once the subroutine begins execution, the Frame Pointer (FP) is initialized by saving the old value of FP and setting FP to the current value of SP.

Instructions for Stack Frame Setup:

o Move FP, -(SP) → Saves the old FP value onto the stack.

o Move SP, FP → Initializes FP with the current value of SP, so both FP and SP now point to the saved FP address.

3. Allocating Space for Local Variables:

o Local variables are pushed onto the stack. To allocate space for them, the following instruction is executed:

 Subtract #12, SP → Reserves space for 3 local variables (each 4 bytes) in this case.

4. Saving Processor Registers (Optional):

o If required, processor registers (e.g., R0, R1) are saved onto the stack to preserve their values during the function execution.

o This is done by pushing the register values onto the stack before executing the subroutine's task.

5. Executing the Subroutine:

o The subroutine now executes its task with its local variables and parameters accessed through the stack frame.

6. Restoring the Stack Frame:

o When the subroutine finishes its task, it begins the clean-up process:

 Restore registers: The saved values of R0 and R1 are popped from the stack and restored to their original registers.

 Remove local variables: The space allocated for local variables is deallocated by executing:

 Add #12, SP → Frees up the space used for local variables.

 Restore old FP: The old value of FP is popped from the stack and restored by:

 Move (SP), FP → Restores the old FP value.

7. Returning to the Caller:

o The SP now points to the return address (address of the instruction after the CALL), so the Return instruction (RET) is executed.

o Control is transferred back to the calling program.

Stack Frame Example:


Let’s break down a simple example:

1. Calling Program (Before Subroutine Call):

o The calling program pushes 4 parameters onto the stack (each 4 bytes).

o The return address is also pushed onto the stack.

2. Subroutine Execution (Setting Up Stack Frame):

o Move FP, -(SP) → Save old FP.

o Move SP, FP → Initialize FP to the current SP value.

o Subtract #12, SP → Allocate space for 3 local variables (12 bytes).

o Push any necessary registers (e.g., R0, R1) onto the stack.

3. Subroutine Task:

o The subroutine performs its task using the parameters and local variables from the stack frame.

4. Subroutine Exit (Restoring Stack Frame):

o Move (SP), FP → Restore old FP value.

o Add #12, SP → Deallocate space for local variables.

o Pop saved registers (e.g., R0, R1) from the stack.

5. Return to Calling Program:

o The Return instruction (RET) is executed, transferring control back to the calling program.

SUBROUTINES • “A subtask consisting of a set of instructions which is executed many times is called a Subroutine”.

Subroutines and Subroutine Nesting

Definition of Subroutine:

 A subroutine is a set of instructions that performs a specific task and can be executed multiple times within a program. It is essentially a "sub-task" of the main program.

 A Call instruction transfers control to the subroutine, and a Return instruction brings control back to the point immediately after the subroutine call.

Subroutine Linkage:

The method that allows a program to call and return from subroutines is referred to as subroutine linkage. In the simplest linkage mechanism:

1. The Call instruction stores the address of the next instruction (the return address) into a Link Register.

2. The processor then branches to the subroutine's address.

3. The Return instruction uses the Link Register to return to the address stored there.

Subroutine Call and Return Mechanism:

1. Call Instruction:

o The Call instruction saves the Program Counter (PC) (which contains the address of the next instruction after the call) into a link-register.

o It then branches to the target address (the address of the subroutine).

Operations of Call:

o Link Register = PC (save the return address).

o Branch to subroutine address.

2. Return Instruction:

o The Return instruction branches to the address stored in the link-register, returning control to the instruction immediately following the subroutine call.

Operations of Return:

o Branch to Link Register (this is the address of the instruction after the subroutine call).

Parameter Passing in Subroutines


When calling a subroutine, it's essential to provide the subroutine with the parameters (inputs) it needs to perform its task. These parameters can be operands or the
addresses of the data to be operated on. The subroutine, in turn, may return computed results to the calling program.
The exchange of data between the calling program and the subroutine is referred to as parameter passing. There are multiple methods for passing parameters to a
subroutine, which will be explained in detail below.
Methods of Parameter Passing
1. Passing Parameters via Registers:
o In this method, the parameters are passed through processor registers.
o Registers are fast and efficient for parameter passing, but their number is limited. If there are too many parameters, using registers alone might not suffice.
Example: Let's say we have a subroutine that computes the sum of a list of numbers:
o The size of the list (n) is stored in register R1.
o The address of the first number (NUM1) is stored in register R2.
o The result (sum) is returned in R0.
; Calling Program
MOV R1, #5 ; Store first number in R1
MOV R2, #10 ; Store second number in R2
CALL ADD ; Call the subroutine
; Subroutine ADD
ADD:
ADD R0, R1, R2 ; R0 = R1 + R2
RET ; Return to calling program

2. Passing Parameters via the Stack:


o If there are many parameters, or if the number of available registers is insufficient, the stack can be used to pass parameters.
o The stack pointer (SP) is used to manage the parameters, with the calling program pushing parameters onto the stack before the call and the subroutine
popping them off when needed.
; Calling Program
PUSH #5 ; Push first number onto the stack
PUSH #10 ; Push second number onto the stack
CALL ADD ; Call the subroutine

; Subroutine ADD
ADD:
POP R1 ; Pop first number into R1
POP R2 ; Pop second number into R2
ADD R0, R1, R2 ; R0 = R1 + R2
RET ; Return to calling program
 #5 and #10 are passed as parameters via the stack.
 The result is returned in R0

3. Passing Parameters by Value and Reference: There are two common methods for passing parameters:
o Pass-by-Value: The actual value of the parameter is passed to the subroutine.
o Pass-by-Reference: Instead of passing the actual data (like a list), the address of the data is passed. This allows the subroutine to modify the original data.
Example:
o Pass-by-Reference: The address of the first element of the list is passed, so the subroutine can access and modify the list directly.
o Pass-by-Value: The actual size of the list (n) is passed, which is used as a value by the subroutine.

; Calling Program
PUSH NUM1 ; Push the address of the first number (pass by reference)
PUSH #5 ; Push the size of the list (pass by value)
CALL LISTADD ; Call the subroutine

; Subroutine LISTADD
LISTADD:
POP R2 ; Pop the address of the first number into R2
POP R1 ; Pop the size of the list into R1
; Perform addition of numbers using R1 and R2
ADD R0, R2, R1 ; Compute the sum and store it in R0
RET ; Return to the calling program
In this example, NUM1 is passed by reference (the address of the first number), while n is passed by value (the number of elements).

Steps for Parameter Passing Using the Stack:


1. Calling Program:
o Push the parameters onto the stack.
o Call the subroutine. The return address is also pushed onto the stack by the CALL instruction.
2. Subroutine:
o Pop the parameters from the stack to retrieve them.
o Perform the desired operations on the parameters.
3. Return:
o The subroutine uses the RET instruction to return control to the calling program.
4. Restoring the Stack:
o After the subroutine returns, the calling program may need to adjust the stack pointer to restore the stack to its original state (e.g., popping parameters off the stack,
restoring registers).
o
o
Subroutine Nesting:
 Subroutine Nesting occurs when one subroutine calls another subroutine.
 In this case, the return address for the first subroutine is stored in the link register.
 If a second subroutine is called, the link register will be overwritten with the return address for the second subroutine. As a result, the return address for the first subroutine is lost.
 To avoid this, before calling another subroutine, the contents of the link-register must be saved (usually onto a stack). This ensures that return addresses are preserved and can be
retrieved in the correct order.

Using the Stack for Subroutine Nesting:


1. Processor Stack:
o A special register, the Stack Pointer (SP), is used to manage the processor's stack.
o The SP points to the top of the stack, where return addresses are stored.
2. Call Instruction with Stack:
o When a subroutine is called, the Call instruction pushes the PC (return address) onto the stack.
3. Return Instruction with Stack:
o The Return instruction pops the return address from the stack and loads it into the PC, transferring control back to the calling program.
Operations of Call and Return with Stack:
o Call:
 Push PC onto stack (Store return address).
o Return:
 Pop return address from stack (Load return address into PC).
4. LIFO (Last In, First Out) Order:
o Return addresses are used in LIFO order, meaning the most recent subroutine called is the first to return.
o The return address of the most recent subroutine call is always popped from the stack first when the subroutine finishes execution.

Example of Subroutine Nesting with Stack:


Let’s illustrate how the stack works with nested subroutine calls.
1. Subroutine 1 is called.
o The return address (the instruction immediately after Subroutine 1) is stored in the link register.
o Control transfers to Subroutine 1.
2. Subroutine 2 is called from within Subroutine 1.
o The return address for Subroutine 2 (the instruction immediately after Subroutine 2) is saved into the link register, overwriting the previous return address.
o The return address of Subroutine 1 is pushed onto the stack to preserve it.
o Control transfers to Subroutine 2.
3. Subroutine 2 finishes execution and returns:
o The return address for Subroutine 2 is popped from the stack and loaded into the PC to return control to Subroutine 1.
4. Subroutine 1 finishes execution and returns:
o The return address for Subroutine 1 (which was saved earlier) is restored from the link register.
o Control returns to the calling program.

Here is a program to evaluate the expression Y=A×B+C×DY = A \times B + C \times DY=A×B+C×D using a single accumulator processor. The processor has the instructions LOAD, STORE,
MULTIPLY, and ADD.
Assume that:
 A,B,C,DA, B, C, DA,B,C,D are stored in memory locations.
 YYY is the result to be stored.
Program Steps:
1. Load the first operand AAA.
2. Multiply it by BBB.
3. Store the result temporarily.
4. Load the second operand CCC.
5. Multiply it by DDD.
6. Add the result of the second multiplication to the temporary result.
7. Store the final result in YYY.
; Assume A is at memory location 1000
; Assume B is at memory location 1001
; Assume C is at memory location 1002
; Assume D is at memory location 1003
; Y will be stored at memory location 1004

LOAD 1000 ; Load A into the accumulator


MULTIPLY 1001 ; Multiply accumulator by B (A * B)
STORE 2000 ; Store the result (A * B) temporarily in memory location 2000

LOAD 1002 ; Load C into the accumulator


MULTIPLY 1003 ; Multiply accumulator by D (C * D)
ADD 2000 ; Add the previous result (A * B) to the current result (C * D)
STORE 1004 ; Store the final result (Y = A * B + C * D) in memory location 1004
Explanation:
 LOAD 1000: Loads AAA from memory into the accumulator.
 MULTIPLY 1001: Multiplies the value in the accumulator (which is AAA) by BBB (from memory location 1001).
 STORE 2000: Stores the result of A×BA \times BA×B in memory location 2000.
 LOAD 1002: Loads CCC from memory into the accumulator.
 MULTIPLY 1003: Multiplies the value in the accumulator (which is CCC) by DDD (from memory location 1003).
 ADD 2000: Adds the previously stored result A×BA \times BA×B (from memory location 2000) to the current result C×DC \times DC×D.
 STORE 1004: Stores the final result YYY in memory location 1004.

You might also like