Question: After executing the following code, please answer the question: int x; int * ptr; ptr = &x; for ( i = 0 ;i < 6

After executing the following code, please answer the question:
int x;
int *ptr;
ptr = &x;
for (i=0;i<6;i++)
{
*ptr=i;
ptr++;
}
1. What's in x?
2. We know &x=0x10010000, &x=
3.Translate above C++ code to assembly language. Please choose/fill in the correct answer of the blank:
.data
x: .word 0:6
.text
li $s1,0 #$s1= i
la $s0,x # $s0= &x
li $t0,6
$s1,$t0, exit
loop: $s1,($s0)
addi $s0,$s0, #ptr++
addi $s1,$s1,1
$s1,$t0,loop
exit: li $v0,10
syscallAfter executing the following code, please answer the question:
int x;
int *ptr;
ptr = &x;
for (i=0;i<6;i++)
{
*ptr=i;
ptr++;
}
1. What's in x?
2. We know &x=0x10010000, &x=
3.Translate above C++ code to assembly language. Please choose/fill in the correct answer of the blank:
.data
x: .word 0:6
.text
li $s1,0 #$s1= i
la $s0,x # $s0= &x
li $t0,6
$s1,$t0, exit
loop: $s1,($s0)
addi $s0,$s0, #ptr++
addi $s1,$s1,1
$s1,$t0,loop
exit: li $v0,10
syscall

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Accounting Questions!