Shop OBEX P1 Docs P2 Docs Learn Events
Compiler Issue — Parallax Forums

Compiler Issue

SamTheManSamTheMan Posts: 43
edited 2009-06-09 02:57 in General Discussion
Dear JonnyMac and Bean,

I'm unsing latest version of SX/B (2.00.24)

I used JohnnyMac code to: PUT array2, array1(0) TO array1(15)

I tried your code and it worked fine. BUT when I pluged the code into my program it did NOT work. ONLY the first two bytes were changed!!!

(in my code, since I'm using many subs, I had to move my SUB definitions·inside the interrupt area (based on Bean's recommendations) because the compiler complained when I had them before the interrupt code.)

I checked the ASM code of my program and I found that the compiler translated the PUT command differently (outside my program and inside it)·!!

What do you think?

the full code is below

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔


Post Edited (SamTheMan) : 6/8/2009 10:52:36 AM GMT
1280 x 800 - 186K

Comments

  • JonnyMacJonnyMac Posts: 9,213
    edited 2009-06-07 12:03
    First things first: your use of big bold letters could be interpreted as SHOUTING; this will not endear you to the people from who you seek help. Second, attache your actual program, not a stripped down version that probably removes the self-induced problems. Finally, a lot of us use SX/B every day for personal and commercial projects; it is better to assume that you, not the compiler, is the root the the problem.

    FWIW, I recognize the names of all of those subs you're using because most of them come from programs I've written. You do not have too many, there is another problem.
  • SamTheManSamTheMan Posts: 43
    edited 2009-06-07 12:50
    Dear Jonny,

    1- I'm sorry if my big bold letters·was interpreted as SHOUTING

    ·· I was not trying to shout, I just wanted to make my point clear. (please accept my appology)

    2-I removed the SUBs coding to make the text short and easy to read. ·and because these subs were mostly written by you, I thought there's no need to post the whole code of what you already know.

    Anyway, here is the whole code:



    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔


    Post Edited (SamTheMan) : 6/8/2009 10:51:25 AM GMT
    1280 x 800 - 186K
  • Shawn LoweShawn Lowe Posts: 635
    edited 2009-06-07 17:35
    I have to ask as I'm trying to learn more about the SX chip. Why would you put your SUB declarations in the Interrupt? That one has me a bit confused.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Shawn Lowe


    When all else fails.....procrastinate!
  • SamTheManSamTheMan Posts: 43
    edited 2009-06-07 17:47
    Shawn Lowe,

    to answer your question check this:

    http://forums.parallax.com/showthread.php?p=655596

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
  • ZootZoot Posts: 2,227
    edited 2009-06-07 21:05
    Shawn -- SamTheMan's ISR placement code is good, however his description is a bit unclear -- what he is describing is putting any ISR code (with a regular JMP/GOTO) AFTER the sub declarations. I usually put the ISR code in the LAST code page of the app, not before "start", but that's secondary to having it after the subs. The reason is that every SUB/FUNC declaration must be in page 0 (the code for the sub/func itself can be anywhere). The start of the ISR (the actual INTERRUPT statement in SX/B or just plain ol' address $000 in ASM) is also in page 0. So as your ISR and/or your list of sub/func declarations gets longer, things can get tight very quickly. In my own apps, rarely would all the sub declarations and even a short ISR routine fit on page 0.

    So the answer is put your ISR code wherever you want (it's not a sub, btw, but an ISR) and GOTO following the INTERRUPT statement:

    
    INTERRUPT 1000
       GOTO Interrupt_Code  ' takes only two instructions
    
    SUB x,y,z  ' can have many many many sub/func declarations
    SUB x,y,z
    FUNC x,y,z 
    ' etc
    
    Start:
     ' init code
    
    Main: 
     ' main loop
    
    ' --- Subroutines
    SUB x
       ENDSUB
    
    ' --- ISR
    Interrupt_Code:
      ' more code here
      RETURNINT
    
    

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    When the going gets weird, the weird turn pro. -- HST

    1uffakind.com/robots/povBitMapBuilder.php
    1uffakind.com/robots/resistorLadder.php
  • ZootZoot Posts: 2,227
    edited 2009-06-07 21:07
    SamTheMan said...
    I checked the ASM code of my program and I found that the compiler translated the PUT command differently (outside my program and inside it) !!

    SamTheMan -- can you ATTACH (rather than paste) both your SX/B program AND the compiled output (.src)?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    When the going gets weird, the weird turn pro. -- HST

    1uffakind.com/robots/povBitMapBuilder.php
    1uffakind.com/robots/resistorLadder.php
  • Shawn LoweShawn Lowe Posts: 635
    edited 2009-06-08 05:22
    Ok, thanks for the explaination Zoot. I *think* I get it (my problem not your explaination!)

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Shawn Lowe


    When all else fails.....procrastinate!
  • SamTheManSamTheMan Posts: 43
    edited 2009-06-08 06:04
    the source is attached

    and the ASM part is:



    get_Requests:··················· ;Sub get_Requests

    · CLR tmp······················· ;·tmp=0

    · MOV FSR,#Temp················· ;put temp,que(0) to que(15)
    · MOV __PARAM1,FSR·············
    · BANK $00·····················
    · MOV FSR,#QUE+0··············· 'I think the problem is here
    · MOV __PARAM2,IND·············
    · MOV FSR,__PARAM1·············
    · MOV IND,__PARAM2·············
    · INC FSR······················
    · MOV __PARAM1,FSR·············
    · BANK $00·····················
    · MOV FSR,#QUE+15·······'and here too·······
    · MOV __PARAM2,IND·············
    · MOV FSR,__PARAM1·············
    · MOV IND,__PARAM2·············
    · BANK $00
    · RETP·························· ;endsub

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
  • JonnyMacJonnyMac Posts: 9,213
    edited 2009-06-08 12:23
    Sam's ISR placement is not a problem but is also not necessary as the ISR is just a couple lines long. The only time one needs to jump over the SUB/FUNC declarations is when the ISR is very long and would push the sub/funcs jump table out of the first half of the code page -- this is not happening here.

    What I think IS a problem, however, is using edge triggered interrupts with the serial stuff; sure one might logically assume that the very short interrupt wouldn't bother the serial stuff but why take a change; I'd use ISR-driven serial and poll the inputs as required during the ISR.
  • SamTheManSamTheMan Posts: 43
    edited 2009-06-08 12:55
    does anyone have an explination of the PUT command problem?

    why the compiler produce an ASM code·for PUT different (inside my program) than outside it?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
  • BeanBean Posts: 8,129
    edited 2009-06-08 14:01
    Sam,
    THANK YOU !!!
    The problem is a bug in the compiler.
    In the "PUT temp, que(0) to que(15)" is that the word "to" must be in upper case to compile correctly.
    I will fix this ASAP. In short the compiler evaluates the "to" as a comma. Changing "to" to "TO" will generate the correct code.

    Bean.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    There is a fine line between arrogance and confidence. Make sure you don't cross it...

    ·
  • BeanBean Posts: 8,129
    edited 2009-06-08 14:13
    I have posted version 2.00.25 of the compiler.
    This issue has been fixed.

    Bean.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    There is a fine line between arrogance and confidence. Make sure you don't cross it...

    ·
  • SamTheManSamTheMan Posts: 43
    edited 2009-06-08 14:17
    Thank you Bean..·you are the best!!

    Dear JonnyMac, you owe me one (just kidding)



    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
  • JonnyMacJonnyMac Posts: 9,213
    edited 2009-06-09 02:57
    Okay, Sam, you're right. I never had a problem because I always manually capitalize keywords. Sorry.
Sign In or Register to comment.