Iterating over words in MIPS

0

I have array of words in .data

array: .word 0x0000012, 0x0000d42f, ..... , 0 // 0 indicates end of array.

I need to print each word's count of '1's and then at the end print the maximum count of '1's .

I tried moving the word to a temporary register and then shift it left, each iteration, but it doesn't work ..

################### Data segment ###################
.data
    x: .word 0x00000001, 0x00000007, 0x0000ffff, 0x20430066, 0
    bits: .word 0
################### Code segment ###################
.text
.globl main
  main:

    lw $a0, x
    li $v0,1
    syscall

    li $v0,10 # exit
    syscall

That code works. but it only refers to the first word in x. I don't know how to get to the second WORD in x

assembly
mips
asked on Stack Overflow Aug 5, 2015 by BVtp • edited Aug 5, 2015 by BVtp

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0