b1 = 1 : b2 = 2 : b3 = 3 : b4 = 4 : b5 = 5 : b6 = 6 : b7 = 7 :b8 = 8 : b9 = 9
symbol Hexptr = b10
symbol Sumptr = b11
symbol Incptr = b12
symbol Decval = b13
symbol IncLW = 32 ; Increasing decimal value (in binary format)
symbol SumLW = 40 ; Present decimal value (in binary format)
symbol HexLW = 48 ; Accumulating decimal value (in binary format)
poke IncLW,1 ; Initialise Increment (Higher word must be clear)
poke SumLW,1 ; Initialise Sum (Higher word and Hex words must be clear)
for bptr = 1 to 9
for Decval = 1 to 9
if @bptr = Decval then ; Add decimal value into binary field
Sumptr = HexLW ; Running total
Incptr = SumLW ; value to add
call sum ; Result returned at Sumptr
endif
Sumptr = SumLW
Incptr = IncLW
call sum ; Next decimal value (in binary format),ie: 1,2..9,10,20..90,100,200..
next
sumptr = sumlw
incptr = inclw
peek Sumptr,b0 : poke Incptr,b0 : inc Sumptr : inc Incptr ; Copy sum to next increment
peek Sumptr,b0 : poke Incptr,b0 : inc Sumptr : inc Incptr
peek Sumptr,b0 : poke Incptr,b0 : inc Sumptr : inc Incptr
peek Sumptr,b0 : poke Incptr,b0
next
sertxd("$")
bptr = HexLW + 3
do
b0 = @bptr / 16
lookup b0,("0123456789ABCDEF"),b0
sertxd(b0)
b0 = @bptrdec // 16
lookup b0,("0123456789ABCDEF"),b0
sertxd(b0)
loop until bptr < HexLW
sertxd(cr,lf)
;; Result Should be = 3ADE68B1
end
sum:
peek Sumptr,b14,b15,b16,b17 ; Read w8:w7 (Hi:Lo)
peek Incptr,b18,b19,b20,b21 ; Read w10:w9
w7 = w7 + w9 ; Add Low words
w8 = w8 + w10 ; Add High words
if w7 < w9 then ; Carry to high word
inc w8
endif
poke Sumptr,b14,b15,b16,b17 ; Store sum
return