Author Topic: get contents of a register?  (Read 4925 times)

guntheria

  • Guest
get contents of a register?
« on: March 03, 2014, 12:29:32 PM »
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

  • Member
  • ****
  • Posts: 578
Re: get contents of a register?
« Reply #1 on: March 03, 2014, 05:13:42 PM »
  invoke crt_printf, chr$(" Value:%d"), eax

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

jj2007

  • Member
  • *****
  • Posts: 8893
  • Assembler is fun ;-)
    • MasmBasic
Re: get contents of a register?
« Reply #2 on: March 03, 2014, 05:24:48 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

  • Guest
Re: get contents of a register?
« Reply #3 on: March 04, 2014, 11:56:19 AM »
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

  • Guest
Re: get contents of a register?
« Reply #4 on: March 04, 2014, 01:52:13 PM »
I stumbled upon the MASM reference in the help files and now I'm off and running. Thanks!