Progrmaming in Bytecode?

Swan, Dean Dean_Swan at Mitel.COM
Thu Aug 1 00:18:29 UTC 2002


Aaron,

	Keep in mind that the Squeak VM bytecode set is fairly simple
compared to some "modern" CPUs.  x86 assembly can be a little tricky
to generate code from because of various modifier prefix bytes and
relative branches that can't be computed until the code in between
the branch and the branch target is generated, and variable sized
op-codes depending on addressing mode, etc.

	It's not uncommon to find x86 code padded with a lot of NOPs
that weren't in the original source.  Sometimes they're there to pad
the execution pipeline, and sometimes it's just because the code
generator allocates a whole large enough for the largest form of an
instruction to simplify the branch target calculations.

	Ned mentioned some good examples of issues for the PIC.  The
8051 and derivatives have similar issues, plus a big incentive to
try to put some variables at certain addresses due to an address
range limitation in the bit field instructions.  Also, there are
a lot of open source and/or pd assemblers out there for different
targets that might be instructive to look at.

	It is true with many seemingly simple things that there is
more to it than is readily apparent to a "casual observer".  I'd
say assemblers can fall in this category.  Due to the "peculiarities"
of some instruction sets, there are even such things as "optimizing
assemblers"!

						-Dean


	

-----Original Message-----
From: Aaron [mailto:reic0024 at d.umn.edu]
Sent: Wednesday, July 31, 2002 4:09 PM
To: squeak-dev at lists.squeakfoundation.org
Subject: Re: Progrmaming in Bytecode?


On Wed, 31 Jul 2002, Dan Ingalls wrote:

> This reminded me that, about ten years ago I wrote in a day or two a
> little assembler for a simple processor.
>
> Anyway, since I said "a page or two", I thought I should put my money
> where my mouth is, so I'm sending along that old code.  Unfortunately
> it's for a slightly different dialect from Squeak, but most of the code
> should still work if you file off the rough edges.  There's nothing
> great about it, but if people think assemblers are hard, this should
> help to allay that fear.

Fun! I'll have to play with it.

People think assemblers are hard?  I always imagined that it'd be a lot
easier to write an assembler than a compiler.  I'm a biologist, not a
computer scientist or elec engineer, but I always thought that you don't
do more than superficial optimization within an assembler, but simply
translate human-readable opcodes, like translating "returnTop" in SqVM
assembly to the byte 7C.

Aaron




More information about the Squeak-dev mailing list