It is currently Sat Jun 06, 2020 8:13 pm

 All times are UTC

 Page 1 of 1 [ 5 posts ]
 Print view Previous topic | Next topic
Author Message
 Post subject: equation evaluationPosted: Sun Jun 19, 2011 11:38 pm

Joined: Sun Jun 19, 2011 1:36 am
Posts: 7
Location: Midwest
How would you use subroutines to evaluate a polynomial expression for a table of numbers? I can make the number table and get how to make a subroutine. The problem I have is that the polynomial is 3x^2+2x+1 or something similar. I know how to square the x, I simply do the following:

MULS D0,D0 ; I multiple the data register D0 by itself. I don't know how to multiply that result by 3 or then add that to a whole other expression 2x. Anyone have any pointers for me?? Thanks.

Top

 Post subject: Posted: Mon Jun 20, 2011 2:57 am

Joined: Mon Jul 26, 2010 11:43 pm
Posts: 198
Location: Aurora, IL
Code:
MOVE.W  D0,D1   ; save x
MULS    D0,D0   ; x * x  (note 16-bit x 16-bit to 32-bit operation)
MULS    #3,D0   ; 3 * (x * x)
MULS    #2,D1   ; 2 * x
ADD.L   D1,D0   ; + 2*x
ADDQ.L  #1,D0   ; + 1

Top

 Post subject: thanksPosted: Mon Jun 20, 2011 3:10 am

Joined: Sun Jun 19, 2011 1:36 am
Posts: 7
Location: Midwest
that is great! I knew what I needed to do but just not the code for it. thanks!!

Top

 Post subject: Posted: Tue Jun 21, 2011 11:27 pm

Joined: Mon Jul 26, 2010 11:43 pm
Posts: 198
Location: Aurora, IL
ElecEngineer73 wrote:
In the code you gave me for the 3X^2+2x+1 I had a question. I have a table with the numbers that will be X. Your first line of code is
MOVE.B D0,D1 wouldn't this move the number value out of D0 into D1?
MULS D0,D0 is your second line but would D0 be empty because of line above?

The MOVE.W D0,D1 copies D0 to D1 (low order 16 bits), it does not destroy D0

If you have a table/array of values for X

Code:
LEA TableX,A0 ; Array of WORDs
LEA TableA,A1 ; Array of LONGs

MOVE.W (A0)+,D0 ; Load next X and advance

.. compute formula

MOVE.L D0,(A1)+ ; Save Answer and advance

.. repeat/loop

Top

 Post subject: thanksPosted: Wed Jun 22, 2011 11:46 am

Joined: Sun Jun 19, 2011 1:36 am
Posts: 7
Location: Midwest
Thanks. I was able to figure this out thanks to you. I also had to figure out how to pass the parameters through the stack as well for this. thanks again.

Top

 Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost timeSubject AscendingDescending
 Page 1 of 1 [ 5 posts ]

 All times are UTC

#### Who is online

Users browsing this forum: No registered users and 6 guests

 You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot post attachments in this forum

Search for:
 Jump to:  Select a forum ------------------ EASy68K Forum    FAQ    Latest Features    EASy68K Questions    68000 Programming Questions    Wish List    Wishes Granted    Undocumented Features    Documented Features    General Discussion    EASy68K Projects