0% found this document useful (0 votes)
6 views

Home Assignment Unit 5

The document outlines various concepts in computer architecture, including types of registers, addressing modes, instruction types, and stack organization. It explains the significance of registers in General Register Organization, the various addressing modes used in CPUs, and the characteristics of different instruction types such as zero, one, two, and three address instructions. Additionally, it covers pipeline processing, RISC architecture, and the evaluation of expressions using Reverse Polish Notation.

Uploaded by

mifegah375
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

Home Assignment Unit 5

The document outlines various concepts in computer architecture, including types of registers, addressing modes, instruction types, and stack organization. It explains the significance of registers in General Register Organization, the various addressing modes used in CPUs, and the characteristics of different instruction types such as zero, one, two, and three address instructions. Additionally, it covers pipeline processing, RISC architecture, and the evaluation of expressions using Reverse Polish Notation.

Uploaded by

mifegah375
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 13

Home Assignment Unit 5

1. What are the different types of registers used in General Register


Organization, and what is their significance?
2. Describe the different types of addressing modes used in CPUs?
3. Demonstrate the pipelining and its advantages and calculate the speed up
factor of pipeline vs non-pipeline
4. List various types of registers and their applications
5. What are Zero Address Instructions?
6. What are One Address Instructions?
7. What are Two Address Instructions?
8. What are Three Address Instructions?
9. What is Reverse Polish Notation?
10. Apply Reverse Polish notation for the expression A*B+C*D
11. Convert the following expression from Infix to postfix notation (Reverse
Polish notation)
(A+B)*C+D/(E+F*G)-H
12. Convert the following expression from Infix to prefix notation (Polish
notation)
(A+B)*C+D/(E+F*G)-H
13. What is the organization of stacks?
14. What is pipeline processing?
15. Briefly explain RISC?
What are the different types of registers used in General Register Organization, and
what is their significance?
In computer architecture, the General Register Organization (GRO) refers to the
set of registers that are directly accessible to the CPU for fast data manipulation
and storage. The types of registers used in the GRO can vary depending on the
specific CPU design, but here are some of the most common types of registers and
their significance:

Accumulator register: The accumulator register is used to store intermediate results


during arithmetic and logical operations. It is often used as a default operand for
arithmetic and logical instructions, and is also used to store the final result of a
computation.

Program Counter (PC) register: The PC register is used to store the memory
address of the next instruction to be executed. It is automatically incremented after
each instruction is executed, causing the CPU to fetch the next instruction from the
memory location specified by the PC.

Stack Pointer (SP) register: The SP register is used to keep track of the memory
address of the top of the stack. The stack is a data structure used for storing
temporary data during function calls and other operations. The SP register is
automatically updated as items are pushed onto or popped off of the stack.

Instruction Register (IR) register: The IR register is used to hold the current
instruction being executed. It is loaded from memory during the fetch cycle, and
the opcode and operands are decoded during the decode cycle.

Index register: The index register is used to hold an offset value that is added to a
memory address to access a specific location in memory. This allows for efficient
access to arrays and other data structures.
Status register: The status register is used to hold various status flags that indicate
the outcome of the most recent arithmetic or logical operation. These flags can be
used to control program flow or to make decisions based on the results of a
computation.

Overall, the different types of registers used in the GRO play crucial roles in the
CPU's operation, allowing it to efficiently manipulate data and execute
instructions.

Describe the different types of addressing modes used in CPUs?

Immediate addressing: The operand is specified directly in the instruction. For


example, "ADD #5, R1" adds the value 5 to the contents of register R1.

Direct addressing: The operand is specified as a memory address. For example,


"LOAD 1000, R1" loads the contents of memory address 1000 into register R1.

Indirect addressing: The operand is not the actual value but rather the address of
the value. The CPU then uses the address to access the value from memory. For
example, "LOAD (R2), R1" loads the contents of the memory location specified by
the contents of register R2 into register R1.

Register addressing: The operand is a register, and the CPU accesses the value
directly from the register. For example, "ADD R2, R1" adds the contents of
register R2 to the contents of register R1.

Relative addressing: The operand is specified as an offset from the current program
counter (PC). This mode is often used for branching instructions, where the offset
specifies the number of instructions to skip or execute. For example, "BRANCH -
5" jumps back five instructions from the current PC.

Indexed addressing: The operand is a memory address that is computed by adding


an offset to a register. For example, "LOAD (R1+5), R2" loads the contents of the
memory location specified by the sum of the contents of register R1 and the value
5 into register R2.

Base addressing: This is similar to indexed addressing, but instead of using an


offset, a base address is added to the contents of a register. For example, "LOAD
500(R3), R2" loads the contents of the memory location specified by the sum of
the contents of register R3 and the value 500 into register R2.

Stack addressing: This mode is used for accessing items on the stack. The stack
pointer register (SP) is used as a base address, and an offset is added to it to access
the desired item. For example, "POP R1" pops the top item from the stack, and
stores it in register R1.

