Assembly Language(MIPS/SPIM) Help

Discussion in 'OT Technology' started by wumpusHunter, Nov 26, 2007.

  1. wumpusHunter

    wumpusHunter New Member

    Nov 24, 2007
    Likes Received:
    Hey guys. I'm very new to assembly language programming... Right now, I'm working on a program that needs to find the hamming distance between two binary strings (zeros and ones). I'll work on the logic of deriving the hamming distance, I just need help with two things to get me started:

    1. How do I prompt the system to read a binary string at system interrupt? I know that for integer inputs, I would use the following instructions:

    addi $v0, $zero, 5 #Read integer input
    syscall #System interrupt

    So, what would the instruction be for reading a binary string? Would I just add a different constant into $v0?

    2. After reading in the binary strings, how would I get the string length of each? For example, if the user enters 1100101, I need the program to know that a seven bit string was entered.

    If any of this isn't making sense, check out the description of the assignment at

    Thanks in advance!

    PS. Let me know if this should be moved to the tutoring forum...
  2. TheDarkHorizon

    TheDarkHorizon \xC0\xFF\xEE

    Sep 26, 2002
    Likes Received:
    San Francisco, CA
    Yes, 8 is the system call for read_string. Additionally, read_string takes the following arguments:

    $a0: Address of buffer for resulting string
    $a1: Size of buffer

    IIRC, strings from read_string are null-terminated, so you can iterate from ($a0) until you encounter byte 0 (or until you have passed $a1 bytes to prevent a buffer overflow).

Share This Page