Hi, I have a procedure I found and modified a little to work 'stand alone' with some of my porgrams. However it uses the 16 bit registers only. I would like to use the 32 bit registers, so that I can have larger numbers in my programs. I am kind of new to assembly, so any help would be cool. So here is the code, how can it be modifed to work with EAX, etc?
; INTA proc. INTager to Ascii conversion
; in your data segment you must define:
; digits db 10 DUP (30h)
; buff dw 0
; Caller passes AX= number to be translated into ascii
; returns a string of length buff, located at DS:DIGITS+10-buff...
; If you want to print this using int 21h (ah=40h)
; BX= 1
; CX= buff (number of bytes to print)
; DX= offset of digits+10-buff (thats the start of your string)
; AH= 40h
; call INT 21h
inta proc
push di ; save di
mov bx,10
mov si, offset digits
add si,9
back:
xor dx,dx
div bx
or dl,30h
mov [si],dl
inc buff
dec si
cmp ax,0
ja back
pop di ;restore di
ret
inta endp
Try the DWTOA procedure in the MASM32 library.
; dwtoa proc dwValue:DWORD, lpBuffer:DWORD
invoke dwtoa,number,ADDR buffer
What if I do not want to use dwtoa? Can I just hard code something myself? If its possible, how would i go about it?
Sure, just write your own version.
Of course you can do it yourself :bg
..if only as a learning experience :wink
So.. what you need to think about it how to 'extract' the value to turn it into ascii.
Little hint: DIVIDE by 10
Ok, I will write my own version, I will need to take a look at dwtoa procedure. Where is it located? (I have masm32, dont use it much yet) Also, is it in readable format? Does it use other procedures that are integrated into the masm32 library?
Do I have to learn ALL of the integrated functions in masm32 in order to understand ONE simple procedure? I am all for making procedures not so tangled up with others.
So anyways, where is this dwtoa located?
Have you tried searching the MASM32 folder? (start, search, c:\masm32, contents "dwtoa"?)
I was just scared to look in there. The last time i looked at a proc. it was very scary stuff, all entangled in other procedures. This one doesnt seem to be.
Thank you.