OK,
32-bit-arithemtik,
sometimes I'm happy to have learned the basics of our job (on a pdp/8 with 12-bit-words an silly switches and lamps on the front).
Div-by-10 ... uuuh ... I feel sleepy!
$7FFFFFFF is decimal 2147483647 .... uuuh, the big one !
I think, you will deal with 7-count numbers....
Just look, if the number is bigger then 999999:
Flag=0
if High_Word>$F Then Flag=1
if High_Word=$F AND Low_Word>$423F Then Flag=1
If it is bigger, count how often by subtracting 1000000 !
Ct=0
If Flag Then
Repeat
If Low_Word<$4240 Then High_Word=High_Word-1
Low_Word=Low_Word-$4240:Ct=Ct+1
[...] copy **** from above
Until Flag=0
Endif
You got an digit ! Just Store or print it ! (LCDWRITE "0"+Ct)
Multiply the rest by 10 !
Gosub Rotate32 (x2)
High_Copy=High_Byte:Low_Copy=Low_Byte
Gosub Rotate32:Gosub Rotate32 (all together x8)
High_Word=High_Word+High_Copy
If Low_Word.15 AND Low_Copy.15 Then High_Word=High_Word+1:Low_Word.15=0:Low_Copy.15=0
Flag=Low_Word.15 or Low_Copy.15
Low_Word=Low_Word+Low_Copy:If Flag AND (Low_Word.15=0) Then High_Word=High_Word+1
Rotate32:
High_Word=High_Word<<1:If Low_Word.15 Then High_Word.0=1
Low_Word=Low_Word<<1:Return
uuuuh ... with assembler its much smoother because of the carry-flag.
Repeat it seven times !
Go sleep!
PBP 2.50C, MCS+ 3.0.0.5, MPLAB 8, MPASM 5.14, ASIX Presto, PoScope, mE mikroBasic V7.2, PICKIT2
Bookmarks