Sign in

username:

password:



Not a member?

Search 68hc12



Search tips

Subscribe to 68hc12



68hc12 by Keywords

68HC1 | 812A4 | 9S12DP256 | Bootloader | CodeWarrior | D60A | Debugger | DP256 | ECT | EEPROM | EVB | Flash | HC1 | HCS12 | I2C | IAR | ICC1 | Interrupts | LCD | M68KIT912DP256 | MC9S12DP256 | MC9S12DP256B | Metrowerks | Motor | MSCAN | Multilink | PLL | Quadrature | SDI | SPI | Transceiver | XFC

Ads

Discussion Groups

Discussion Groups | 68HC12 | Menu Interface

Join our technical discussions about Freescale Microcontrollers: M68HC12. (Freescale Semiconductor is a Subsidiary of Motorola).

Menu Interface - "mr.mattyg" - May 2 9:17:34 2008

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 )


Re: Menu Interface - Matt Gauthier - May 2 18:17:53 2008

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 )

Re: Menu Interface - Edward Karpicz - May 3 3:42:23 2008

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 )