We have been working very hard since 2009 to facilitate in learning Read More. We can't keep up without your support. Donate.

www.bit.ly/vucodes

+ Link For Assignments, GDBs & Online Quizzes Solution

www.bit.ly/papersvu

+ Link For Past Papers, Solved MCQs, Short Notes & More

Total Marks = (15 + 5)

 

Q1.

 

Part a. Write an SRC assembly language program to evaluate the following expression: 

 

 a = 32(b-c) +8(d+32)

 

 

Note that your code should not change the source operands and also keep in mind that the SRC does not have a multiply instruction

 

 

Part b. You need to determine memory map for the above program using the following scenario.

 

.ORG  100      ; start the next line at address 100

b:         .DW                1          ; reserve one word for the label b in the memory

c:         .DW                1          ; same for c… this will be at address 104

d:         .DW                1          ; the 32-bit memory word d will be at address 108

a:         .DW                1          ; reserve one word for the result also

;

 

.ORG 200       ; start the code at address 200

The code starts at address 200 and each instruction takes 32 bits in the memory.

 

 


+ http://bit.ly/vucodes (Link for Assignments, GDBs & Online Quizzes Solution)

+ http://bit.ly/papersvu (Link for Past Papers, Solved MCQs, Short Notes & More)

+ Click Here to Search (Looking For something at vustudents.ning.com?)

+ Click Here To Join (Our facebook study Group)


Views: 719

Attachments:

Replies to This Discussion

Please Discuss here about this assignment.Thanks

any one help us please.........share idea solution here to help us...thanks in advance,

At lecture 4 same example is mention...you can consult from that particular example.... 

CS501+Assignment#1+Solution_(www.vustudents.ning.com

See the attached file please

Attachments:

CS501 Assignment No 1 Solution Spring 2012

Assignment No 1

CS501

 

Total Marks = (15 + 5)

 

Q1.

 

Part a. Write an SRC assembly language program to evaluate the following expression: 

 

 a = 32(b-c) +8(d+32)

 

 

Note that your code should not change the source operands and also keep in mind that the SRC does not have a multiply instruction

 

Solution:

 

           

a = 32(b-c) +8(d+32)

 

ld  Rl, d                        ; d is a lable used for a memory

addi R3,Rl,32               ; R3 contain (d+32)

shl R7,R3, 32               ; R7 contain 8(d+32)

ld R4,b

ld R5, c

sub R6,R4,R5              ; R6 contain (b-c)

shl R8, R6 , 16 ; R8 contain 32(b-c)

addi R9,R7,R8             ; the result is in R9

st R9,a                         ; store the result in memory location a

 

Part b. You need to determine memory map for the above program using the following scenario.

 

.ORG   100      ; start the next line at address 100

b:         .DW                 1          ; reserve one word for the label b in the memory

c:          .DW                 1          ; same for c… this will be at address 104

d:         .DW                 1          ; the 32-bit memory word d will be at address 108

a:          .DW                 1          ; reserve one word for the result also

;

 

.ORG 200        ; start the code at address 200

The code starts at address 200 and each instruction takes 32 bits in the memory.

 

Solution:

 

Memory Address

Memory Content

100

Un known

104

Un known

108

Un known

112

Un known

….

-------------

200

Id Rl,d

204

addi R3,Rl,32

208

Shl R7,R3,32

212

ld R4,b

216

ld R5,c

220

sub R6, R4, R5

224

shl R8,R6 ,16

228

addi R9,R7,R8

232

st R9,a

 

Tariq! Excellent effort. Watch lecture 4 for detailed description of these operations.

http://www.youtube.com/watch?v=QmkYt6SVfIw&feature=relmfu

There are some mistakes in the solutions provided previously.

In part a, to multiply a number with 8 you dont need to shift left that much times. shifting left 3 times a register will multiply it by 8 and shifting left 5 times a register will multiply it by 32.

In part b, the memory variables a,b, c & d are not mapped, which makes the whole memory map wrong. Append the variables at last and continue the memory map with increment of 4. Adding the variables will have the memory location  of last instruction 248 

BEST OF LUCK

Osama can you put the values in above solution, and show us the correct solution... so this will be more helpful

thanks

CS501 Assignment No 1 Solution Spring 2012

Assignment No 1

CS501

 

Total Marks = (15 + 5)

 

Q1.

 

Part a. Write an SRC assembly language program to evaluate the following expression: 

 

 a = 32(b-c) +8(d+32)

 www.vustudents.ning.com

 

 

Note that your code should not change the source operands and also keep in mind that the SRC does not have a multiply instruction

 

Solution:

 

           

a = 32(b-c) +8(d+32)

 

ld  Rl, d                        ; d is a lable used for a memory

addi R3,Rl,32               ; R3 contain (d+32)

shl R7,R3, 32               ; R7 contain 8(d+32)

ld R4,b

ld R5, c

sub R6,R4,R5              ; R6 contain (b-c)

shl R8, R6 , 16 ; R8 contain 32(b-c)

addi R9,R7,R8             ; the result is in R9

st R9,a                         ; store the result in memory location a

 

Part b. You need to determine memory map for the above program using the following scenario. www.vustudents.ning.com

 

 

.ORG   100      ; start the next line at address 100

b:         .DW                 1          ; reserve one word for the label b in the memory

c:          .DW                 1          ; same for c… this will be at address 104

d:         .DW                 1          ; the 32-bit memory word d will be at address 108

a:          .DW                 1          ; reserve one word for the result also

;

 

.ORG 200        ; start the code at address 200

The code starts at address 200 and each instruction takes 32 bits in the memory.

 

Solution:

 

Memory Address

Memory Content

100

Un known

104

Un known

108

Un known

112

Un known

….

-------------

200

Id Rl,d

204

addi R3,Rl,32

208

Shl R7,R3,32

212

ld R4,b

216

ld R5,c

220

sub R6, R4, R5

224

shl R8,R6 ,16

228

addi R9,R7,R8

232

st R9,a

RSS

© 2021   Created by + M.Tariq Malik.   Powered by

Promote Us  |  Report an Issue  |  Privacy Policy  |  Terms of Service

.