On Fri, Oct 31, 2008 at 4:21 AM, Gerardo Richarte <gera@corest.com> wrote:
Eliot Miranda wrote:
>     I wonder if anyone has any 32-bit processor implementations,
> either in Smalltalk or in some other, preferrably easy-to-parse,
> formal semantics.
   I thought about this several times, but never came down to implement
it: The Intel manuals do have a very concrete pseudocode for every
instruction, and it does look quite parsable. I did start once, but the
need for it disappeared, and I never finished...

the description for ADD is:

DEST ← DEST + SRC + CF;

and for AAA (Ascii adjust after addition) is more complex:
IF 64-Bit Mode
   THEN
        #UD;
   ELSE
        IF ((AL AND 0FH) > 9) or (AF = 1)
              THEN
                  AL ← AL + 6;
                  AH ← AH + 1;
                  AF ← 1;
                  CF ← 1;
                  AL ← AL AND 0FH;
              ELSE
                  AF ← 0;
                  CF ← 0;
                  AL ← AL AND 0FH;
        FI;
FI;

   I think it really is an option to write a compiler from PDF to
Smalltalk :)

   richie

Superficially this looks good.  But it is only a part of the semantics.  This is a fairly abstract semantics.  It leaves out definitions of registers (e.g. DEST ← DEST + SRC + CF;) and all the instruction decode, which on x86 is complex and easy to screw up.