(darn! hit the ENTER key too soon)
Posted on 2002-08-01 17:10:31 by rondog
I'm afraid there's no solution for this with current fasm capabilities. There still may be some ersatz, you could manually bite off the first character for macro (like STRING_HIBIT 'H','ello'), or limit the string length to 8 characters (because this is the largest value fasm can make calculations on) and do something like:


macro STRING_HIBIT str
{
if str<100h
db 80h or str
else if str<10000h
dw 80h or str
else if str<1000000h
dw 80h or (str and 0FFFFh)
db str shr 16
else if str<100000000h
dd 80h or str
else if str<10000000000h
dd 80h or (str and 0FFFFFFFFh)
db str shr 32
else if str<1000000000000h
dp 80h or str
else if str<100000000000000h
dp 80h or (str and 0FFFFFFFFFFFFh)
db str shr 48
else
dq 80h or str
end if
}
Posted on 2002-08-02 02:04:51 by Tomasz Grysztar
Isn't a simple



lea esi, string
mov al, byte ptr [esi]
or al, 80h
mov byte ptr [esi], al


possible? (am a bit tired so please forgive me a logical mistake :) )


>....There still may be some ersatz...

Heh, you speak German? ;)
Posted on 2002-08-02 02:35:13 by bazik
at assembly time, bAZiK!


> Heh, you speak German?
No, it's influence of a friend who speak German. Beside English I speak Polish (of course :grin: ) and a bit Russian.
Posted on 2002-08-02 02:46:47 by Tomasz Grysztar

at assembly time, bAZiK!


FASM can't use assembly instructions in a Macro? :tongue:
Posted on 2002-08-02 03:01:38 by bazik
Originally posted by Hiroshimator
quit showing off pingo :tongue:
Posted on 2002-08-02 03:07:26 by Tomasz Grysztar
Posted on 2002-08-02 03:40:23 by bazik
>I'm afraid there's no solution for this with current fasm capabilities.

I was afraid you would say that :-(

>

Like this:

%macro hibit 1
%strlen charcnt %1

db charcnt ; a counted string
%substr onechar %1 1
db onechar OR 080h ; but first char is tagged

%assign i 2
%rep charcnt-1
%substr onechar %1 i
db onechar ; emit rest of string
%assign i i+1
%endrep
%endmacro


IMHO this is needlessly complicated, but it is much better than having to do:

db 5, 'H'+080h,'ello'

for every string instead of

hibit 'Hello'

Is there a possibility of some string macros for 1.40? :-)
Posted on 2002-08-02 10:48:17 by rondog
I will work on it :alright:
Posted on 2002-08-03 04:51:12 by Tomasz Grysztar
You are a great man :-)
Posted on 2002-08-04 00:38:45 by rondog
Finally I have solved this problem with the new extension of load directive in the fasm 1.40 beta 4 (work stage version of docs for it are available here). It now allows not only loading constant from external file, but also from the already generated code, for example:


virtual at 0
mov eax,[esp]
ret
load procdata dword from 0
end virtual
mov eax,procdata

The above source will generate the "mov eax,0C324048B" instruction, quite useful for self-modifying code.

Now your macro can be reproduced this way:


macro STRING_HIBIT [string]
{ common
local size
virtual at 0
db string
size = $
end virtual
db size
repeat size
local char
virtual at 0
db string
load char from %-1
end virtual
if % = 1
db 80h or char
else
db char
end if
end repeat
}


It's even better than NASM's version, because it accepts the arguments like "db" directive, for example:


STRING_HIBIT 'Hello!',13,10
Posted on 2002-08-06 13:41:25 by Tomasz Grysztar