With reference to this post , I am still struggling to understand proper use of arithmetic operators in my code.
Take for example this code from Gooligum's tutorial (Baseline, Lesson 6, page 6) related to setting up the Option register:
Now, the first example is quite clear to me and is what I am used to doing. The second example is a bit more difficult to decipher to my inexperienced eye, but they both do the same thing in the same number of steps.
Putting aside the actual symbols used in the second example, my question is why can those arithmetic operators be used in what looks like regular code? How does one distinguish what looks like an ordinary program instruction from an Assembler directive? Or simply put, why can't one use the same code as in the second example to set bits in any other register?
In any case, I am confused. Is there a particularly good teaching resource that presents multiple examples? As an example of what I mean, compare the instruction set descriptions included in individual PIC datasheets with what is included in Section 29 of the whole manual (DS31029A). The former includes one example at best for each instruction. The latter has two or three examples for each, and I found it far easier to understand.
John
Take for example this code from Gooligum's tutorial (Baseline, Lesson 6, page 6) related to setting up the Option register:
Code:
movlw b'11110110' ;configure timer0:...
;--1-----
;----0---
;-----110
option
Code:
movlw 1<<TOCS|0<<PSA|b'110'
option
Now, the first example is quite clear to me and is what I am used to doing. The second example is a bit more difficult to decipher to my inexperienced eye, but they both do the same thing in the same number of steps.
Putting aside the actual symbols used in the second example, my question is why can those arithmetic operators be used in what looks like regular code? How does one distinguish what looks like an ordinary program instruction from an Assembler directive? Or simply put, why can't one use the same code as in the second example to set bits in any other register?
In any case, I am confused. Is there a particularly good teaching resource that presents multiple examples? As an example of what I mean, compare the instruction set descriptions included in individual PIC datasheets with what is included in Section 29 of the whole manual (DS31029A). The former includes one example at best for each instruction. The latter has two or three examples for each, and I found it far easier to understand.
John