News:

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

guntheria

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
   XOR EAX,EAX
   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
   RET
Main EndP



ragdog

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

http://msdn.microsoft.com/en-us/library/aa246400%28v=vs.60%29.aspx

jj2007

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 msvcrt.inc
deb needs MasmBasic.inc
str$ needs masm32rt.inc

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

guntheria

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 

      Errors:

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


      Then added msvcrt.inc 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 masm32rt.inc, I get more errors...


     If I include masm32rt.inc I get:
     ------------------------------------------
     WARNING Duplicate include file windows.inc
     ------------------------------------------
     -----------------------------------------
     WARNING Duplicate include file masm32.inc
     -----------------------------------------
     -------------------------------------------
     WARNING duplicate include file kernel32.inc
     -------------------------------------------
     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 windows.inc
Include kernel32.inc
Include masm32.inc
;Include msvcrt.inc  ; tried this
;Include masm32rt.inc  ; tried this

IncludeLib kernel32.lib
IncludeLib masm32.lib

guntheria

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