1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

Solved: Anyone familiar with MIPS code?

Discussion in 'Software Development' started by ElementOfMagic, Jan 3, 2013.

Thread Status:
Not open for further replies.
  1. ElementOfMagic

    ElementOfMagic Thread Starter

    Joined:
    Dec 30, 2012
    Messages:
    52
    Hello. :)

    I am currently writing a sample program, to test whether a number is prime or not. If it is (and only if it is), that number should be printed to the screen.
    My problem is that for some reason when I try to run the program, I am getting an 'invalid program counter' error. :confused:

    I am using MIPS 4.2, if that's any help.

    Here's my code:

    Code:
    .data 
    
    printPrime:
    addi $v0, $zero, 1
    add $a0, $zero, $t4
    syscall
    
    .text 
    
    #Set registers
    add $s0, $zero, 3
    add $t4, $zero, $s0
    
    #Test if each num in sequence is prime
    rem $t1, $t4, 2
    bnez $t1, printPrime
    
    Thank-You to anyone who can help me out. (y)
     
  2. ElementOfMagic

    ElementOfMagic Thread Starter

    Joined:
    Dec 30, 2012
    Messages:
    52
    Let me know if you need any extra info' to help me out. :)
     
As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/1083611

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice