Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Trouble with simple Assembly

Status
Not open for further replies.

G3orgeLuc4s

Programmer
Dec 11, 2007
2
US
So I wrote these simple multiplication and devision assembly programs.. I'm getting some errors I don't really understand... my multiplication program always outputs 0... and the division one I'm not even sure what it's doing...
Anyways here's the code:

Multiplication:

.BEGIN
IN A
IN B
CLEAR COUNT
CLEAR SUM
LOOP: LOAD B
COMPARE COUNT
JUMPGT PRINT
LOAD SUM
ADD A
INCREMENT COUNT
JUMP LOOP
PRINT: OUT SUM
HALT
A: .DATA 0
B: .DATA 0
COUNT: .DATA 0
SUM: .DATA 0
.END


Division:

.BEGIN
IN A
IN B
CLEAR Q
LOAD A
STORE R
LOOP: LOAD B
COMPARE R
JUMPLT PRINT
LOAD R
SUBTRACT B
INCREMENT Q
JUMP LOOP
PRINT: OUT Q
OUT R
HALT
A: .DATA 0
B: .DATA 0
Q: .DATA 0
R: .DATA 0
.END




Thanks for your time.
 
Just a FYI: some of the indentation is messed up due to me copying it to the board.. the indentation is correct in the actual program
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top