This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Hi,
I have an assembly-function I would like to call from C:
.global touch
.sect ".text"
B .S2 loop ; Pipe up the loop
|| MVK .S1 128, A2 ; Step by two cache lines
|| ADDAW .D2 B4, 31, B4 ; Round up # of iters
B .S2 loop ; Pipe up the loop
|| CLR .S1 A4, 0, 6, A4 ; Align to cache line
|| MV .L2X A4, B0 ; Twin the pointer
B .S1 loop ; Pipe up the loop
|| CLR .S2 B0, 0, 6, B0 ; Align to cache line
|| MV .L2X A2, B2 ; Twin the stepping constant
B .S2 loop ; Pipe up the loop
|| SHR .S1X B4, 7, A1 ; Divide by 128 bytes
|| ADDAW .D2 B0, 17, B0 ; Offset by one line + one word
[A1] BDEC .S1 loop, A1 ; Step by 128s through array
|| [A1] LDBU .D1T1 *A4++[A2], A3 ; Load from [128*i + 0]
|| [A1] LDBU .D2T2 *B0++[B2], B4 ; Load from [128*i + 68]
|| SUB .L1 A1, 7, A0
loop:
[A0] BDEC .S1 loop, A0 ; Step by 128s through array
|| [A1] LDBU .D1T1 *A4++[A2], A3 ; Load from [128*i + 0]
|| [A1] LDBU .D2T2 *B0++[B2], B4 ; Load from [128*i + 68]
|| [A1] SUB .L1 A1, 1, A1
BNOP .S2 B3, 5 ; Return.global touch
.sect ".text"
..........
BNOP .S2 B3, 5 ; Return
However, the linker isn't able to resolv this function when linking a C program.
I would be really grateful if somebody could show me how to call it.
Although the function was taken from the C66 Cache User's Guide it seems very old.
Are the function parameters still passed via the same registers?
Thx
Your code fragment declares "touch" as a global label, but does not actually define any label named "touch." Are you sure you've defined it? Try changing ".global" to ".def". Also, are you using EABI or COFF ABI?
Thanks for your answer =)
I would like to use EABI, am I right to assume the assembler is written for COFF? I only have experience with linear assembly, however the mentioned function is the only example how to do miss pipelining properly.
Thx
The assembler works for both EABI and COFF, as long as you use the right command-line option. Always invoke the assembler through the compiler (cl6x) and always use the --abi=eabi option.
Hi Archeologist,
Thanks to your hint, I was able to get the assembly function working :)
Hopefully it will be helpful to other users interested in miss-pipelining:
.global touch
.sect ".text"
touch: .asmfunc
B .S2 loop ; Pipe up the loop
|| MVK .S1 128, A2 ; Step by two cache lines
|| ADDAW .D2 B4, 31, B4 ; Round up # of iters
B .S2 loop ; Pipe up the loop
|| CLR .S1 A4, 0, 6, A4 ; Align to cache line
|| MV .L2X A4, B0 ; Twin the pointer
B .S1 loop ; Pipe up the loop
|| CLR .S2 B0, 0, 6, B0 ; Align to cache line
|| MV .L2X A2, B2 ; Twin the stepping constant
B .S2 loop ; Pipe up the loop
|| SHR .S1X B4, 7, A1 ; Divide by 128 bytes
|| ADDAW .D2 B0, 17, B0 ; Offset by one line + one word
[A1] BDEC .S1 loop, A1 ; Step by 128s through array
|| [A1] LDBU .D1T1 *A4++[A2], A3 ; STB .D1T1 A2, *A4++[A2] ;
|| [A1] LDBU .D2T2 *B0++[B2], B4 ; STB .D2T2 B2, *B0++[B2];
|| SUB .L1 A1, 7, A0
loop:
[A0] BDEC .S1 loop, A0 ; Step by 128s through array
|| [A1] LDBU .D1T1 *A4++[A2], A3 ; STB .D1T1 A2, *A4++[A2] ;
|| [A1] LDBU .D2T2 *B0++[B2], B4 ; STB .D2T2 B2, *B0++[B2]
|| [A1] SUB .L1 A1, 1, A1
BNOP .S2 B3, 5 ; Return
Tomorrow I'll do some tests, to see if it really makes any difference.
Thx