I am trying to write a program in the MARIE assembly language that will divide two numbers using repeated subtraction. I need to count the number of subtractions needed before reaching zero or minus numbers. I am having a few problems with this, here is my code so far:
Load A
Store A
Load, Load A
Subt B
Skipcond 800
Jump Endloop
Load C
Add One
Store C
Endloop, Output
Halt
A, DEC 10
B, DEC 2
C, DEC 0
One, DEC 1
Any help would be much appreciated as I have been struggling with this for a while
UPDATE:
I have changed my code but now get an infinite loop - any ideas how I can fix this?
Input
Store A
Input
Store B
Load A
Skipcond 800
Jump Endloop
Loop, Subt B
Store A
Load X
Add One
Store X
Load A
Skipcond 400
Jump Loop
Load X
Endloop, Halt
A, DEC 0
B, DEC 0
X, DEC 0
One, DEC 1