$t4=0x12345678
$t5=2000
L1: sw $t4,0($t5)
sll $t4,$t4,4
addi $t5,$t5,4
bne $t4,$zero,L1
And they ask how is the memory altered throught the program.Also, one doubt i have is what does 0($t5) returns
Code: Select all
unsigned int t4 = 0x12345678;
// t5 is a pointer on an array
unsigned int *t5 = 2000;
do
{
// Get the value at the address of $t5
t4 = *t5;
// Ignore the 4bits on the left of the register
t4 = t4 << 4
// Change the pointer to the next number (in MIPS, numbers are 32bits = 4 bytes)
t5 += 4;
}
while (t4 != 0)
Shouldn't sw $t4,0($t5) be :noname120 wrote:Code: Select all
// Get the value at the address of $t5 t4 = *t5;
Code: Select all
// Store the value of $t4 to the address $t5
*t5 = t4;
I think the same, and it has more sense^^xerpi wrote:Shouldn't sw $t4,0($t5) be :noname120 wrote:Code: Select all
// Get the value at the address of $t5 t4 = *t5;
?Code: Select all
// Store the value of $t4 to the address $t5 *t5 = t4;
lw $t4,0($t5) would be t4 = *t5.grief3r wrote:sw means store word not load word
Code: Select all
u32 data = 0x12345678;
u32* dataptr = (u32*)2000;
do{
*dataptr = data;
data *= 16;
dataptr++;
}
while (data != 0);
memory is altered starting from position 2000 all the way to 2032nunks wrote:how is the memory altered throught the program
it will return 0x12345678 as that is what is written there the first time it loopsnunks wrote:what does 0($t5) returns
what makes no sense is your post, it may not be a pointer on the PSP, but this is generic MIPS, it could be a pointer on another system or it could just be made up to teach MIPS itself, also just because it's in decimal doesn't mean it's not a pointer, they are both two different ways of showing the same data and are both treated the same way at low level (the machine doesn't make any distinction between decimal and hex).noname120 wrote:This has really no sense because t5 = 2000 (not a pointer), but it is then used as a pointer with sw $t4,0($t5) (get the value at address $t5 and store it in $t4)