|Compiler Deisgn. Matthew.Webb@net1.demon.co.uk (Matthew Webb) (1998-05-12)|
|Re: Compiler Deisgn. email@example.com (Kirk Abbott) (1998-05-15)|
|Re: Compiler Deisgn. firstname.lastname@example.org (1998-05-27)|
|Re: Compiler Design. email@example.com (Torbjorn Drevin) (1998-05-30)|
|Re: Compiler Design. firstname.lastname@example.org (1998-06-03)|
|From:||"Torbjorn Drevin" <email@example.com>|
|Date:||30 May 1998 11:58:05 -0400|
|References:||98-05-058 98-05-098 98-05-126|
Anton Ertl wrote in message 98-05-126...
>Matthew Webb wrote:
>>> My diassembler/assembler are bassically just one massive case statment
>>> the bytes or text strings. The look identical but the reversed.
>>> Can anyone give another structure other than a case statment please?
One can use a table with data and function pointers instead of a large
case-statement. The function pointers can point to a specific
"actionfunction", if needed. If the opcode in a specific record does not
need to have an "action function", then it should contain NULL. I have used
this technique both in an assembler, and when I wrote a printer emulator, to
parse incoming esc-sequences. When the scanner has collected a token it
searches in the table for the token. If found, it looks at the data in the
record, and makes a jump to the "action function" if the pointer != NULL.
Torbjorn Drevin, firstname.lastname@example.org / email@example.com
Return to the
Search the comp.compilers archives again.