Shop OBEX P1 Docs P2 Docs Learn Events
Menus in Assembler — Parallax Forums

Menus in Assembler

LoopyBytelooseLoopyByteloose Posts: 12,537
edited 2006-12-11 23:34 in General Discussion
I am a bit stumped.· I have enough difficulty making a menu in PBasic, but I have need to create such in SASM.

I have Guenther's multiboard with RS232 connected to one of my CANbus boards via SPI.· What I would like to do is have an SX28 present a menu on my PC via Hyperterminal and I could respond via keyboard.· I intend the setup to be full duplex.

Any suggestions? [noparse][[/noparse]I do know that SX/B would be much easier]

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"If you want more fiber, eat the package.· Not enough?· Eat the manual."········
···················· Tropical regards,····· G. Herzog [noparse][[/noparse]·黃鶴 ]·in Taiwan

Comments

  • JonnyMacJonnyMac Posts: 9,213
    edited 2006-12-06 16:56
    You're really just sending a set of strings (or one big one with embedded CRs) to the terminal, then checking the input after the menu has been presented.
  • Sparks-R-FunSparks-R-Fun Posts: 388
    edited 2006-12-06 18:21
    Kramer,

    I agree. Creating a menu for the first time would be much easier in SX/B than trying to create one from scratch in assembler! So I would start there.

    Here is how I would do it. First I would create the desired logic structure in SX/B. Then, if I needed to present it in assembly language I would use CTRL-L to list the assembly output. Then I would modify the code produced to fit the rest of my assembly program.

    For example, to process a single byte value as a menu selection I would use the SX/B command LookDown to check for a valid menu selection followed by a Branch statement to go to the portion of my code that handles that menu selection.

    Borrowing from an example in the SX/B help files...

    LOOKDOWN Menu_Selection, "F", "B", "S", Menu_Index   ' compare against valid commands
    
    BRANCH Menu_Index, Forward, Backward, Stop_Bot       ' execute valid command
    



    Becomes...

    MOV __PARAM1,#-1               ;    LOOKDOWN Menu_Selection, "F", "B", "S", Menu_Index     ' compare against valid commands
    
    INC __PARAM1                  
    CJNE Menu_Selection,#"F",@$+7 
    MOV Menu_Index,__PARAM1       
    
    INC __PARAM1                  
    CJNE Menu_Selection,#"B",@$+7 
    MOV Menu_Index,__PARAM1       
    
    INC __PARAM1                  
    CJNE Menu_Selection,#"S",@$+7 
    MOV Menu_Index,__PARAM1       
    
    
        
    MOV __PARAM1,Menu_Index        ;  BRANCH Menu_Index, Forward, Backward, Stop_Bot       ' execute valid commands
    
    TEST __PARAM1                 
    JZ @Forward                   
    
    DEC __PARAM1                  
    JZ @Backward  
                    
    DEC __PARAM1                  
    JZ @Stop_Bot
    




    If you examine this example for a while you should be able to figure out how it works. You need to change the variables, the menu options and the branch locations to fit your program. That should not be too difficult. 90% of the menu processing work is already done for you!

    - Sparks
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2006-12-07 14:12
    Thanks,
    I'll print this out and try again.

    I don't know if it is just me that has trouble with the concept of menus [noparse][[/noparse]branches and pointers, etc]. If not, please jump in and ask more questions as I can't think of the right ones.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    "If you want more fiber, eat the package.· Not enough?· Eat the manual."········
    ···················· Tropical regards,····· G. Herzog [noparse][[/noparse]·黃鶴 ]·in Taiwan
  • BeanBean Posts: 8,129
    edited 2006-12-07 15:14
    LOOKDOWN Menu_Selection, "F", "B", "S", Menu_Index   ' compare against valid commands
    
    BRANCH Menu_Index, Forward, Backward, Stop_Bot       ' execute valid command
    
    

    This can be done easier with the ON...GOTO command like:

    ON Menu_Select = "F", "B", "S" GOTO Forward, Backward, Stop_Bot
    

    Check out the help file for command "ON", it's very handy.

    Bean.


    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Cheap used 4-digit LED display with driver IC·www.hc4led.com

    Low power SD Data Logger www.sddatalogger.com
    SX-Video Display Modules www.sxvm.com
    Stuff I'm selling on ebay http://search.ebay.com/_W0QQsassZhittconsultingQQhtZ-1

    "People who are willing to trade their freedom for·security deserve neither and will lose both." Benjamin Franklin
    ·
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2006-12-08 07:51
    Try to consider the significance of a good user interface.· We are moving beyond BOEbots at lightspeed.

    I am still working on this and have done a lot of searching for a tutorial with a good approach.
    The fundamentals seems to have been lost in the sands of time [noparse][[/noparse]was 1980 really that long ago?]

    This is an important topic as it is one of the mainstays of user interface - very revelant when handed a keyboard and a screen. {other are the GUI and the command line interface}

    This time it is an SX project.· With the Propeller doing video and characters, we seem to have to go back to such topics.· (I am still ponder the cursor, the delete and the backspace for TV Terminal too.)

    I really don't want to do a command line interface, but I suppose it would be easier.· In fact, it might be easier to develop in comand line and morph to a menu.

    Hmmm....





    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    "If you want more fiber, eat the package.· Not enough?· Eat the manual."········
    ···················· Tropical regards,····· G. Herzog [noparse][[/noparse]·黃鶴 ]·in Taiwan

    Post Edited (Kramer) : 12/8/2006 5:21:04 PM GMT
  • Sparks-R-FunSparks-R-Fun Posts: 388
    edited 2006-12-08 17:35
    Kramer,

    If I knew of a good user interface tutorial I would point you to it. Unfortunately, I do not. Hopefully someone else will know of a good one.

    In the mean time, if you would like help or ideas on what your menu should look like and how it should behave and function, etc., why not list all of the things you want your user to be able to do?

    Maybe your options will fit well under a menu and sub-menu structure such as:

    1.) Operations
    2.) Configuration
    3.) Advanced Settings
    4.) Exit

    etc.

    Just a thought.

    - Sparks
  • Mike CookMike Cook Posts: 829
    edited 2006-12-08 17:58

    Kramer,

    Take a look at this Nuts'N'Volts article:

    http://www.parallax.com/dl/docs/cols/nv/vol2/col/nv62.pdf

    Maybe you could apply some of Jon's concepts outlined here.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Mike
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2006-12-10 14:56
    I read the 'Menus made Easy' article some time ago and numerous times.
    Somehow, it just doesn't sink in. I begin to wonder if I need more keys or less keys and how do I make them tie into the LCD output, and so on....

    I get dizzy.

    Nonetheless, I am making progress. Starting with a 'command line interface' and later sorting them into levels with related graphic screens seems to be really the right approach. In fact, I suspect that is why many DOS menu programs also came with a command line version.

    It works for me.

    With GUI I can see why everyone wants C. Just call the Library and ignore the low level stuff.

    [noparse][[/noparse]But I suspect there is real $$$ in the low levels and embedded systems; all those C programers have to buy an interface. Hee Hee.]

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    "If you want more fiber, eat the package.· Not enough?· Eat the manual."········
    ···················· Tropical regards,····· G. Herzog [noparse][[/noparse]·黃鶴 ]·in Taiwan
  • JonnyMacJonnyMac Posts: 9,213
    edited 2006-12-11 23:34
    It helps to think of things in levels. Attached you'll find a program for a possible EFX-TEK product that is a simple serial interface for the KIT-74 relay box. Notice how the code grabs a character from the stream, then jumps to the section that handles it, sometimes waiting for another depending on the options available after the initial character (command).
Sign In or Register to comment.