![]() | ![]() | ![]() |
| | |||||||
| Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc. |
| | LinkBack | Thread Tools | Display Modes |
| | (permalink) |
| Code: main: clrf count
movlw 0x23
movwf bdata
loop: rrcf bdata,f
btfsc STATUS,C
incf count
movf bdata,w
bnz loop clrf = 1 movlw = 1 rrcf = 1 btfsc = 1 or 2 incf = 1 movf = 1 bnz = 1 or 2 The number cycles for that code is 39 cycles. Can anyone check it if this is right ? thanks | |
| |
| | (permalink) |
| The execution time for the code will be longer due to the fact that it loops and so some sections get repeated many times. Trying to work out the timing manually would be very difficult due to the fact that the bnz instruction can be branching dependent on the outcome of two different instructions (the rrcf and inc) [Edit, actually just on the value of bdata which is dependent on count]. If you copy the code into MPLAB, set the processor to 18Fxxxx and use the stopwatch, then MPLAB will work it out for you. That really is a horrible bit of code. Looking at it again, I think you will end up with 2 different values dependent on whether the Carry flag was set prior to calling it. Mike. Last edited by Pommie; 28th February 2007 at 11:12 PM. | |
| |
| | (permalink) |
| Woops, just realised you have counted the loops. I make it 38 if carry clear and 56 if carry set. Mike. | |
| |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
| |
| | ||||
| Title | Starter | Forum | Replies | Latest |
| Assembly? | Marks256 | Micro Controllers | 43 | 28th July 2006 04:45 PM |
| Clock speeds and CPU cycle | loosewire | Micro Controllers | 3 | 23rd December 2004 09:10 AM |
| LDR and ADD in instruction cycle | rds1975 | Micro Controllers | 1 | 22nd September 2004 09:21 PM |
| Assembly Language Question | Jeggyman | General Electronics Chat | 6 | 30th January 2004 10:54 PM |
| Processor Instruction Format | mus3na | Micro Controllers | 1 | 19th January 2004 07:13 PM |