![]() | ![]() | ![]() |
| | |||||||
| 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) |
| anyone can help me i need 8bit and 16bit division algorithm and program code for pic microcontroller thanks | |
| |
| | (permalink) |
| Easy think shift instructions. When you use a RRF (Rotate Right File) the extra bit is deumped in the carry. ie: Code: div2 macro upperbyte, lowerbyte RRF upperbyte,F RRF lowerbyte,F endm ; This macro will divide the two params by 2. ; so you could div by 8, by calling that 4 times, div8 macro upperbyte, lowerbyte div2 upperbyte, lowerbyte div2 upperbyte, lowerbyte div2 upperbyte, lowerbyte div2 upperbyte, lowerbyte endm ; And once again to get a div by 16, call div 8 twice div16 macro upperbyte, lowerbyte div8 upperbyte, lowerbyte div8 upperbyte, lowerbyte endm | |
| |
| | (permalink) | |
| Quote:
| ||
| |
| | (permalink) |
| hehehe it changed shift too bleep sh!ft is a bad word ! | |
| |