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
give the explaination of timing diagram minimum mode memory write cycle


LENGTH : Byte Length of a Label: This directive is not available in MASM. This is used to mention to the length of a data array or a string. MOV CX. LENGTH ARRAY This sta

how we can take permission


#I submitted my assignment this morning and it is still processing. How long does it take?

Request a depreciation of the item, year of purchase, cost of item, number of years to be depreciated (estimated life ) and,the method of depreciation . Method of depreciation sh

8279 Keyword /Display Controller : Figure shows the structure of 8279 and its interface to the bus. Addressing is according to the table given below. CS        RD

#include"lcd.asm"       ; assembly file is included for displaying lcd characters Main: PORTA EQU 0xF80  ; PORTS PORTB EQU 0xF81 PORTC EQU 0xF82 PORTD EQU 0xF83 R

Register Organization of 8086 8086  has  a great  set  of registers  containing  special  purpose and general  purpose  registers.  All the 8086 resisters are 16-bit registers.