![]() |
![]() |
![]() |
|
|
|||||||
| Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc. |
|
|
Thread Tools | Display Modes |
|
|
(permalink) |
|
I want to run a routine seven times. Would something like this work?:
Code:
Counter equ 20 ; variable to put the counter in ; Main code here. ; At some point it'll call RoutineName RoutineName movlw b'01111111' movwf Counter RoutineLoop Goto Transmit ; this being the routine to be done seven times RRNFC Counter,1 ; roll the bits right, don't use carry, store result in counter? BTFSC Counter,1 ; check counter. skip next line if it's clear? Goto RoutineLoop ; repeat loop if there are still bits in Counter Return ; if there are no bits in Counter return to where RoutineName was called Any suggestions appreciated.. Mark
__________________
Muss es Sein? Es muss sein... |
|
|
|
|
|
|
(permalink) |
|
What's RRNFC?. Assuming this is PIC assembler, bits go from 0 to 7, so the least significant bit would be 0, not 1.
If you want to see how loops are done, have a look at my PIC tutorials, many of those use loops. |
|
|
|
|
|
|
(permalink) |
|
DECFSZ is best for loop counting.
Code:
Counter equ 20 ; variable to put the counter in
; Main code here.
; At some point it'll call RoutineName
RoutineName
movlw 7
movwf Counter
RoutineLoop
CALL Transmit ; this being the routine to be done seven times
DECFSZ Counter,f
Goto RoutineLoop ; repeat loop if there are still bits in Counter
;
Return ; if there are no bits in Counter return to where RoutineName was called
__________________
"Having to do with Motion Control" |
|
|
|
|
|
|
(permalink) | |
|
Thanks for the help. I see now how complicated i was trying to make it!
Quote:
Rotate right (no carry) (found it in the MPLAB help files)
__________________
Muss es Sein? Es muss sein... |
||
|
|
|
|
|
(permalink) |
|
Ah! - 16 bit core, not 12 or 14 :lol:
|
|
|
|
|
|
|
(permalink) |
|
Remeber ASM is very specific, its best when asking for help that you clearly say what device you are using, the fuse settings, as well as a breif overview of what the final application will be.
Low end microcontrollers, been developed in ASM, don't deal very well with the idea of box design, where you don't care about other peoples code to be run on the same micro. |
|
|
|
|