2025年3月8日 星期六 甲辰(龙)年 月初七 设为首页 加入收藏
rss
您当前的位置:首页 > 计算机 > 编程开发 > 汇编

汇编程序 99乘法表,已添加注释,分享一下

时间:04-20来源:作者:点击数:71

99乘法表,已添加注释,分享一下

以下是源代码:

  • assume cs:code,ds:data,ss:stack
  • data segment
  • db 100 dup(0)
  • data ends
  • stack segment
  • dw 100 dup(0)
  • stack ends
  • code segment
  • ;dl*dh=ax
  • show:
  • push si
  • push dx
  • push ax
  • ;被乘数
  • mov si,0
  • add dl,48
  • mov [si],dl
  • ;乘号
  • inc si
  • mov byte ptr [si],'*'
  • ;乘数
  • inc si
  • add dh,48
  • mov [si],dh
  • ;等号
  • inc si
  • mov byte ptr [si],'='
  • ;前面 mul dl 的积 一直是存放在 ax 中,现在拿ax 除以10 ,如果商为0 说明只有一位数,直接转换成对应的 ascii码 存入到内存中
  • inc si
  • mov dl,10
  • div dl
  • ;判断al商是否为0
  • cmp al,0
  • je zero
  • ;如果这里被执行,说明商有2位数,这里只需要把个位转换就下了,十位ah ,永远都会被转换
  • add al,48
  • mov byte ptr [si],al
  • inc si
  • ;al商为零就跳转到这里来
  • zero:
  • add ah,48
  • mov byte ptr [si],ah
  • ;结果后面加个空格方便好看
  • inc si
  • mov word ptr [si],' '
  • add si,2
  • mov byte ptr [si],'
  • ;打印
  • mov dx,0
  • mov ah,9
  • int 21h
  • pop ax
  • pop dx
  • pop si
  • ret ;返回到94行 inc dh
  • start:
  • mov ax,data
  • mov ds,ax
  • mov ax,stack
  • mov ss,ax
  • mov sp,200
  • mov cx,9
  • mov dl,1 ;dl*dh-->dl*al
  • s0:
  • push cx
  • mov dh,1 ;dh=1
  • mov cl,dl ;cl=1
  • mov ch,0 ;ch=0
  • s1:
  • mov al,dh ;al=1
  • mul dl ;dh*dl
  • call show
  • inc dh ;dh++
  • loop s1
  • push dx
  • mov ah,2h
  • mov dl,0ah
  • int 21h
  • mov ah,2h
  • mov dl,0dh
  • int 21h
  • pop dx
  • inc dl ;dl++
  • pop cx
  • loop s0
  • mov ax,4c00h
  • int 21h
  • code ends
  • end start

 

方便获取更多学习、工作、生活信息请关注本站微信公众号城东书院 微信服务号城东书院 微信订阅号
推荐内容
相关内容
栏目更新
栏目热门