southafrikanse
Junior Member level 1
- Joined
- Jun 12, 2007
- Messages
- 15
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1,281
- Location
- Amora, Portugal
- Activity points
- 1,418
z01z said:What compiler do you use?
For Keil C51 use this syntax:southafrikanse said:z01z said:What compiler do you use?
I have to use the Keil compiler.
House_Cat said:The "NOP" assembly language instruction does nothing but eat clock cycles (3 clock cycles per NOP).
atferrari said:Whether you say it "does something" or "does nothing at all", a NOP instruction as a whole, involves four clock cycles. In all PIC micros I can recall.
Moreover, any instruction cycle takes four clock cycles.
Sorry House_Cat, that's not always true. Take a look at this simple example:House_Cat said:A high level compiler will simply optimize a pushed ASM('NOP') completely out of the code - you achieve NOTHING by using it. Not even 4 clock cycles or 3 clock cycles - NOTHING gets coded for the processor.
#include <intrins.h>
#include <REG52.H>
void main (void)
{
while(1)
{
_nop_();
_nop_();
_nop_();
P1 ^= 0x01; // Toggle P1.0
_nop_();
_nop_();
P1 ^= 0x01; // Toggle P1.0
_nop_();
}
}
You'll recognize that the compiler keeps the NOPs - that's its job.ASSEMBLY LISTING OF GENERATED OBJECT CODE
; FUNCTION main (BEGIN)
; SOURCE LINE # 4
; SOURCE LINE # 5
0000 ?C0001:
; SOURCE LINE # 6
; SOURCE LINE # 7
; SOURCE LINE # 8
0000 00 NOP
; SOURCE LINE # 9
0001 00 NOP
; SOURCE LINE # 10
0002 00 NOP
; SOURCE LINE # 11
0003 639001 XRL P1,#01H
; SOURCE LINE # 12
0006 00 NOP
; SOURCE LINE # 13
0007 00 NOP
; SOURCE LINE # 14
0008 639001 XRL P1,#01H
; SOURCE LINE # 15
000B 00 NOP
; SOURCE LINE # 16
000C 80F2 SJMP ?C0001
; FUNCTION main (END)
That means that the controller needs 12 clock (crystal) cycles to execute one machine cycle. A NOP instruction is executed in one machine cycle = 12 clock cycles. So in a classical 8051 no instruction can be processed faster. It's a hardware feature.The original 8051 core ran at 12 clock cycles per machine cycle, with most instructions executing in one or two machine cycles. With a 12 MHz clock frequency, the 8051 could thus execute 1 million one-cycle instructions per second or 500,000 two-cycle instructions per second.
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?