汇编语言-子函数找素数
2014-05-21 14:10
281 查看
1. 题目:找出100~200内所有的素数。
2. 要求:将100~200内所有的素数找出并显示值,要求每行显示5个素数。
3. 要求素数的判定算法用子程序来实现,子程序在判定数是否为素数后有不同的返回参数。
测试结果
2. 要求:将100~200内所有的素数找出并显示值,要求每行显示5个素数。
3. 要求素数的判定算法用子程序来实现,子程序在判定数是否为素数后有不同的返回参数。
; Example assembly language program -- adds two numbers ; Author: Karllen ; Date: revised 05/2014 .386 .MODEL FLAT ExitProcess PROTO NEAR32 stdcall, dwExitCode:DWORD INCLUDE io.h ; header file for input/output cr EQU 0dh ; carriage return character Lf EQU 0ah ; line feed .STACK 4096 ; reserve 4096-byte stack .DATA ; reserve storage for data promot BYTE "The program is to find primes from 100 to 200",cr,Lf,0 cmm BYTE " ",0 crlf BYTE cr,Lf,0 number DWORD ? flai DWORD ? value BYTE 11 DUP(?) PUBLIC _start ; make entry point public .CODE ; start of main program code _start: output promot mov number,99 mov flai,0 doFirstWhile: inc number cmp number,200 jg endFirstWhile mov eax,number push eax call findPrime add esp,4 ; cmp eax,0 je endSecond inc flai dtoa value,number output value output cmm mov eax,flai mov ecx,5 cdq idiv ecx cmp edx,0 je printCrlf endSecond: jmp doFirstWhile printCrlf: output crlf jmp doFirstWhile endFirstWhile: INVOKE ExitProcess, 0 ; exit with return code 0 findPrime PROC NEAR32 push ebp mov ebp,esp mov ebx,2 mov eax,[ebp+8] mov ecx,eax docuWhile: cmp ebx,ecx je found mov eax,ecx cdq idiv ebx cmp edx,0 je noFound inc ebx jmp docuWhile found: mov eax,1 jmp endcuWhile noFound: mov eax,0 endcuWhile: pop ebp ret findPrime ENDP END ; end of source code
测试结果
相关文章推荐
- 汇编语言输出10000以内的素数(小模式下)
- 用C语言和汇编语言实现将1个整数分解成几个素数的乘积
- 汇编语言-判断素数:找出前100以内的素数
- Eratosthenes筛法求1——100000之间所有的素数(32位汇编语言)
- 汇编语言: 判断素数
- nyist-基础语言-题目24(素数距离问题)
- 直接定址表02 - 零基础入门学习汇编语言73
- 汇编语言中使用有符号数还是无符号数问题
- 汇编语言(王爽 第三版)实验七
- 使用BIOS进行键盘输入和磁盘读写01 - 零基础入门学习汇编语言75
- 使用汇编语言编写程序,设计一个用8051单片机控制的循环彩灯控制系统
- 编译器是如何用汇编语言实现C++的虚函数表和隐式传递this指针(三)
- 汇编语言学习方法与环境的搭建
- 汇编语言第一章 -基础知识
- 王爽汇编语言学习笔记(一)
- 80x86汇编语言:在屏幕上模拟输入密码的过程
- 汇编语言基础2
- 处理器、指令集和汇编语言【转】
- Linux内核源代码情景分析读书笔记(3)-Linux内核中的汇编语言
- 个人整理 汇编语言的基本指令