Professional Documents
Culture Documents
R0
R1
R2
R3
I/O Channel
Page 1 of 10
Role # ___________________ Section ____________
c. You will need to calculate the arithmetic operation ((B-D)/(C+A))*D for these 4 numbers,
Please show how will you perform the arithmetic operation using the following Booth
algorithm for multiplication and successive subtraction for the division algorithm (9+9)
A= -1.1101001011 21010
B= -011110111.10 20010
C= 1110.1010011 20001
D= 111111111110000 2-0100
PLEASE NOTE THAT THESE ARE NOT IN SIGNED NUMBER FORM. ALSO NOTE:
B-D = -(B+D)
C+A WILL BE NEGATIVE
THEREFOR SET X = B+D AND Y = C+A, THEN –X/Y WILL BE POSITIVE
(PLEASE GIVE FULL MARKS IF SOMEONE HAS REACHED THIS POINT, EVEN
IF THEY DO THE BOOTH ALGORITHM WRONG)
Page 2 of 10
Role # ___________________ Section ____________
BOOTH ALGORITHM
START
A 0, Q-1 0
M Multiplicand
Q Multiplier
Count n
= 10 = 01
Q0, Q-1
= 11
A A-M = 00 A A+M
Arithmetic shift
right: A,Q,Q-1
Count Count-1
NO YES
END
Count = 0 ?
Page 3 of 10
Role # ___________________ Section ____________
Question 2 (20):
A Microprocessor will need to perform the arithmetic calculation, Y = ((C*(A+D)/(C-B))/A, on the 4
binary numbers of question 1. You will design an Instruction Set for a microprocessor that can
perform this arithmetic:
a. Show how this arithmetic operation will be performed by the CPU using 2 addresses(5)
Load Y, A
ADD Y, D
MPY Y,C
Store Temp, Y
Load Y, C
Sub Y,B
Div Y, Temp
Mpy Y,A
You can do the multiplication and division the same way as in Question 1. Now answer the
following:
b. What types of operands will you choose for your Instruction Set design (2)
NUMBERS, LOGICAL DATA
c. What types of operations will you choose for your Instruction Set design (3)
ARITHMATIC, LOGICAL, TRANSFER OF CONTROL
d. How will you implement the Booth’s algorithm using conditional branching? Only show
relevant portions where you will use conditional branching (5+5)
i. FOR TESTING BITS Q0, Q-1 WE WILL LOGICAL “AND” A WITH NUMBERS THAT CAN TELL
IF THE BITS ARE 00, 01, 10 OR 11:
0000 AND A, 00
0001 BRZ 1001
0002 AND A, 01
0003 BRZ 2000
0004 AND A, 10
0005 BRZ 1000
0006AND A, 11
0007 BRZ 1001
Page 4 of 10
Role # ___________________ Section ____________
Page 5 of 10
Role # ___________________ Section ____________
Question 3 (25):
Consider the following code for main program, Subroutine A and B.
a. Write sequence of execution cycle for the main program.(7)
THEY NEED TO DO IT FOR THE MAIN PROGRAM ONLY (NOT THE SUBROUTINES)
EXAMPLE (REST IS THE SAME WAY)
: PC = F000
- FETCH INSTRUCTION POINTED TO BY PC(IR LOAD A100)
- DECODE THAT THIS IS A LOAD INTRUCTION
- RESOLVE ADDRESS FOR OPERAND (A100)
- FETCH DATA THAT IS STORED AT A100
- PC = PC+1
MAIN PROGRAM:
Address Instruction Operation
F000 LOAD A100 AC AC + (A100) SP = FFFF
F001 ADD B100 AC AC + (B100) SP = FFFF
F002 CALL 1001 CALL SUB A SP = FFFE, FFFE = F003
F003 SUB C100 AC AC-(C100) SP = FFFF
F004 CALL 1001 CALL SUB A SP = FFFE, FFFE = F005
F005 MPY D100 AC AC*(D100) SP = FFFF
SUB A:
Address Instruction Operation
1001 ADD B100 AC AC + (B100) SP = FFFE
1002 CALL 5001 CALL SUB B SP = FFFD, FFFD = 1003
1003 SUB C100 AC AC-(C100) SP = FFFE, FFFE = F003
1004 CALL 5001 CALL SUB B SP = FFFD, FFFD = 1005
1005 MPY D100 AC AC*(D100) SP = FFFE, FFFE = F003
1006 RET SP = FFFF, PC = F003
(FFFE POPED INTO PC)
SUB B:
Address Instruction Operation
5001 ADD B100 AC AC + (B100) SP = FFFD, FFFD = 1003
5002 DIV C100 AC AC / (C100) SP = FFFD, FFFD = 1003
Page 6 of 10
Role # ___________________ Section ____________
d. If we replace the code in SUB A at location 5006 with the following lines in SUB B then
show how the Stack will be used (5+5)
Page 7 of 10
Role # ___________________ Section ____________
Question 4 (30):
PLEASE BE VERY GENERAOUS WITH THIS QUESTION. ACCEPT ANY PROPER
EXPLAINATION OR ASSUMPTIONS. FOLLOWING IS ONE SET OF ANSWERS
Consider the following code in Table A for a microprocessor. The values (in Hex) for each step are
also shown:
Initially AC = 00000000; R1 = 00000100; A100 = 00000002; A102 = 00000003; A200 = 00000002;
00000100 = 0000A100; 0000102 = 00000200; PC = 0000; 0000103 = 00000005; 0000002 =
00000100;
(All value are in Hex; AC is accumulator, R1 is register, PC is program counter, “A100 =
00000002” means memory address A100 contains value = 00000002)
ADDRESS INSTRUCTION EXECUTION ADDRESSING Number of Effective
RESULT MODE? Address address
references?
00000000 MOV R1,A100 AC=00000002 PRE-INDEXING 2 (0100 +
A100 =
A200
00000001 ADD 0003 AC = 00000005 IMMEDIATE 0 NA
00000002 SUB A100 AC=00000003 DIRECT 1 A100
00000003 MPY R1 AC=00000200 REGISTER 1 R
(THERE
IS AN
ERROR
AC
SHOULD
BE 300)
00000004 DIV A200,R1 AC = 00000001 AUTO- 3 200 =
INDEXING (A200) +
100
00000005 STORE R1 AC=00000001 REGISTER 2 (100)
INDIRECT
00000006 ADD A100,R1 AC=00000006 POST-INDEXING 3 103 =
(A100) +
R1
00000007 SUB 0100 AC = ERROR (DO NOT ERROR ERROR
FFFF5F06 GRADE)
00000008 ADD R, A000 AC = ERROR (DO NOT ERROR ERROR
FFFF5F08 GRADE)
00000009 SUB A00,R AC ERROR (DO NOT ERROR ERROR
=FFFF5F0B GRADE)
R1 = 00000101
TABLE A
a. Please fill in the above TABLE A addressing modes for each instruction that will produce
the results of the second column?(10) Also fill in the column for number of address
references and effective address? (5)
Page 8 of 10
Role # ___________________ Section ____________
b. For the following program in table B, please fill the missing values indicated by a question
mark (10)? Also fill in the column for number of address references and effective address?
(5)
Page 9 of 10
Role # ___________________ Section ____________
Page 10 of 10