- Aug 21, 2005
- 3,888
- 8
- 81
Hey guys,
I am trying to write a program that does a multiplication of two 8 bit values and displays the results on 4-seven segment LED characters. I am having difficulty with understanding what I'm doing wrong. Can someone care to digest this and tell me why it doesn't work?
I followed my code and I think I have it somewhat correct, but when I try to issue the command for this, it only adds one value.
I am trying to write a program that does a multiplication of two 8 bit values and displays the results on 4-seven segment LED characters. I am having difficulty with understanding what I'm doing wrong. Can someone care to digest this and tell me why it doesn't work?
Code:
mult: LOAD sE, sA ; load multiplicand into register sE (to be right shifted)
LOAD sF, sA ; load multiplicand to be added to total (to be left shifted)
LOAD s8, 04 ; loop counter
mult_loop: COMPARE s8,00
JUMP Z, final ; goes back to main program
CALL multiply
SUB s8,01
JUMP mult_loop
multiply: SR0 sE ; shifts multiplicand to check for carry bit
JUMP C, mult_add ; if carry = 1 is detected, add value to total
SL0 sF
RETURN
mult_add: ADD s3, sF ; register s3 for the right byte on display
ADDCY s4, 00 ; register s4 for the left byte on display
RETURN
I followed my code and I think I have it somewhat correct, but when I try to issue the command for this, it only adds one value.