Re: Disassembling Pentium ColorForth
Mark Slicker <[email protected]>
| Newsgroups | gmane.comp.lang.forth.colorforth |
|---|---|
| Message-ID | <[email protected]> |
On Thu, 29 Dec 2005, John Drake wrote: > > > --- Mark Slicker <[email protected]> wrote: > >> On Wed, 28 Dec 2005, John Drake wrote: >> >>> So 6 instructions for colorForth versus 6 >>> instructions for optimized SwiftForth. Not >>> bad! But I want to make sure I've done the >>> disassembly right. Rummaging through the >>> c.l.f. archives I noticed Mark Slicker wrote >>> a definition for a non-existent MISC machine >>> that did it in 4 instructions. His definition >>> used "+IF" which ColorForth doesn't have. >>> I suppose you could add that as a Pentium >>> macro though. >> >> Just to clarify, this was 4 instructions for the >> non-existent machine, not >> 4 pentium instructions. > > Well I did say "non-existent MISC machine" but > the extra clarification is appreciated. :) > Note, in retrospect was that really 4 > instructions or 5? > > ====================================== > : digit > -10 + ( 2 bytes, transfer sign ) > +if 17 + ( 2 bytes, sign is positive ) > then 40 + ( 2 bytes, always ) > ; ( 1 byte, always ) > ====================================== > > I'm thinking the jump implied by "+if" > is a seperate instruction from "17 +"? > This is just an idea I had for instruction set. Think of ARM crossed with MISC. Each instruction can be executed conditionally, so +if 17 + then can be done in one instruction (2 bytes). 2-bits denote the condition and 6-bits denote the instruction, and the literal follows in the next byte. In one post I revised the conditions to: > - return following instruction > - execute the instruction if the sign is positive > - execute the instruction if the sign is negative > - execute the instruction always and came up with a 3 instruction 6 byte encoding: : digit -10 + ( 2 bytes, always ) +if 17 + then ( 2 bytes, sign is positive ) 58 + ; ( 2 bytes, return ) This is just a hypothetical machine to illustrate that if you really want a low instruction count in this example that can be acheived without much change to MISC. But as I said before, I'm not sure that examples such as this are the best for comparing different machines or designing new machines. I think we have to look at larger more complete programs, factoring in the cost of data flow, control flow, parameter passing, and subroutine execution. In addition, we need more variety if we are going to compare different general purpose machines on a more scientific basis than at present. >> I'm not sure I would add >> +if, since it is very >> close to -if, and in colorforth you are supposed to >> be thinking in terms >> of a MISC machine. In that particular example I >> think either would have >> worked. > > Samuel Tardieu sent me a colorforth > solution that is closer to what you > wrote and better than mine in that > it only uses 5 instructions. > > : digit -9 + -if -7 + then 64 + ; > > Which I assume dissassembles to: > > add EAX, -9 > jns label > add EAX, -7 > label add EAX, 64 > ret > Yeah, that is the idea.