0

I'm trying to get the size of a string that esi holds the address of the first byte.

mov ebx, SIZEOF [esi]

Why won't this run? For an error it gives me error A2081: mi, for that line number.

1 Answers1

1

Why won't this run?

The syntax for SIZEOF is:

  SIZEOF variable | type

This only works at assembly-time, not at run-time. And it's not translated into code. So you can't use it anywhere you want.

An example:

.data
string BYTE "Hello World", 0

.code
mov eax, SIZEOF string ;  the size will be translated into an immediate value

If you can't know in advance the length of that string, you need to call some function to get it.

JosEduSol
  • 5,268
  • 3
  • 23
  • 31