Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Using only at most r 0 , r 1 , r 2 , and r 3 , return the middle value of r 0 ,

Using only at most r0, r1, r2, and r3, return the middle value of r0, r1, and r2.
test bench:
#include
int middle( int r0, int r1, int r2){
int t;
if ( r2< r1){
t = r2; r2= r1; r1= t;
}
if ( r2< r0){
t = r2; r2= r0; r0= t;
}
r0= r0< r1? r1 : r0;
return r0;
}
extern int test(int r0, int r1, int r2);
int test_harness( void )
{
int expected, res;
expected = middle(1,2,3);
res = test(1,2,3);
if ( res != expected ){
printf("expected %d, got %d
", expected, res );
return 1;
}
else {
printf("passed test1
");
}
expected = middle(3,1,2);
res = test(3,1,2);
if ( res != expected ){
printf("expected %d, got %d
", expected, res );
return 1;
}
else {
printf("passed test2
");
}
expected = middle(2,3,1);
res = test(2,3,1);
if ( res != expected ){
printf("expected %d, got %d
", expected, res );
return 1;
}
else {
printf("passed test3
");
}
return 0;
}
my work:
.arch armv4
.syntax unified
.arm
.text
.align 2
.global test
.type test, %function
test:
cmp r0,r1
movgt r3,r0
movle r3,r1
cmp r3,r2
movle r3,r2
cmp r3,r2
moveq r3,r0
cmp r3,r1
movle r0,r3
movgt r3,r1
mov r0,r3
mov pc, lr
not getting the correct value
solve the question based on this test bench and my work(change what need to change)
make sure the middle value 2 is the answer
don't use any previous answer or AI generated answers

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

What are Measures in OLAP Cubes?

Answered: 1 week ago

Question

How do OLAP Databases provide for Drilling Down into data?

Answered: 1 week ago

Question

How are OLAP Cubes different from Production Relational Databases?

Answered: 1 week ago