News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

A macro that return a number usable by a constant

Started by ToutEnMasm, June 27, 2005, 12:45:57 PM

Previous topic - Next topic

ToutEnMasm

Hello,
Translating the headers of the SDK , I found a problem
#define L_MAX_URL_LENGTH    (2048 + 32 + sizeof("://"))

Beginning of the translate is easy:

L_MAX_URL_LENGTH equ  (2048 + 32 + Its hard)

In a macro(SIZE)     i = 0    ,later,      EXITM %i    return the number but .......

L_MAX_URL_LENGTH equ  (2048 + 32 + SIZE("://")) failed

I try SIZESTR ,I try <%i>,i,<i> but no more result  , Is it possible ?.That seem work only for an another macro.

The error occured when         Variable dd L_MAX_URL_LENGTH

                                          ToutEnMasm

                                   






Jeff

since that is c, i believe a string, :// would be 4 bytes right? (including null terminator)  ;)

2048 + 32 + 4

it might be a good idea to evaluate the expression rather than leaving it as is.  i could be wrong.

gfalen


Jeff

the problem with that is that it takes the entire literal string's size.  that means, it includes the quotes.  what's worse is that it still doesnt account for the null terminator (as used in c).  tout may be more interested in the best resemblence to c.   ;)

MazeGen

Quote from: Jeff on June 27, 2005, 03:19:43 PM
the problem with that is that it takes the entire literal string's size.  that means, it includes the quotes.

@SizeStr(://)

or

@SizeStr(<://>)

ToutEnMasm

Hello,
I have made a lot of test and that is the result
#define AL_MAX_URL_LENGTH    (2048 + 32 + sizeof("://")) =2084
AL_MAX_URL_LENGTH  equ  (2048 + 32 + @SizeStr("://")) = 2085

to resume it      in c  sizeof("://") =  size of  :// + zero =4
                   in asm  @SizeStr("://") = size of "://"  = 5

I have also made a macro that can be of interest:
The syntax is  mov edx,SIZECHAINE ((I am a string))     ;note the double (())
It return the lenght of the entire string , except if there is spaces at the end,they are troncated

Thanks for the help

                                   ToutEnMasm

             
                     SIZECHAINE MACRO chaine:REQ
      local nombre
      .const
      nombre equ @SizeStr chaine
      .code
      mov eax,nombre
      EXITM <eax>
        ENDM

MazeGen

ToutEnMasm,
your SIZECHAINE macro is unnecessary. You can always use

mov edx, @SizeStr (Iamastring)

mov edx, @SizeStr (<I am a string>)