Passimg multiple parameters to PASM
G'day,
Just wondering how I pass multiple parameters (in this case, variable pointers), to PASM code. Or to achieve this would I pass one variable pointer, and then somehow be able to change the other variable using the same pointer..? Add 4(?) to the pointer?
Thanks,
John
Just wondering how I pass multiple parameters (in this case, variable pointers), to PASM code. Or to achieve this would I pass one variable pointer, and then somehow be able to change the other variable using the same pointer..? Add 4(?) to the pointer?
Thanks,
John

Comments
-Phil
Top "Object":
CON _clkmode = xtal1+pll16x _xinfreq = 5_000_000 OBJ SigmaDelta : "SigmaDelta" Serial : "Serial" VAR long readings[2] PUB Main Serial.start(31, 30, 0, 9600) SigmaDelta.SigmaDelta(@readings) repeat Serial.tx(16) Serial.dec(readings[1]) Serial.tx(13) Serial.dec(readings[2]) waitcnt(clkfreq/2+cnt)SigmaDelta Library:
{{ ***************************************** * generic ADC driver v1.0 * * Author: Beau Schwabe * * Copyright (c) 2007 Parallax * * See end of file for terms of use. * ***************************************** }} CON SDF1 = 6 'sigma-delta feedback SDI1 = 7 'sigma-delta input SDF2 = 4 SDI2 = 5 PUB SigmaDelta (sample) cognew(@asm_entry, sample) 'launch assembly program in a COG DAT org asm_entry mov dira,#1<<SDF1 'make SDF pin an output movs ctra,#SDI1 'POS W/FEEDBACK mode for CTRA movd ctra,#SDF1 movi ctra,#%01001_000 mov frqa,#1 { mov dira,#1<<SDF2 movs ctrb,#SDI2 movd ctrb,#SDF2 movi ctrb,#%01001_000 mov frqb,#1 } mov asm_c1,cnt 'prepare for WAITCNT loop add asm_c1,asm_cycles :loop waitcnt asm_c1,asm_cycles 'wait for next CNT value '(timing is determinant after WAITCNT) mov asm_new1,phsa 'capture PHSA mov asm_new2,phsb mov asm_sample1,asm_new1 'compute sample from 'new' - 'old' sub asm_sample1,asm_old1 mov asm_old1,asm_new1 'mov asm_sample2, asm_new2 'sub asm_sample2, asm_old2 'mov asm_old2, asm_new2 wrlong asm_sample1,par 'write sample back to Spin variable "sample" wrlong asm_sample2,par+1 '(WRLONG introduces timing indeterminancy here..) '(..since it must sync to the HUB) jmp #:loop 'wait for next sample asm_cycles long $FFFF '(use $FFFF for 16-bit, $FFF for 12-bit, or $FF for 8-bit) asm_c1 res 1 'uninitialized variables follow emitted data asm_cnt1 res 1 asm_new1 res 1 asm_old1 res 1 asm_sample1 res 1 asm_temp1 res 1 asm_c2 res 1 'uninitialized variables follow emitted data asm_cnt2 res 1 asm_new2 res 1 asm_old2 res 1 asm_sample2 res 1 asm_temp2 res 1 DAT {{ ┌──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐ │ TERMS OF USE: MIT License │ ├──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤ │Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation │ │files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, │ │modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software│ │is furnished to do so, subject to the following conditions: │ │ │ │The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.│ │ │ │THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE │ │WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR │ │COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, │ │ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. │ └──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘ }}I'm wanting to access the par flag on the lines "wrlong asm_sample1, par", and the line below that. So for example, what would I put in to write asm_sample1 to the first element, and then asm_sample2 to the second?
Cheers,
John
VAR long var1,var2,var3 PUB cognew(@asm,@var1) ... DAT asm mov vp1,par mov vp2,par add vp2,#4 mov vp3,par add vp3,#8 ... vp1 res 1 vp2 res 1 vp3 res 1If this is not possible then you can use a mailbox (an array with the variable pointers, as Phil suggested):
VAR long mailbox[3] long var1,var5,var2,var7,var3 PUB mailbox[0] := @var1 mailbox[1] := @var2 mailbox[2] := @var3 cognew(@asm,@mailbox) ... DAT asm mov tmp,par rdlong vp1,tmp add tmp,#4 rdlong vp2,tmp add tmp,#4 rdlong vp3,tmp ... vp1 res 1 vp2 res 1 vp3 res 1Andy
Worked, thank you very much!
-John