lilltroll: For a confused programmer, you are certainly doing pretty well! I really should add that I am also an not very experienced XMOS ASM developer either- I am more familiar with the 68000 and 8051 processors.
First, if I write a CALC.S, can I use all registers r0-r11 without destroying anything in the bypass function ?
2) How does the simplest working ASM program look like that just passes the data from IN_data -> OUT_data ?
The XMOS document abi97.pdf says on page 3
Function calling uses the first four registers to pass parameters. Additional parameters
are passed on the stack.
Except where otherwise stated, data types with size greater than int and all structures
are passed by passing a pointer. The callee must make a copy of the structure if it
needs to be modified. Scalar types smaller than 32 bits are passed as zero or sign
extended 32-bit values.
In an earlier version of a floating point divide function I wanted extra registers to hold temporaries so the preexisting values had to be first stored to memory as below:
entsp 0x8
stw r4, sp[0x1]
stw r5, sp[0x2] # r5 holds result exponent
stw r6, sp[0x3] # r6 holds result quotient
stw r7, sp[0x4] # r7 holds main divide loop counter
ldc r6, 0x0 # clear quotient
ldc r7, 0x0 # clear loop counter
add r3, r0, 0x0 # copy return address to r3
add r4, r2, 0x0 # copy op1 address to r4
ldaw r0, sp[0xa]
ldc r2, 0x8
bl __crt_memcpy #copy r1 (op0) to memory at sp[0xa]
At the end of the function, the data are copied into the return address and the extra registers that have been used are restored
ldaw r1, sp[0x18]
add r0, r3,0x0
ldc r2, 0x8
bl __crt_memcpy
ldw r7, sp[0x4]
ldw r6, sp[0x3]
ldw r5, sp[0x2]
ldw r4, sp[0x1]
retsp 0x8
I would be happier if some one else would jump in here and I won't have to continue exposing my ignorance.
John