News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests

Main Menu

Masm question

Started by RuiLoureiro, March 22, 2013, 09:32:03 PM

Previous topic - Next topic

RuiLoureiro

Hi
     is there a procedure to be used in console application to print
     values and strings like this:

          invoke  ThatProcedure, "pimpipmpim", str$(eax),"pumpumpum",
                      str$(ebx), 32, str$(edx), ...
          or
          invoke  ThatProcedure, str$(eax), str$(ecx), "pumpumpum",
                      str$(ebx), 32, str$(edx), ...

    Thank you !  :biggrin:

         switch/case uses registers or they are all free ?
   

hutch--


jj2007

Quote from: RuiLoureiro on March 22, 2013, 09:32:03 PM
invoke  ThatProcedure, str$(eax), str$(ecx)

Not with eax & ecx, but this works:

include \masm32\include\masm32rt.inc
.code
print3 proc arg1, arg2, arg3
  print arg1
  print arg2
  print arg3
  ret
print3 endp

start:
   mov esi, 111
   mov edi, 222
   invoke print3, str$(esi), chr$("<>"), str$(edi)
   inkey " - ok?"
   exit
end start


Quoteswitch/case uses registers or they are all free ?

Only eax, and it will have the Switch XXX value (see macros.asm):

    switch macro _var:req, _reg:=<eax>
        mov _reg, _var


RuiLoureiro

Hello __Hutch__  :biggrin:

        How are you ?

        cat$ ?  How do i use it ?

_Jochen,

        How are you ?  ;)
        Good help
        (but i need to learn something about how to write macros )

        If "switch macro _var:req, _reg:=<eax>"
        so _reg is EAX
        so mov _reg, _var  => mov eax, _var

        Instead of "mov eax, _var" it could be
        "push    dword ptr _var"

        Thank you !  :icon14:

qWord

Quote from: RuiLoureiro on March 23, 2013, 01:55:36 AMbut i need to learn something about how to write macros
read chapter 9 of MASM's Programmer's guide.

Quote from: RuiLoureiro on March 23, 2013, 01:55:36 AMIf "switch macro _var:req, _reg:=<eax>"
        so _reg is EAX
        so mov _reg, _var  => mov eax, _var
"parameter:=<default token>" tells MASM to use the text inside the angle brackets if the parameter is not specified on macro call.
(":req" denotes a macro argument, which must be present on call - otherwise errors are thrown)
MREAL macros - when you need floating point arithmetic while assembling!

hutch--

Rui,

"cat$" is fully documented in the help file. Find it in "hlhelp.chm".

RuiLoureiro

Hutch,
            Thanks, i found it and it helps ! ;)

RuiLoureiro

I wanted to replace this 4 instructions by only 1
which is used in a loop and with cat$ i cannot
do it

                    print   "X Y=  "
                    print   str$(ebx),32
                    print   str$(esi)," value = "
                    print   addr _StrValue,13,10

jj2007

Rui,

Here is an example how to do it. The MasmBasic version is only marginally simpler, in fact cat$ is a really efficient Masm32 macro:

include \masm32\MasmBasic\MasmBasic.inc        ; download
.data?
buffer        db 100 dup(?)
        Init
        .Repeat
                Print Str$(esi), Tb$, Str$(ebx), CrLf$
                inc esi
                dec ebx
        .Until esi>3
        Print "Now the same with plain Masm32:", CrLf$
        mov edi, offset buffer
        .Repeat
                and byte ptr [edi], 0
                print cat$(str$(esi), chr$(9), str$(ebx), chr$(13, 10))
                inc ebx
                dec esi
        .Until Sign?
        inkey "ok"
        Exit
end start

The and byte ptr [edi], 0 serves to reset the buffer, of course.