Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

MIPS Assembly and working with bytes

  1. Feb 5, 2012 #1
    1. The problem statement, all variables and given/known data
    I need to put in a byte in register $s1 that is 0b10101011

    2. Relevant equations
    $zero (if needed)

    3. The attempt at a solution
    I attempted at putting in a byte in register $s1 as follows:
    add $s1, $zero, 0b10101011
    however it throws an error, I can't use 0x10101011 because isn't that hex? it would throw a huge number at me otherwise. So how in the world do I load up a binary number into register $s1 ?
  2. jcsd
  3. Feb 6, 2012 #2
    Any takers? Anyone trained or have used Assembly before? I've used it for the 8051 intels but MIPS is a little different as to what you can and can't do.
  4. Feb 7, 2012 #3


    Staff: Mentor

    Try addi, or add immediate value. What you're trying to store is a constant, rather than an address or the value of some register. Doing stuff with constants is what the immediate instructions are for.
  5. Feb 7, 2012 #4
    Nope doesn't work. It considered the byte (as it is) 0b10101011 an invalid language element.
  6. Feb 7, 2012 #5

    D C

    User Avatar

    It might be the case that your MIPS assembler doesn't support binary literal constants. In that case, you probably need to convert your number to hexadecimal or decimal first (0xAB or 171). What assembler are you using?
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook