News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

how to print contents of eax?

Started by lingjie, May 05, 2007, 07:44:07 PM

Previous topic - Next topic

lingjie

I want to print the integer stored in eax, how do I do that?

.386
.model flat,stdcall       ; FLAT memory model & STDCALL calling
option casemap:none       ; set code to case sensitive

include \masm32\include\masm32rt.inc
ccount  PROTO :DWORD,:BYTE


.stack  4096                  ; reserve 4096-byte stack
.data                         ; reserve storage for data

.code                              ; start of main program code
start:

mov eax, 200
print eax   ; want to print 200, this line of code gives me error

invoke ExitProcess, 0      ; return 0;
PUBLIC start


end start                          ; end of source code

MichaelW

You can use the ustr$ macro. The ;; commented statements are not necessary.

;;.386
;;.model flat,stdcall       ; FLAT memory model & STDCALL calling
;;option casemap:none       ; set code to case sensitive

include \masm32\include\masm32rt.inc
ccount  PROTO :DWORD,:BYTE


;;.stack  4096                  ; reserve 4096-byte stack
.data                         ; reserve storage for data

.code                              ; start of main program code
start:

mov eax, 200
print ustr$(eax)   ; want to print 200, this line of code gives me error

invoke ExitProcess, 0      ; return 0;
PUBLIC start


end start                          ; end of source code
eschew obfuscation

Vortex

include \masm32\include\masm32rt.inc

.data
message db 'The value of eax = %d',0

.data?
buffer db 100 dup(?)

.code

start:

    mov     eax,200
    invoke  wsprintf,ADDR buffer,ADDR message,eax
    invoke  StdOut,ADDR buffer
    invoke  ExitProcess,0

END start