问题描述
- 汇编语言问题:怎么改成用十六进制输出1~9的立方,怎么控制多次输入
-
DATA SEGMENT
BUF DB 0AH,0DH,'PLEASE INPUT X(0...9):$'
TABLE DW 0,1,4,9,16,25,36,49,64,81
X DB ?
RESU DW ?
OUTD DB 0AH,0DH,'THE RESULT IS:$'
INERR DB 0AH,0DH,'INPUT ERROR!$'
DATA ENDS
CODE SEGMENT
ASSUME DS:DATA,CS:CODE
START:MOV AX,DATA
MOV DS,AX
MOV DX,OFFSET BUF
MOV AH,09H
INT 21H
MOV AH,01H
INT 21H
CMP AL,'0'
JB LERR
CMP AL,'9'
JA LERR
AND AL,0FH
MOV X,AL
MOV DX,OFFSET OUTD
MOV AH,09H
INT 21H
MOV BX,OFFSET TABLE
MOV AL,X
MOV AH,0
SHL AX,1
ADD BX,AX
MOV DL,[BX]
MOV DH,[BX+1]
MOV RESU,DX
MOV CL,4
SHR DL,CL
ADD DL,30H
MOV AH,2
INT 21H
MOV DX,RESU
AND DL,0FH
ADD DL,30H
MOV AH,2
INT 21H
MOV DL,48H
MOV AH,2
INT 21H
EXIT:MOV AH,4CH
INT 21H
LERR:MOV DX,OFFSET INERR
MOV AH,09H
INT 21H
JMP EXIT
CODE ENDS
END START
时间: 2024-12-27 04:38:39