CS501 Assignment 1 Solution Fall 2018


Please carefully read the following instructions before attempting assignment.
RULES FOR MARKING
It should be clear that your assignment would not get any credit if:
  • The assignment is submitted after the due date.
  • The submitted assignment does not open or file is corrupt.
  • Strict action will be taken if submitted solution is copied from any other student or from the internet.

You should concern the recommended books to clarify your concepts as handouts are not sufficient.

You are supposed to submit your assignment in .doc or docx format.
Any other formats like scan images, PDF, zip, rar, ppt and bmp etc. will not be accepted.
Topic Covered:
·         Instruction set features
·         Addressing modes
·         Comparison of the instruction sets

NOTE
No assignment will be accepted after the due date via email in any case (whether it is the case of loadshedding or internet malfunctioning etc.). Hence refrain from uploading assignment in the last hour of deadline. It is recommended to upload solution file at least two days before its closing date.
If you people find any mistake or confusion in assignment (Question statement), please consult with your instructor before the deadline. After the deadline no queries will be entertained in this regard.
For any query, feel free to email at:

Q 1. Write the SRC assembly language program to evaluate the following expression.
X = 4(7+c) – 8*d + 64(21+e)
Where c=11, d=17 and e= 23
Note: X, c, d and e are memory labels

Q 2. Write 0-address assembly instructions to evaluate the expression given in Q 1.



Solutions



Note: X, c, d and e are memory labels

                             .ORG 300                             ;Start the next line at address 300
c                            .Dw 11                                    ;reserve one word for the label c in the memory
d                                 .Dw  17                                    ;reserve c word for d , this will be at address 304
e                            .Dw 23                                    ;reverse c word for e , this will be at address  308
x                            .Dw 0                                    ;reserve one word for the final result 312


ld         R0, e         
ld         R1,21                                         
addi     R2,R1 R0,                       
shl       R3,R2,6                           
ld         R4,c
addi     R5, R4,7
shl      R6,R5, 2 
ld        R7,d      
mul     R8, R7,8
sub      R9,R6,R7.
addi     R10,R3,R7
st          R10,x        

Q 2. Write 0-address assembly instructions to evaluate the expression given in Q 1.



push e
push 21 
add
push 64
mul
push c
push 7
add
push 4
mul
push d
push 8
mul
sub
add
pop x

Post a Comment

Don't Forget To Join My FB Group VU Vicky
THANK YOU :)

Previous Post Next Post