I'm not sure how you're testing your Divisor array, but it should not be filled with 3's.
What you should actually be seeing is something like this;
Code:
b = 0 : Divisor 0 = 2
b = 1 : Divisor 1 = 11
b = 2 : Divisor 2 = 4
b = 3 : Divisor 3 = 5
b = 4 : Divisor 4 = 3
Divisor[b] should always contain the low byte of the result H/w anded with $0F.
If you just want to extract individual digits from H, then let PBP do it for you with the DIG
operator.
Code:
FOR b = 0 to 4
divisor [b] = H DIG b
NEXT b
This divides by 10 returning the remainder.
Example: If H = 37234 then
b = H DIG 0 = 37234/10 = 3723.4 <-- Now b = 4
b = H DIG 1 = 37234/10 = 3723.4. 3723/10 = 372.3 <-- Now b = 3
b = H DIG 2 = 37234/10 = 3723.4. 3723/10 = 372.3. 372/10 = 37.2 <-- Now b = 2
Etc,,
Your entire program gets reduced to this;
Code:
Divisor VAR byte[5]
H VAR WORD
b VAR BYTE
Main:
H=37234
'fill divisor with digits 0 to 4 from H
FOR b = 0 to 4
divisor [b] = H DIG b
NEXT b
GOTO Main
END
Bookmarks