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
Flag Manipulation and Processor Control Instructions These instructions control the functioning of available hardware inside the processor chip. These are categorized into thes

Write a program to do the following: 1. Print your name 2. Using a bottom testing loop, prompt the user to enter a number from 1 to 5.  If the number entered is not 1..5, pri

Memory Segmentation : The  memory in an 8086/8088  based system is organized as segmented memory. In this scheme, the whole physically available memory can be divided into a n

2. Write a program to separate out positive and negative numbers from a given series of 16-bit hexadecimal numbers.

move a byte string ,16 bytes long from the offset 0200H to 0300H in the segment 7000H

LIST p=18f4550 #include org 0x0000 movlw 0x00 _________ movlw 0xFF movwf PORTB end .

CANI GET HELP WRITTING THIS CODE

SEG : Segment of a Label:- The SEG operator is which is used to decide the segment address of the, variable, label or procedure and substitutes the segment base address in plac

1. The microwave has a clock (hh:mm:ss am/pm) and the user should be able to change the clock at any time. 2. For cooking the user should first enter the time. The user can ente

Write a 68hc11 assembly language program which generation of the following waveforms connected to your DAC i)   Square wave ii)  Saw tooth waveform iii) Sine wave iv) U