midterm #6, #7

23 views
Skip to first unread message

Frank (sjsu) Lin

unread,
Nov 1, 2016, 12:14:31 PM11/1/16
to SJSUcmpe120
Proposed #6 answer is quite right. There is no need for the first instruction MOV R1, #0 though.

MOV R2, #A 

MOV R3, #A+400 

​LOOP:​ 
ADD (R2), #4

ADD R2, #4 

CMP R2, R3 

BLT LOOP 


For #7, this is how I would answer it.

MOV R1, #0 

MOV R2, #400 

​LOOP: ​
ADD R1(A), #4 
ADD A(R1), #4

ADD R2, #4 ADD R1, #4

CMP R1, R2 

BLT LOOP 

other ideas?

  1. (3 pt) Suppose you have an ISA instruction sets:  

MOV, ADD, CMP and conditional JMPxx (eq, ne, lt, gt, le, ge) ... equal, not equal, less than, etc

Implement the following C program in ISA instructions with register indirect addressing.

int A[100];

for (i=0; i<100; i++) A[i] = A[i] + 4;

  1. (3 pt) Same problem as above, but implement it with index addressing.

Reply all
Reply to author
Forward
0 new messages