Hi, i have just got a cortex-m0(LPC1114) based dev board. I'm reading about the architecture and instructions. My understanding is that it supports most thumb 16-bit instructions and a handful thumb-2 32-bit instructions. If the processor has a 32-bit bus which instructions are fetched(im assuming this, also i have limited knowledge of a CPU's inner workings), why don't it support more thumb-2 instructions? It seems like a waste, or maybe it fetches two 16-bit instructions?
My other issue is related to to my first question. I'm trying to set the core registers with immediate values using MOV. I read that you can use MOV for the for the 16 lower bits, and MOVT for the 16 higher bit(this is only for cores which supports ARM32 i suppose). However first it seems MOVT is not supported by cortex-m0, in arm-none-eabi-as: "Error: selected processor does not support Thumb mode `movt r0 , r1'. Also when i read the ARMv6-M reference manual, i read that MOV can only set a immediate value up to 8-bits long. This all seems very strange to me. I got a hint on a IRC that your really supposed to use PC relative addressing to set registers "directly", which i haven't read much into. Are there no efficient way to set immediate 32-bit values for registers, using MOV or other data instructions?
Thanks for responses!
Hello,I think the reason why Cortex-M0 only supports Thumb (not Thumb-2) is to reduce core size by simplifying the decode logic. As you imagine, the internal bus width is 32 bit and the prefetch logic can 2 Thumb instructions at one read cycle, reducing the prefetch power.Regarding 32 bit immediate, the Thumb usually takes the load pc-relative instruction. It loads the 32 bit immediate word from the literal pool on the memory. It would be the most code size effect way. That is, a 16 bit length instruction can load a 32 bit immediate.For example,
LDR Rt,[pc,#imm] @ pc+imm indicates the label Mem ..... .....Mem: .word 0x12345678
acts as
MOV Rt,#0x12345678.
Best regards,Yasuhiko Koumoto.
Since the bus is 32-bit, are instructions fetched in pairs? If so, will a memory fetch occurs when the IF isn't using the bus be faster than when a collision occurs?
Hello,
what do you mean by the word 'collision'?
Does the 'IF' mean the Instruction Fetch Stage?
Cortex-M0 fetches 32 bit data at every fetch stage.
That is, they are 2 instructions if both instruction's length are 16 bit and 1 instruction if the instruction length is 32 bit.
The length of 'LDR PC' is 16 bit and it will be possible to fetch also the next instruction at one time.
Best regards,
Yasuhiko Koumoto.
So if the first instruction is 16-bit and is a B, the following instruction is thrown away? if so, does that mean the following instruction is thrown away? I ask because some 32-bit CPUs with 16-bit instructions still perform the instruction IF it is nuclear e.g.LD R0,#0. You can see the advantage. No empty slots in the pipeline.
I ask because the BBC are having a custom M0 produced for the BBC Microbit (my target) and I wondered if it's a possible modification to approach the dhrystone per MIP boundary.
Thank you for your expert advice
muffin wrote: Since the bus is 32-bit, are instructions fetched in pairs? If so, will a memory fetch occurs when the IF isn't using the bus be faster than when a collision occurs?
muffin wrote:
Unfortunately it won't, as the instruction timing is fixed on the Cortex-M0.
The disadvantage is obvious, but there are two advantages to this:
1: The core will use less silicon space.
2: It's easier to calculate timings "by hand".
View all questions in Cortex-M / M-Profile forum