tags:

views:

49

answers:

0

I'm learning assembly using the MARIE program but I cant figure out hot to do this this is the question from the book

divide one number by another and store the quotient and the remainder in two different memory locations.

this is what I have so far what am I doing wrong? FYI there is no divide or multiplication built into the program so I have to do it using a loop but i guess im missing something.

the program can be had here http://computerscience.jbpub.com/ecoa/2e/downloads/MarieSim-v1.3.01.zip

ORG 100
Input           / Enter a number
Store X         / Saves the number 
Input           / Enter a number
Store Y         / Saves the number
Load Zero       / Move 0 into AC
Store Z         / Set Z to 0
If, Load Z      / Load Z
Skipcond 400    / If AC=0 (Z=0), skip the next instruction
Jump Endif      / Jump to Endif if X is not greater than 1
Then, Load X
Subt Y          / X - Y
Store X         / X = X - Y
Endif, Load Z   / Load Z into AC
Add One         / Add 1 to Z
Store Z         / Z = Z + 1
Output          / Print to screen
Halt            / Terminate program
X, Dec 0        / X has starting value
Y, Dec 0        / Y has starting value
Z, Dec 0
One, Dec 1      / Use as a constant
Zero, Dec 0     / Use as a constant
END