#177037 - Timofiend - Fri Dec 02, 2011 2:58 am
So I am attempting to copy some character data from a header file into the character base block, but I have gone wrong somewhere. It compiles, but when linking I am told that in another function there is an undefined reference to "r7" and "ip"
This is how I am trying to copy the data:
FontCBB2 is a 32 bit pointer to the location in the character base block I am trying to write to, and fontData is a 32 bit pointer to my array full of character data.
I tried removing the function that was referenced, but it just caused the same problem with a different function, so I assume I have done something wrong in the asm code.
Any ideas? I am fairly new at this so if theres anything else I haven't included that would help locate the problem just ask. I am trying to integrate this into my c code.
On a different note while I am here I had another question - When using labels for branches in asm code that is in a function, I have no troubles as long as the function is being called once, but if I call the function more than once I am told the error message that my labels are already define, is there something I should be doing to avoid that?
Here is an example of what I am doing, this is in a print text function I have written to avoid the text going off the screen
We have been asked to demonstrate knowledge of how to integrate asm into our code - if you were wondering why I am using this.
Thanks
This is how I am trying to copy the data:
Code: |
asm volatile( ".arm\n\t" "mov r3, #0\n\t" "ldr r0, =%[fontcbb]\n\t" "ldr r1, =%[fontdata]\n" "for_loop:\n\t" "ldr r2, [r1, r3, lsl #2]\n\t" "str r2, [r0, r3, lsl #2]\n\t" "add r3, #1\n\t" "cmp r3, #7\n\t" "blt for_loop\n\t" ".code 16" : [fontcbb] "+r" (fontCBB2) : [fontdata] "r" (fontData) : "cc", "r0", "r1", "r2", "r3" ); |
FontCBB2 is a 32 bit pointer to the location in the character base block I am trying to write to, and fontData is a 32 bit pointer to my array full of character data.
I tried removing the function that was referenced, but it just caused the same problem with a different function, so I assume I have done something wrong in the asm code.
Any ideas? I am fairly new at this so if theres anything else I haven't included that would help locate the problem just ask. I am trying to integrate this into my c code.
On a different note while I am here I had another question - When using labels for branches in asm code that is in a function, I have no troubles as long as the function is being called once, but if I call the function more than once I am told the error message that my labels are already define, is there something I should be doing to avoid that?
Here is an example of what I am doing, this is in a print text function I have written to avoid the text going off the screen
Code: |
asm volatile(
"cmp %[tempOut], #32\n\t" "blt end\n" "loop1:\n\t" "sub %[tempOut], %[tempIn], #32\n\t" "cmp %[tempOut], #31\n\t" "bgt loop1\n\t" "cmp %[tempOut], #31\n\t" "bne skip\n\t" "add %[cursorPosOut], %[cursorPosIn], #1\n" "skip:" "cmp %[tempOut], #32\n\t" "bne end\n\t" "add %[cursorPosOut], %[cursorPosIn], #2\n" "end:\n\t" :[tempOut] "+r" (temp), [cursorPosOut] "+r" (cursorPos) :[tempIn] "r" (temp), [cursorPosIn] "r" (cursorPos) ); |
We have been asked to demonstrate knowledge of how to integrate asm into our code - if you were wondering why I am using this.
Thanks