?? 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 + -