Overall, the different addressing modes provide flexibility to CPUs, allowing them
to manipulate data and execute instructions in a variety of ways.

What are Zero Address Instructions?


Zero address instructions are computer instructions that do not explicitly specify
any operands or addresses. Instead, they assume that the operands are stored in the
top of the stack, and the result of the operation is also stored back onto the top of
the stack. Here are some examples of zero address instructions:

ADD: This instruction pops the top two values from the stack, adds them, and
pushes the result back onto the stack. The instruction does not specify any
addresses or operands explicitly.
SUBTRACT: This instruction pops the top two values from the stack, subtracts
them, and pushes the result back onto the stack.

MULTIPLY: This instruction pops the top two values from the stack, multiplies
them, and pushes the result back onto the stack.

DIVIDE: This instruction pops the top two values from the stack, divides them,
and pushes the result back onto the stack.

DUP: This instruction duplicates the top value on the stack, pushing a copy of it
onto the stack.

SWAP: This instruction swaps the top two values on the stack.

In each case, the instruction assumes that the operands are already on the top of the
stack, and it performs the operation by popping the operands from the stack,
performing the operation, and pushing the result back onto the top of the stack.

What are One Address Instructions?


One address instructions are computer instructions that specify only one operand
explicitly. The other operand is assumed to be in a fixed location, such as an
accumulator register. Here are some examples of one address instructions:

LOAD: This instruction loads a value from memory into an accumulator register.
The operand specifies the memory address to load from.

STORE: This instruction stores a value from an accumulator register into memory.
The operand specifies the memory address to store to.
INC: This instruction increments the value in an accumulator register.

DEC: This instruction decrements the value in an accumulator register.

NEG: This instruction negates the value in an accumulator register.

JMP: This instruction jumps to a specified memory address.

In each case, the instruction specifies only one operand explicitly, and the other
operand is assumed to be in a fixed location, such as an accumulator register. One
address instructions are often used in simple, low-level programming environments
where the programmer needs to have direct control over the hardware.
What are Two Address Instructions?
Two address instructions are computer instructions that specify two operands
explicitly. These types of instructions typically take the form of "destination =
source1 operation source2", where the result of the operation is stored in the
destination operand. Here are some examples of two address instructions:

MOV: This instruction copies the value of one operand into another operand. The
first operand specifies the source, and the second operand specifies the destination.

ADD: This instruction adds the value of one operand to another operand and stores
the result in the second operand.

SUB: This instruction subtracts the value of one operand from another operand and
stores the result in the second operand.
MUL: This instruction multiplies the value of one operand by another operand and
stores the result in the second operand.

DIV: This instruction divides the value of one operand by another operand and
stores the result in the second operand.

CMP: This instruction compares the values of two operands and sets flags in the
processor based on the comparison result.

In each case, the instruction specifies two operands explicitly, and the result of the
operation is stored in the second operand. Two address instructions are commonly
used in higher-level programming languages where the programmer does not need
to have direct control over the hardware.

What are Three Address Instructions?

Three Address Instructions are a type of instruction format used in computer


processors and assembly languages that can perform operations with three
operands.

In a three-address instruction, an operation is performed on two operands, and the


result is stored in a third operand. The general syntax of a three-address instruction
is:

result_operand = source_operand1 operator source_operand2

For example, in the following three-address instruction, the values in registers R1


and R2 are added together, and the result is stored in register R3:
R3 = R1 + R2

Three-address instructions are used extensively in compiler design, where high-


level programming language statements are translated into low-level machine
instructions. These instructions are also used in hardware architectures, such as
graphics processing units (GPUs), where the high parallelism requires the use of
multiple data paths.

Some processors and assembly languages support multiple types of three-address


instructions, including arithmetic, logical, shift, and comparison operations. The
use of three-address instructions provides greater flexibility and allows more
complex operations to be performed with fewer instructions.

What is Reverse Polish Notation?

Reverse Polish Notation (RPN) is a mathematical notation in which operators


follow their operands, unlike the more commonly used infix notation where
operators are placed between their operands.

In RPN, operators are written after the operands. For example, instead of writing
"3 + 4", we would write "3 4 +".

To evaluate an expression in RPN, we read from left to right and perform the
following steps:

When we encounter a number, we push it onto a stack.


When we encounter an operator, we pop the top two numbers from the stack, apply
the operation, and push the result back onto the stack.
We continue reading and performing operations until we reach the end of the
expression. The final result is the top element of the stack.
For example, to evaluate the expression "3 + 4 * 5" in RPN, we would write it as
"3 4 5 * +". We start by pushing 3 onto the stack. Then, we encounter 4 and push it
onto the stack as well. We encounter 5 and see that the next operator is
multiplication, so we pop 4 and 5 from the stack, multiply them, and push the
result (20) back onto the stack. Finally, we encounter the addition operator, so we
pop 3 and 20 from the stack, add them, and get the final result of 23.

What is the organization of stacks?


