Thanks Richard,
I won't pretend to comprehend the assembly voodoo but I think we can shave another BYTE worth of RAM off that thing by declaring Result as a BYTE instead of a WORD. At least it seems to work :-)
/Henrik.
Thanks Richard,
I won't pretend to comprehend the assembly voodoo but I think we can shave another BYTE worth of RAM off that thing by declaring Result as a BYTE instead of a WORD. At least it seems to work :-)
/Henrik.
Richard,
Just wanted to thank you once again, the code is now incorporated in my project and I can display my two 32bit variables nicely.
I hardcoded the divisor to 100k and got rid of the Divisor variable. It grew the codebase by 230bytes and 34bytes of RAM out of which 11 is an array to which I write the resultCode:DWORDtoString: CALL DivBy100k ' QUOTL top word, Remainder low word. ' Get Remainder into PBP system variables in preparation for DIV32 ASM MOVE?BB Remainder, R2 MOVE?BB Remainder + 1 , R2 + 1 MOVE?BB Remainder + 2, R0 MOVE?CB 0, R0 + 1 RST?RP ENDASM Result = DIV32 10000 Remains = R2 IF QUOTL THEN ARRAYWRITE DWordString, [DEC QUOTL, DEC Result, DEC4 Remains, 0] ELSEIF Result THEN ARRAYWRITE DWordString, [DEC Result, DEC4 Remains, 0] ELSE ARRAYWRITE DWordString, [DEC Remains, 0] ENDIF
Is it possible to describe the method or algorithm to get the decimal from the possible 8 hexadecimal of 32 bit number.... the conversion itself is pretty straight forward but the 8 bit manipulations are confusing...
.
.![]()
Just wanted to thank you once again
No problem Henrik glad you could make it work for you. its good to exercise the grey matter occasionally
@amgen
to which 8bit manipulations do you refer ?the conversion itself is pretty straight forward but the 8 bit manipulations are confusing...
Warning I'm not a teacher
Consider this code.
Is this what you're looking for?Code:dim array[8] as byte ' your hex bytes ($00-$0F) are input here from MSN to LSNibble decimal as long ' 32 bit value decimal = 0 for i = 0 to 7 decimal = decimal * 16 ' nibble max value is 16, so multiply the existing value by 16 to move decimal value one nibble to the left decimal = decimal + array[i] ' add in the new nibble next ' at this point, decimal contains the converted value of the hex digits
Bookmarks