I apologize for bombarding this forum with what seem like silly questions, but I don't see alot of other conversations to follow on stackoverflow etc.
How do you set the cp register? A ldc instruction can only load a 16b literal, but any named symbol is going to have an address of more than 16b. It seems like the chicken before the egg problem. Is there an instruction to load a 32b constant at the pc and increment the pc (to skip the constant on the next fetch)? Thanks for being patient, I'll get up to speed pretty quick.....
set cp?
-
- Member++
- Posts: 19
- Joined: Wed Jan 14, 2015 2:17 am
OK, I get it. First, cp seems to get set automaticly to the section where I have my data anyway:
Second, I see that:
will load a pc relative address up to 20b.
Code: Select all
.section .cp.rodata, "ac", @progbits
Code: Select all
ldap r11,symb
-
- XCore Expert
- Posts: 844
- Joined: Sun Jul 11, 2010 1:31 am
Right. And you can always play silly games like
to load "symb" (in the range 0x10000..0x1ffff) into r11.
Code: Select all
ldc r0,symb-0x10000
mkmsk r11,16
ladd r0,r11,r0,r11,r11
-
- Member++
- Posts: 19
- Joined: Wed Jan 14, 2015 2:17 am
Cool, thanks.