Re: Help


[Prev][Next][Index][Thread]

Re: Help



ytes it does. everything with an END needs to actually be terminated with
END, lest you get stack overflow problems. in the TI-85, as said before,
stack overflows are reported by a 15-mem error due to the calculator
auto-expanding the stack.

NB: the stack is something like a temporary storage pile.

for your pc-assembler gurus, this is a clear concept.. if not:

(taking a PC, although the Z80 (85's chip) has a similar thing)

the segment and offset for the current position in the stack on a PC is
SS:SP. whenever you want to put data on the stack, you merely have to PUSH
<register>. this updates the stack offset (SP) to point at the next word up
(assuming you are in 16-bit mode). when you POP <register>, it first goes
down a word, then retrieves the thing into what you specified. This is
extremely useful for internal use, whenever you call subroutines, or just
are making loops in general. let's say I call a subroutine. the actual
format is:

CALL <memory adress>

<memory adress>:
...code...
RET

what CALL and RET actually do is:

push CS and IP (the current place where we are executing our code.. the CPU
get's its next command from there) on the stack.

RET retrieves them.

the stack is used for loads of stuff. on PCs, it's used a lot when doing
Coprocessor arithmetic. It's also used extensively to store looping info.

If the program never encounters an END, the info will never be popped off
the stack, and therefore the stack pointer will go ever upwards. all memory
below the stack pointer is assigned as used (since you can't write over the
used stack space... if you do that, and later info is POPped back off the
stack, invalid info is popped off), and eventually you run out of stack
space. the TI-85 (this does NOT happen in a PC, btw.) then auto-expands the
stack space. This keeps going and going until:

1) you run out of mem. the program is quit, and a mem 15 is generated)
2) you quit the prog. this auto-clears ALL alloted stack space to the
program in question.

Errors that don't take from the stack what you put in it are called Stack
Overflow or Stack Memory errors, also called unfinished loops when not
speaking asm business, are hard to detect unless you use special tools for
debugging (which are not available on the TI-85... pretty much impossible
to do.).
--
-R.Zwitserloot@BTInternet.com

Nadler <sn11162@WWW.CEDARNET.ORG> wrote in article
<3394F27B.FF577C51@www.cedarnet.org>...
> Jeff Tyrrill wrote:
> >
> > Just replace that with
> >
> > If X=1
> > Goto X
> > ...more code...
> > Lbl X
> >
> > When an IF statement does not have a THEN statement after it, the
statement
> > after the IF statement is considered to be the one statement in the "IF
loop".
> > ________________
> >
> > Jeff Tyrrill's TI Calculator Site: Contains programming tips,
undocumented
> > discoveries and tips for power users, and comparisons of the different
> > calculator models.
> > http://tyrrill-ticalc.home.ml.org/
> >
> > TI-Files member: The premiere TI site on the web, with reviews of games
and
> > more.
> > http://ti-files.home.ml.org/
> >
> > -----Original Message-----
> > From:   Open discussion of TI Graphing Calculators  On Behalf Of Nadler
> > Sent:   Tuesday, June 03, 1997 1:04 PM
> > To:     CALC-TI@LISTS.PPP.TI.COM
> > Subject:        Help
> >
> > I know that exiting a loop with the goto command takes up mem, but does
> > it also take up mem when it is used like this:
> >
> > If X=1
> > Then
> > Goto X
> > End
> > (misc code)
> > Lbl X
> >
> > It is not a loop but GOTO is still being used before END.
> > >From Things that I have done it seems like this takes up some mem but
> > not as much as exiting a loop.
> >
> > Paul
>
> That is not what I wanted to know, I just wanted to know if it takes up
> memory.  What I wrote before was just an example.  Maby this would be a
> better example:
>
> If X=1
> Then
> (code)
> Goto X
> End
> (code)
> Lbl X
>
> Paul
>


References: