Talk About Network



Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Basic Compiler > Re: BASIC gramm...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 9 of 14 Topic 75 of 149
Post > Topic >>

Re: BASIC grammar

by arargh403NOSPAM@[EMAIL PROTECTED] Mar 10, 2004 at 02:14 AM

On Tue, 09 Mar 2004 14:29:56 -0600, arargh403NOSPAM@[EMAIL PROTECTED]
 pushed the wrong button before I was finished.  Plus, I wanted
to think a little more before finishing.

>On Tue, 09 Mar 2004 19:16:56 +1100, Johnathan
><zork_666@[EMAIL PROTECTED]
> wrote:
>
<snip>
>
>>I think I might even go back to my original idea of Modula-2/Pascal 
>>subsets, especially now that you mention there's little scope for 
>>optimisation of any kind (it's certainly the case my original will use 
>>calls to the standard C library).
If it weren't for Pascal permitting nested SUBs/FUNCTIONs, I could
write a front end similar to BCET and use the rest of the system
pretty much as is.  I don't think that Pascal would be all that
different (internally) from Basic.  However, I don't have a good
grammar for Pascal, nor all that much interest.

>The BCET code generator emits pretty simple code, for:
>	C = A + B
>you get:
>	lod	A
>	lod	B
>	add
>	sto	C
>which BOPT changes to:
>	lod	A
>	add	B
>	sto	C

This should be closer to:
The BCET code generator emits pretty simple psedo code, for:
	C = A + B
you get:
	lod	eax,A
	lod	ebx,B
	add	eax,ebx
	sto	eax,C
which BOPT changes to:
	lod	eax,A
	add	eax,B
	sto	eax,C

With different regs, probably.

There are several places where BCET could optimize more.  Common
sub-expression, for one:
	C = (A + B) * (A + B) 
will calculate (A + B) twice.  Hopefully, neither A or B are function
calls with side effects. :-)

Constant expression folding:
	C = ASC("A")
actually generates the code to do it, but what should happen is:
	mov	C, 65

Turn SELECT CASE's into a jump table, in some cases.

But these things require a pass over the expression tree between BCET
& BGEN.

>>
>>> There isn't too much that can be done in terms of code optimaztion.
>>> Basic generally winds up doing so many library calls, that there isn't
>>> much left to optimize.  Take a look at the intermediate files of a
>>> BCET compile.
	Or a QuickBasic/PDS/VBDOS listing.

>>
>>You've worked on BCET since 1992?  What was that paper you mentioned in 
>>the FAQ which gave you a hint about code generation?
>I believe it was this one:
>http://www.cs.princeton.edu/software/iburg/iburg.pdf
>and the .PS files in this one:
>ftp://ftp.cs.princeton.edu/pub/packages/iburg.zip
>
>>
>>> Gee, that's where I was, 12 years ago.  
>>
>>12 years... hmmm.  Long road ahead. :)
>It was a part time project most of the time.  If I had had any formal
>schooling on the subject, it would gone faster.

-- 
Arargh403 at [drop the 'http://www.'
from ->] http://www.arargh.com
BCET Basic Compiler Page: http://www.arargh.com/basic/index.html

To reply by email, remove the garbage from the reply address.




 14 Posts in Topic:
BASIC grammar
Johnathan <zork_666@[E  2004-03-09 01:35:52 
Re: BASIC grammar
erewhon@[EMAIL PROTECTED]  2004-03-08 14:51:57 
Re: BASIC grammar
Johnathan <zork_666@[E  2004-03-09 04:52:32 
Re: BASIC grammar
"Stephen J. Rush&quo  2004-03-08 13:58:24 
Re: BASIC grammar
Johnathan <zork_666@[E  2004-03-09 08:02:15 
Re: BASIC grammar
arargh403NOSPAM@[EMAIL PR  2004-03-08 16:01:11 
Re: BASIC grammar
Johnathan <zork_666@[E  2004-03-09 19:16:56 
Re: BASIC grammar
arargh403NOSPAM@[EMAIL PR  2004-03-09 14:29:56 
Re: BASIC grammar
arargh403NOSPAM@[EMAIL PR  2004-03-10 02:14:26 
Re: BASIC grammar
arargh403NOSPAM@[EMAIL PR  2004-03-08 15:47:38 
Re: BASIC grammar
"Markku Alén" &  2004-03-08 23:30:26 
Re: BASIC grammar
Johnathan <zork_666@[E  2004-03-09 19:22:03 
Re: BASIC grammar
"Markku Alén" &  2004-03-21 02:31:17 
Re: BASIC grammar
"Scott Moore" &  2004-03-10 08:22:41 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Fri May 16 22:41:04 CDT 2008.