How does this work?

Cyclelicious Shop
Bicycle Lights - Wald Baskets - Dahon - Strida

IMPORTANT: This content is deprecated. Please visit the new CYCLELICIOUS 2.0.
Wednesday, April 12, 2006
By Yokota Fritz

Are there any x86 programming geeks that now how this down() function works? A colleague and I were puzzling over the "jmp 1b" code below (bolded). How does this function ever break out of this? This is from the file include/asm-i386/semaphore.h in the Linux kernel source.

static inline void down(struct semaphore * sem)
__asm__ __volatile__(
"# atomic down operation\n\t"
LOCK "decl %0\n\t" /* --sem->count */
"js 2f\n"
"2:\tlea %0,%%eax\n\t"
"call __down_failed\n\t"
"jmp 1b\n"
:"=m" (sem->count)

    IMPORTANT: Please post comments for this article at the new CYCLELICIOUS 2.0 version of this page.
You had me at "hello"...
Post a Comment

Links to this post:

Create a Link

Blog Widget by LinkWithin Cyclelicious Home

Scotts Valley Cycle Sport

Scotts Valley Cycle Sport Santa Cruz California


Powered by Blogger

Subscribe to
Posts [Atom]