Thanks for any help.
SaveNumber db 0
holdp db " ",0
BufAdd dd 0
dwtoa PROTO :DWORD, lpBuffer: PTR BYTE
; MY CODE...
; edx is the input field
; ebx holdp is the output field
push ebx
lea ebx, holdp ; convert number
inc ebx ; save 1st byte for # sign
xor edx, edx
mov dl, SaveNumber ; filled in other parts of program
mov BufAdd, ebx
invoke dwtoa, edx, BufAdd ; Hex DD to string
; End My Code.....
; Code from the MASM32 Forum
dwtoa proc public uses esi edi dwValue:DWORD, lpBuffer:PTR BYTE
; -------------------------------------------------------------
; convert DWORD to ascii string
; dwValue is value to be converted
; lpBuffer is the address of the receiving buffer
; EXAMPLE:
; invoke dwtoa,edx,addr buffer
;
; Uses: eax, ecx, edx.
; -------------------------------------------------------------
mov eax, dwValue
mov edi, [lpBuffer]
; Is the value negative?
.if (sdword ptr eax < 0)
mov byte ptr [edi], '-' ; store a minus sign
inc edi
neg eax ; and invert the value
.endif
mov esi, edi ; save pointer to first digit
mov ecx, 10
.while (eax > 0) ; while there is more to convert...
xor edx, edx
div ecx ; put next digit in edx
add dl, '0' ; convert to ASCII
mov [edi], dl ; store it
inc edi
.endw
mov byte ptr [edi], 0 ; terminate the string
; We now have all the digits, but in reverse order.
.while (esi < edi)
dec edi
mov al, [esi]
mov ah, [edi]
mov [edi], al
mov [esi], ah
inc esi
.endw
ret
dwtoa endp
; -----------------------------------
; -----------------------------------
; Here is the mess I made of it
; It is a work in progress
SaveNumber db 0
holdp db ' ',0
BufAdd dd 0
DwValue dd 0
invoke dwtoa ; Hex DD to string
; My Code
; edx is the input field
; ebx holdp is the output field
push ebx
lea ebx,[holdp] ; convert number
inc ebx ; save 1st byte for # sign
xor edx,edx
mov dl, [SaveNumber] ; input
mov [BufAdd],ebx
invoke dwtoa ; Hex DD to string
; End My Code
; Note - do I need to pass parameters here by pushing them on the
; stack???
dwtoa:
; FRAME public uses esi edi dwValue:DWORD, lpBuffer:PTR BYTE
; -------------------------------------------------------------
; convert DWORD to ascii string
; dwValue is value to be converted
; lpBuffer is the address of the receiving buffer
; EXAMPLE:
; invoke dwtoa,edx,addr buffer
;
; Uses: eax, ecx, edx.
; -------------------------------------------------------------
xor eax,eax
mov al,[SaveNumber]
mov [dwValue],eax
mov edi,[BufAdd]
; Is the value negative?
; .if (sdword ptr eax < 0)
?? cmp ADDR [dwValue],< 0
jnl >n60
mov B[edi], '-' ; store a minus sign
inc edi
neg eax ; and invert the value
; .endif
n60:
mov esi,edi ; save pointer to first digit
mov ecx,10
; .while (eax > 0) ; while there is more to convert...
doitagn:
cmp eax,0 ; while there is more to convert...
jle >n61
xor edx,edx
div ecx ; put next digit in edx
add dl,0' ; convert to ASCII
mov [edi],dl ; store it
inc edi
jmp doitagn
; .endw
n61:
; mov byte ptr [edi], 0 ; terminate the string
mov B[edi], 0 ; terminate the string
; We now have all the digits, but in reverse order.
; .while (esi < edi)
doitagn2:
?? cmp (esi < edi)
jge >n62
dec edi
mov al,[esi]
mov ah,[edi]
mov [edi],al
mov [esi],ah
inc esi
jmp doitagn2
; .endw
n62:
ret
;dwtoa endf