Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Could use inline asm in _Tcc?
#1
they said c could add inline asm in the code,tcc support it? :?:
#2
looks like there are some words "asm.__asm...mov" in tcc.dll...how to use it? Smile
#3
Look in tcc website.
http://bellard.org/tcc/tcc-doc.html#TOC10

example from there
Code:
Copy      Help
static inline void * my_memcpy(void * to, const void * from, size_t n)
{
int d0, d1, d2;
__asm__ __volatile__(
        "rep ; movsl\n\t"
        "testb $2,%b4\n\t"
        "je 1f\n\t"
        "movsw\n"
        "1:\ttestb $1,%b4\n\t"
        "je 2f\n\t"
        "movsb\n"
        "2:"
        : "=&c" (d0), "=&D" (d1), "=&S" (d2)
        :"0" (n/4), "q" (n),"1" ((long) to),"2" ((long) from)
        : "memory");
return (to);
}

test in qm
Macro tcc asm
Code:
Copy      Help
__Tcc x.Compile("" "my_memcpy")

POINT p d
p.x=3; p.y=4

call x.f &d &p sizeof(POINT)

out _s.getstruct(d 1)


#ret
void * my_memcpy(void * to, const void * from, int n)
{
int d0, d1, d2;
__asm__ __volatile__(
"rep ; movsl\n\t"
"testb $2,%b4\n\t"
"je 1f\n\t"
"movsw\n"
"1:\ttestb $1,%b4\n\t"
"je 2f\n\t"
"movsb\n"
"2:"
: "=&c" (d0), "=&D" (d1), "=&S" (d2)
:"0" (n/4), "q" (n),"1" ((long) to),"2" ((long) from)
: "memory");
return (to);
}

More examples: download tcc source code, find file tcctest.c, and find text __asm__.
#4
great! but have to read more docs... :roll:


Forum Jump:


Users browsing this thread: 1 Guest(s)