Fun with BASIC :)

Got a brilliant program idea? Let us know!

Moderator: MaxCoderz Staff

ssartell
Regular Member
Posts: 76
Joined: Fri 02 Dec, 2005 5:39 pm

Fun with BASIC :)

Post 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
threefingeredguy
Calc King
Posts: 2195
Joined: Sun 27 Mar, 2005 4:06 am
Location: sleeping
Contact:

Post by threefingeredguy »

You can already recurse in programs. And uh, have fun with the rest of that :D. Pointers would be nice.
Image
User avatar
Dwedit
Maxcoderz Staff
Posts: 579
Joined: Wed 15 Dec, 2004 6:06 am
Location: Chicago!
Contact:

Post by Dwedit »

Faking pointers is easy, it's called ARRAY INDICES.
You know your hexadecimal output routine is broken when it displays the character 'G'.
ssartell
Regular Member
Posts: 76
Joined: Fri 02 Dec, 2005 5:39 pm

Post 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.
User avatar
Fr0stbyte124
Regular Member
Posts: 75
Joined: Thu 16 Feb, 2006 9:59 pm

Post 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.
ssartell
Regular Member
Posts: 76
Joined: Fri 02 Dec, 2005 5:39 pm

Post 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...
DarkAuron
Maxcoderz Staff
Posts: 1349
Joined: Sat 18 Dec, 2004 6:53 pm

Post 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..)
[Gridwars Score] - E: 1860037 M: 716641 H: 261194
User avatar
Timendus
Calc King
Posts: 1729
Joined: Sun 23 Jan, 2005 12:37 am
Location: Netherlands
Contact:

Re: Fun with BASIC :)

Post 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.
http://clap.timendus.com/ - The Calculator Link Alternative Protocol
http://api.timendus.com/ - Make your life easier, leave the coding to the API
http://vera.timendus.com/ - The calc lover's OS
DarkAuron
Maxcoderz Staff
Posts: 1349
Joined: Sat 18 Dec, 2004 6:53 pm

Post by DarkAuron »

Except on-calc practice I guess.
[Gridwars Score] - E: 1860037 M: 716641 H: 261194
ssartell
Regular Member
Posts: 76
Joined: Fri 02 Dec, 2005 5:39 pm

Post 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.
threefingeredguy
Calc King
Posts: 2195
Joined: Sun 27 Mar, 2005 4:06 am
Location: sleeping
Contact:

Post by threefingeredguy »

One of the summer of code projects on Detached Solutions is a new language for calcs, maybe you could do that.
Image
ssartell
Regular Member
Posts: 76
Joined: Fri 02 Dec, 2005 5:39 pm

Post 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?
User avatar
benryves
Maxcoderz Staff
Posts: 3087
Joined: Thu 16 Dec, 2004 10:06 pm
Location: Croydon, England
Contact:

Post 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.
ssartell
Regular Member
Posts: 76
Joined: Fri 02 Dec, 2005 5:39 pm

Post by ssartell »

Wow that'll work. Thanks!
ssartell
Regular Member
Posts: 76
Joined: Fri 02 Dec, 2005 5:39 pm

Post 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?
Post Reply