News:

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

Main Menu

A problem with a macro

Started by RuiLoureiro, June 05, 2014, 04:39:07 AM

Previous topic - Next topic

RuiLoureiro

Quote from: RuiLoureiro on Today at 02:50:18 AM
i don't get the echo ...  why ?

Because the ECHO directives are placed inside the conditional block
"IF srs_val NE LenOfRecords".

    . Yes it is and I DON'T KNOW WHY !
   
    . This is your first version that i saved
      in my file LkdList10.mac.     
    . My version was done from this version
      by copy/paste/modify.
   
      I don't know why %echo is BEFORE ENDIF.
      After working correctly i never watched
      where was the ENDIF.
    . But it is true that i forgot that detail.
      Copy/paste problems ? maybe.
      Thanks
Quote
SETRECORDSIZE1  MACRO   kInt
   IF kInt LE 0
      .err <what ever>
      EXITM
   ENDIF   
   srs_val = kInt
   .radix 2
      srs_txt TEXTEQU %srs_val
   .radix 10

   srs_log2p1 SIZESTR srs_txt
   srs_pow2 = 1 SHL (srs_log2p1-1)
   IF srs_val NE srs_pow2
      IF srs_pow2 EQ 80000000h
         .err <value to large>
      ENDIF
      srs_pow2 = srs_pow2 * 2
   ENDIF
   
   %echo _kInt=kInt --> @CatStr(%srs_pow2)

   LenOfRecords  = srs_pow2                   ;;  ???
      $RECORDSIZE   = srs_log2p1
      $RECORDSIZE4  = LenOfRecords / 4
ENDM

qWord

I did use the ECHO directive only for debugging purpose, to give a direct feed back what the macro does ... I thought this was clear.
Just remove them in the final version.
MREAL macros - when you need floating point arithmetic while assembling!

RuiLoureiro

Quote from: RuiLoureiro on Today at 02:50:18 AM
It seems to mean this (more or less) by other words :
-Redefinitions of input parameters
are not allowed because...

It is no redefinition - the identifier "kInt" is replaced by "15"
when you call "COMPUTERECORDSIZE 15".
-----------------------------------------------
I think you are taking my words in a wrong way.
What i said means this:

MACROx          MACRO   thisX
                ...
                ;; the bad idea
                ;;-------------
                thisX   = 12345    ;; redefine thisX
                                   ;; because we may give it
                                   ;; with «MACROx thisX»
                ...
ENDM

Well, when i write elsewhere

       MACROx 15                    ;; replace thisX by 15

    i get:

;MACROx          MACRO   thisX
                ...
                ;;-------------
                ;; the bad idea
                ;;-------------
                15   = 12345         ;; redefine thisX
                ...
;ENDM
it seems to be clear.
In any way, thanks for your lesson.  :t

RuiLoureiro

Quote from: qWord on June 06, 2014, 04:53:49 AM
I did use the ECHO directive only for debugging purpose, to give a direct feed back what the macro does ... I thought this was clear.
Just remove them in the final version.
No it is helpful qWord.
               If we define the NODE structure with a length of 200
               bytes and we do COMPUTERECORDSIZE 60
               we have problems unless we use
               COMPUTERECORDSIZE sizeof NODE.
               Download the next version 10 of LinkedList
               that i will post and you can see all this work.

               To be simple, i never used: % /TEXTEQU/CATSTR/INSTR/SUBSTR or EXITM.
               I need to try to use it. But one day
               Thank you so much, qWord  :t


RuiLoureiro

Hi
How do i convert MACRONAME to a string to be printed ?
Thanks  :t

TESTTHISMACRO       MACRO       MACRONAME, $start, $end
                                 LOCAL       labelAA
                    ;;
                    ;; I want to print the string "MACRONAME"
                    ;;                      HERE
                    ;;
                    ;; when i call
                    ;;
                    ;;     TESTTHISMACRO thismacro, 1, 100
                    ;;
                    ;; i want to print the string: "thismacro",0
                    ...
                                       
ENDM

RuiLoureiro

Quote from: RuiLoureiro on July 29, 2014, 08:43:58 PM
Hi
How do i convert MACRONAME to a string to be printed ?
Thanks  :t

TESTTHISMACRO       MACRO       MACRONAME, $start, $end
                               LOCAL         labelAA, $tmpstr$, labelBB
                    ;;
                    ;; I want to print the string "MACRONAME"
                    ;;                      HERE
                    ;;
                    ;; when i call
                    ;;
                    ;;     TESTTHISMACRO thismacro, 1, 100
                    ;;
                    ;; i want to print the string: "thismacro",0
                    ...                                       
ENDM
SOLUTION I

                    $tmpstr$    CATSTR <chr$(">, <MACRONAME>, <",13,10)>
                    print           $tmpstr$

SOLUTION II

                    $tmpstr$    CATSTR <">, <MACRONAME>, <">
.data
labelBB        db $tmpstr$, 0
.code
                    print       addr labelBB,13,10

Is there another way ?

jj2007

include \masm32\include\masm32rt.inc

TESTTHISMACRO       MACRO       MACRONAME, $start, $end
print "This is &MACRONAME with &$start and &$end", 13, 10
ENDM

.code
start:   TESTTHISMACRO TheName, TheStart, TheEnd
   exit

end start

Output: This is TheName with TheStart and TheEnd

RuiLoureiro

Hi Jochen,
                  is far better  :t
                  Thanks