Shop OBEX P1 Docs P2 Docs Learn Events
why "undefined ?_ret symbol" — Parallax Forums

why "undefined ?_ret symbol"

stevenolanstevenolan Posts: 3
edited 2012-12-27 11:23 in Propeller 1
Would appreciate any advice on why I am getting "undefined ?_ret symbol" error on following code.
Compiler complains about RD_SDI symbol.

Using Prop Tool V1.3.2.
I cannot find any relevant posted help with this problem.
Many thanks in advance.

Steve Nolan..


VAR
long cog

PUB start
cog := cognew(@entry) + 1

PUB stop
if cog
cogstop(cog~ - 1)

DAT
org 0
entry and dira,pinsoff '
or dira,pinson ' Set Output Pins
or outa,pinson ' All Outputs are Pulled High
RD_16 xor outa,#%00_0100 ' CS Low
xor outa,#%00_1000 ' CK Low
call #RD_SDI
mov ch0,rdpins
mov loop1,#15
gbits call #RD_SDI
shl ch0,#1
or ch0,rdpins
djnz loop1,gbits
or outa,#%00_1000 ' CK High
or outa,#%00_0100 ' CS High
mov loop1,#500
:wait4me
nop
djnz loop1,#:wait4me
jmp #RD_16

RD_SDI or outa,#%00_1000 ' CK High
mov rdpins,ina ' Read Pins
xor outa,#%00_1000 ' CK Low
and rdpins,#%10_0000 ' SDI pin
shr rdpins,#5
ret

pinsoff long $ffff_ffc0 ' Uses Pins P0..P5
pinson long $0000_001d ' Output Pins

rdpins res 1
ch0 res 1
ch1 res 1
loop1 res 1

Comments

  • ratronicratronic Posts: 1,451
    edited 2012-12-27 10:05
    steve to return from the call you need to end it with not just "ret" but "RD_SDI_ret ret".
  • Mike GMike G Posts: 2,702
    edited 2012-12-27 10:06
    See page 269 in the propeller manual. The ret is missing a label; RD_SDI_ret.


    Please enclose source code in [ code ] [/code ] tags. The code tags keep the original formatting.
  • BeanBean Posts: 8,129
    edited 2012-12-27 10:06
    You need a label "RD_SDI_ret" on the "ret" line of the RD_SDI subroutine.

    RD_SDI_ret ret

    This is because the propeller does not use a stack for subroutine calls. It changes the "ret" instruction to jump back, so it needs a label on the ret line.

    Bean
  • Heater.Heater. Posts: 21,230
    edited 2012-12-27 10:33
    As Bean says the Propeller CALL instruction does not save an address to return to on a stack, as most other processors do now a days. Instead it saves the return address in the RET instruction of the subroutine you are calling. In order to do this the assembler (Prop Tool or whatever) needs to know where that RET instruction is. It does this with the naming convention referred to above.

    All I want to add is that you should be aware of the consequences of this:
    1) You cannot have recursive subroutine calls in PASM unless you implement your own stack mechanism. i.e. No funcA calls funcA or funcA calls funcB calls funcA, etc etc.
    2) You can only have one exit point, RET, in your subroutine. To make an early exit from the routine you must JMP to your RET location.
  • stevenolanstevenolan Posts: 3
    edited 2012-12-27 11:23
    ok thanks guys.. got it .. so much to learn. just trying out prop mostly for vga. trying to interface mcp3901 adc. not an easy move from atmel / microchip. still not sure if prop is for me. could do with a bit more cog memory. maybe if i endeavour to persevere.
Sign In or Register to comment.