仅当此算法最常见时,我的程序才会显示此显示:
digits1 digits2 digits3%DIG == digits2 digits3%DIG == digits3%DIG = rem
dig1,2,3 = the digits of the nember
Dig = the Divisor
该计划非常有效,(000,1); (999,1)... 但如果我像这样尝试输入(999,5); (999,9) 该程序返回"分区再保留不等于" 当正确的回归应该是:
"999%5 = 99%5 = 9%5 = 4
感谢您的帮助
;
; LAB 3 KFIR & ILAN
;
.MODEL SMALL
.STACK 100h
.DATA
DisplayString DB 'Please Enter Number (from 000 up to 999):',13,10,'$'
DisplayStringDIG DB 13,10,'Please Enter Digit (from 0 up to 9):',13,10,'$'
DisplayStringResY DB 13,10,'XXX mod X == XX mod X == X mod X = X',13,10,'$'
DisplayStringResN DB 13,10,'The divisions remainer is NOT equal',13,10,'$'
d1 DB ?
d2 DB ?
d3 DB ?
dig DB ?
NUM DB ?
rem DB ?
ten db 10
handret DB 100
.CODE
ProgStart:
MOV AX,@DATA ; DS can be written to only through a register
MOV DS,AX ; Set DS to point to data segment
MOV AH, 9 ; set print option for int 21h
MOV DX, OFFSET DisplayString ; set DS:DX to point to DisplayStirng
INT 21h
MOV AH, 1 ; set read option for int 21h
INT 21h ; read
MOV d1 ,AL
MOV DisplayStringResY[2],AL ; Put insert user digit in the original string
SUB d1, '0' ; Ascii to int
MOV AH, 1 ; set read option for int 21h
INT 21h ; read
MOV d2 ,AL
MOV DisplayStringResY[3],AL; Put insert user digit in the original string
MOV DisplayStringResY[15],AL
SUB d2, '0' ; Ascii to int
MOV AH, 1 ; set read option for int 21h
INT 21h ; read
MOV d3 ,AL
MOV DisplayStringResY[4],AL; Put insert user digit in the original string
MOV DisplayStringResY[16],AL
MOV DisplayStringResY[27],AL
SUB d3, '0'; Ascii to int
MOV AH, 9 ; set print option for int 21h
MOV DX, OFFSET DisplayStringDIG ;
INT 21h
MOV AH, 1 ; set read option for int 21h
INT 21h ; read
MOV dig ,AL
MOV DisplayStringResY[10],AL; Put insert user digit in the original string
MOV DisplayStringResY[22],AL
MOV DisplayStringResY[33],AL
SUB dig, '0'
MOV AL ,d3
MOV AH,0
DIV dig
MOV rem, ah
ADD AH,'0' ; int to Ascii
MOV DisplayStringResY[37],AH; Put insert rem digit in the original string
mov al,d2
mul ten
add al,d3
MOV NUM,AL
MOV AH,0
DIV dig
CMP AH,rem
JNE WorngRES ; Jump and print mess if not Equal
MOV AL,d1
mul handret
add AL,NUM
MOV AH,0
DIV dig
CMP AH,rem
JNE WorngRES ; Jump and print mess if not Equal
MOV AH, 9 ; set print option for int 21h
MOV DX, OFFSET DisplayStringResY ; set DS:DX to point to DisplayStirng
INT 21h
JMP EXIT
WorngRES:
MOV AH, 9 ; set print option for int 21h
MOV DX, OFFSET DisplayStringResN ; set DS:DX to point to DisplayStirng
INT 21h
EXIT:
mov ah,4ch
INT 21h ; Return to DOS (terminate program)
END ProgStart