The Gateway to Computer Science Excellence
0 votes
114 views
Given 2 machine instructions,

LW R4 #400

LW R1, 0,(R4)

IN second instruction what will be loaded in R1,is it the operand at memory location 400?or some random memory location operand..I want to clarify weather value stored in register is same as adress that register points.
in CO and Architecture by (113 points) | 114 views
0
please answer. it would be a great help.

1 Answer

+1 vote
It will not be some random value - the second instruction is an example of indexed addressing mode.

It means that the value of R4 with an offset of 0 will be loaded.

However, it varies from ISA to ISA - what the actual syntax of the instruction is.
by Loyal (6.7k points)
0
"value of R4 with  0 offset".
you mean  it has nothing to do with #400 of 1st instruction?
0
Actual syntax is a bit long and the question is of pipeline topic.
0
It does - the purpose of this is to load 400 into R1. The () denotes that value of R1 is loaded.
0
ok. if in place of 0 we have got anyother value (! 0)  then we cannot tell what will loaded. right?
0
ok. the complete question is something like..

LW R4#400

L1: LW R1, 0,(R4)

LW R2, 400(R4)
ADDI R3, R1, R2
SW R3, 0(R4)

SUB R4, R4, #4

BNEZ R4, L1

HOW MANY TIMES WILL THE LOOP RUN
0
I guess 100?

Inside the loop, we store the value stored at R4 and R4+400 in R1 and R2 respectively.

The third line doesn't make a lot of sense though - we are storing the contents of R3 into R4, but there's no mention of what R3 actually contains.

As I said, what is the instruction set architecture given? What do the instructions mean?

Can you post the entire question as a new question?
0
what about 4th instruction? architecture is not given. I think, by default RISC architecture will be considered.

Related questions

Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true
50,741 questions
57,251 answers
198,045 comments
104,671 users