常见汇编程序源代码示例Word格式.docx

上传人:b****2 文档编号:14769642 上传时间:2022-10-24 格式:DOCX 页数:33 大小:32.55KB
下载 相关 举报
常见汇编程序源代码示例Word格式.docx_第1页
第1页 / 共33页
常见汇编程序源代码示例Word格式.docx_第2页
第2页 / 共33页
常见汇编程序源代码示例Word格式.docx_第3页
第3页 / 共33页
常见汇编程序源代码示例Word格式.docx_第4页
第4页 / 共33页
常见汇编程序源代码示例Word格式.docx_第5页
第5页 / 共33页
点击查看更多>>
下载资源
资源描述

常见汇编程序源代码示例Word格式.docx

《常见汇编程序源代码示例Word格式.docx》由会员分享,可在线阅读,更多相关《常见汇编程序源代码示例Word格式.docx(33页珍藏版)》请在冰豆网上搜索。

常见汇编程序源代码示例Word格式.docx

负数的和并输出。

10

8.有一个首地址为string的字符串,剔除string中所有的空格字符。

请从字符

串最后一个字符开始逐个向前判断、并进行处理。

12

9.有一个首地址为string的字符串,分别统计string中空格、英文字母、数字

和其它字符的个数并输出。

13

10.palindrome(回文)是指正读和反读都一样的数或文本。

例如:

11、121.12321等,编写程序,求10到10000之间所有回文数并输出。

要求每行输出10个数。

15

11.编写程序,求出所有满足勾股定理且边长不大于500的直角三角形。

.17

12.编写一个求n!

的子程序,利用它求1!

+2!

+引+4!

+5!

+6!

+7!

+8!

的和并输出。

22

13.编写一个判断闰年的子程序,利用它求出2010年到2060年之间所有的闰

年并输出。

25

14.编写一个求解双字型有符号数数组元素的平均值子程序,并验证它的正确性。

26

2x(x<

0)

s=<

3x(0<

=x<

=10)

4xx>

ineludeio32.inc

.code

start:

callreadsid

empeax,0

jlsmall

empeax,10

jlemid

jmplarge

small:

imuleax,2

jmpdone

mid:

imuleax,3

large:

imuleax,4

done:

calldispsid

exit0

endstart

2・输入一个年份(调用readuid子程序),判断是否是闰年.

.data

yes_msgbyte'

isleap:

13,10,0

no_msgbyte'

noleap'

13,10,0

callreaduid

movedx,0

movecx,4

divecx

empedx,0

jefirst

jmpsecond

first:

movecx,100

jneleap

second:

movecx,400

jeleap

jmpnoleap

leap:

moveax,offsetyes_msg

calldispmsg

noleap:

moveax,offsetno_msg

3・输入三个无符号整数(调用readuid子程序),判断并输出这三个数是否能构成一个三角形的三条边。

若这三个数能构成一个三角形的三条边,输出三角形的形状:

msg^dengyaobyte'

dengyao:

13,10,0;

等腰三角形

msg_dengbianbyte'

dengbian'

13,10,0;

等边三角形

msg_zhijiaobyte'

zhijiao'

直角三角形

msg_xiesanjiaobyte'

xiesanjiaoxing:

13J0,0;

斜三角形

msg^wrongbyte'

wrong:

13,10,0;

无法构成三角形

sqrdword0

;

在ebx,ecx,edx分别保存三条边的长度

callreaduid;

读取第一个数和第二个数到ebx、ecx

movebx,eax

movecx,eaxcmpebx,ecxjggreatjmpnext

great:

xchgebx,ecx

next:

movedx,eaxcmpebx,edxjgthirdsmallcmpecx,edxjgthirdmidjmporder;

如果第三个数最小thirdsmall:

moveax,edx

movedx,ecx

movecx,ebx

jmporder

如果第三个数在最中间thirdmid:

xchgecx,edx

确保ebx<

=ecx

读取第三个数到edx

如果第三个数最小

如果第三个数在最中间

执行至此三个数(ebx,ecxzedx)已经从小到人排序

order:

moveaxzebx

addeax,ecx

cmpeax,edx;

最小的两边之和大于第三边

jlewrong

cmpebx,ecxjeb_equal_ccmpecx,edxjec_equal_djmpgeneralb_equal_c:

cmpecx,edxjedengbianjmpdengyaoc_equal_d:

cmpebx,ecx

第一条边等于第二条边

第二条边等于第三条边

非等腰(等边)三角形

继续比较,确认是否为等边三角形

 

jedengbian

jmpdengyao

执行至此,能否构成三角形,以及三角形是否等边等腰已经确定,输出

判断是否为直角三角形

general:

moveax,ebx

imuleax,eax

movsqr;

eax

moveax,ecx

addsqr,eax

cmpsqr;

jezhijiao

jmpxiesanjiao

xiesanjiao:

moveax,offsetmsg_xiesanjiao

jmplast

zhijiao:

moveax,offsetmsg_zhijiao

dengbian:

moveax,offsetmsg_dengbian

dengyao:

moveax,offsetmsg_dengyao

wrong:

moveax,offsetmsg_wrong

输出完毕,运行结束

last:

4.采用无条件和条件转移指令构造while和dowhile循环结构,完成下面的求和任务并输出sum(sum为双字)。

sumdword0

movecx,eax

getsum:

cmpecx,0

jenext

addsum,ecx

dececx

jmpgetsum

moveax,sum

calldispuid

calldispcrlf

思考题:

假设sum为双字无符号整数,在和不溢出的情况下求出n的最大值;

输出sum和n的值。

movecx,l

moveax,sumaddsum,ecxjcnextincecx

jmpgetsumnext:

备份sum的值

进位的话跳出循环,此时的eax中保存最大sum,而ecx=n+l

calldispuidcalldispcrlf

输出sum

输出n

calldispuidcalldispcrlfexit0endstart

5.编写程序,

求0到100间所有偶数和并输出。

要求采用loop.While

和dowhile三种不同的循环结构完成。

•以下采用loop循坏

xoreax,eax

again:

loopagain

结果2550

•以下采用while循环

movecx,100

empecx,0

jldone

subecx,2

jmpagain

•以下采用dowhile循坏

jldonejmpagaindone:

6.Fibonaccinumbers的定义:

fl=l,f2=l,fn=fn-1+fn-2n>

=3编程输出Fibonaccinumbers的前30项。

spacebyte'

0;

输出空格

fldword1;

fn-l

f2dword1;

fn-2

输出fl

输出f2

movecx,30moveax,flcalldispdececxmoveax,f2calldisp

again:

moveax,fladdeaxzf2calldispmovebx,f2movfl,ebxmovf2,eaxloopagainjmpdone

eax=fn

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > IT计算机 > 电脑基础知识

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1