Subject: Re: [TI994A] Re: XB Cross Compiler

From: mark wills <[email-masked]>
Date: Tue, 3 Nov 2009 10:11:56 +0000 (GMT)

Yeah, hard to do though:

x=SQR(X/2*1.449*(INT((y/3)*7))+ATN(7.998)

And the assembly equivalent is? :-/

I believe stack-like systems are used to resolve complex arguments like the one above.

;-)

>
>From: kabldb <[email-masked]>
>To: [email-masked]
>Sent: Tue, 3 November, 2009 10:54:08
>Subject: [TI994A] Re: XB Cross Compiler
>
> >
>
>
>
>  
>Okay, so I guess you would produce machinecode or assembler source instead of XB bytecode. You could do both though ...
>
>>:-)
>
>>--- In TI994A@yahoogroups. com, "Tursi" <yahoogroup@ ...> wrote:
>>>
>>> > Writen an Extended Basic cross-compiler would be a big, fun task ;-)
>>> 
>>> It's something I've talked about doing and is still high on my list.. 
>>> but like many things on my list, someone else may get to it first. ;)
>>> 
>>> I'd kind of like to do it and have it able to export for MSX and 
>>> ColecoVision, too.. we'll force them to use OUR language. ;)
>>>
>
>
> > >

---

From: "Tursi" <[email-masked]>
Date: Tue, 3 Nov 2009 11:08:31 -0500

>I believe stack-like systems are used to resolve complex arguments like 

I already have written code that can parse most of that (it doesn't 
support the function calls as it stands today, but it supports six 
functions (+,-,*,/,%,^) and order of operations. It also optimizes the 
resulting code and does constant folding. It does use a stack approach 
since that was simplest, especially for the optimization phase. Today 
it's for Jaguar RISC (I did it as an example for someone) but it's 
simple enough to port. Although conceptually stack-based, the code is 
designed for free implementation, on the RISC I actually use nothing but 
registers emulating a stack.

The resulting stack was actually inspired by Forth, so the result may be 
familiar. ;)

Anyone curious to look at it can see it at 
http://harmlesslion.com/temp/parser.zip  -- there's no executable to 
look at, only source for Windows, but I tried to comment it fairly well 
since it was an example for someone.