Prime finder - assembly program, Assembly Language

Prime Finder - assembly program:

Problem:  Prime Finder
 
In this problem you will write a small program that tests whether a given integer is a prime number or not.  Let's call the number we are testing A and let's assume that it starts in R0 - at the end of your program R1 should contain 1 if the number is prime and 0 if it is not.
 
Here is the pseudo-code for the procedure
 
If (A <= 1) {
  PRIME_FLAG = 0;
  GOTO END
}
 
B = 2;
PRIME_FLAG = 1;  // we assume that the number is prime until we prove otherwise
 
While (B*B <= A) {
  If (A % B == 0) { // check if A is divisible by B
    PRIME_FLAG = 0;
    GOTO END
}
B = B+1
}
 
END
 
You should think about why this code works.
 
For this part you should turn in two files: prime.asm and prime_script.txt

Posted Date: 2/11/2013 2:51:31 AM | Location : United States







Related Discussions:- Prime finder - assembly program, Assignment Help, Ask Question on Prime finder - assembly program, Get Answer, Expert's Help, Prime finder - assembly program Discussions

Write discussion on Prime finder - assembly program
Your posts are moderated
Related Questions
how o create the flow chart for scan ROW4, Column 1 and 3.tq


write a Mips program that read a string AND PRINT IT ON THE SCREEN


As an instance of the normal priority mode, imagine that initially AEOI is equal to 0 and all the ISR and IMR bits are clear. Also consider that, as shown in given figure, requests

1. Write an assembly program that adds the elements in the odd indices of the following array. Use LOOP. What is the final value in the register? array1 DWORD 10, 20, 30, 40, 50, 6

External Hardware-Interrupts External hardware-interrupts are generated by controllers of external devices or coprocessors and are connected to the processor pin for Non Mask a

1 st Generation Microprocessor : At the end of the 70s a group of engineers developed a chip is able to processing data. This chip was called processor chip. Big processors w

Multiply two numbers by using shift and rotate instruction

Memory Interface                                                                  Figure: Memory Modulation design The memory of a computer contain of number of memo