it is not possible, since i developed the macro system this way specifically for performance reasons.
Forum / Source Help
detecting '\'
A community discussion post from the original code:zIRON forum.
Replies
btw i updated RTL macro strJoin to cover for eax
inline function strJoin(;) {
$maxbuf = $argc - 1;
$if deftype($arg[$maxbuf]) <> 'int':
$raise 'strJoin final argument must be maximum buffer length';
$end
$i = 1;
$to = $argc - 2;
$repeat $to:
$if $arg[$i] = 'eax':
push eax;
$end;
$end;
$repeat $to:
$if $arg[$i] = 'eax':
pop eax
$end;
eax = strAppend($arg[0], $arg[$i], $arg[$maxbuf]);
$i++;
$end;
$return eax;
}
but of course it would be better to use another free register, since its 1 less push/pop
sorry fixed a bug and made a little better:
inline function strJoin(;) {
$maxbuf = $argc - 1;
$if deftype($arg[$maxbuf]) <> 'int':
$raise 'strJoin final argument must be maximum buffer length';
$end
$i = 1;
$to = $argc - 2;
$repeat $to:
$if $i > 1:
$if $arg[$i] = 'eax':
push eax;
$end;
$end;
$i++;
$end;
$i = 1;
$repeat $to:
$if $i > 1:
$if $arg[$i] = 'eax':
pop eax
$end;
$end;
eax = strAppend($arg[0], $arg[$i], $arg[$maxbuf]);
$i++;
$end;
$return eax;
}
sorry , i have to go now , if i have time i will post again tonight .
http://www.freewebs.com/ogremagic/index.htm
firs you will need to make a fix to strlcpy in strings.zir, replace the whole strlcpy macro with:
//
// Copyright (c) 2012. OverHertz Ltd
//
inline procedure m_strcpy_std(dst, ssrc, ln) {
push edi
push esi
push ecx
edi = $dst;
esi = $ssrc;
ecx = $ln;
shr ecx, 2
rep movsd
ecx = $ln;
and ecx, 3
rep movsb
pop ecx
pop esi
pop edi
}
inline procedure m_strcpy_mmx(dst, ssrc, ln) {
push edi
push esi
push ecx
push edx
edi = $dst;
esi = $ssrc;
ecx = $ln;
edx = ecx;
shr ecx, 6
if (ecx <> 0) {
repeat {
//$if defined(assembler_SSE_ON) == true:
//$end
movq mm0, qword[esi+0]
movq mm1, qword[esi+8]
movq mm2, qword[esi+16]
movq mm3, qword[esi+24]
movq mm4, qword[esi+32]
movq mm5, qword[esi+40]
movq mm6, qword[esi+48]
movq mm7, qword[esi+56]
movq qword[edi+0], mm0
movq qword[edi+8], mm1
movq qword[edi+16], mm2
movq qword[edi+24], mm3
movq qword[edi+32], mm4
movq qword[edi+40], mm5
movq qword[edi+48], mm6
movq qword[edi+56], mm7
esi += 64;
edi += 64;
edx -= 64;
ecx -= 1;
} until (ecx == 0);
}
ecx = edx;
shr edx, 3
if (edx <> 0) {
repeat {
movq mm0, qword[esi]
movq qword[edi], mm0
esi += 8;
edi += 8;
ecx -= 8;
edx -= 1;
} until (edx == 0);
}
rep movsb
pop edx
pop ecx
pop esi
pop edi
emms
}
inline procedure strlcpy(dest, source, len) {
$if defined(assembler_MMX_ON) == true:
$if $len of 0:
$if $len < 64:
m_strcpy_std($dest, $source, $len);
$else
m_strcpy_mmx($dest, $source, $len);
$end
$else
if ($len < 64) {
m_strcpy_std($dest, $source, $len);
} else {
m_strcpy_mmx($dest, $source, $len);
}
$end;
$else
m_strcpy_std(dest, source, len);
$end
}
ok now the fix is done, here is small string sample:
program WIN32CUI 'test';
#include 'ch.zir';
char* myArr[2];
//constant mem
myArr[0] = 'String 1';
myArr[1] = 'String 2';
print(myArr[0], ' ', myArr[1], '\r\n');
//dynamic
myArr[0] = malloc(16);
myArr[1] = malloc(16);
strlcpy(myArr[0], 'Test 1', sizeof 'Test 1');
strlcpy(myArr[1], 'Test 2', sizeof 'Test 2');
print(myArr[0], ' ', myArr[1], '\r\n');
delete myArr[0];
delete myArr[1];
wait_key();
ExitProcess(0);
ok , but this not allowed
for(ecx = 0 to 1)
{
print(myArr[ecx], '\r\n');
}
http://www.freewebs.com/ogremagic/index.htm
i plan to add this but for now:
edi = @myArr;
for(ecx = 0 to 1) {
print([edi+ecx*4], '\r\n');
}