The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: korte on December 15, 2007, 07:56:19 PM

Title: MACRO string byte to byte
Post by: korte on December 15, 2007, 07:56:19 PM


xxx macro "SAMPLE"
  for
    ; step character to character S, next A, next M....


  endm
Title: Re: MACRO string byte to byte
Post by: ragdog on December 15, 2007, 08:17:15 PM
hi

here is a simple example
i hope i can help you

greets


[attachment deleted by admin]
Title: Re: MACRO string byte to byte
Post by: korte on December 15, 2007, 08:34:28 PM
not.


I thing FORC


FORC char,string
 
endm


And next problem:

if char="a"

elseif char="b"

endif

how to work this in macro?



Title: Re: MACRO string byte to byte
Post by: korte on December 15, 2007, 08:44:03 PM


xxx macro p1
  forc char,p1
    if char="S"    ; <---- not work

   endif

endm

endm

   xxx "SAMPLE"
Title: Re: MACRO string byte to byte
Post by: ragdog on December 15, 2007, 09:51:16 PM
mean you this
I do not understand that which you to say want thereby  :wink
you can become more concrete

String macro args:VARARG
    mov edx,args
@@:
    xor eax,eax
    mov al,byte ptr [edx]
     or al,al
     jz @F
   push edx

   .if eax=="S"   

     .elseif eax=="A"
     
     .elseif eax=="M"
     
     .elseif eax=="P"
     
     .elseif eax=="L"
     
     .elseif eax=="E"
     
   .endif
    pop edx
    inc edx
    jmp @B
@@:
endm   


Title: Re: MACRO string byte to byte
Post by: MichaelW on December 16, 2007, 01:08:53 AM
korte,

I’m not sure what you are trying to do, so I’m guessing that you want to process the characters of the string at compile time.

; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
    include \masm32\include\masm32rt.inc
; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
forcex MACRO quotedstring
  FORC char, <quotedstring>
    IFIDN <char>, <">
      echo "
    ELSEIFIDN <char>, <S>
      echo S
    ELSEIFIDN <char>, <A>
      echo A
    ELSEIFIDN <char>, <M>
      echo M
    ELSE
      echo ?
    ENDIF
  ENDM
ENDM
; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
    .data
    .code
; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
start:
; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
    forcex "SAMPLE"

    inkey "Press any key to exit..."
    exit
; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
end start


Assembling: C:\masm32\My\_TRY\kortexxx.asm
"
S
A
M
?
?
?
"

Title: Re: MACRO string byte to byte
Post by: korte on December 16, 2007, 08:34:06 AM
YES!

thanks MichaelW