Many years back, I solved the problem like this.
I have a variable Total defined as 4 bytes
In the routine that increments the total, I did it like this
Code:
Total var byte[4] ' packed BCD totalizer upto 99999999
asm
; assembler code embedded into PBP increments Total till 99999999 and then rolls over
incf _Total+3
movlw 100
subwf _Total+3,w
btfss status,c
goto DoneTotal
clrf _Total+3
;
incf _Total+2
movlw 100
subwf _Total+2,w
btfss status,c
goto DoneTotal
clrf _Total+2
;
incf _Total+1
movlw 100
subwf _Total+1,w
btfss status,c
goto DoneTotal
clrf _Total+1
;
incf _Total+0
movlw 100
subwf _Total+0,w
btfss status,c
goto DoneTotal
clrf _Total+0
DoneTotal:
endasm
This allows for a maximum total content of 99,99,99,99 with Total[3] being the lowest byte
Now, in the display routine, I did something like this to show the lower 6 digits. Mind you, this is only for unsigned values.
Code:
Dat = Total[2] dig 0
gosub Code2Segment ' convert to 7 segment code
gosub Dsp_Data ' display the 7 segment code
Dat = Total[2] dig 1
gosub Code2Segment
gosub Dsp_Data
Dat = Total[1] dig 0
gosub Code2Segment
gosub Dsp_Data
Dat = Total[1] dig 1
gosub Code2Segment
gosub Dsp_Data
Dat = Total[0] dig 0
gosub Code2Segment
gosub Dsp_Data
Dat = Total[0] dig 1
gosub Code2Segment
gosub Dsp_Data
I hope this will help you find some solution to your stated problem.
Cheers
Bookmarks