1

I need to loop through this array of bytes

testCases: .byte 0x0,0x1,0x2,0x3,0x4,0x5,0x6,0x7,0x40,0x41,0x42,0x43,0x44,0x45,0x46,0x47

Im assuming I would do something like this, but not sure

  ori $a1, $0, 0x0   # Initialize index with 0
LOOP:  
    lw $t1, testCases($a1)   
         ...
         ...
    addi $a1, $a1, 1   # Increment index by 1
    j LOOP

and isolate the b6,b2,b1,b0 bits using a bitmask. I'm very new to mips and would appreciate any help. Thank you.

1 Answers1

0

No, lw stands for load word. A word is 4 bytes. If you want to load a single byte you should use lb (if you want sign-extension) or lbu (if you want zero-extension).

Michael
  • 57,169
  • 9
  • 80
  • 125
  • can you offer any other help – user6806552 Nov 04 '16 at 17:46
  • StackOverflow is a Q&A site, not a forum for open-ended discussions. So you need to ask a specific question, and someone might be able to answer it (note: separate questions should be posted as separate questions, not bundled together). The only specific question I could deduce from what you had posted was how to read a byte from an array, so that's what I answered. – Michael Nov 04 '16 at 17:53
  • thats not all i asked, read carefully next time before you call me out. – user6806552 Nov 04 '16 at 17:57
  • Well, I didn't find it clear from the question that you're having any trouble with the bit isolation part - and if so, what. But for that you would use bitwise operations like AND, OR and shifts, just like in C and Java and many other languages. Consult the MIPS instruction set reference (_MIPS32™ Architecture For Programmers Volume II: The MIPS32™ Instruction Set_) – Michael Nov 04 '16 at 18:03