Hi Guys,
So I'm writing a menu interface that takes input from a keypad and
displays info on an LCD.
Basically I have a main menu and three selections. The user can enter
1, 2, or 3 to access one of three sub-menus. What I do is input the
keypad entry, make sure it was number 1, 2, or 3, since those are my
only sub menu options. I also have the sub menu function addresses
stored in a table using the code:
'MENU_TBL FDB MENU1, MENU2, MENU3'
So once I have my valid keypad entry, I decrement the entry and apply
a logical shift left. This aligns the entry with table, decrement
since table starts at index 0, and logical shift left since each index
is 2 bytes wide. Now I load index register X with #MENU_TBL and then
use the code JSR A,X (A holding my adjusted and valid keypad entry).
Initially I thought JSR would grab the content that is stored in the
Address in X+A and jump to there, but I guess it only reads X+A as an
address and jumps to that address. Is there anyway to accomplish what
I'm trying to do?
CODE:
ldx #MENU_TBL ;load x with menu table
deca ;adjust input so compat with table
lsla
jsr a,x ;jump to correct menu
Thanks,
Matt
------------------------------------

(You need to be a member of 68hc12 -- send a blank email to 68hc12-subscribe@yahoogroups.com )
Never Mind, figured it out.
Need to use the following code that utilizes Accum D Offset indexed
addressing
jsr [d,x] ;jump to correct menu
Thanks,
Matt
On Fri, May 2, 2008 at 9:17 AM, mr.mattyg
wrote:
> Hi Guys,
>
> So I'm writing a menu interface that takes input from a keypad and
> displays info on an LCD.
>
> Basically I have a main menu and three selections. The user can enter
> 1, 2, or 3 to access one of three sub-menus. What I do is input the
> keypad entry, make sure it was number 1, 2, or 3, since those are my
> only sub menu options. I also have the sub menu function addresses
> stored in a table using the code:
>
> 'MENU_TBL FDB MENU1, MENU2, MENU3'
>
> So once I have my valid keypad entry, I decrement the entry and apply
> a logical shift left. This aligns the entry with table, decrement
> since table starts at index 0, and logical shift left since each index
> is 2 bytes wide. Now I load index register X with #MENU_TBL and then
> use the code JSR A,X (A holding my adjusted and valid keypad entry).
> Initially I thought JSR would grab the content that is stored in the
> Address in X+A and jump to there, but I guess it only reads X+A as an
> address and jumps to that address. Is there anyway to accomplish what
> I'm trying to do?
>
> CODE:
> ldx #MENU_TBL ;load x with menu table
> deca ;adjust input so compat with table
> lsla
> jsr a,x ;jump to correct menu
>
> Thanks,
> Matt
>
>
>
[Non-text portions of this message have been removed]
------------------------------------

(You need to be a member of 68hc12 -- send a blank email to 68hc12-subscribe@yahoogroups.com )Matt Gauthier wrote:
> Never Mind, figured it out.
Very good!
> Need to use the following code that utilizes Accum D Offset indexed
> addressing
>
> jsr [d,x] ;jump to correct menu
>
That's not indexed, but indexed indirect [] addressing. d,x addresses
something at X+D address. [d,x] addresses something pointed by a word
address stored at X+D.
What you had previously
>> jsr a,x ;jump to correct menu
also could be fixed loading x with contents of word at a,x, then jump to 0,x
ldx a,x
jmp 0,x
Regards
Edward
> Thanks,
> Matt
>
> On Fri, May 2, 2008 at 9:17 AM, mr.mattyg
wrote:
>
>> Hi Guys,
>>
>> So I'm writing a menu interface that takes input from a keypad and
>> displays info on an LCD.
>>
>> Basically I have a main menu and three selections. The user can enter
>> 1, 2, or 3 to access one of three sub-menus. What I do is input the
>> keypad entry, make sure it was number 1, 2, or 3, since those are my
>> only sub menu options. I also have the sub menu function addresses
>> stored in a table using the code:
>>
>> 'MENU_TBL FDB MENU1, MENU2, MENU3'
>>
>> So once I have my valid keypad entry, I decrement the entry and apply
>> a logical shift left. This aligns the entry with table, decrement
>> since table starts at index 0, and logical shift left since each index
>> is 2 bytes wide. Now I load index register X with #MENU_TBL and then
>> use the code JSR A,X (A holding my adjusted and valid keypad entry).
>> Initially I thought JSR would grab the content that is stored in the
>> Address in X+A and jump to there, but I guess it only reads X+A as an
>> address and jumps to that address. Is there anyway to accomplish what
>> I'm trying to do?
>>
>> CODE:
>> ldx #MENU_TBL ;load x with menu table
>> deca ;adjust input so compat with table
>> lsla
>> jsr a,x ;jump to correct menu
>>
>> Thanks,
>> Matt
>>
> [Non-text portions of this message have been removed]
> ------------------------------------

(You need to be a member of 68hc12 -- send a blank email to 68hc12-subscribe@yahoogroups.com )