Shop OBEX P1 Docs P2 Docs Learn Events
SpinLMM help — Parallax Forums

SpinLMM help

max72max72 Posts: 1,155
edited 2010-10-01 10:11 in Propeller 1
I tried to use the spinLMM object, but evidently I'm missing something obvious.
I created an object and copied the spinLMM sum code in the manual.

I cannot get it working properly.

Has anyone a suggestion, or a working sample?

Thanks in advance,
Massimo

Comments

  • Dave HeinDave Hein Posts: 6,347
    edited 2010-09-30 09:16
    Massimo,

    The code looks OK. I'll try running it tonight when I get home. What happens when you run the code?

    Did you try the SipnLMM demo program? Did that run OK for you?

    Dave
  • max72max72 Posts: 1,155
    edited 2010-09-30 09:26
    Thanks for checking.
    The demo works perfectly.

    With my test routine I get a number (the same all the time, even if I increase the numbers to be summed).
    If I modify the object code the number changes. This is not happening if I change the main program.

    Massimo
  • max72max72 Posts: 1,155
    edited 2010-10-01 00:16
    Got it..
    in the manual sample pcurr is used, while in the demo dcurr is used to get the data.

    So apparently when I call an LMM asm function with do(a,b), I directly get the address of the variable with the dcurr stack pointer, and I can use it to read the long.
    So.. what pcurr does? I tried to combine do(@a,@b) with pcurr with no luck.

    Next question will be.. if I have a string to manipulate, I'm already passing the address, how can I use it? And how can I retrieve a string address?

    Massimo
  • Dave HeinDave Hein Posts: 6,347
    edited 2010-10-01 06:36
    Massimo,

    I apologize for the error. dcurr is the Spin stack pointer, and not pcurr. I never actually ran the sample code in the manual. Thank you for finding the error in the manual. I'll add a notice to the OBEX description for SpinLMM.

    I believe pcurr is the Spin program counter. I'll check into that when I get a chance.

    If you pass a string address it will be put on the stack just like any other variable. Your LMM program would pop it off the stack just like any other variable. You would then use ldbyte with the string address to access a character. Look at the code for strsize or strcomp in SpinLMM.spin for an example of how a string is accessed.

    Dave
  • max72max72 Posts: 1,155
    edited 2010-10-01 08:18
    Thanks,
    I started playing with strings, and the address passing seems working.
    Another question about calls:
    Can I have multiple calls (to different funcions)?
    For instance inside the main code I call a get a char, which calls a subtract 48 from ascii, which calls a multiply by ten?

    Massimo
  • Dave HeinDave Hein Posts: 6,347
    edited 2010-10-01 08:50
    Massimo,

    The FCALL psuedo-op stores the return address in the lmm_ret register. A return operation is done by executing a "mov lmm_pc, lmm_ret" instruction. If a function calls another function you need to save the contents of the lmm_ret register.

    Look at the Unpack2 function in the float_lmm object. The first line in the function is "mov t2, lmm_ret". The last line in the function executes a return with the instruction "mov lmm_pc, t2".

    Dave

    Note: The FRET and FRETX psudeo-ops return control back to the Spin interpreter. They are not used to return from an FCALL, even though their names might seem to indicate that. Maybe these should have been called FEXIT and FEXITX. To save space in the LMM intepreter I did not implement a return psuedo-op for the FCALL instruction. That is why a "mov lmm_pc, lmm_ret" instruction is used instead.
  • Dave HeinDave Hein Posts: 6,347
    edited 2010-10-01 09:43
    I added a note to the SpinLMM description in the OBEX, and I added an updated manual at http://obex.parallax.com/objects/download/aux/104/ that replaces pcurr with dcurr.

    Dave
  • max72max72 Posts: 1,155
    edited 2010-10-01 09:47
    Thanks.
    I got the FRET and FRETX, and from the manual it looks clear.
    I have to play with it a little bit and study your sample code to better understand is.

    Do you think it would be possible to debug spinLMM code with one of the available tools?

    Thanks again for the help and for the spinLMM code.

    Massimo
  • max72max72 Posts: 1,155
    edited 2010-10-01 10:11
    At last I got the string passing...
    From the stack I get the string address (with a rdlong). I then use this address as a pointer to rdbyte the string.

    Thanks again.
    Massimo
Sign In or Register to comment.