Shop OBEX P1 Docs P2 Docs Learn Events
GAS Toggle: CMM vs LMM mode — Parallax Forums

GAS Toggle: CMM vs LMM mode

SRLMSRLM Posts: 5,045
edited 2013-02-21 13:18 in Propeller 1
Hi All,

I'm getting inconsistent results. The attached program works in LMM mode, but not CMM mode.
user@desktop/propgcc/projects/gastoggle$ propeller-elf-g++ -mcmm -O0  -o main.elf toggle.cpp toggle.S
user@desktop/propgcc/projects/gastoggle$ propeller-load -r -t main.elf
Propeller Version 1 on /dev/ttyUSB0
Loading main.elf to hub memory
4600 bytes sent                  
Verifying RAM ... OK
[ Entering terminal mode. Type ESC or Control-C to exit. ]
hello, world!
user@desktop/propgcc/projects/gastoggle$ propeller-elf-g++ -mlmm -O0  -o main.elf toggle.cpp toggle.S
user@desktop/propgcc/projects/gastoggle$ propeller-load -r -t main.elf
Propeller Version 1 on /dev/ttyUSB0
Loading main.elf to hub memory
6468 bytes sent                  
Verifying RAM ... OK
[ Entering terminal mode. Type ESC or Control-C to exit. ]
hello, world!
toggle cog has started

In CMM mode, it outputs only the first hello, world and some gibberish characters (not shown above), and doesn't toggle the pins. In LMM mode it seems to operate correctly.

Comments

  • ersmithersmith Posts: 6,054
    edited 2013-02-20 04:51
    I'm not sure how you're building the program (the Makefile wasn't included) but my guess would be that when compiling toggle.S the -mcmm flag is included in the command line. That would cause the code to be compressed, which means it cannot execute directly on the COG (and would instead do random things). You could try adding a ".compress off" directive to the top of toggle.S and see if that would help. ".compress off" says that instructions should never be compressed.

    A bit of background: when ".compress on" is in effect (the default with -mcmm) the assembler output is compressed bytecode, which must be decompressed by the CMM kernel. The assembly language instruction sets for LMM and CMM modes are basically the same, but the binary representations are very different. LMM code is the native instruction set, so it can execute directly on the COG, but CMM can't.

    Eric
  • SRLMSRLM Posts: 5,045
    edited 2013-02-20 12:08
    You are correct: adding the ".compress off" and ".compress default" fix the problem when running in both CMM mode and LMM.

    Would it be appropriate to add the .compress statements to the official GAS toggle demo on the Google Code site?
  • ersmithersmith Posts: 6,054
    edited 2013-02-21 04:45
    SRLM wrote: »
    You are correct: adding the ".compress off" and ".compress default" fix the problem when running in both CMM mode and LMM.

    Would it be appropriate to add the .compress statements to the official GAS toggle demo on the Google Code site?

    Yes, that's a good idea -- those demos were written before we had a CMM mode.

    Thanks,
    Eric
  • jazzedjazzed Posts: 11,803
    edited 2013-02-21 12:02
    Hi Cody.

    Since you have commit access, if you like you could commit the change to both default and p2test branches.
    The change MUST be exactly the same for both branches to avoid branch merge conflicts later.
    We could guide you through the process.

    If you prefer not to commit the change, just post your diffs here and someone will take care of it.

    --Steve
  • ersmithersmith Posts: 6,054
    edited 2013-02-21 13:18
    Actually I've already committed the change to p2test, it just needs to be merged to the default branch. I don't have that checked out right now... I can do it later, if someone else doesn't beat me to it.

    Eric
Sign In or Register to comment.