Hello to all,
I need a small help with the processor instructions. Can anybody provide me an example where during execution, the functional unit must not be used or it must be deactivated?
All data-processing and data-transfer instruction need the functional unit. Initially, I thought the NOP instruction can be one of the examples, but while going through the documentations, I got to know that NOP instruction is nothing but the MOV R8,R8.
I really want to measure the effect of functional unit activation and deactivation. So, is there any instruction example or any measurement technique, which will be helpful in our case?
I am working on ARM Cortex-M4.
Thanking you in advance,
Warm Regards,
Himanshu
>I got to know that NOP instruction is nothing but the MOV R8,R8.
That's not true for Cortex-M (and recent Arm processors). Before ARM1176 it is correct that there is no real "NOP" instruction and development tools use MOV instruction to implement NOP. But since ARM1176 we have added NOP instruction (as part of Thumb-2 technology) and all Cortex-M processors support NOP instruction.
regards,
Joseph
Dear Mr. Yiu,
Thank you very much for your quick reply. But while implementing the MOV R8,R8 was displayed as the nop instruction in the assembly. Therefore, I got confused.
(this assembly file has been generated for Cortex-M4 for LPCXpresso 54114 board)
But, when I implemented the only "NOP" instruction, (not in any other instruction form) directly, then I got to know the assembly of NOP is different. (As shown in the attached picture)
So, in my case, is it okay to consider the NOP instruction as an instruction, which does not use the functional unit or deactivates the functional unit??
Because, as seen in the uploaded picture the first line of instruction is MOV R8,R8 has been also shown as the NOP instruction. And we know that the MOV instruction uses the functional unit.
So, is it okay to use the NOP instruction directly??...If not then which instruction shall I use, which won't use the functional unit.
Sorry for posting the wrong remarks earlier. Since I got confused with the assembly stuff.
Thanking you once again for your proper guidance,
Kind Regards,
No problem.
That's a bit strange. I don't know why the toolchain generated "MOV R8, R8". The instruction encoding 0xBF00 is correct for NOP.
You can insert NOP in your C code using :
__NOP();
This is defined in the CMSIS-CORE header files.
Thank you very much for the clarification. With the provided instruction example, I am getting the nop instruction assembly. Thank you very much.
But, still I do have one question:
1. Therefore, Is it okay to use the NOP instruction (with assembly 0xBF00) which does not use the functional unit?
Thanking you,
Regards,
Yes, it is perfectly fine to use NOP instructions. However, there is no guarantee that each NOP will generate 1 cycle delay.
Thank you very much for your quick reply. Therefore any of the NOP with 0xBF00 (16-bit NOP instruction) or NOP.W with 0xF3AF8000 (32-bit NOP instruction) can be used in our case (No usage of the functional unit), am I right?
(generated from Cortex-M4)
Thanking you once again,
Yes, that's correct.
>No usage of the functional unit
Bear in mind that the processor will still be decoding and fetching subsequent instructions, so there is some activities in the processor.
Thank you very much once again for the tip. I will surely keep in mind.