| TIP: Click on subject to list as thread! | ANSI |
| echo: | |
|---|---|
| to: | |
| from: | |
| date: | |
| subject: | strlen |
Hi Bill.
16-Apr-04 20:16:00, Bill Birrell wrote to Jasen Betts
BB> After I wrote that screed, I dug out the assembler and things and had a
BB> look.
BB> This is what worked like strlen():
BB> Obviously it would need a C interface around it to be useful, but I
BB> just
BB> wanted to confirm that I hadn't got it completely arse about face
I couldn't get my real mode dos compiler (tc2) and assembler (arrow) to
cooperate (they used to cooperate ok... dunno what went wrong)
here's one as inline assenmmbler (GCC)
int sleng( char *c)
{
asm(
" movl %0 ,%%edi; "
" xorl %%eax ,%%eax; "
" movl %%eax ,%%ecx; "
" notl %%ecx; "
" cld; "
" repnz ; scasb; "
" movl $-2,%%eax; "
" subl %%ecx,%%eax; "
: /* no outputs - eax becomes the function's return value */
:"rm"(c)
:"eax","ecx","edi","cc");
}
This is my first attempt at gcc style inline asm, I'd welcome any
comments...
hmm, if I had the glibc source I could see how the experts did it.
is the syntax for inline asm described somewhere in the GCC info tree?
(where?)
-=> Bye <=-
---
(3:640/1042)
* Origin: You think "I'm no fool!" but I am! - Spike MilliganSEEN-BY: 633/267 270 @PATH: 640/1042 531 954 774/605 123/500 106/2000 633/267 |
|
| SOURCE: echomail via fidonet.ozzmosis.com | |
Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.