![]() | ![]() | ![]() |
| | |||||||
| 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) |
| Hi I have a COUNT variable. When power up the PIC don’t know what value in it. (It depends on the last saved value in EEPROM) I want to check whether it is ZERO or other. If it is zero I want to goto NORMAL program. If not zero I want to goto UPDATE routine. Here is my code please tell me am I right? Code: movf COUNT,W ;get the count value xorlw 00h ;compare with zero btfss STATUS,Z ;check the ZERO bit goto UPDATE ;NO, it is not ZERO goto NORMAL ;YES, it is ZERO | |
| |
| | (permalink) |
| Yep that'll work. MPASM also has a couple of macros built in to make that eaiser. so.. Code: movf COUNT,W ;sets the z flag bz NORMAL ;it's zero so branch goto UPDATE ;not zero so goto UPDATE | |
| |
| | (permalink) |
| Another useful way to test for zero is movf COUNT,F. This will set/clear the zero flag without corrupting W. Mike. | |
| |
| | (permalink) |
| Oh I see now I got it.Everywhere I'm corrupting W I must prevent this by moving the value to the FILE register. Also built in macros really helpful.I must give a try for that. Thank you both of you for the instant replies. | |
| |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
| |
| | ||||
| Title | Starter | Forum | Replies | Latest |
| How can I check a transistor is working | mettam | General Electronics Chat | 6 | 2nd October 2006 02:48 AM |
| How to check a Live Chassis | walters | General Electronics Chat | 5 | 17th August 2005 08:06 AM |
| Chip talk | dreamproject | Electronic Projects Design/Ideas/Reviews | 8 | 2nd April 2005 08:24 PM |
| Motor control interface | dreamproject | Micro Controllers | 0 | 31st March 2005 04:48 AM |
| Check this Out! | mechanicats | General Electronics Chat | 1 | 7th February 2003 08:28 PM |