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 i can write a program to divide 2 numbers

Assembly Code for Reading Flow & Generating Serial Output The timer is timer 1 is set for the baud rate 9600, as the crystal used is of 11.0592 Hz.  Then the timer 1 is starte

what is the hex value in ax after executing the instructions ax= 1E8A bx=4080 add al,bl sub ah,bh

Write a program to calculate the first 20 numbers of Fibonacci series. Use the stack (memory) to store the calculated series. Your debugger output should look like the following sc

Write a M68000 assembly language subroutine MULSUM that takes an array named A containing n bytes of positive numbers, and fills two arrays, array B containing n

Zero flag: The next line compares the value in register. A with the value 1. If they are equivalent, the Zero flag is set (to 1). The next line then jumps to start: only if th

SHL/SAL : Shift logical/Arithmetic Left: These instructions shift the operand byte or word bit by bit to the left and insert 0 in the newly introduced least significant bits. In c

Fourth  Generation Microprocessor : The single chip 32-bit microprocessor was introduced in 1981 by Intel as iAPX 432. The other 4th generation  microprocessors  were;  Hewlett

hi, i''m new to assembly language and my teacher told us to look for an example of the odd and even numbers program using debug.exe in ms dos as a guide since we just started. plea

1. Write a program that will generate an array of ten random 32-bit integers, and that will  display on the monitor the numbers followed by either the words " has the fourth bit se