login
Header Space

 
 

Re: [RFC] Convert builin-mailinfo.c to use The Better String Library.

Score:
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: Johannes Schindelin <Johannes.Schindelin@...>
Cc: Andreas Ericsson <ae@...>, Wincent Colaiuta <win@...>, Dmitry Kakurin <dmitry.kakurin@...>, Linus Torvalds <torvalds@...>, Matthieu Moy <Matthieu.Moy@...>, Git <git@...>
Date: Friday, September 7, 2007 - 12:09 pm

Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:


That assumes that the original task can even expressed well in C.
Multiple precision arithmetic, for example, requires access to the
carry bit.  You can code around this, for example by writing something
like

unsigned a,b,carry;

[...]

carry = (a+b) < a;

but the problem is that those are ad-hoc idioms with a variety of
possibilities, and thus the compilers are not made to recognize them.
Another thing is mixed-precision multiplications and divisions: those
are _natural_ operations on a normal CPU, but have no representation
in assembly language.

As a consequence, most high performance multiple-precision packages
contain assembly language in some form or other.

gcc's assembly language template are excellent in that they actually
cooperate nicely with the optimizer, so the optimizer can do all the
address calculations and register assignments and opcode reorderings,
and then the actual operations that are not expressible in C can be
done by the programmer.

But anyway, I have worked as a graphics driver programmer for some
amount of time, and bit-stuffing memory-mapped areas with data was
still something where hand assembly was best.

I have also done BIOS terminal emulators, and being able to write
something like

ld b,whatever
myloop:
push bc
push hl
call nextchar
pop hl
pop bc
ld (hl),a
inc hl
djnz myloop

in order to suspend the terminal driver until the application comes up
with the next `whatever' output characters in an escape sequence is
_wagonloads_ more maintainable than using a state machine or whatever
else for distributing material delivered into the driver.

But this requires that nextchar can do something like
nextchar: ld (driverstack),sp
  ld sp,(appstack)
  ret

and the entrypoint, in contrast, does

outchar: ld (appstack),sp
  ld sp,(driverstack)
  ret

Cheap and expedient.  You just need to set up a small stack, and
presto: coroutines, at absolutely negligible cost.  I know that there
are some "portable" coroutine implementations that use setjmp/longjmp
in a rather horrific way, but those are way more unnatural.

-- 
David Kastrup, Kriemhildstr. 15, 44793 Bochum
-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
Re: [RFC] Convert builin-mailinfo.c to use The Better String..., Johannes Schindelin, (Fri Sep 7, 6:21 am)
Re: [RFC] Convert builin-mailinfo.c to use The Better String..., Johannes Schindelin, (Fri Sep 7, 6:56 am)
Re: [RFC] Convert builin-mailinfo.c to use The Better String..., David Kastrup, (Fri Sep 7, 12:09 pm)
Re: [RFC] Convert builin-mailinfo.c to use The Better String..., Johannes Schindelin, (Fri Sep 7, 6:26 am)
Re: [RFC] Convert builin-mailinfo.c to use The Better String..., Johannes Schindelin, (Fri Sep 7, 6:28 am)
Re: [RFC] Convert builin-mailinfo.c to use The Better String..., Johannes Schindelin, (Thu Sep 6, 8:08 am)
speck-geostationary