ee446exp4plw - Hüseyin Cihan Yaşar 1293273 EE446 LAB...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Hüseyin Cihan Yaşar 1293273 EE446 LAB EXP#4 Preliminary Work Thursday Morning THM Page1 of 3 Q.1) INSTRUCTION CODE INSTRUCTION 16 15 14 13 12 11 10 9 8 7 6 AND R3,R0;R3 0 0 0 0 0 0 1 0 1 0 1 NOR R2,R0;R2 0 0 0 0 0 0 1 0 0 0 0 XOR R1,R0;R2 0 0 0 0 0 0 1 0 0 1 1 XNOR R2,R0;R3 0 0 0 0 0 0 1 0 1 0 0 SHFL R2 0 0 0 0 0 0 0 1 1 1 0 5 1 1 0 1 0 4 1 1 0 1 1 3 1 0 1 0 0 2 1 1 1 1 1 1 1 0 0 1 0 HEX CODE 02BF 021A 0266 029B 01CA Q.2) Q2 LABEL INSTRUCTION AGAIN: INP COMP R0;R0 SET R1 LOOP1: SET R2 LOOP2: DEC R2 JIC LOOP2 DEC R1 JIC LOOP1 JMP AGAIN INSTRUCTION CODE 16 15 14 13 12 11 10 9 8 7 6 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 1 0 0 1 0 0 0 0 0 0 0 1 0 1 1 0 0 0 0 0 0 0 1 0 1 1 0 0 0 0 0 0 0 0 1 1 1 1 0 0 0 0 1 1 0 0 0 1 0 0 0 0 0 0 0 0 1 1 1 1 0 0 0 0 1 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 0 0 5 0 1 0 0 1 0 1 1 0 4 0 0 0 1 1 0 0 0 0 3 0 0 1 0 0 0 1 0 0 2 0 0 0 1 1 0 0 0 0 1 0 0 1 0 0 0 1 0 0 HEX CODE 0: 0400 1: 0250 2: 02C5 3: 02CA 4: 01FA 5: 0C40 6: 01F5 7: 0C30 8: 0800 Q.3) Q3 LABEL INSTRUCTION CODE 16 15 14 13 12 11 10 9 8 7 6 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0 1 0 0 0 0 0 0 1 0 1 0 1 0 0 0 0 0 0 0 1 1 1 1 0 0 0 0 1 1 0 0 0 1 1 0 0 0 0 1 0 0 0 1 0 1 0 0 0 0 0 0 0 1 1 1 1 0 0 0 0 1 1 0 0 1 0 0 0 0 0 0 1 0 0 0 1 0 1 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 1 1 1 1 0 0 0 0 1 1 0 0 1 0 0 1 1 1 1 0 0 0 0 1 1 1 INSTRUCTION INP MOVE R0;R1 MOVE R0;R2 DEC R2 JIC GO JMP FIN GO: DEC R2 JIC LOOP JMP FIN LOOP: ADD R0,R1;R0 DEC R2 JIC LOOP FIN: END 5 0 0 0 1 0 0 1 1 0 1 1 1 1 4 0 0 0 1 0 0 1 0 0 0 1 0 0 3 0 0 0 0 0 0 0 0 0 1 0 0 0 2 0 0 1 1 0 0 1 0 0 0 1 0 0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 HEX CODE 0: 0400 1: 02A1 2: 02A2 3: 01FA 4: 0C60 5: 08A0 6: 01FA 7: 0C90 8: 08A0 9: 0194 A: 01FA B: 0C90 C: F0F0 Finding square means adding the number by itself as many times as its magnitude. i.e. 32 = 3 + 3 + 3 Hüseyin Cihan Yaşar 1293273 Q.4) Q4 LABEL INSTRUCTION INP MOVE R0;R1 DEC R1 JIC LOOP1 JMP FIN ADD R1,R0;R0 DEC R1 JIC LOOP1 MOVE R0;R1 MOVE R0;R2 DEC R2 JIC GO JMP FIN DEC R2 JIC LOOP2 JMP FIN ADD R0,R1;R0 DEC R2 JIC LOOP2 END EE446 LAB EXP#4 Preliminary Work Thursday Morning THM Page2 of 3 LOOP1: GO: LOOP2: FIN: INSTRUCTION CODE 16 15 14 13 12 11 10 9 8 7 6 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0 1 0 0 0 0 0 0 0 1 1 1 1 0 0 0 0 1 1 0 0 0 1 0 0 0 0 0 1 0 0 1 0 0 1 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 1 1 1 1 0 0 0 0 1 1 0 0 0 1 0 0 0 0 0 0 0 1 0 1 0 1 0 0 0 0 0 0 1 0 1 0 1 0 0 0 0 0 0 0 1 1 1 1 0 0 0 0 1 1 0 0 1 1 0 0 0 0 0 1 0 0 1 0 0 1 0 0 0 0 0 0 0 1 1 1 1 0 0 0 0 1 1 0 1 0 0 0 0 0 0 0 1 0 0 1 0 0 1 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 1 1 1 1 0 0 0 0 1 1 0 1 0 0 0 1 1 1 1 0 0 0 0 1 1 1 5 0 0 1 1 1 1 1 1 0 0 1 1 1 1 0 1 1 1 0 1 4 0 0 0 0 0 0 0 0 0 0 1 0 0 1 0 0 0 1 0 0 3 0 0 1 0 0 1 1 0 0 0 0 0 0 0 0 0 1 0 0 0 2 0 0 0 0 0 0 0 0 0 1 1 0 0 1 0 0 0 1 0 0 1 0 1 1 0 0 0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 HEX CODE 0: 0400 1: 02A1 2: 01F5 3: 0C50 4: 0930 5: 0194 6: 01F5 7: 0C50 8: 02A1 9: 02A2 A: 01FA B: 0CD0 C: 0930 D: 01FA E: 0D00 F: 0930 16: 0194 17: 01FA 18: 0D00 19: F0F0 In Q.4, the finding square of a number algorithm in Q.3 is used after Address 6. Q.5) Q5 LABEL INSTRUCTION INP MOVE R0;R1 INP MOVE R0;R2 DEC R1 JIC GO JMP RST DEC R1 JIC LOOP JMP FIN ADD R2,R0;R0 DEC R1 JIC LOOP JMP FIN CLR RO END INSTRUCTION CODE 16 15 14 13 12 11 10 9 8 7 6 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0 1 0 0 0 0 0 0 0 1 1 1 1 0 0 0 0 1 1 0 0 0 1 1 0 0 0 0 1 0 0 0 1 1 1 0 0 0 0 0 0 0 1 1 1 1 0 0 0 0 1 1 0 0 1 0 1 0 0 0 0 1 0 0 0 1 1 1 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 1 1 1 1 0 0 0 0 1 1 0 0 1 0 1 0 0 0 0 1 0 0 0 1 1 1 0 0 0 0 0 0 1 0 0 0 1 1 1 1 1 0 0 0 0 1 1 1 5 0 0 0 0 1 1 0 1 0 1 1 1 0 1 1 1 4 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 3 0 0 0 0 1 0 0 1 0 0 0 1 0 0 0 0 2 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0 0 1 0 0 1 0 0 0 1 0 0 0 0 HEX CODE 0: 0400 1: 02A1 2: 0400 3: 02A2 4: 01F5 5: 0C70 6: 08E0 7: 01F5 8: 0CA0 9: 08F0 A: 0198 B: 01F5 C: 0CA0 D: 08F0 E: 0230 F: F0F0 GO: LOOP: RST: FIN: In Q.5 multiplication is done by adding the multiplicand by itself. This operation has been done by decreasing multiplier by 1, and for each decrease the addition of multiplicand is processed. So, the result of the multiplication is obtained as for example : 5x3=5+5+5 Multiplicand : 5, Multiplier: 3, addition of multiplicand by itself is done for 3 times. Hüseyin Cihan Yaşar 1293273 Q.6) Q6 LABEL INSTRUCTION INP MOVE R0;R1 AGAIN: INP MOVE R0;R2 DEC R2 JIC GO JMP AGAIN GO: CLR R2 LOOP: INC R2 SUB R1,R0;R0 JIC LOOP DEC R2 MOVE R2;R0 END EE446 LAB EXP#4 Preliminary Work Thursday Morning THM Page3 of 3 INSTRUCTION CODE 16 15 14 13 12 11 10 9 8 7 6 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0 1 0 0 0 0 0 0 0 1 1 1 1 0 0 0 0 1 1 0 0 0 1 1 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 1 0 0 0 0 1 1 0 0 1 0 0 0 0 0 0 0 0 0 1 1 1 1 0 0 0 0 0 0 1 0 1 1 1 1 1 1 1 0 0 0 0 1 1 1 5 0 0 0 0 1 1 0 1 0 0 0 1 1 1 4 0 0 0 0 1 0 0 1 1 0 0 1 1 0 3 0 0 0 0 0 0 0 0 0 1 0 0 0 0 2 0 0 0 1 1 0 0 1 1 0 0 1 0 0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 HEX CODE 0: 0400 1: 02A1 2: 0400 3: 02A2 4: 01FA 5: 0C70 6: 0820 7: 023A 8: 000A 9: 0164 A: 0C80 B: 01FA C: 02F8 D: F0F0 In Q.5 the first input is the dividend and the other one is the divisor. Program asks for the divisor again if it is entered as 0(zero). In this question the division is done by successive subtraction of the divisor from the divident until divident becomes smaller than divisor. So the number of subtractions gives the quotient i.e. result of the interger divison. ...
View Full Document

Ask a homework question - tutors are online