In computer science, a stack is a linear data structure that follows the Last-In, First-
Out (LIFO) principle, where elements are added and removed from the same end,
typically referred to as the "top" of the stack. The organization of a stack typically
includes the following components:

Stack Pointer: It is a special register that keeps track of the top of the stack,
indicating the memory address where the next element will be pushed or popped.

Stack Memory: It is a contiguous block of memory used to store the elements of


the stack. It can be implemented using an array or a linked list.

Push Operation: It is the operation that adds an element to the top of the stack. It
typically involves incrementing the stack pointer and storing the element at the
memory location pointed to by the stack pointer.

Pop Operation: It is the operation that removes the element from the top of the
stack. It typically involves retrieving the element from the memory location
pointed to by the stack pointer, decrementing the stack pointer, and returning the
value.
Overflow Condition: It occurs when the stack is full and no more elements can be
pushed onto it. This can result in an error or an exception, depending on the
programming language or environment.

Underflow Condition: It occurs when the stack is empty and no elements can be
popped from it. This can also result in an error or an exception.

Stack Size: It refers to the maximum number of elements that can be stored in the
stack at any given time, which is typically determined by the size of the stack
memory.

Stack Operations: In addition to the basic push and pop operations, stacks may
support other operations such as peek or top, which allows you to view the top
element without removing it, and is_empty, which checks if the stack is empty.

These are some of the key components that define the organization of stacks in
computer science. Stacks are commonly used in programming and computer
systems for tasks such as function call management, expression evaluation,
memory allocation, and more.

What is pipeline processing?


Pipeline processing, also known as pipeline computing, is a method of organizing
and executing a sequence of tasks or operations in a systematic and efficient
manner, where the output of one task is fed as input to the next task, forming a
"pipeline" of processing stages. Each task in the pipeline performs a specific
operation on the input data, and the output is passed to the next task for further
processing. This approach allows for parallelism and overlapping of tasks,
resulting in faster and more efficient processing compared to sequential processing.
In the context of computer programming, pipeline processing is often used in data
processing, image processing, and signal processing applications, where large
amounts of data need to be processed in a series of steps. Each step in the pipeline
can be optimized for a specific operation, and the overall processing time is
reduced as data flows through the pipeline, with different stages working on
different parts of the data simultaneously.

Pipeline processing can be implemented in hardware, software, or a combination of


both. In hardware, specialized processors or hardware components may be used for
each stage of the pipeline. In software, the pipeline is typically implemented using
a combination of data structures, algorithms, and programming techniques to
manage the flow of data and processing tasks.
Overall, pipeline processing is a powerful technique for achieving efficient and
parallel processing of data and tasks, resulting in improved performance and
throughput in various computational applications.

Briefly explain RISC?


RISC stands for Reduced Instruction Set Computing. It is a type of computer
architecture that emphasizes simplicity and speed in the execution of instructions.
The RISC architecture is characterized by a small and highly optimized instruction
set that can be executed very quickly.

In RISC, each instruction performs a very specific and limited task, and they are
designed to be executed in a single clock cycle. This means that RISC processors
can execute instructions much faster than processors based on Complex Instruction
Set Computing (CISC) architectures, which have more complex and variable-
length instructions.

RISC processors also rely on pipelining, a technique that allows multiple


instructions to be executed simultaneously, further increasing their performance.
RISC architectures are commonly used in embedded systems, mobile devices, and
high-performance computing applications where speed and efficiency are critical.
Polish Notation Algorithm
Now we will see how to evaluate a polish expression using stack.
The algorithm for evaluation of a polish expression is given below.

Step 1: Insert a symbol (say #) at the left end of the prefix expression or
polish expression

Step 2: Scan the expression from right to left and follow the Step 3 and
Step 4 for each of the symbol encountered.

Step 3: if an element is encountered insert it into the stack. Here


elements are the numbers used in the expression.

Step 4: if an operator (say &) is encountered, pop the top element A


(say) and next to top element B (say). Now, perform the following
operation x = (A & B) then push x into the top of the stack.

Step 5: if the symbol # is encountered then stop scanning.

Question 4: Evaluate the prefix expression or polish expression


× 5 – 4 3 using stack?
Question 5: Evaluate the Polish expression
-+-x43250/x784 using stack?
Reverse Polish Notation Algorithm
Now we will see how to evaluate a Reverse Polish Expression or Postfix
Expression using stack. The algorithm for evaluation of it is given below.

Step 1: Insert a symbol (say #) at the right end of the postfix expression.

Step 2: Scan the expression from left to right and follow the Step 3 and
Step 4 for each of the symbol encountered.

Step 3: if an element is encountered insert it into the stack.

Step 4: if an operator (say &) is encountered pop the top element A (say)
and next to top element B (say) perform the following operation x = B &
A. Push x into the top of the stack.

Step 5: if the symbol # is encountered then stop scanning.

Question 8: Evaluate the post fix expression or reverse polish


expression 50 4 3 × 2 – + 7 8 × 4 / – using stack?

You might also like