John Chris
Senior Member
Hi there,
I'm working with the uALFAT. I have looked through BCJKiwi's work on the uALFAT and am presently making sure I understand the subroutines used to deal with the HEX, DWORD ascii string output by the uALFAT that describes media capacity, and media free space.
I would like to eventually read a string like $00040000 (equivalent to $00 $04 $00 $00 == DWORD if I understand correctly)
It seems to me that some of the elements in the process described below are required to do this:
1) Start off with 8 ascii chars representing a hex DWORD e.g. 00040F00 (see uALFAT documentation)
2) divide into 4 groups of 2 ascii chars representing a hex byte e.g. 00, 04, 0F, 00
3) convert 2 ascii chars representing hex byte into numeric.
4) LET DWORD_pos = 0 ' Eprom pointer. Write $00 (call this mmsb) to DWORD_pos + 0. Write $04 (msb) to DWORD_pos + 1, $0F (lsb) to DWORD_pos + 2 and $00 (llsb) to DWORD_pos + 3
5) pass DWORD_pos to a subroutine that takes 4 bytes and displays an ascii string representing a 32-bit number.
Really, one would want to further process this DWORD into a) rounded number and b) a number that has units of 'megabytes of memory' as opposed to 'bytes of memory'. Here, 32-bit precision is not required, A WORD variable would be sufficient.
Perhaps the whole procedure would be simpler if one represented (or merely thought about) the DWORD as two WORD variables.
The last item in the list (5) is the one that I need help with.
Stepping away from all the complications I have presented in my description above, Can anyone propose a method to convert 4 bytes or 2 words into an ascii string representing a 32 bit decimal number?
Any thoughts / suggestions are greatly appreciated.
Chris
I'm working with the uALFAT. I have looked through BCJKiwi's work on the uALFAT and am presently making sure I understand the subroutines used to deal with the HEX, DWORD ascii string output by the uALFAT that describes media capacity, and media free space.
I would like to eventually read a string like $00040000 (equivalent to $00 $04 $00 $00 == DWORD if I understand correctly)
It seems to me that some of the elements in the process described below are required to do this:
1) Start off with 8 ascii chars representing a hex DWORD e.g. 00040F00 (see uALFAT documentation)
2) divide into 4 groups of 2 ascii chars representing a hex byte e.g. 00, 04, 0F, 00
3) convert 2 ascii chars representing hex byte into numeric.
4) LET DWORD_pos = 0 ' Eprom pointer. Write $00 (call this mmsb) to DWORD_pos + 0. Write $04 (msb) to DWORD_pos + 1, $0F (lsb) to DWORD_pos + 2 and $00 (llsb) to DWORD_pos + 3
5) pass DWORD_pos to a subroutine that takes 4 bytes and displays an ascii string representing a 32-bit number.
Really, one would want to further process this DWORD into a) rounded number and b) a number that has units of 'megabytes of memory' as opposed to 'bytes of memory'. Here, 32-bit precision is not required, A WORD variable would be sufficient.
Perhaps the whole procedure would be simpler if one represented (or merely thought about) the DWORD as two WORD variables.
The last item in the list (5) is the one that I need help with.
Stepping away from all the complications I have presented in my description above, Can anyone propose a method to convert 4 bytes or 2 words into an ascii string representing a 32 bit decimal number?
Any thoughts / suggestions are greatly appreciated.
Chris
Last edited by a moderator: