![]() | ![]() | ![]() |
| | |||||||
| 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) |
| in c, we have if or case select to select different cases... but how can we do it in assembly? especially for the PIC programming? can anyone give me some suggestion? thx... | |
| |
| | (permalink) | |
| Quote:
I'm presuming you are talking about the 4 bit A2D result you asked about in another thread, if so there's an easier and faster way to do it. As you have only 16 possible results (with 4 bits) you could use a jump table. This works exactly like a lookup table, except instead of RETLW lines it uses GOTO's instead. | ||
| |
| | (permalink) |
| Instead of subtraction, you can also use XOR function to test if variable = constant expression.
__________________ "There is no way to peace, peace is the way!" | |
| |
| | (permalink) |
| Here's a PIC16 code sample: Code: ; On entry, W reg contains the switch value ; SWITCH: movwf TEMP ; Save to a temporary register ; movlw CASE1_VAL subwf TEMP,W skpnz goto CASE1 ; movlw CASE2_VAL subwf TEMP,W skpnz goto CASE2 ; return CASE1: return CASE2: return
__________________ "Having to do with Motion Control" | |
| |