Macros : detecting *all* MixEDcAsE combinations of an argument

Started by chep, June 22, 2005, 07:55:31 AM

Previous topic - Next topic

chep

Hi,

As part of the Stack Probing PROLOGUE macro I'm writing I need to check for FORCEFRAME and LOADDS arguments
eg :

TestProc PROC <FORCEFRAME> ...

For full compatibility with MASM's default behaviour I need to be able to recognize all combinations of lower/uppercase characters, eg. forceframe ForceFrame FORCEFRAME fOrCEFramE etc

Ok, I admit that things like fOrCEFramE are not likely to be typed by anyone but a self-proclamed 1337 kiddie, but as this is the first potentially useful MASM macro I'm writing I'd *really* like it to be 200% compatible with PROLOGUEDEF.

The first thing that came to my mind is to convert the arguments to lowercase before doing comparisons, however I don't find any relevant info about this in MASM reference.

Otherwise I also thought about the "classic"
IF "F" OR "f"
  IF "O" OR "o"
    ...
but I *won't* implement this, I hate ugly things.


Does anyone have an idea about how to achieve this ??
If not, I guess it'll be ok with the common forms forceframe/FORCEFRAME/ForceFrame, and loadds/LOADDS/LoadDS/LoadDs.

Thx

Jeff

nothing wrong with being anal about worrying about all cases.  at least, thats what i tell myself.  :)

the first thing you could try is using MASM's conditional, string comparing directives (with case insensitivity):
IFIDNI <[argument]>,<[string]>
    ;...
ENDIF
(IFIDN - i read as "if identical" and the closing 'I' makes it case insensitive)
which leads to:
IFIDNI <arg>,<forceframe>

chep

:dance: Yey! It works! :cheekygreen:

Thanks Jeff! I didn't know that keyword... :U :thumbu :thumbu :thumbu

MazeGen

BTW, there's no lowercase/uppercase operator in MASM, you have to use user-defined macros:


$lcase MACRO string:REQ
local lowerstr, letter, pos, char

lowerstr TEXTEQU <>
FORC letter, <string>
   pos INSTR <ABCDEFGHIJKLMNOPQRSTUVWXYZ>, <letter>
   IF pos
     char SUBSTR <abcdefghijklmnopqrstuvwxyz>, pos, 1
   ELSE
     char TEXTEQU <letter>
   ENDIF
   lowerstr CATSTR lowerstr, char
ENDM

EXITM lowerstr
ENDM

$ucase MACRO string:REQ
local upperstr, letter, pos, char

upperstr TEXTEQU <>
FORC letter, <string>
   pos INSTR <abcdefghijklmnopqrstuvwxyz>, <letter>
   IF pos
     char SUBSTR <ABCDEFGHIJKLMNOPQRSTUVWXYZ>, pos, 1
   ELSE
     char TEXTEQU <letter>
   ENDIF
   upperstr CATSTR upperstr, char
ENDM

EXITM upperstr
ENDM