Take into account that if the byte at tops
is 0, the loop will actually run 256 times, and the result will overflow. In fact, the result will overflow with any value equal or greater than 23.
This program takes into consideration both issues. Result is in 16 bit HL register.
ld a,(tops)
ld hl,0
ld d,0
or a
jr z,EndSum
ld e,a
Loop: add hl,de
dec e
jr nz,Loop
EndSum: