作业帮 > 综合 > 作业

汇编编程(找水仙花数):invalid instruction operands是什么错误

来源:学生作业帮 编辑:神马作文网作业帮 分类:综合作业 时间:2024/11/16 00:08:06
汇编编程(找水仙花数):invalid instruction operands是什么错误
DATAS SEGMENT
;此处输入数据段代码
IN1 DB 13,10,'The number is :',13,10,'$'
N DW 100
A1 DB 0;百位数字除后余数
A2 DB 0;十位数字除后余数
B1 DW 0;百位立方之和
B2 DW 0;十位立方之和
B3 DW 0;个位立方之和
SUM DW 0 ;各位立方之和
M DB 0;显示时的中间变量
DATAS ENDS
STACKS SEGMENT
;此处输入堆栈段代码
STACKS ENDS
CODES SEGMENT
ASSUME CS:CODES,DS:DATAS,SS:STACKS
START:
MOV AX,DATAS
MOV DS,AX
;此处输入代码段代码
MOV CX,900
;求百位数
L1:XOR AX,AX
\x05MOV AX,N
\x05MOV BL,100
\x05DIV BL;AL->商(百位数),AH->余数
\x05MOV A1,AH
\x05MOV DL,AL
\x05;百位数做立方运算
\x05MUL AL
\x05MUL DL
\x05MOV B1,AX
\x05;求十位数
\x05MOV AL,A1
\x05MOV AH,0
MOV BL,10
DIV BL;AL->商(十位数),AH->余数(个位数)
;求十位数的立方
MOV A2,AH
MOV DL,AL
MUL AL
MUL DL
MOV B2,AX
;求个位数的立方
\x05MOV AL,A2
\x05MOV DL,AL
\x05MUL AL
\x05MUL DL
\x05MOV B3,AX
ADD DX,B1
ADD DX,B2
ADD DX,B3
MOV SUM,DX
CMP N,SUM;;;;;;;;;;;;;;;;;;;;;;;;这行有错误,并帮忙看一下能否运行,
JZ L2
INC N
\x05LOOP L1
\x05
L2:\x05LEA DI,IN1
\x05MOV AH,09H
\x05INT 21H
\x05;百位显示
\x05MOV AX,SUM
\x05MOV BL,100
\x05DIV BL
\x05MOV M,AH
\x05ADD AL,30H
\x05MOV DL,AL
\x05MOV AH,02H
\x05INT 21H
\x05;十位显示
\x05MOV AL,M
\x05MOV BL,10
\x05DIV BL
\x05ADD AL,30H
\x05MOV DL,AL
\x05MOV AH,02H
\x05INT 21H
\x05;个位数显示
\x05ADD AH,30H
\x05MOV DL,AH
\x05MOV AH,02H
\x05INT 21H
\x05
\x05MOV AH,4CH
INT 21H
CODES ENDS
END START
汇编编程(找水仙花数):invalid instruction operands是什么错误
DATAS SEGMENT
IN1 DB 13,10,'The number is :$'
A1 DB 0 ;百位数
A2 DB 0 ;十位数
A3 DB 0 ;个位数
B1 DW 0 ;百位立方
B2 DW 0 ;十位立方
B3 DW 0 ;个位立方
DATAS ENDS
CODES SEGMENT
ASSUME CS:CODES,DS:DATAS
START:
MOV AX,DATAS
MOV DS,AX
MOV CX,999
L1:
MOV AX,CX
MOV BL,100
DIV BL ;AL=百位数,AH=余数
MOV A1,AL ;百位
MOV AL,AH
MOV AH,0
MOV BL,10
DIV BL
MOV A2,AL ;十位
MOV A3,AH ;个位
CALL LIFANG ;求各个立方
MOV AX,B1
ADD AX,B2
ADD AX,B3
CMP AX,CX
JNE NEXT
CALL PRINT ;相等则显示
NEXT:
LOOP L1 ;循环到0为止
MOV AH,4CH
INT 21H
;------------------------------
LIFANG:
MOV AL,A1
MOV AH,0
MOV BX,AX
MUL BX
MUL BX
MOV B1,AX
MOV AL,A2
MOV AH,0
MOV BX,AX
MUL BX
MUL BX
MOV B2,AX
MOV AL,A3
MOV AH,0
MOV BX,AX
MUL BX
MUL BX
MOV B3,AX
RET
;------------------------------
PRINT:
LEA DX,IN1
MOV AH,9
INT 21H
MOV AH,2
MOV DL,A1 ;百
ADD DL,30H
INT 21H
MOV DL,A2 ;十
ADD DL,30H
INT 21H
MOV DL,A3 ;个
ADD DL,30H
INT 21H
RET
;------------------------------
CODES ENDS
END START
执行后显示:
c:\masm510>XX
The number is :407
The number is :371
The number is :370
The number is :153
The number is :001
c:\masm510