CS501 Advance Computer Architecture Assignment # 1 solution Fall 2012

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

f = 4(k+32) + 16(g-h)

 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: 5 marks

Draw memory map table for the above program using the following scenario and assume that SRC uses 16-bit memory in this case.

.ORG  300      ; start the next line at address 300

k:         .DW                1          ;

g:         .DW                1          ;

h:         .DW                1          ;

f:          .DW                1          ;

;

.ORG 400       ; start the code at address 400

The code starts at address 400 and each instruction takes 16-bits in the memory.

Solution:

Part a) Solution

ld R1,g                  ;

ld  R3,h                 ;

sub R5,R3,R1        ;

shl  R4,R5,4           ; l

addi R7,R6,32        ;

shl R8,R7,2           ;

add R9,R8,R4

st R9,f

Part b: 5 marks

Draw memory map table for the above program using the following scenario and assume that SRC uses 16-bit memory in this case.

 

.ORG  300      ; start the next line at address 300

k:         .DW                1          ;

g:         .DW                1          ;

h:         .DW                1          ;

f:          .DW                1          ;

;

 

.ORG 400       ; start the code at address 400

The code starts at address 400 and each instruction takes 16-bits in the memory.

 

Solution

Memory Map

Memory Address

Memory Contents

300

unknown

304

unknown

308

unknown

312

unknown

…..

400

ld R1,g

402

ld  R3,h

404

sub R4,R3,R1

406

shl  R4,R5,4

408

addi R7,R6,32

410

shl R8,R7,2

412

add R9,R8,R4

414

st R9,f

 

DOWNLOAD SOLUTION HERE
loading...