复习一下汇编
编写一个十进制的乘法程序,被乘数和乘数均以ASCII码的形式存放在内存中,将乘积在屏幕上显示出来
;/**
;*
; * @author Xredman
; */
DATA SEGMENT
BUF DB 'The result is: ', '$'
X1 DB 11
X2 DB 11
DATA ENDS
STACK SEGMENT PARA STACK
DB 64 DUP(?)
STACK ENDS
CODE SEGMENT
ASSUME CS: CODE, DS: DATA
START: MOV AX,DATA
MOV DS,AX
MOV AH, 9H
MOV DX, OFFSET BUF
INT 21H
MOV AL, X1
MOV BL, X2
;//实现X1和X2的相乘//////////
MUL BL
MOV BX, AX
CALL DISPLAY
MOV AH, 1H;
INT 21H
MOV AH,4CH
INT 21H
;///////////////显示数字////////////////
; 以递归调用实现
DISPLAY PROC
PUSH AX
PUSH DX
MOV AX, BX
MOV DX, 0
MOV CX, 10
DIV CX
CMP AX, 0
MOV BX, AX
JZ FUN
CALL DISPLAY
FUN: CALL DISCHAR
POP DX
POP AX
RET
DISPLAY ENDP
;//////////子程序调用,显示单个字符//////////////
DISCHAR PROC
PUSH AX
ADD DL,30H
MOV AH, 2H
INT 21H
POP AX
RET
DISCHAR ENDP
;///////////////////////////
CODE ENDS
END START
;*
; * @author Xredman
; */
DATA SEGMENT
BUF DB 'The result is: ', '$'
X1 DB 11
X2 DB 11
DATA ENDS
STACK SEGMENT PARA STACK
DB 64 DUP(?)
STACK ENDS
CODE SEGMENT
ASSUME CS: CODE, DS: DATA
START: MOV AX,DATA
MOV DS,AX
MOV AH, 9H
MOV DX, OFFSET BUF
INT 21H
MOV AL, X1
MOV BL, X2
;//实现X1和X2的相乘//////////
MUL BL
MOV BX, AX
CALL DISPLAY
MOV AH, 1H;
INT 21H
MOV AH,4CH
INT 21H
;///////////////显示数字////////////////
; 以递归调用实现
DISPLAY PROC
PUSH AX
PUSH DX
MOV AX, BX
MOV DX, 0
MOV CX, 10
DIV CX
CMP AX, 0
MOV BX, AX
JZ FUN
CALL DISPLAY
FUN: CALL DISCHAR
POP DX
POP AX
RET
DISPLAY ENDP
;//////////子程序调用,显示单个字符//////////////
DISCHAR PROC
PUSH AX
ADD DL,30H
MOV AH, 2H
INT 21H
POP AX
RET
DISCHAR ENDP
;///////////////////////////
CODE ENDS
END START