Loading ...
Sorry, an error occurred while loading the content.

Need help with program printing multiples of input number

Expand Messages
  • dragonsunrise
    Hi All, I could use some help with a programming assignment due for one of my classes. Here is the assignment: (we are using a MIPS simulator, not sure which
    Message 1 of 1 , Jul 1, 2002
    • 0 Attachment
      Hi All,
      I could use some help with a programming assignment due for one of my
      classes. Here is the assignment: (we are using a MIPS simulator, not
      sure which one)

      3) Write a program to print the first 6 multiples of a given number.
      Hint: Use .data
      .word to declare the input number

      And here is what I have (so far; no looping yet):
      .text

      addi $a0 $zero getnum #get the input number

      #for (counter = 1; counter <= 6; counter++)
      # print getnum * counter
      li $t1 1 # init $t1 to 1
      lw $t2 getnum # init $t2 to input number getnum
      mult $t1 $t2 # lo = $t1 * $t2
      mflo $t3 # $t3 = lo

      li $v0 1 # prepare to print integer
      move $a0 $t3 # move value in $t3 to $a0
      syscall

      .data
      getnum: .word 5

      =============
      Eventually I'd like to prompt for the input number, but first these
      are the error messages I get:
      CMD:read prog3.asm
      Syntax error at line 7 char 5 of input
      Syntax error at line 9 char 11 of input
      Syntax error at line 12 char 2 of input
      3 errors

      Any assistance would be greatly appreciated, I'm pretty clueless
      here. :>
      -ds
    Your message has been successfully submitted and would be delivered to recipients shortly.