maybe something like this old gem
Code:
Hours VAR WORD[2] ; 32-bit (Dword) Holds up to 99999.9 hoursHoursH VAR Hours(1)
HoursL Var Hours(0)
Result Var Word
Remainder Var Word
;----[Load a 32-bit (Dword) variable into PBP registers, Prior to DIV32]--------
Asm
PutMulResult?D macro Din
MOVE?BB Din, R2
MOVE?BB Din + 1 , R2 + 1
MOVE?BB Din + 2, R0
MOVE?BB Din + 3, R0 + 1
RST?RP
endm
EndAsm
;====[Simple loop to test the HourMeter]========================================
MainLoop:
gosub AddHourTenth
Gosub ShowHourMeter
goto MainLoop ;============================================================
;----[Add 1 tenth of an hour to the hourmeter]----------------------------------
AddHourTenth:
HoursL = HoursL + 1
IF HoursL = 0 then HoursH = HoursH + 1
if (HoursH = $F) and (HoursL = $4240) then ; Roll over at 1,000,000
HoursH = 0 ; 99999.9 + .1
HoursL = 0
endif
return
;----[Display hourmeter using LCDOUT]-------------------------------------------
ShowHourMeter:
@ PutMulResult?D _Hours
Result = DIV32 1000
Remainder = R2
LCDOUT $FE, 2 ; Home Cursor
IF Result > 0 then
LCDOUT Dec Result, DEC2 Remainder/10,".",DEC1 Remainder//10
else
LCDOUT DEC Remainder/10,".",DEC1 Remainder//10
endif
return
the other way is n-bit math
like post #23 here
Bookmarks