0% found this document useful (0 votes)
3 views11 pages

Problems

Uploaded by

k v ramani
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)
3 views11 pages

Problems

Uploaded by

k v ramani
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

1.

Addressing modes

Solution:
2. Status register

If A = 11110000 and B = 00010100, determine what are the flags set as result of the operation

A-B

3. Compare different CPU architectures for performing the operation C + A + B.

Single Accumulator organization, Stack organization, General Register organization.


4.

4. Instruction formats

Explain different instruction formats wit example and evaluate (A+B)  (C+D)

Using zero-address, one-address, two-address, three-address instructions.

Example: Evaluate (A+B)  (C+D)

 Three-Address

1. ADD R1, A, B ; R1 ← M[A] + M[B]

2. ADD R2, C, D ; R2 ← M[C] + M[D]

3. MUL X, R1, R2 ; M[X] ← R1  R2

Example: Evaluate (A+B)  (C+D)

 Two-Address

1. MOV R1, A ; R1 ← M[A]

2. ADD R1, B ; R1 ← R1 + M[B]

3. MOV R2, C ; R2 ← M[C]

4. ADD R2, D ; R2 ← R2 + M[D]

5. MUL R1, R2 ; R1 ← R1  R2

6. MOV X, R1 ; M[X] ← R1

Example: Evaluate (A+B)  (C+D)

 One-Address
1. LOAD A ; AC ← M[A]

2. ADD B ; AC ← AC + M[B]

3. STORE T ; M[T] ← AC

4. LOAD C ; AC ← M[C]

5. ADD D ; AC ← AC + M[D]

6. MUL T ; AC ← AC  M[T]

7. STORE X ; M[X] ← AC

Example: Evaluate (A+B)  (C+D)

 Zero-Address

1. PUSH A ; TOS ← A

2. PUSH B ; TOS ← B

3. ADD ; TOS ← (A + B)

4. PUSH C ; TOS ← C

5. PUSH D ; TOS ← D

6. ADD ; TOS ← (C + D)

7. MUL ; TOS ← (C+D)(A+B)

8. POP X ; M[X] ← TOS

Example: Evaluate (A+B)  (C+D)

 RISC

1. LOAD R1, A ; R1 ← M[A]

2. LOAD R2, B ; R2 ← M[B]

3. LOAD R3, C ; R3 ← M[C]

4. LOAD R4, D ; R4 ← M[D]

5. ADD R1, R1, R2 ; R1 ← R1 + R2

6. ADD R3, R3, R4 ; R3 ← R3 + R4

7. MUL R1, R1, R3 ; R1 ← R1  R3

8. STORE X, R1 ; M[X] ← R1
5.

Write the postfix notation or reverse polish notation for the (A+B)*[C*(D+E)+F]

6.

Evaluate the expression (3*4)+(5*6) using stack and draw the status of stack in each step

Convert (3*4)+(5*6) into postfix we get 3*56*+ then we use stack to evaluate this.

If an operand is encountered, push that operand onto stack

If an operator is encountered, perform the operation on top two elements of the stack and push
the result back to stack
7. Write all the RTL statements for PUSH and POP operations of stack organized
computer
8. Explain the shift operations in detail
Problem 1: Arithmetic Right Shift
Question: Given the 8-bit signed binary number 11110100 (-12 in 2's complement),
perform an arithmetic right shift by 2 places. [1, 2]
Solution:
Original number: 11110100 (Sign bit is 1, meaning it is negative)
Shift all bits 2 positions to the right, discarding the two LSBs (00).
Fill the 2 vacant positions at the left with the original sign bit (1).
Result: 11111101 (Decimal: -3)

Problem 2: Arithmetic Left Shift


Question: Given the 8-bit signed binary number 00000011 (3 in 2's complement),
perform an arithmetic left shift by 3 places.
Solution:
Original number: 00000011
Shift all bits 3 positions to the left, discarding the three MSBs.
Fill the 3 vacant positions at the right with zeros (000).
Result: 00011000 (Decimal: 24)

Problem 3: Detect Overflow in Arithmetic Left Shift


Question: Given the 8-bit signed binary number 01000000 (64 in 2's complement),
perform an arithmetic left shift by 2 places. Did an overflow occur?
Solution:
Original number: 01000000
Shift bits left by 2: 00000000
Evaluate the result: The original value was +64. Multiplying by 2² should equal 256, but
in an 8-bit signed range (-128 to +127), the value overflows.

9.

Given an 8-bit register containing a binary value A=11011100. Determine the 8-bit decimal and
binary outputs for the following operations on A.

a. Logical left shift


b. Arithmetic right shift
c. Circular left shift

Solution:

A=11011100

Logical left shift


Arithmetic right shift

You might also like