Related articles |
---|
Three Address Code smitha_chandran@yahoo.com (2000-09-11) |
Re: Three Address Code Sid-Ahmed-Ali.TOUATI@inria.fr (Sid Ahmed Ali TOUATI) (2000-09-13) |
Re: Three Address Code tnaran@direct.ca (Travers Naran) (2000-09-13) |
Re: Three Address Code tnaran@direct.ca (Travers Naran) (2000-09-15) |
Re: Three Address Code dancohen@nospam.canuck.com (Dan Cohen) (2000-09-15) |
Re: Three Address Code leupers@ls12.cs.uni-dortmund.de (Rainer Leupers) (2000-09-17) |
From: | Dan Cohen <dancohen@nospam.canuck.com> |
Newsgroups: | comp.compilers |
Date: | 15 Sep 2000 01:37:03 -0400 |
Organization: | Compilers Central |
References: | 00-09-088 00-09-094 |
Keywords: | code, architecture |
Travers Naran wrote:
>
> <smitha_chandran@yahoo.com> wrote in message
> > I would like to know if Three Address Code can be implemented in some
> > way other then quadruple or triples.
>
> I don't get it: isn't three address code inherently a n-tuple of
> addresses? Finding another implementation is looking for something
> other than three address code, isn't it? I am curious about this
> because I've only ever used n-tuples (quadruple or triples) and I too
> would be interested if there was another way.
My first computer was a microprogrammed machine. The micro instructions
allowed me to create a new programming language. I was pretty new to
programming, so I chose a 3-address scheme, like this:
op source1 source2 destination
and the operands were all memory (RAM) addresses.
Here's an example program to convert to upper case: (the dashes are
place holders, my input was formatted)
toUpper:
in tty0 - buffer ! input a character from console
comp buffer 'a' - ! set flags by internal subtract
jump neg - dont ! buffer < 'a', not lower case
comp buffer 'z' - ! set flags by internal subtract
jump pos - dont ! buffer > 'z', not lower case
sub 'a' buffer buffer ! lower - 'a'
add 'A' buffer buffer ! + 'A' gives UPPER
dont:
...
It seemed like a good idea at the time. But you'll notice that every
instruction coded in this routine has an unused field, or else a
duplicate field. Actually, in use, I had a lot of instructions with 2
fields unused, too.
Well, my assembler program worked, and I am proud of it. But I'll never
do it that way again.
Today, I sometimes to 803876, but actually I prefer 65c02 or 68000.
-- Dan Cohen in Calgary
Return to the
comp.compilers page.
Search the
comp.compilers archives again.