Propeller Manual

Table Of Contents
CALL – Assembly Language Reference
CALL
Instruction: Jump to address with intention to return to next instruction.
CALL #Symbol
Result: PC + 1 is written to the s-field of the register indicated by the d-field.
Symbol (s-field) is a 9-bit literal whose value is the address to jump to. This field
must contain a
DAT symbol specified as a literal (#symbol) and the corresponding
code should eventually execute a
RET instruction labeled with the same symbol plus a
suffix of “_ret” (Symbol_ret
RET).
Opcode Table:
–INSTR– ZCRI –CON– –DEST– –SRC– Z Result C Result Result Clocks
010111 0011 1111 ????????? sssssssss
Result = 0 --- Written 4
Concise Truth Table:
In Out
Destination Source Z
C
Effects
Destination
1
Z C
2
$----_----; - $----_----; - -
-
wz wc
31:9 unchanged, 8:0 = PC+1 0 1
1
The Destination register’s s-field (lowest 9 bits) are overwritten with the return address (PC+1) at run-time.
2
The C flag is set (1) unless PC+1 equals 0; very unlikely since it would require the CALL to be executed from the top of cog RAM
($1FF; special purpose register VSCL).
Explanation
CALL records the address of the next instruction (PC + 1) then jumps to Symbol. The routine
at Symbol should eventually execute a
RET instruction to return to the recorded address
(PC+1; the instruction following the
CALL). For the CALL to compile and run properly, the
Symbol routine’s
RET instruction must be labeled in the form Symbol with “_ret” appended to
it. The reason for this is explained below.
The Propeller hardware does not use a call stack, so the return address must be stored in a
different manner. At compile time the assembler locates the destination routine as well as its
RET instruction (labeled Symbol and Symbol_ret, respectively) and encodes those addresses
into the
CALL instruction’s s-field and d-field. This provides the CALL instruction with the
knowledge of both where it’s going to jump to and exactly where it will return from.
At run time the first thing the
CALL instruction does is store the return address (PC+1) into the
location where it will return from; the “Symbol_ret
RET” instruction location. The RET
Page 268 · Propeller Manual v1.1