📄 42.asm
字号:
dseg segment
data db 100
dseg ends
sseg segment stack
stack db 20 dup(0)
sseg ends
cseg segment
assume cs:cseg,ds:dseg
assume ss:sseg
start: mov ax,dseg
mov ds,ax
mov ax,sseg
mov ss,ax
mov sp,size stack
xor ax,ax
mov bh,0 ;数字1初始化为0
mov bl,9 ;递减9次
outt: inc bh
mov dh,bh ;显示数字2 如: 1(bh)*1(dh),把bh赋给dh
inn: call dis1
call star
call dis2
call equl ;等号
mov al,bh ;乘法第一项
mul dh ;和第二项相乘
;mov ah,al ;因为结果不超过127(9*9=81),所以把al赋给ah不会出错(这步意义在于可能的al值dis后改变,考虑删掉)
call dis3 ;显示乘积
dec dh ;内层计数器减1(数字2减1) 如: 2*2后变为2*1
jnz spac ;减1后不为0则显示' ' 和后面输出隔开
call cr_lf ;为0则进行下一个数字
dec bl ;外层计数器减1
jnz outt ;外层计数器不为0继续下一个数字
mov ah,4ch ;退出程序
int 21h
spac: call spa ;打印一个空格
jmp inn ;调到内层循环
;--------------------------
;显示数字1
dis1 proc near
mov dl,bh
add dl,30h
mov ah,2
int 21h
ret
dis1 endp
;-------------------------
;显示数字2
dis2 proc near
mov dl,dh
add dl,30h
mov ah,2
int 21h
ret
dis2 endp
;--------------------------
;显示数字3
dis3 proc near
push cx
mov cl,10
cbw
div cl
push ax
mov dl,al
add dl,30h
mov ah,2
int 21h
pop ax
mov dl,ah
add dl,30h
mov ah,2
int 21h
pop cx
ret
dis3 endp
;-------------------------
;显示'*'
star proc near
mov dl,'*'
mov ah,2
int 21h
ret
star endp
;-------------------------
;显示' '
spa proc near
mov dl,' '
mov ah,2
int 21h
ret
spa endp
;-------------------------
;显示'='
equl proc near
mov dl,'='
mov ah,2
int 21h
ret
equl endp
;-------------------------
;子程序:回车换行
cr_lf proc near
mov ah,2
mov dl,0dh
int 21h
mov dl,0ah
int 21h
ret
cr_lf endp
;---------------------------
cseg ends
end start
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -