winapiassemblyx86masm32

Assembly - put in buffer register value


My eax register has the following value

EAX DDCCBEE6

I want to put the value of eax to buffer so I can use it as it, I mean if I used SetDlgItemText it must set the text value of edit control to eax value which is DDCCBEE6

The value of eax is a result of math instructions


Solution

  • You can use wsprintf for that purpose:

    .data
    format  db "%X",0
    
    .data?
    buffer  db 256 dup (?)
    
    .code
    invoke wsprintfA,ADDR buffer,ADDR format,eax
    

    Note that there are safer alternatives to wsprintf, but I don't know if they can be found in the masm32 include files and import libraries.