Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

get contents of a register?

Started by guntheria, March 03, 2014, 12:29:32 PM

Previous topic - Next topic


Mega simple question, but very frustrating.

All I want to do is get the output the value of a register. I'm working in a WinAsm console program.

Main Proc
   Print_Text Msg         ; set in .inc file, works
        Print_Text CRLF       ;  new line
         MOV EAX, 22            ; me goofing off
                                         ; All I want to do is output (or print) the value of EAX
   Get_Input Msg4,inbuf  ;holds the console open
Main EndP


  invoke crt_printf, chr$(" Value:%d"), eax


Quote from: guntheria on March 03, 2014, 12:29:32 PM; All I want to do is output (or print) the value of EAX

I would use deb, but print str$(eax) works, too. It depends on the libraries you are using:
crt_printf requires
deb needs
str$ needs

With crt_printf and str$ you need to preserve eax if you still need its value after displaying it.


Thank you for your responses, but I've tried just about everything and keep getting errors. I am just starting to explore assembly and downloaded masm32 and WinAsm and created a Bare Bones Console app through the wizard. Assume I know nothing.

Here's what I've tried:

invoke crt_printf, chr$(" Value:%d"), eax 


        C:\MASMx\MyConsole2\Console.Asm(33) : error A2006: undefined symbol : crt_printf

      Then added and got give me the errors:
        C:\MASMx\MyConsole2\Console.Asm(33) : error A2006: undefined symbol : chr$
        C:\MASMx\MyConsole2\Console.Asm(33) : error A2114: INVOKE argument type mismatch : argument : 0

I looked at using deb, but when I clicked on the link, the information was over my head. (I just started Sunday)

So, I started to investigate using str$(), but when I include, I get more errors...

     If I include I get:
     WARNING Duplicate include file
     WARNING Duplicate include file
     WARNING duplicate include file
     C:\MASMx\MyConsole2\Console.Asm(33) : error A2008: syntax error : offset
     C:\MASMx\MyConsole2\Console.Asm(32) : error A2138: invalid data initializer

   I clicked on the link, but the information was way over my head.

Here are the includes and libraries I'm using and used:

;Include  ; tried this
;Include  ; tried this

IncludeLib kernel32.lib
IncludeLib masm32.lib


I stumbled upon the MASM reference in the help files and now I'm off and running. Thanks!