![]() |
|
#1
|
|||
|
|||
Will pay through Paypal if somebody helps me.Hi every body..i am not sure whats wrong with the code. I have to submit this assignment today. If any body solves the program and the extra credit, I would pay him through paypal. This program is very important to me. Rit now this program just prints the prime nos till 9. later prints the unwanted nos. Please help me out. here is the program requirement:
************************************************** *************** Overview Write a program that will generate and print all prime numbers that are less than or equal to a user-defined limit. The program will contain 4 procedures: main and 3 procedures to read the user limit, generate the prime numbers, and print the prime numbers. In addition, the program will have 2 macros to make it more convenient to print text strings and print numeric output. Details The program will define an array of 1000 unsigned integers. The main procedure will call each of the other 3 procedures to do the following 3 tasks. 1. This procedure will call the macro to ask the user for an upper limit for the prime numbers. Then procedure will read in and check that the limit is not larger than 7919, the 1000th prime number. If it is larger, the procedure will call the macro to print a warning message that the limit is reset to 7919. Then the procedure will return the limit back to the main procedure. 2. This procedure will fill the array with prime numbers up to the limit. The array is passed into this procedure by address. Algorithm to generate the prime numbers: a. initialize the first 2 elements of the array to 2 and 3 (the first 2 prime numbers) <!--[endif]--> <!--[if !supportLists]--> b. <!--[endif]-->loop through all odd numbers less than or equal to the limit, starting with the number 5, and test each number this way: <!--[if !supportLists]--> - Divide the test number by each array element (starting at 3) until the quotient is smaller than the divisor, or until the test number is divisible by the array element. <!--[if !supportLists]--> - If the test number is divisible by the array element, it is not a prime number. Start the loop again with the next test number. <!--[if !supportLists]--> - If the quotient becomes smaller than the divisor, the test number is a prime. Put it in the next available spot in the array and update the next available index. (Note that when you first start the loop, the next available index is at the third element of the array) To see the calculation of the first several prime numbers, click here. <!--[if !supportLists]--> 3. <!--[endif]-->This procedure will call the macro to print a header, and then print all the prime numbers in the array, 10 numbers per line. To print each prime number, the procedure will call a macro to print the number and a space. Again, the array should be passed by address to this procedure. In addition to the 4 procedures, the program also has 2 macros. The first macro makes printing text strings easier. If the name of the macro is ‘print’, the programmer can code: print str1 where str1 is a string which has been defined in the data segment. The second macro prints a numeric value and a space. If the name of the macro is 'printNum', the programmer can code: printNum eax and the numeric value in eax will be printed followed by a space character. To think about - Don't forget to save and restore registers that are used by each macro and each procedure - In 32-bit mode, the size of each data value on the stack is 32 bits or 4 bytes. This means that to access data in the stack, you should use multiples of 4 for the offset from EBP. - For the array of prime numbers, you can use word or doubleword data. When you walk the array, just remember to increment by the right number for your data size. Absolute must haves - Use the stack to pass input arguments and return values. Except for the main procedure, all other procedures must get input data from the stack and return data through the stack. These procedures should not use any memory variables defined in the .data section, with the exception of string constants used to print to screen.1 - Implement the prime number algorithm given in this lab. Do not use a different algorithm. - As before, document your program clearly. When it comes to parameter passing through the stack, clear documentation will save you a lot of headaches. - Programs that do not assemble successfully will receive 1/3 credit at most. 1 Extra Credit (2 pts) - Implement the procedures so the string constants are passed to them through the stack. This means these procedure does not directly fetch any data from the .data section ************************************************** ************** TITLE Lab 5 (lab5.asm) Code:
Last edited by LuciWiz : 06-Dec-2007 at 10:59.
Reason: Please insert your code between [code] & [/code] tags
|
Recent GIDBlog
Meeting the populace by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| PayPal accepting Malaysians now! | JdS | eCommerce / Merchant Account Forum | 35 | 03-Jul-2006 09:39 |
| Noticed a HUGE change in PayPal recently | BobbyDouglas | eCommerce / Merchant Account Forum | 18 | 04-Jan-2005 06:49 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The