Page 1 of 2

Fun with BASIC :)

Posted: Thu 04 May, 2006 9:07 pm
by ssartell
So I just felt like posting some fun ideas that I've thought about implementing in basic, but don't really have the time to do so. Most of this is purely based on data structure ideas.

faking pointers: enough said
stack: push, pop, stack pointer
recursive programs: making use the stack feature
fake dynamic memory: so you could write some nice sub programs to allocate and de-allocate dynamic memory
binary search trees: making use of dynamic memory
red/black trees: same
patricia trees: if you're just looking for a nasty challenge

Posted: Thu 04 May, 2006 11:11 pm
by threefingeredguy
You can already recurse in programs. And uh, have fun with the rest of that :D. Pointers would be nice.

Posted: Fri 05 May, 2006 12:23 am
by Dwedit
Faking pointers is easy, it's called ARRAY INDICES.

Posted: Fri 05 May, 2006 2:03 am
by ssartell
I'm not planning on actually writing any of this. I just figured I'd share some ideas with some of the people who are just learning to program. I know (and have already done) the things I posted for my courses, but I thought it might be good learning/entertainment for people who haven't or don't know how and also implementing them without actually having pointers and crap provides a slight challenge for BASIC programming. It was just a suggestion for anyone who wants to try it.

Posted: Fri 05 May, 2006 3:10 am
by Fr0stbyte124
The difficulties faced by BASIC programmers are a direct result of their chosen language. Assembly is the best (and usually only) solution to many of those problems. That's from experience; I'm sure most of us have tried this stuff, but the language is about as rigid as a functional language could be (there are exceptions, but those are mostly joke languages).

And btw, BASIC would make a mockery out of the efficiency of the tree system. And iteration can be done faster than recurse.

Posted: Fri 05 May, 2006 4:45 pm
by ssartell
Ok I guess I didn't make my point clear when I stated that these ideas were purely for learning and entertainment. I'm fully aware of the problems with basic and if you want me to state my credentials in terms of education to get across the simple idea of "I know!!!!" I'll gladly do so if it'll help stop people from pointing that out and then maybe consider that the issues with basic can be looked at as a challenging learning tool. This is why I presented non-native ideas (building new "datatypes" and data structures) in hopes that the people who need the experience might try them out and learn a thing or two or even meddle with the ideas in their head. Regardless of how slow BASIC is to z80 ASM, there are reasons people program in higher level languages and why they are developed which I hope you've learned in all that "experience" you have (thanks for pointing that one out for us frostybit).

Now to clear up a few other points. Naturally basic allows one program to call another program including itself, but this program (assuming it does some intensively recursive calculation) will overwrite it's own variables since they are all global. With this in mind the problem is more geared towards resolving scoping, either dynamically or statically, and will probably require you to implement a stack (natural for recursion) or some other type of data structure with what you have (hence the challenge).

The trees were offered as ideas in hopes that people might gain experience with graphs (directed or undirected) and consider options they have for data structures even in BASIC all things considered. With implementing trees this allows even BASIC programmers to consider styles of traversal or even shortest path algorithms. I was even considering posting ideas about implementing a higher level language in basic (if you haven't taken a compilers course, they often teach you how to write a compiler in a high level language so you don't have to try and mess with assembly) so maybe people might learn more about scoping, implementing enviroments, stores, typing, or maybe continuations. With this idea in mind it might also be useful to develop a high level language in z80 ASM other than BASIC for the calculator (even if the z80 is a CISC cpu) if not for you, but for others. We all know BASIC is slow, but this might make people consider why it is and how one might implement a faster language.

PS. I know BASIC is slow...

Posted: Fri 05 May, 2006 5:34 pm
by DarkAuron
The way I see it, some things are not meant for BASIC, others you just need to really train your programming skills to attain good results (like Pure TI-le..)

Re: Fun with BASIC :)

Posted: Sat 06 May, 2006 8:35 pm
by Timendus
ssartell wrote:stack: push, pop, stack pointer
I already wrote that once to explain the use of the stack to some Basic coders, here on this forum. Don't know where though :) I used L1 for a stack I think. Anyway, it's really not very helpful for anything.

Posted: Sun 07 May, 2006 3:06 am
by DarkAuron
Except on-calc practice I guess.

Posted: Tue 09 May, 2006 10:10 pm
by ssartell
So I had posted before the prospects of someone creating a new higher level language for the z80 besides BASIC and I put some thought into how I might implement such a language and compiler and I'm actually kind of curious about the project. I think I would probably make it similar to C/C++ in most regards. I'm positive I could make a faster and more efficient language than BASIC and I've taken a couple courses in programming languages and compilers so I have a good understanding of how they work. I think I could create a language with more versatility in terms of types and I'm certain I could make it much faster than basic. Would such an endeavor actually be intersting to anyone? I don't know if I would actually use it for many projects myself (I don't really have much of an interest in z80 programming anymore) but I am entirely interested in the prospect of building a language and compiler for it.

Posted: Wed 10 May, 2006 12:42 am
by threefingeredguy
One of the summer of code projects on Detached Solutions is a new language for calcs, maybe you could do that.

Posted: Wed 10 May, 2006 9:38 pm
by ssartell
I'm not so hot with group projects so I think I still might just try on my own. See what I can come up with. And then I also don't have any responsibility to finish anything if I can't find the time.

Just for clarification purposes so I can plan some things ahead, correct me if I'm wrong about anything with the hardware of the 83+. The z80 is a multicycle, non-pipelined, 8-bit processor with capabilities of 64K of addressable memory. The 83+ specifically has 32K of addressable flash mem and 32K of RAM with the most significant bit differentiating right?

Posted: Thu 11 May, 2006 11:28 am
by benryves
Download the TI-83 Plus Developer Guide for a memory-map, as well as fairly useful information on the rest of the hardware. The system routines manual is pretty useful as well.

Posted: Thu 11 May, 2006 4:14 pm
by ssartell
Wow that'll work. Thanks!

Posted: Fri 12 May, 2006 8:05 pm
by ssartell
So I'm trying to decide which language to use to build my compiler. I plan on converting from C++ style (probably not a full implementation) to z80 asm. I don't think I want to use C/C++ to write it because of stricting type checking and rigid data structures (unless I can figure out how to make a more dynamic data structure). I was considering using a offspring of Lisp because of the versatilities of list structures. However I'm not sure it'd be that great in other aspects. Does anyone have any good suggestions or experience that might help guide my decision?