0

I'm writing on of my first assembly programs in MASM, and am trying to print out a number using StdOut. Here is my code (snippet):

.data
Su dword 0
.code
start:
        mov Su, 65
        invoke StdOut, addr Su
        invoke ExitProcess, 0
end start

The problem is, instead of printing out 65, it prints out the ASCII representation A. How can I make it print out an integral value?

1 Answer 1

3

StdOut takes a string argument, so you'll need to convert the dword to a decimal string. This is not hard to do by hand, or you can look for a library function to do it. The discussion at http://www.masm32.com/board/index.php?topic=16316.0 would suggest one of dwtoa, itoa, or crt_itoa, depending on what libraries you're linking with. (Note that the link is talking about ascii->integer, so it uses atoi and atodw.)

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.