A86: Re: Assembly-86 Digest V1 #870


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

A86: Re: Assembly-86 Digest V1 #870




CRUD!!!  AFTER WRITING THIS I REALIZED THAT I DIDN'T GET 'N' OUT OF THE
EQUASION ENTIRELY...so this whole thing is wrong, i hope you get the idea
though.

jimi
======================================
the ti86 has tons of these routines built in
there are two main ways to do that program:
    1    inside the program, display the formula [A = P(1+r/n)^(nt)] and
have the user input the numbers (ti has given us a routine to do this, if
you don't have it, tell me and i'll send it to you).  then display the
answer
    2    have the user store real numbers into the variables used in the
equasion and then run the program.  the program will store the answer in
'n'.  and then display it on completion.  you could even have it delete all
the variables used besides 'n'.


to solve for 'n', you have to figure out the series of key strokes that
would solve it.  a good way to start that is to solve the whole equasion in
terms of n.  have you learned log() yet?  if not, then it'll be hard for you
to figure it out on your own.  log() is used to get unknown variables out of
the exponents of stuff.  you have to do it to both sides.  don't worry about
that if you don't know what i'm talking about yet and just take my word for
it.  (**i'm not perfect so i could have done some things wrong in my
math..someone else might want to check me**)

n=(log(A) - t log(P*(1+r/n))) / (log(P*(1+r/n)))

for the assembly use of real (*.86n) numbers, i haven't done any work with.
i've only used other people's routines to do that.  if you really can't find
that stuff, i'll try to get it for you and send it along.  let me know.
dux's tutorial part 9 or 10 (i think) is an *excellent* source on the
absolute vat mnipulation!

that should be the equasion. you might want to solve for log(P+(1+r/n))
first.  there are some op code calls that do that.  the rest should just be
plug and play math using the op registers.  it should look something like
this:

    <get r.86n into op1>
    <get n.86n into op2>
    call _FPDIV            ; op1=op1/op2
    call _op2set1        ;op1=1
    call _FPADD        ;above
    <get p.86n into op2>
    call _FPMULT        ;op1=op1*op2
    call _LOGXP        ;op1=log(op1)
    call _LOGXP
    call _OP1TOOP2    ;op1 copied to op2
    call _OP2TOOP5    ;op2 copied to op5

now we've got log(P*(1+r/n)) stored into op2 and into op5 (for use later).
we need to multiply it to t.86n and put that into op4:
    <get t.86n into op1>
    call _FPMULT    ;op1=op1*op2
    call _OP1TOOP2
now we've got "t log(P*(1+r/n))" into op2.  we need to get a.86n into op1
and take the log of it and subtract op2:
    <get a.86n into op1>
   call _LOGXP    ;op1=log(op1)
    call _FPSUB    ;op1=op1-op2
now we need to divide all that by the log(P(1+r/n)) to get our final result,
display it, and store it into n.86n:
    call _OP5TOOP2
    call _FPDIV    ;op1=op1/op2
    call _dispOP1    ;like the disp command in ti-basic
    <store op1 into n.86n>
    <delete a,p,r>

if you need some help with this let me know and i'll show you were to get
the routines and help you edit your own.


try looking at the source file 'triangle.asm'.  it should be in the
ticalc.org archives.  it's an excellent use of the input routine ti gave us.
i'll send it to you if you don't have it.  it's nice because it displays a
string as a prompt.  i'll email it if you don't have it.


jimi

>Date: Sun, 18 Apr 1999 22:30:46 -0400
>From: Chris Magill <v8r@juno.com>
>Subject: A86: Solving Compound Intrest for N
>
>I was going through my calculator earlier today and I noticed that I had
>a whole bunch of programs for my math class that performed various
>operations.  Most of them are written in basic and therefore are rather
>slow.  I am thinking about creating one assembly program which will
>feature all these operations.  This would also really free up some space
>on my calculator.  I know I am just begining to program in asm, but I
>figure I could at least compile a list of all the algoritms I need.  I
>was looking at my compound intrest program and found that it realies on
>solver to do all of it's work.  Since there is no routine to use sover
>"at least not that I know of" I have to figure out the actual formulas...
>
>I managed to solve the equation A = P(1+r/n)^(nt) for everything but n...
>
>Is it even possible to solve this equation for n by some theorem or
>property that I have not yet learnt.
>
>If anyone could help with this then then please let me know...
>
>Thanks,
>
>Chris
>
>P.S: >  Are there actually any input calls to get user input or would I
>need to make one using the getkey routine...
>
>
>
>








Follow-Ups: