New dwtoa has two speed advatages with previous my version. And also correct the bag in version in MASM32 SP2 that I reported in prior. 1. It perform one iteration less. 'Cause cheking condition is 9 not 0. 2. Reverse string operation is replaced with shift operation with in prior putting simbols in decreasing address order. It apeared to be much faster as tests showed.


dwtoa proc public uses esi edi ebx dwValue:DWORD, lpBuffer:DWORD

   	  mov	eax, dwValue
	  mov edi, 
	  or eax,eax	;it'll set both sf and zf
	  jnz sign
zero:     mov word ptr ,30h
	     ret
sign:	  jns pos		;sf already set  by or eax,eax we don't need cmp it again
	  mov byte ptr ,'-'
	  neg eax
	  inc edi
pos:	  
	mov ecx,429496730
	mov byte ptr [10],0
	lea esi, [9]
	cmp eax,10
	jl less10

@@:	mov ebx,eax
	mul ecx		
	mov eax,edx	;edx == reminder of division eax by 10

	lea edx,
	add edx,edx
	.IF edx > ebx ;check for exeption array
	sub edx,10    ;correct result
	dec eax
	.ENDIF

	sub ebx,edx
	add bl,30h
	mov ,bl
	dec esi
	cmp eax,9	;don't do last iteration if it's already figure
	ja @B

less10:  
	or al,30h		;just convert it to simbol
	mov edx,	;shift to the beginning of the buffer
	or eax,03030h
	mov ,al
	mov ecx,
	mov eax,
	mov [4],ecx
	mov ,eax
	mov [8],edx
    ret

dwtoa endp
Posted on 2001-04-18 09:42:00 by The Svin
Excerpt from MASM programmer's guide concerning those labels:
Anonymous Labels When you code jumps in assembly language, you must invent many label names. One alternative to continually thinking up new label names is to use anonymous labels, which you can use anywhere in your program. But because anonymous labels do not provide meaningful names, they are best used for jumping over only a few lines of code. You should mark major divisions of a program with actual named labels. Use two at signs (@@) followed by a colon (:) as an anonymous label. To jump to the nearest preceding anonymous label, use @B (back) in the jump instructionís operand field; to jump to the nearest following anonymous label, use @F (forward) in the operand field. The jump in the following example targets an anonymous label: jge @F . . . @@: The items @B and @F always refer to the nearest occurrences of @@:, so there is never any conflict between different anonymous labels.
Posted on 2001-04-21 02:22:00 by Qweerdy
less10: or al,30h ;just convert it to simbol mov edx, ;shift to the beginning of the buffer ; or eax,03030h ! remove this line. it was left after experimenting with aam :) The Svin. PS. I'll answer later.
Posted on 2001-04-21 05:59:00 by The Svin
I just happened to remember this was somewhere in "TFM" :D (Oh yeah, and it beats explaining it myself - microsofts greatest invention IMO is cut & paste :P)
Posted on 2001-04-21 11:30:00 by Qweerdy