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
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
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"
str_lea macro regtouse,txtStr
LOCAL txtS
txtS db txtStr
lea regtouse,txtS
str_lea endm
usage:
str_lea esi,"Hello"
str_lea macro reg,str
LOCAL @@var
.const
@@var db str,0
.code
mov reg, OFFSET str
str_lea endm
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")
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
John