So, I recently made a code to count the number of binary 1's in C-code and in MIPS code. I did so in C by using a remainder value and increment a count_one variable. In MIPS, I did the same program but I shifted the bytes of the number until it counted all of the 1's. Howver, I want to try to learn how to use pointers but I can not seem to grasp the concept. My MIPS code is as follows:
.data
prompt: .asciiz "Enter a integer: "
.text
li $v0,4
la $a0, prompt
syscall
li $v0,5
syscall
move $s0,$v0
j count
count:
beq $s0,0, exit
andi $t0,$s0,1
add $t1,$t1,$t0
srl $s0,$s0,1
j count
exit:
move $a0,$t1
la $v0,1
syscall
li $v0,10
syscall
I get this complete MIPS code but I am unsure on how pointers completely work in MIPS and after reading I still don't understand. Any advice on how to implement pointers?
Most common the command determines the mind of data.
For example in pseudo code
inc $a0
this command increment data in register $a0
work with it as with number
lw $s1, 0($a0)
this command load data from memory pointed by register $a0
work with it as with pointer