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

From: ti99_forever <[email-masked]>
Date: Tue, 3 Nov 2009 03:13:57 -0800 (PST)

But in Forth, it is up to the programmer to parse such expressions.
But yes, a stack can be used to evaluate this - elementary computer science.
And yes, the TI has the value stack to utilize in evaluating these expressions.

--- On Tue, 11/3/09, kabldb <[email-masked]> wrote:

From: kabldb <[email-masked]>
Subject: [TI994A] Re: XB Cross Compiler
To: [email-masked]
Date: Tuesday, November 3, 2009, 5:59 AM

    
                  Would think so. Much like your Forth implementation I guess ?

:-)

--- In TI994A@yahoogroups. com, mark wills <markrobertwills@ ...> wrote:

> 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 <kabldb@...>

> >To: TI994A@yahoogroups. com

> >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: mark wills <[email-masked]>
Date: Tue, 3 Nov 2009 03:33:09 -0800 (PST)

Not really, it's so simple in Forth it's actually funny. That's because it's arguments always come from the stack. So the words that do something take something off the stack, and put the answer back on the stack. That's ALL they do:

X 2 / 1.449 * Y 3 / INT 7 * 7.998 ATN +

You'd write it (something) like that in Forth.

So, / is actually an executable word. It is programmed to take two arguments off the stack, do the calculation, and place the answer on the stack. 

The compiler just compiles the addresses of the executable words. That's all a forth program is, a list of addresses. For constants/numbers, it compiles a call to LIT which pushes the number on the stack.

For traditional languages, it looks like you have to walk the argument, and tokenise as you go. Each time you come to a ( or a ) or an operator like + - * / etc you push to the stack, as a sort of place holder.

I think it's quite a complex routine, decoding arguments. I'd like to look at it more when I get time.

Probably the sort of thing you could prototype in C or even XB, to get the theory working.

Then code the sucker in 9900 and watch it fly! Next thing you, new version of basic!

>Sent: Tue, 3 November, 2009 11:59:17

---

From: mark wills <[email-masked]>
Date: Tue, 3 Nov 2009 03:33:59 -0800 (PST)

Any useful sources I could read?

M

>
>From: ti99_forever <[email-masked]>
>Sent: Tue, 3 November, 2009 12:13:57
>Subject: Re: [TI994A] Re: XB Cross Compiler
>
> >
>
>
>
>  
>--- On Tue, 11/3/09, kabldb <kabldb@yahoo. dk> wrote:
>
>
>>From: kabldb <kabldb@yahoo. dk>

---

From: ti99_forever <[email-masked]>
Date: Tue, 3 Nov 2009 03:35:44 -0800 (PST)

Actually, easy... one of the entry levels of computer science you do it. Data Structures, IIRC, when stacks were introduced. Later we did a version as a binary tree. Why? I dunno, use the simplest data structure that can do the work, I always say.

We even did it again in Computer Organization...

--- On Tue, 11/3/09, mark wills <[email-masked]> wrote:

From: mark wills <[email-masked]>
Subject: Re: [TI994A] Re: XB Cross Compiler
To: [email-masked]
Date: Tuesday, November 3, 2009, 6:33 AM

    

For traditional languages, it looks like you have to walk the argument, and tokenise as you go.
 Each time you come to a ( or a ) or an operator like + - * / etc you push to the stack, as a sort of place holder.

To:
 TI994A@yahoogroups. com

:-)

--- In TI994A@yahoogroups. com, mark wills <markrobertwills@ ...> wrote:

---

From: mark wills <[email-masked]>
Date: Tue, 3 Nov 2009 03:42:06 -0800 (PST)

Hrmph... I knew I should have gone to college... My family couldn't afford it though, so it was off to work for me, at the age of 16 :-(

>Sent: Tue, 3 November, 2009 12:35:44
>We even did it again in Computer Organization. ..
>
>--- On Tue, 11/3/09, mark wills <markrobertwills@ yahoo.co. uk> wrote:
>
>
>>From: mark wills <markrobertwills@ yahoo.co. uk>
>>>To: >>> TI994A@yahoogroups. com

---

From: ti99_forever <[email-masked]>
Date: Tue, 3 Nov 2009 04:22:25 -0800 (PST)

Of course! Somewhere!

I have a Data Structures book that has both the pseudo-code and code (in Pascal) for just that thing. I'd have to find it. And I was entering most of those sources into UCSD Pascal at one point...

I bet a Google search would turn up what you need. And I do have my computer organization book, but I don't think it has any code - just how to do it yourself.

I was probably the fastest in my class. 

Wait, who am I talking to here! Mark, if you can transpose an infix expression to postfix for Forth, you are already doing it. Just think about how the stack data structure helps you to perform this operation.

 

M

From: ti99_forever <ti99_forever@ yahoo.com>
To: TI994A@yahoogroups. com
Sent: Tue, 3 November, 2009 12:13:57
Subject: Re: [TI994A] Re: XB Cross
 Compiler

 

:-)

--- In TI994A@yahoogroups. com, mark wills <markrobertwills@ ...> wrote:

---

From: mark wills <[email-masked]>
Date: Tue, 3 Nov 2009 04:34:30 -0800 (PST)

<snip>
Wait, who am I talking to here! Mark, if you can transpose an infix
expression to postfix for Forth, you are already doing it. Just think
about how the stack data structure helps you to perform this operation.
</snip>

Yeah, I guess you're right! Hmmm... I need to think about that!

Mark

>Sent: Tue, 3 November, 2009 13:22:25