Shop OBEX P1 Docs P2 Docs Learn Events
Losing Variables between SX/B and inline assembly code — Parallax Forums

Losing Variables between SX/B and inline assembly code

Andrew FabianAndrew Fabian Posts: 2
edited 2006-11-01 22:45 in General Discussion
Hello all,

I'd like to start out by saying that I've having a ton of fun learning to program the SX. After years of programming, this makes me feel like I'm back to freshman year in college all over again. So much to learn about low-level programming!

I've found something I'm stuck on though. The original goal was to get Jon William's MIDI Control application running. During the course of debugging my project, I found that the ISR is receiving valid bytes of data, but that the main program was blocking forever waiting for GetByte to return. As I started outputting the value of the various rx* variables at different points in the program, it appears to me that the variables are being lost between the assembly ISR and the BASIC code around it.

In the attached file, there are three lines that i've inserted for testing, with comments like "INSTANCE 1: This works". All three are basically "MOV CtrlLo, rxHead" (to light up LEDs indicating the value of rxHead), but only the first instance works. The others show that rxHead = 0 always.

Can anyone help me out? Thanks!

Andrew Fabian

Comments

  • BeanBean Posts: 8,129
    edited 2006-11-01 22:34
    Andrew,
    After the assembly code changes FSR with "MOV FSR,#rxBuf" any variables in location > $0F, until FSR is reset with "BANK $00"
    In the code you posted rxHead and rxByte both must be in location <= $0F. Try declaring them first.

    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

    "People who are willing to trade their freedom for·security deserve neither and will lose both." Benjamin Franklin
    ·
  • Andrew FabianAndrew Fabian Posts: 2
    edited 2006-11-01 22:45
    Bean,

    That worked perfectly, and makes a ton of sense. Thanks a lot!

    Andrew
Sign In or Register to comment.