divide overflow急,32位除法源程序:.486DATA SEGMENTNUM1 DD 10000010HNUM2 DW 1000HNUM3 DW NUM4 DW DATA ENDSCODE SEGMENTASSUME CS:CODE,DS:DATASTART:MOV AX,DATAMOV DS,AXLEA SI,NUM1MOV AX,[SI]MOV DX,[SI+2];CWDMOV CX,NUM2;MOV CX,2DIV CXMOV NUM3,DXM
来源:学生作业帮助网 编辑:作业帮 时间:2024/11/17 15:35:48
divide overflow急,32位除法源程序:.486DATA SEGMENTNUM1 DD 10000010HNUM2 DW 1000HNUM3 DW NUM4 DW DATA ENDSCODE SEGMENTASSUME CS:CODE,DS:DATASTART:MOV AX,DATAMOV DS,AXLEA SI,NUM1MOV AX,[SI]MOV DX,[SI+2];CWDMOV CX,NUM2;MOV CX,2DIV CXMOV NUM3,DXM
divide overflow急,32位除法
源程序:
.486
DATA SEGMENT
NUM1 DD 10000010H
NUM2 DW 1000H
NUM3 DW
NUM4 DW
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START:MOV AX,DATA
MOV DS,AX
LEA SI,NUM1
MOV AX,[SI]
MOV DX,[SI+2]
;CWD
MOV CX,NUM2
;MOV CX,2
DIV CX
MOV NUM3,DX
MOV NUM4,AX
MOV AH,4CH
INT 21H
CODE ENDS
END START
divide overflow急,32位除法源程序:.486DATA SEGMENTNUM1 DD 10000010HNUM2 DW 1000HNUM3 DW NUM4 DW DATA ENDSCODE SEGMENTASSUME CS:CODE,DS:DATASTART:MOV AX,DATAMOV DS,AXLEA SI,NUM1MOV AX,[SI]MOV DX,[SI+2];CWDMOV CX,NUM2;MOV CX,2DIV CXMOV NUM3,DXM
整数32位除16位有一半的机会Divide overflow,所以除之前先要识别再处理.
可以用高16位被除数与16位除数比较,如果高16位>=除数,用例外程序进行分支处理.