I think I might have asked this before, but does anyone have any sort of solutions for defining string constants at assembly time? I.e. something along the lines of

lea esi, "Hello"
lea edi,
mov ecx, len
rep movsb

Which would load the constant "Hello" into memory.. I don't want to have to define:

tmp db "Hello",0

For every single constant if i can avoid it... suggestions?

John
Posted on 2003-03-29 23:31:15 by coogle
you could write a macro to do this... i'm not a macro guru by any stretch of the imagination - not even sure that the following will work (but it should):

str_lea macro regtouse,txtStr
LOCAL txtS
txtS db txtStr
lea regtouse,txtS
str_lea endm

usage:
str_lea esi,"Hello"
Posted on 2003-03-30 12:39:09 by jademtech
str_lea macro reg,str

LOCAL @@var
.const
@@var db str,0
.code
mov reg, OFFSET str
str_lea endm
Posted on 2003-03-30 13:11:19 by comrade
This would be even better (more flexible):
CTEXT MACRO value

LOCAL @@str, off
.const
@@str db value, 0
EXITM <OFFSET @@str>
ENDM

mov eax, CTEXT("Hello")
Posted on 2003-03-30 13:12:28 by comrade
That's great... I'll try to translate those to fASM... but if someone has a FASM one that'd be even better :) (At least I know I can do it, probably)..

John
Posted on 2003-03-30 13:25:06 by coogle