I am trying to create a program in LMC which checks if a number evenly divides into another one (such as 10/2), with the program below I am able to do divison and halt the program as required
INP
STA DIVIDEND
INP
STA DIVISOR
LOOP LDA DIVIDEND
BRZ END
SUB DIVISOR
STA DIVIDEND
LDA ANSWER
ADD INC
STA ANSWER
BRP LOOP
END LDA ANSWER
OUT
SUB ANSWER
STA ANSWER
HLT
DIVIDEND DAT 0
DIVISOR DAT 0
ANSWER DAT 0
INC DAT 1
I need to find a way, within the same program, for LMC to recongzie that the numbers that user inputed do NOT evenly divide (such as 10/3) in which case it is to output zero and ask for two new numbers. I have tried doing this with another loop but if seems to always conflict with the loop I have for subtraction. I have tried whatever I could think and don't know how to make LMC fulfill this requiremnet while also retaining the requirement of halting the program when inputs do evenly divide