Shop OBEX P1 Docs P2 Docs Learn Events
Passing Object output into assembly code — Parallax Forums

Passing Object output into assembly code

stephenwagnerstephenwagner Posts: 147
edited 2011-01-24 05:10 in Propeller 1
I found a microphone to headphone with delay and echo example on this forum. http://forums.parallax.com/showthread.php?97402-Microphone-to-Headphones-Object&p=676274
I have successfully modified the assembly code to produce a 10 bit audio delay for my project.
I would like to change the delay and attenuation with a rotary encoder/decoder object found in the object exchange.
I need an example of passing object outputs into assembly code. I understand I will need to limit the delay and attenuation values to prevent undesired results.

Stephen Wagner

Comments

  • JonnyMacJonnyMac Posts: 9,208
    edited 2011-01-18 10:03
    It's not very difficult: the value you want to pass to a PASM routine is written to a hub variable that can be accessed from the PASM cog with rdlong. There are many objects that use this process to pick up a value from the hub. You PASM program only needs to know the hub address of the variable it is to read.

    Really simply... you can start a PASM cog pointing to the variable
    cognew(@entry, @myvar)
    

    The address of that variable (a long) is now in the par register and your PASM code can read it
    dat
    
                            org     0
    
    entry                   rdlong  tmp1, par                       ' read parameter
    
                            ' now do something with it
    

    This is just one variable. If you need to pass more then you'll pass the address of the first in a group and build and address list at the top of your PASM code.
  • Mike GreenMike Green Posts: 23,101
    edited 2011-01-18 10:11
    The passing of values to a cog has to be designed into the code because the routine running in the cog has complete control and other cogs have no access to that cog's memory. Normally this is done through a location in hub memory and this is read using RDLONG / RDWORD / RDBYTE. It's really easy to read two values from hub memory. It's harder to figure out what to do with them. Usually attenuation is done by multiplication or division which has to be done by subroutine on the Propeller unless it's always in terms of powers of two. Changing the delay time depends on how the delay is handled.
  • stephenwagnerstephenwagner Posts: 147
    edited 2011-01-19 08:13
    I am going to work some SPIN and PASM issues this weekend and post. Thanks for the tips.

    SJW
  • Graham StablerGraham Stabler Posts: 2,510
    edited 2011-01-19 08:45
    http://forums.parallax.com/showthread.php?94027-Assembly-step-by-step

    Steps 3 and 4 cover this sort of thing.

    Graham
  • stephenwagnerstephenwagner Posts: 147
    edited 2011-01-24 05:10
    Thanks.

    I also found the Jan. 2011 Spin Zone to be very helpful.


    SJW
Sign In or Register to comment.