My first post - so forgive me if this sound crap (I have searched the posts but couldn't find anything)

I am tring to write my first asm program that monitors virtual memory. I get the value back in a MEMORYSTATUS struct. I now want to be able to format this into thousand units e.g 1,234,567,890.

My problem is I keep crashing my prog when using the following code.

Here are snippets of the program
debug db "%lu ",0

buffer db 255 dup (?)
sizebuffer db 255 dup (?)
mov nf.Grouping,3
mov nf.LeadingZero,0
mov nf.NumDigits,3
mov nf.lpDecimalSep, "."
mov nf.lpThousandSep , ","
mov nf.NegativeOrder,0
invoke GlobalMemoryStatus, addr memStat
invoke wsprintf, ADDR sizebuffer,addr debug, memStat.dwTotalPhys ; convert to a chars
invoke GetNumberFormat,0,0, addr sizebuffer,0, ADDR buffer,255
invoke SendMessage, hStatus, SB_SETTEXT, 0, ADDR buffer

if I replace the crash line with

invoke GetNumberFormat,0,0, addr memStat.dwAvailVirtual,0, addr buffer,20

it doesn't crash but I dont get any output.

If someone knows how to use this function or a better way to get the required output I would be mst greateful if they could post it.



PS This sight is great and I try to follow all the postings (It's a little bit difficult sometimes as I coming from a vb background to understand, but I keep on trying)
Posted on 2002-03-20 10:01:13 by taff
I managed to get this git to work in the end

added this

szComma db ",",0
szDecimal db ".",0

and chaged this

mov nf.lpDecimalSep, "."
mov nf.lpThousandSep, ","


mov nf.lpDecimalSep,offset szDecimal
mov nf.lpThousandSep,offset szComma

(they needed to be null terminated strings)

There's a difference a few hours rest make. And I agree with someone comemets on a previous thread don't assume anything in assembler, unlike in VB.
Posted on 2002-03-21 03:45:38 by taff
In case if you are interested in much faster way to format with
comma delimiter:

InsertComma proc uses esi edi len,lpszStringIn,lpszStringOut
mov esi,lpszStringIn
mov edi,lpszStringOut
mov ecx,-1
mov eax,len
@@: inc ecx
sub eax,3
jnbe @B
test ecx,ecx ;if length less than 4
je lastmove
mov edx,[esi]
add eax,3
mov [edi],edx
add esi,eax
mov byte ptr [edi][eax],2Ch
dec ecx
lea edi,[edi][eax][1]
je lastmove
@@: mov eax,[esi]
add esi,3
mov al,2Ch
dec ecx
mov [edi],eax
lea edi,[edi][4]
jne @B
mov eax,[esi]
mov [edi],eax
InsertComma endp
Posted on 2002-03-21 10:24:26 by The Svin