九九乘法表程序设计(1)
输出九九乘法表程序设计(附源代码)
Rabbit 徐
摘 要: 本程序主要完成一个输出九九乘法表的程序,主程序实现九九乘法表的输出。程序输出界面为阶梯型,程序设计中主要应用了条件转移指令判断,通过更改字符对应的ASII码达到乘法字符输出。
关键字: 汇编;程序;九九乘法表;阶梯行输出
九九乘法表在生活应用非常广泛,本程序利用汇编语言针根据平时生活中的需要对九九乘法表输出。
一、 需求
分析
定性数据统计分析pdf销售业绩分析模板建筑结构震害分析销售进度分析表京东商城竞争战略分析
在日常生活中,我们经常需要使用到九九乘法口诀,以达到一些计算目的。因此编写一个输出九九乘法表程序能够帮助许多学生学习此口诀。而且本程序通过汇编语言实现,汇编语言具有许多其他语言不可替代的优点,其目标程序占用内存空间少,运行速度快,在一些硬件配置较差的机器上也能大显身手。
二、 概要设计
(一)数据类型
程序中主要用了byte型变量,以及cs,ds,ax,bx寄存器。将提示信息存储在byte型变量数组中,然后将偏移地址存储在ax寄存器中,以用于输出信息。用bl暂存乘数,用bh暂存被乘数。
(二)主要类型
程序中主要用byte型变量存储提示信息,用bl寄存器存放乘数,bh寄存器存放被乘数,进行乘法运算。
(三)主要
流程
快递问题件怎么处理流程河南自建厂房流程下载关于规范招聘需求审批流程制作流程表下载邮件下载流程设计
development of freezing plans and emergency precautions. 3, night-time setting the full-time attendant to ensure someone on duty and on duty day and night recording, while setting the Weatherman, responsible listens to and published on the weather conditions. 4, should complete the construction of the winter rainy season Shi ... Has not finished filling the pit covered with a poncho, should be drained before the next fill clean water content meet the requirements before construction began. 5, higher in the winter rain, prior to construction, priority project areas, and built a simple waste water facilities, in order to ensure normal construction. The 12th chapter, resources planning and advancement, introduction of new technology, new technology, new equipment, new material measures in order to ensure the survival of seedlings planted, in the planting process except in strict accordance with the tender specified planting methods and technical measures, the application of new technology to ensure quality: 1, the use of some new scientific achievements and improve survival. (1) ABT-3 rooting powder. This kind of rooting powder for Evergreen coniferous trees take root and valuable species of fast rooting, improve the survival rate is obvious. (2) KD-1 Super absorbent polymers. Insurance agent can enhance soil water storage, water retention and improve survival. (3) the use of puffing chicken manure. High temperature expansion
开 始
显示1*1=1
被乘数加1 显示 置首位
不
高
乘数赋值为1 于
换
行
被乘数与乘数比
较大小,是否需换
行
大于不换行
显 示
乘数加1
不高于 乘数与9比较大是
小,是否结束
高于
返回DOS
程序结束
development of freezing plans and emergency precautions. 3, night-time setting the full-time attendant to ensure someone on duty and on duty day and night recording, while setting the Weatherman, responsible listens to and published on the weather conditions. 4, should complete the construction of the winter rainy season Shi ... Has not finished filling the pit covered with a poncho, should be drained before the next fill clean water content meet the requirements before construction began. 5, higher in the winter rain, prior to construction, priority project areas, and built a simple waste water facilities, in order to ensure normal construction. The 12th chapter, resources planning and advancement, introduction of new technology, new technology, new equipment, new material measures in order to ensure the survival of seedlings planted, in the planting process except in strict accordance with the tender specified planting methods and technical measures, the application of new technology to ensure quality: 1, the use of some new scientific achievements and improve survival. (1) ABT-3 rooting powder. This kind of rooting powder for Evergreen coniferous trees take root and valuable species of fast rooting, improve the survival rate is obvious. (2) KD-1 Super absorbent polymers. Insurance agent can enhance soil water storage, water retention and improve survival. (3) the use of puffing chicken manure. High temperature expansion
三、 详细设计
本程序首先是程序代码段开始code segment用main proc far使程序模块化,子程序
和调用程序不在同一段,方便数据调用。使各寄存器入栈,初始化,并使用乘法调整指令,
将各种字符转换为ASCII码值,方便输出。利用JNA判断,实现判断循环功能。程序的具体
代码如下:
输出九九乘法表程序设计
code segment;数据段开始
main proc far;子程序调用时使用的参数 assume cs:code;设定数据放入cs寄存器 push ds;DS寄存器入栈
mov ax,0;
push ax;ax寄存器入栈
mov bl,1;乘数赋值为1
lop2: mov bh,1;被乘数赋值为1 lop1: mov al,bh;被乘数存放如al寄存器当中 mul bl; 将bl与bh相乘 结果送到ax中 aam ;
add bh,30h ;变为ASCII的值
add bl,30h
mov cx,ax
mov dl,bh ;
mov ah,2
int 21h
mov dl,'*' ;显示乘号
mov ah,2
int 21h
mov dl,bl ;显示乘数
mov ah,2
int 21h
mov dl,'=' ;显示等号
mov ah,2
int 21h
cmp ch,0 ;查看高位有没有值
je tu;等于转移
add ch,30h ;若有则显示
mov dl,ch
mov ah,2
int 21h
tu:add cl,30h ;否则显示低位
mov dl,cl
mov ah,2
int 21h
mov dl,' ' ;显示空格
development of freezing plans and emergency precautions. 3, night-time setting the full-time attendant to ensure someone on duty and on duty day and night recording, while setting the Weatherman, responsible listens to and published on the weather conditions. 4, should complete the construction of the winter rainy season Shi ... Has not finished filling the pit covered with a poncho, should be drained before the next fill clean water content meet the requirements before construction began. 5, higher in the winter rain, prior to construction, priority project areas, and built a simple waste water facilities, in order to ensure normal construction. The 12th chapter, resources planning and advancement, introduction of new technology, new technology, new equipment, new material measures in order to ensure the survival of seedlings planted, in the planting process except in strict accordance with the tender specified planting methods and technical measures, the application of new technology to ensure quality: 1, the use of some new scientific achievements and improve survival. (1) ABT-3 rooting powder. This kind of rooting powder for Evergreen coniferous trees take root and valuable species of fast rooting, improve the survival rate is obvious. (2) KD-1 Super absorbent polymers. Insurance agent can enhance soil water storage, water retention and improve survival. (3) the use of puffing chicken manure. High temperature expansion
mov ah,2
int 21h
sub bh,30h ;将ASCII还原为BCD数 sub bl,30h
inc bh ;将被乘数加一
cmp bh,bl ;比较看是不是要换行 jna lop1;
mov dl,0ah ;换行与置首位显示 mov ah,2
int 21h
mov dl,0dh;置于首位置并显示 mov ah,2
int 21h
inc bl;否则乘数加一
cmp bl,9;比较乘数与9的大小,是不是要结束
jna lop2
mov ah,4ch ;返回dos
int 21h
main endp
code ends
end main
调试分析
例如,输入程序名无错误,即可输出
四、 测试结果示例
development of freezing plans and emergency precautions. 3, night-time setting the full-time attendant to ensure someone on duty and on duty day and night recording, while setting the Weatherman, responsible listens to and published on the weather conditions. 4, should complete the construction of the winter rainy season Shi ... Has not finished filling the pit covered with a poncho, should be drained before the next fill clean water content meet the requirements before construction began. 5, higher in the winter rain, prior to construction, priority project areas, and built a simple waste water facilities, in order to ensure normal construction. The 12th chapter, resources planning and advancement, introduction of new technology, new technology, new equipment, new material measures in order to ensure the survival of seedlings planted, in the planting process except in strict accordance with the tender specified planting methods and technical measures, the application of new technology to ensure quality: 1, the use of some new scientific achievements and improve survival. (1) ABT-3 rooting powder. This kind of rooting powder for Evergreen coniferous trees take root and valuable species of fast rooting, improve the survival rate is obvious. (2) KD-1 Super absorbent polymers. Insurance agent can enhance soil water storage, water retention and improve survival. (3) the use of puffing chicken manure. High temperature expansion
首先在模拟dos环境进入程序,测试结果如下图:
五、 心得体会
通过本次汇编课程设计,我深刻感受到了汇编语言在程序运行效率,以及时间、空间上的优越性。对汇编中常用的寄存器有了一定的了解,了解了一些子程序调用时需使用的参数如main proc far和main proc near等。同时对程序设计的基本步骤有了一定的了解,此次编程对编程知识了解太少,动手能力不够强,以后在程序的调试过程在不断完善功能,使程序功能更强大,能够处理更多的错误,处理更多的异常。本次课程设计,我感受到编程成功带来的成就感,也感受到的汇编语言的特点。
参考文献
[1] 钱晓捷.微机原理与接口技术,基于IA-32处理器和32位汇编语言[M].2008年1月:30-100
6月:56-70 [2] 陈涛.16/32位微机原理,汇编语言及接口技术[M]. 2008年
[3] 白中英.计算机组成原理[M].2008年1月:45-53
汇编语言程序设计:从DOS到Windows[M].2006年10月:101-120 [4] 张雪兰.
[5] 王爽. 汇编语言[M]. 2008年3月:135-140
development of freezing plans and emergency precautions. 3, night-time setting the full-time attendant to ensure someone on duty and on duty day and night recording, while setting the Weatherman, responsible listens to and published on the weather conditions. 4, should complete the construction of the winter rainy season Shi ... Has not finished filling the pit covered with a poncho, should be drained before the next fill clean water content meet the requirements before construction began. 5, higher in the winter rain, prior to construction, priority project areas, and built a simple waste water facilities, in order to ensure normal construction. The 12th chapter, resources planning and advancement, introduction of new technology, new technology, new equipment, new material measures in order to ensure the survival of seedlings planted, in the planting process except in strict accordance with the tender specified planting methods and technical measures, the application of new technology to ensure quality: 1, the use of some new scientific achievements and improve survival. (1) ABT-3 rooting powder. This kind of rooting powder for Evergreen coniferous trees take root and valuable species of fast rooting, improve the survival rate is obvious. (2) KD-1 Super absorbent polymers. Insurance agent can enhance soil water storage, water retention and improve survival. (3) the use of puffing chicken manure. High temperature expansion