ticalc.org
Basics Archives Community Services Programming
Hardware Help About Search Your Account
   Home :: Archives :: News :: Feature: C Programming Editorial

Feature: C Programming Editorial
Posted by Nick on 13 May 2000, 07:06 GMT

Scott Dial of the TCPA (both of which are down because Dim-TI's server is acting up again =[ ) has written our next (belated) feature on C programming on calculators. It's opinionated, so I have to say that Scott's opinions don't reflect my opinion or that of ticalc.org's.


The use of C on a calculator is a horrible waste of space. I love the idea as much as the next guy, but there simply isn't enough space for all the bloated code. GCC doesn't produce the most optimized code by far. *gasp* I understand using it to ruff in some program that you need real quick, but any complex program is going to bloat that much more. I even particurally like the fact that I can port a program for my pc to the 89 relatively easily.

What I can't stand is how many people think that C is so much better than asm... There are some real complex things you can do with C that I would be wary of attempting with ASM, but it still could be done cleaner in ASM. The GCC compiler isn't exactly optimal either. Anyone ever looked at the source (-S) it produces? Who in their right mind would use moveq.l #0,d0 to clear it? It has no clue that there is even a better choice... Or how about it moves values on the local stack that don't even need to be preserved or referenced in that method... movew d0,-2(a6) \ tst.w -2(a6). No one can replace the human mind.

I would hate to see all the programmers of tomorrow using C because it is easier... nothing great is ever easy. C is the lazy mans excuse to not learn to really program the calculator. What's that you say? The AMS was written in C... well yes it was and I hate TI for it. Space is not a luxury on such a small memory capacity. If every new programmer that comes in starts writing everything in C then space becomes even less of a luxury. Long live assembly!

 


The comments below are written by ticalc.org visitors. Their views are not necessarily those of ticalc.org, and ticalc.org takes no responsibility for their content.


Re: Feature: C Programming Editorial
Dark_Ninja

I just have two comments...one about the article, and one miscellaneous question.

1. Scott, you mentioned something about C being the lazy man's way out of programming ASM and nothing great is ever accomplished when it is easy (or something to that effect). Anyway, I'm just here to say that C, and it's sister language, C++ are very strong languages that have become the staple of programming in the computer world. As for writing them on the calculator, personally, although I know ASM is better in some cases, it doesn't matter to me whether someone programs in C or ASM. Games and programs are what most people are looking for. I don't think too many people care that much if a program was written in C or directly in ASM.

2. As for my question, I'm wondering why high scores can't be stored when a program is archived? Is there any way around this? And, how exactly does a game work when it is archived and you run it? (Like...what's the process the calculator goes through?) Thanks for any help.

Dark Ninja

     13 May 2000, 17:42 GMT


Re: Re: Feature: C Programming Editorial
Zeljko Juric  Account Info
(Web Page)

About high scores:

Every time the archived program is executed a twin copy of it is created in RAM, and this twin is executed in fact instead of the original program (this is necessary to allow self-modifying programs to run correctly). Now, if the program keeps highscores in the program file itself, updating highscores will update the twin program, not the original one. After execution, twin symbol will be deleted, and the end of this story may be concluded from here...

Any solution? Keep high scores in a separate file (not in the program file itself), which of course must not be archived, except if you want to write directly to the archive memory (although this is also not so hard: TIOS function EM_write is dedicated for it, and it will be included in TIGCCLIB 2.0). Of course, keeping high scores in a separate file is harder. For keeping in the program file itself, it is enougt to declare an array as "static"...

     13 May 2000, 18:08 GMT

A technique for saving high scores
James!  Account Info

I have an idea about how to save high scores for archived programs. Doors Explorer has the ability to "hide" variables from view in TIOS. If a program wanted to save high scores, it could create a variable, hide it in the same manner as Doors Explorer does, and save its scores there. That way, programs would only appear as one variable on the Var-Link screen (I hate programs that take up more than one variable) and people wouldn't accidentally archive the high score variable and mess up the program. This seems to me to be a good solution for saving high scores. The only problem is that every program would have to have a unique name for its variable or they would overwrite each other. What do you guys think about this idea?

     13 May 2000, 22:31 GMT

Re: A technique for saving high scores
JaggedFlame

Well, let's say your program stores it in the variable "high" and hides it. Then, the user tries to store a variable to the variable 'high' - say he's working on a minimum/maximum problem. Then he's wondering why it says "Non-algebraic expression in variable"...

But overall it's a good strategy.

     13 May 2000, 23:09 GMT


Re: Re: A technique for saving high scores
James!  Account Info

I think that it is easy enough to pick obscure names for hidden variables that no one would ever use. Instead of "high" you could use "high3463" or "fooblah6," two names which I am sure no one would ever try to use. On a different note, storing high scores this way wouldn't fill up your calc's memory with variables since it would take hundreds of these small variables to even make a dent in the TI-89's memory capacity, and they would all be deleted when the calculator was reset anyway.

     16 May 2000, 00:46 GMT


Re: A technique for saving high scores
Paulo Marques  Account Info
(Web Page)

Well, since we're talking about C, why not create an interface to access a file named highscore' or smtg which would include all highscores and saves, like a table, or database. It's better than having unknown memory ocupied or hidden vars, i think. Anyway, I believe games should achieve a common way to do it.

Cd_Slayer

     14 May 2000, 02:53 GMT


Re: Re: A technique for saving high scores
Sebastian Reichelt  Account Info

This is a good idea. We should make a registry variable that acts like the Windows Registry, and create a C header file to access it. Then highscores and settings could easily be saved, and you could also make a backup utility for it.

Any ideas on how to make this fast enough? Can you hide folders? Then you could use a hidden folder with variables for each key.

     14 May 2000, 07:00 GMT


Re: Re: Re: A technique for saving high scores
Paulo Marques  Account Info
(Web Page)

On a lighter comment, note that the keywords here are easy and fast.
Anyway, filling the calc with folders might create the invisible vars problem again (with folders), and would probably be too many anyway. My idea was having some sort of database... with an index at the begining (or end, maybe more practical) where a program would check out where to write in the file. But that would mean fixed space... And another thing would be making the OS copy it, let the copy be changed, and copy it back and archive it.


Cd_Slayer

(Sorry, no solutions, I don't know how far these things CAN be made.)

     16 May 2000, 00:17 GMT


Re: Re: Re: Re: A technique for saving high scores
Sebastian Reichelt  Account Info

What I was thinking is having one folder and a variable for each key. That would solve the "fixed size" problem, but it would be nice if the folder could be hidden. Also, you could archive variables seperately.

     16 May 2000, 02:16 GMT


Re: Re: Re: Re: Re: A technique for saving high scores
Paulo Marques  Account Info
(Web Page)

Duh! Of course...
Hope someone is reading this thread... someone with superpowers, enough to make Doors and TIGCC and... all the the other nice things.

Cd_Slayer

     17 May 2000, 14:14 GMT

Re: Re: Re: Feature: C Programming Editorial
-Syldaril  Account Info

Hey Zelco !
I wanted to ask you about all the ROM knowledge you have, where did you find all the information about the parameters you use for every ROM call, wheter to use the sp, d0, a6, etc, and what kind of data you would expect the routine to generate ? I guess you didn't have any source and you've been studying the calc memory by yourself. Am I wrong ?

     14 May 2000, 22:26 GMT


Re: Re: Re: Re: Feature: C Programming Editorial
Zeljko Juric  Account Info
(Web Page)

You are right. I haven't any sources. All my knowledge about ROM calls is from studying the ROM manually (using VTI). For some routines, this is not so hard. As I have good programming experience, for some routines I have apriori assumption what they should to do. And, very often, when you succeed to discover usage of one routine, a lot of other related routines become more clear. Sometimes, when I had no idea about parameters of some routines, I traced execution of some TI-BASIC programs to see what TIOS do during execution of particular BASIC commands. For example, I used this technic to discover proper usage of menu and dialog functions.
Usage of registers is very clear: everything is in according to C calling conventions. The only problem for discovering was unusual usage of A6 in floating point routines, but when one routine is broken, the similar is automatically true for a lot of others...

     15 May 2000, 09:33 GMT


Re: Re: Re: Feature: C Programming Editorial
-Syldaril  Account Info

Ooops, I'm sorry for mispelling.....I meant
Hey Zeljco.........

     14 May 2000, 22:33 GMT


Re: Re: Re: Re: Feature: C Programming Editorial
Zeljko Juric  Account Info
(Web Page)

Misspeling again... right is "Zeljko" :-)

Nothing strange about misspeling, this name is fairly uncommon for everybody which is not familiar with Bosnian lagnuage (or with very related Croatian and Serbian languages).

     15 May 2000, 09:36 GMT

Re: Feature: C Programming Editorial
taliessin penfound  Account Info

I know that everyone here is hard at work dissin' C, but has anyone with a TI-89 tried the AeroX demo? It's fast, pretty small, and has great graphics and effects!

     13 May 2000, 18:24 GMT


Re: Re: Feature: C Programming Editorial
MathJMendl
(Web Page)

That is one good example of a good C program. The only problem is that it takes 22k and all you can do is go through a single, short track! If all programs were so big then you could probably hold fewer programs. I haven't heard of any other notable C program, however, aside from SnoBoard, but it crashes my calculator and so I choose not to use it.

     13 May 2000, 22:18 GMT

Re: Re: Re: Feature: C Programming Editorial
Blue_Z  Account Info
(Web Page)

There are many assembler games that are huge without any reasons ! For example, Bomberboy. So that is not C's fault.

     13 May 2000, 23:45 GMT


Re: Re: Re: Feature: C Programming Editorial
Mike Grass Account Info
(Web Page)

>I haven't heard of any other notable C program,
>however, aside from SnoBoard, but it crashes my
>calculator and so I choose not to use it

TI-Chess is in C. It is probably one of the greatest TI programming examples there is. C can be bloated for games and such, but math programs (which are nearly impossible in ASM) are fast--much more so than BASIC math programs-and can be very nice.

     13 May 2000, 23:58 GMT


Re: Re: Re: Re: Feature: C Programming Editorial
Sebastian Reichelt  Account Info

AUTOmatix, my Lotus port, will be in C. Look at the "Custom 3D Road." It's small and fast.

     16 May 2000, 02:19 GMT

Calculus Test
MarkHazard  Account Info

I found the AB test easy overall. The cacl-less Free Response was killer though! They don't teach the BC stuff @ my high school. Was the BC easier than the AB?

Mark Hazard fellow AP Calc student

     13 May 2000, 19:07 GMT

Re: Calculus Test
ColdFusion

I gotta agree... the Calculus AB test was easy as hell; I was shocked at its simplicity. Then we got to the final section, the calc-less free response questions, and they were some sons of bastards.

     13 May 2000, 19:24 GMT

Re: Re: Calculus Test
Sebastian Reichelt  Account Info

You're absolutely right. I even made a mistake in question 4 that forced me to calculate 121^(2/3) by hand, and a lot of other unpleasant calculations. But I finished everything.

     13 May 2000, 19:34 GMT

Re: Re: Calculus Test
sean noonan  Account Info

the calc-less free response were completely unexpected by me. i'll have to say that i enjoyed the multiple choice and the calc-less free response more that the other free response...of course, this could be because i made a few (read: hopefully less than i'm afraid of) stupid mistakes throughout. the MC was really easy though. just my thoughts though. a little bit too long....4 and a half hours for an AP test....granted, it was my first of two this year (I have chem on tuesday), but still...the seniors who were in the class with me agreed it was long. (i'm the only junior)...aaaaarrrrrggggghhhhh

     13 May 2000, 19:42 GMT


Re: Re: Calculus Test and Assembly language and C
v8

I just took the Calculus AB test last year, and my friend just took the exam and it was practically the same simplistic test it will always be. I just took Calculus III my first year in college this semester, and you will have mirth once you get into Calculus III and start doing multiple integrals,functions of several variables, and partial differentiation.

As for assembly language and C, nobody will ever agree on this subject. Assembly language which is low-level programming and requiring as many as two dozen lines of code to add two numbers. Yes, assembly language programs are more quandary and tedious to write, neverless, assembly language code is condensed, operates quickly, and, when assembled, is more efficient than a compiled program written in a high-level language.

C which is a high level programming language integrates the efficacy of high-level programming languages with efficiency of an assembly language. I enjoy C++ because it has all the advantages of the C language with those of object-oriented programming languages.

     13 May 2000, 23:46 GMT

Re: Calculus Test
Daniel Bishop  Account Info

I took the BC test last year and got a 5 for both the BC score and the AB subscore. It was very easy (or maybe it just seemed that way because I had taken the english test the day before)

     13 May 2000, 20:03 GMT


Re: Re: Calculus Test
Doug Torrance  Account Info
(Web Page)

Yeah, I thought BC was easy last year too--talking to all my AB friends afterwards, it seemed like it was practically the same test. Of course, that was before the AP Board made the free response no calcs. :)

     14 May 2000, 03:00 GMT

Re: Calculus Test
MathJMendl
(Web Page)

The BC test was not too difficult, except for the Part I multiple choice section without a calculator (which was still doable). The second mult choice, with a calculator, was amazingly easy, and the free response section was also very easy.

     13 May 2000, 22:20 GMT

Re: Re: Calculus Test
Ryser  Account Info

I agree with you. The no-calc multiple choice was a pain in the ass, but the rest was pretty simple.

     14 May 2000, 21:57 GMT


Re: Re: Calculus Test
Russell Howes  Account Info

I found it pretty much the same, except for number one on the free-response (which was also on the AB test.) If anybody remembers it, I tried to integrate it from zero to one instead of calculating point of intersection, and then I did something else which involved trying to divide by zero, so I put off the question and ended up trying to milk it for points at the end of the non-calc portion, which I doubt worked.

I'm pretty sure I passed it, albeit not with a 5. And if I didn't, I can always try again next year. Could anybody tell me what Statistics is about? I'm taking that next year and I'd like to know what I'm getting into.

     15 May 2000, 07:32 GMT

Re: Calculus Test
bilal
(Web Page)

Hmmm... yeah, the calc AB exam was pretty easy. Too bad I didn't get to use all the neat programs I snatched from ticalc.org for my TI-89 :)

     14 May 2000, 00:05 GMT


Re: Re: Calculus Test
Sebastian Reichelt  Account Info
(Web Page)

My calculator froze when I tried to graph something during the exam. Sux.

     19 May 2000, 00:55 GMT

Re: Calculus Test
Michael Brunner  Account Info
(Web Page)

I took, AB. I probably fudged up a few questions, so I'd say I probably got a 3 or a 4. I couldn't get free-response question number 5 (the one about tangent line slopes). All the other questions were surprisingly easy.

     14 May 2000, 02:24 GMT

Re: Re: Calculus Test
FryGuy1013

5(c) was a bit difficult. I had to come back to it. If i remember right, the problem was xy^2 - x^3y = 6, and it was needed to find the x coord where the tangent line was vertical. it gave us the derivative indirectly, which calcing it out now was:

2xyy' + y^2 - x^3y' - 3x^2y = 0
y'(2xy - x^3) = 3x^2y - y^2
dy/dx = (3x^2y - y^2) / (2xy - x^3)

and they wanted where the tangent line was vertical, so that would mean that dx/dy = 0 (i think). so:

dx/dy = (2xy - x^3) / (3x^2y - y^2) = 0
so:
2xy - x^3 = 0
x(2y - x^2) = 0
x = 0; y = (1/2)x^2

this is where i got stuck.. I think what we were supposed to do is plug this back into the original equation.

modifying the original equation:
xy^2 - x^3y = 6
and plugging in 2y=x^2
1/4x^5 - 1/2x^5 = 6
-1/4x^5 = 6
x = 24^(1/5)

hmm.. you calc 3 people respond :)

