In: Computer Science
1. If a processor addresses a maximum of (2 to the power of 20) bytes of memory, then, what is the maximum number of 16-bit words that can be stored in this memory?
2. Convert the following base 12 number "A1B" to decimal. Assume it is unsigned.
3. If a certain processor has a system frequency of 100 MHz, what is the clock period?
4. Write the code to implement the expression
A = (B + C) * (D + E)
On 3, 2, 1, and 0 address machines. In accordance with programming language practice, computing the expression should not change the value of its operands.
5. Compare the number of memory accesses for data needed to compute the expression by the four machines of question 3. A = (B + C) * (D + E)
6. What must an Instruction specify?
7. Instructions can be devided into 3 classes:
8. What is the meaning of the following RTN statement:
(OP:=12) R[ra] <-----R[rb]+R[rc]:
9. Describe the following RTN statements:
a. IR <31..0>
b. OP<4..>:=IR<31..27>
10. What decimal value does the binary word 1010 1111 0101 0100 have when it represents an:
a. Unsigned integer
b. 2's compliment
Ans-1)
1 byte = 8 bits = 23 bits
As a processor can address max = 220 bytes, so number of bits addressed by processor = 220 * 23 = 223 bits
Now, one word requires 16 bits = 24 bits.
Therefore,
Maximum number of 16 bits word that can be stored =
= = =
Ans-2)
To convert base-n number into decimal, one should follow following rule:
In this example, given number is A1B
Note: For any number system greater than decimal (10), 9 is followed by A, B, C, D... representing 10,11,12,13,...in decimal number system.
Now in given example base is 12
Follow the steps to get answer:
(122 x 10) + (121 x 1) + (120 x 11) = 1440 + 13 + 11 = 1464
Thus 1464 is decimal equivalent of A1B base 12.
Ans-3)
Clock period = = = 10-8 seconds = 10 nanoseconds
Ans-4)
A=(B+C) * (D+E)
3-ADDRESS: In 3 address code, it has 3 addresses - 2 operands and 1 result.
ADD R1, B, C // Add B and C then stores at register R1 ADD R2, D, E // Add D and E then stores at register R2 MUL A, R1, R2 // Multiply R1 and R2 then stores at A
2-ADDRESS: In 2 address code, it has 2 addresses - 1 source and 1 destination
MOV R1, B //Move B into register R1 ADD R1, C //Add C with R1. It means R1 = R1 + C MOV R2, D //Move D into register R2 ADD R2, E //Add E with R2. It means R2 = R2 + E MUL R1, R2 //Multiply R1 and R2. It means R1 = R1 * R2 MOV A, R1 //Store result R1 into A.
1-ADDRESS: In 1 address code, it can have only one operand(i.e. Accumulator (inbuilt register)).
LDA B // Load B into accumulator(inbuilt register) ADD C // Add C with Acc. It means Acc = Acc + C STA T // Store Acc at memory location T. LDA D // Load D into accumulator(inbuilt register) ADD E // Add E with Acc. It means Acc = Acc + E MUL T // Multiply data at T with Acc. STA A // Store result Acc at A
0-ADDRESS: In 0 address code, no address are referenced. Inbuilt Stack operation( Push and Pop) are used.
PUSH B //Top of Stack <- B PUSH C //Top of Stack <- C ADD //Pop C and B then add both operands and push them at Top of Stack<-(B+C) PUSH D //Top of Stack <- D PUSH E //Top of Stack <- E ADD //Pop E and D then add both operands and push them at Top of Stack<-(D+E) MUL //Multiply first two elements of stack and push them at Top of Stack <- (B + C) * (D + E) POP A //Pop Top of Stack and store at A