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
init_lcd                        ;(this initialises a 2 row lcd)     bcf     TRISA,0             ;PORTA bit 0 as an output (lcd RS pin)     bcf     TRISA,1             ;PORTA bit 1

Interrupt System Based on Multiple 8259As A multiple 8259A interrupt system is diagrammed in given figure in this figure data bus drivers are not indicated, but they could be i

I am running a small minecraft server off of my old mac mini, and am having a big issue. My computer isn''t very good, and even just running this server is an issue. I use a comma

Tabular comparison for µ PS' Parameters Tables (a) and (b) list the characteristic of Intel microprocessor. Table(a):   Table(b): It has a 64 bit da

to separate positive and negative numbers

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

Cache controller The cache controller is the mind of the cache.  Its responsibilities include:  performing the  snarfs and snoops, updating the  TRAM  and SRAM and implementing

1) Write an 80x86 assembly language program in EXE file format to do the following tasks: a) Open and read the contents of a file into memory (use at least 1 kB). b) Sort the li

Pointer and Index Registers The pointers contain offset within the specific segments. The pointers BP, IP and SP generally containoffsets within thedata, code and stack segment

The definitions of the bits in ICWI are following: Always set to the value 1. It directs the received byte to ICWI as oppose to OCW2 or OCW3. Which also utilize the even addr