It is currently Thu Apr 09, 2020 7:19 am

 All times are UTC

 Page 1 of 1 [ 2 posts ]
 Print view Previous topic | Next topic
Author Message
 Post subject: Lookup FUnction TablesPosted: Thu Jul 02, 2015 3:56 am

Joined: Thu Jul 02, 2015 3:46 am
Posts: 1
Hello.

I am really interested in knowing how the lookup function table works.

How do I convert a specific number into an X location on the table

For instance...

I have this "defined" table:
0,400,800,1200,1600,2000,2400,2800,3200,3600,4000,4400,4800,5200,5600,6000,6400,6800,7200,7600,8000 for X axis

if i have an independent variable of 4000, the result should be 11 on the lookup, but how do I perform this function? Or how do I create this table with those Xs or labels?

The code I am looking at looks like this
move #4000,d2
cmpi.w #\$A000,d2
lsr.w #3,d2

in theory it should result in 11, but it results in 500 for D2 (\$1F4).

Any help is REALLY appreciated.

Thanks

Top

 Post subject: Re: Lookup FUnction TablesPosted: Tue Jul 07, 2015 1:16 pm

Joined: Thu Dec 16, 2004 6:42 pm
Posts: 1118
Here is a quick example.
Code:
*-----------------------------------------------------------
* Title      : Table search example
* Written by : Charles Kelly
* Date       : July 7th, 2015
*-----------------------------------------------------------
OPT     SEX         ; Expand structured code
ORG     \$1000
START:                  ; first instruction of program

* Put program code here
* Search table of word values pointed to by A0 for value contained in D2.
lea TABLE,A0        ; A0 is pointer to Table
move.w  #4000,D2    ; Search value in D2
bsr     SEARCH      ; Call SEARCH subroutine

SIMHALT             ; halt simulator

* Search table of word values pointed to by A0 for value contained in D2.
* Pre:  A0 contains adddress of Table
*       D2.W contains search value
* Post: D3 contains index to value or -1 if not found
SEARCH
clr.l D3            ; Index in D3
while.w (A0) <lo> #TABLE_END do
if.w D2 <eq> (A0)+ then ; if found
rts
else
endi
endw
rts

* Put variables and constants here

* Table array
TABLE   DC.W       0
DC.W     400
DC.W     800
DC.W    1200
DC.W    1600
DC.W    2000
DC.W    2400
DC.W    2800
DC.W    3200
DC.W    3600
DC.W    4000
DC.W    4400
DC.W    4800
DC.W    5200
DC.W    5600
DC.W    6000
DC.W    6400
DC.W    6800
DC.W    7200
DC.W    7600
DC.W    8000
TABLE_END   ORG *

END    START        ; last line of source

_________________
Prof. Kelly

Top

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

 All times are UTC

#### Who is online

Users browsing this forum: No registered users and 8 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