Kevin
fryguy1013@yahoo.com

     14 May 2000, 04:50 GMT

Re: Re: Re: Calculus Test
Sebastian Reichelt  Account Info

If my math teacher was right (sometimes he's not, I hope he is this time), all you have to do in such a case is set the denominator of dy/dx equal to zero, which would give an undefined slope. Then you have an equation with x and y; you solve it for y, and then plug it back into x*y^2 - x^3*y = 6. This would give you x.

I know this is basically what you are saying in short terms, but here is the one mistake you made, which will probably cost you points:

dx/dy is NOT 1/(dy/dx)

dy/dx implies that y is a function of x (or whatever you would call it in implicit differentiation). TI-89s made that clear to me, because you have to type d/dx(y(x)) for them. You get a different formula for dx/dy, because in that case, x is a function of y. Try it with some equations, and you'll find out that I'm right.

Anyways, you probably have the right answer. I don't remember.

     14 May 2000, 08:13 GMT

Re: Re: Re: Re: Calculus Test
Jason Schoenfelder  Account Info

dx/dy IS 1/(dy/dx). The notations imply different dependent/independent variables, but the resulting expression is still the same. Next time you find both dy/dx and dx/dy on the 89/92/whatever, put dx/dy in terms of x or dy/dx in terms of y (manually if you must). You might be surprised at the result.

     14 May 2000, 14:29 GMT


Re: Re: Re: Re: Calculus Test
O4saken1  Account Info

your math IS right.
Hey, let me ask EVERYONE who took the AP CALCULUS AB test. Is it just me, or was the WHOLE THING the simplest test in the world? My god, I walked out KNOWING that I got a 5. I think maybe our teacher OVER PREPARED us.
Also, I've been confused sinces 1st grade. but is math common sense to you guys? b/c it is to me, and I don't understand how people can not get it, (even the smartest people sometimes). And I'm not bragging cuz I SUCK at history and other social studies. But I just wanted you guys' opinions on our "higher level" of mathematics. I figured if you can program video games and learn different computer languages, then math should be somewhat of an insult when presented to you. (cuz sometimes I feel insulted). AAAAAAAAAand, (I know i'm talking but not really saying anything) I know i'll be taking calculus BC next year as a freshman in college, but what's AFTER calculus?????????????????
BTW, Today, may 14 (mother's day) Is my birthday. Look out world........

     14 May 2000, 14:35 GMT


Re: Re: Re: Re: Re: Calculus Test
Andy Selle  Account Info
(Web Page)

I must say I'm dismayed by the number of people "bragging" about how easy the calculus AP was for them. Who really cares? There's lots of fun stuff in the realm of higher mathematics. There is differential equations (much more complicated than the simple ones you've encountered). There's number theory, sequences and series of numbers (convergence, etc.). There is also complex analysis (derivatives, integrals, and lots of other fun things extended to the complex plane). There's topology, hyperbolic geometry... As far as calculus, there's still lots of fun things left. For example, Calc III extends calculus to n dimensions. This has consequences that are beneficial to physics. You will learn about functions of multivariables, partial derivatives, gradiants, line integrals, multiple integrals, surface integrals, and lots of other fun things.

     14 May 2000, 23:32 GMT


Re: Re: Re: Calculus Test
Jonah Cohen  Account Info
(Web Page)

-1/4x^5 = 6
x = (-24)^(1/5)

Negative 24, not positive.

     14 May 2000, 15:48 GMT


Re: Re: Re: Re: Calculus Test
sean noonan  Account Info

actually, i don't feel like doing the math right now, but i did on the test. both positive and negative came out. however, i believe that the negative root did not fit something or other, so only the positive one applied. i don't completely remember. but now, its off to take the chem test tomorrow.

     16 May 2000, 00:22 GMT


Evil Number 5!!!! grrrrr........
MarkHazard  Account Info

It's nice to know that I wasn't the only one who got his butt kicked by number 5! I think I got a three on that one. Hey, who here is taking more than the three AP tests I'm doing? Govt., Calc AB, and English Lit?

Mark Hazard

     14 May 2000, 06:37 GMT


AP tests........
BPacker2000  Account Info

I've will have taken 11 AP tests after tomorrow...and Calc AB (last year) was by far the easiest one...

my lack of effort in BC calc kinda screwed me up with a couple of the questions...I was rather unprepared for the little dissertation on slope fields in #6

this year I'm taking/taken AP Lit, Govt., Biology, Chem, and Calc BC

     17 May 2000, 02:39 GMT


Re: AP tests........
Mark Leverentz

What did you think about the Chemistry test?

I thought it was significantly harder than any of the AP tests I've taken before.

     18 May 2000, 00:18 GMT


Re: Re: AP tests........
BPacker2000  Account Info

I thought the MC wasn't bad at all...the FR wasn't very cool...the lab question kinda screwed me...
I'll get at least a 4 though...but it doesn't really matter to me...the Chem credit is worthless to my college degree...

     18 May 2000, 01:48 GMT


Re: Calculus Test
Nathan Walters  Account Info

it's funny, you know? i hardly used a calculator on the calc free response, but on the calcless free responce, i wish i had it. oh well. i fell i did rather well. i took the ab.

     16 May 2000, 00:12 GMT

1  2  3  4  5  6  

You can change the number of comments per page in Account Preferences.

  Copyright © 1996-2012, the ticalc.org project. All rights reserved. | Contact Us | Disclaimer