Eight of us attended.  Clockwise they were:  Terry, Clive, Simon, Tim,
Steve, Ralph, Peter, Victor.

Many things discussed.  Some are below.  If they seem familiar it's
probably because it was me waffling astride a hobbyhorse.

Terry had a shiny new Novatech netbook for £170.  /proc/cpuinfo said it
was an Intel N270.  160GB hard drive, 1GiB RAM.  There was confusion
over whether it is single or dual core.  It's single core, dual threaded
using Intel's http://en.wikipedia.org/wiki/Hyper-threading, their term
for SMT, http://en.wikipedia.org/wiki/Simultaneous_multithreading.

Tim has built a UK101 in the past, a 6502-based computer,
http://en.wikipedia.org/wiki/UK101.  And someone mentioned the
Tangerine, http://www.geoff.org.uk/microtan/index.htm.

People building their own CPUs.  Two well-known examples, the Magic-1,
http://www.homebrewcpu.com/, and Harry Porter's Relay computer,
http://web.cecs.pdx.edu/~harry/Relay/.

The "NAND" book, leads you through building a simple CPU using Java
simulators for a hardware description language before having you write
an assembler, VM, and compiler for it.  http://www1.idc.ac.il/tecs/

The Little Book of Semaphores.  http://www.greenteapress.com/semaphores/

Russ Cox has a good page bringing together information on the
alternative style of concurrent programming descending from C. A. R.
Hoare's CSP.  http://swtch.com/~rsc/thread/

Dunkels' uIP uses Protothreads in its implementation.
http://www.sics.se/~adam/uip/uip-1.0-refman/a00142.html

How uninitialised memory can be used as a sparse data structure and also
give simple traversal of all elements.
http://research.swtch.com/2008/03/using-uninitialized-memory-for-fun-and.html

How bc(1) is, apart from GNU's implementation, a preprocessor for dc(1),
the arbitrary-precision postfix (reverse Polish notation) desk
calculator.  And how dc can still be handy.

    dc <<<16i48656C6C6F20776F726C64210AP

HP's calculators famously used RPN.
http://en.wikipedia.org/wiki/List_of_HP_calculators#Characteristics

Massalin's brief paper on his Superoptimizer, which found the optimal
sequence of machine instructions given an equivalent sequence.
http://www.cs.utexas.edu/users/lasr/shangri-la/reference/massalin87superoptimizer.pdf
One nice example is converting a binary-coded decimal byte into its
decimal value, e.g. 0x42 is the BCD of decimal 42.  Instead of the
obvious

    ((n & 0xf0) >> 4) * 10 + (n & 0x0f)

his Superoptimizer came up with

    move.b d0, d1   ; Copy n in d0 to d1.
    and.b #$F0, d1   ; Isolate top nibble of d1.
    lsr.b #3, d1   ; Divide d1 by 8, so it's now double the 16s digit.
    sub.b d1, d0   ; Lessen n, d0, by d1.
    sub.b d1, d0   ; And again, twice more.
    sub.b d1, d0

It's masking off the top nibble of n, getting us the 16s digit of the
BCD number, e.g. `4', given 0x42.  In the decimal number we want, that
column would be the number of 10s, not 16s, so the value there
represents how many extra sixes there are in 0x42, 66 decimal, compared
to the desired 42.

    0x42 - 4 * 6 = 42

Rather than shift that top nibble down four bits so it's a bottom
nibble, and then multiply it by six, it shifts it right only three bits,
leaving it double the number of sixes to subtract, and then subtracts it
three times.

    n - ((n & 0xf0) >> 3) * 3 =
    n - ((n & 0xf0) >> 4) * 2 * 3 =
    n - ((n & 0xf0) >> 4) * 6

The book _Hacker's Delight_, on bit-twiddling.  The website provides
another superoptimiser.  http://www.hackersdelight.org/

Using C preprocessor macros to convert from binary literals to numeric
literals the C compiler can handle at compile time.  Several approaches
exist.

    Shifting 1s.  http://c-faq.com/misc/sd27.html

    Writing hex and then masking bits out.
    http://c-faq.com/misc/sd28.html

    Turning four bits into a hex nibble and concatenating them.
    http://www.cakoose.com/wiki/c_preprocessor_abuse#2

RatC, a compiler for a slimmed-down C aimed at small environments.
Seemingly a derivative of Cain's Small-C compiler.

    http://onlinedictionary.datasegment.com/word/ratc
    http://en.wikipedia.org/wiki/Small-C

--
Next meeting: Bournemouth, Wednesday 2010-08-04 20:00
http://dorset.lug.org.uk/     http://www.linkedin.com/groups?gid=2645413
   Chat: http://www.mibbit.com/?server=irc.blitzed.org&channel=%23dorset
           List info: https://mailman.lug.org.uk/mailman/listinfo/dorset

Reply via email to