Hi all,
Can any guru clear this up for me please - I'm getting all confused about directives and instructions.
I was pretty happy when I learnt to programme pic's that directives (#Define) controlled the assembler and instructions (decfsz) controlled the MC.
Now I'm coming across mpasm code with 'IF/ELSE' and 'WHILE' type directives that are actively part of the programme - rather than controlling how it is assembled. For example in a macro:
Somemacro macro somevar
IF someVar == 1
bsf GPIO, 1
ELSE
bcf GPIO, 1
ENDIF
endm
I didn't think asm had an IF or WHILE instruction! Assuming asm does, when would I use these rather than simulating them with decfsz and btfss etc.? IF and WHILE loops are obviously much easier to read and understand in a block of asm, but are they as efficient as simulation through pic instructions?
Efficiency is quite important in my current code (hence choice of asm rather than C) as my current project acts as a slave for a bespoke protocol (similar to I2C) translating it to standard I2C, so all work needs to be done between bespoke protocol packets as there is no way of pausing transmission.
Can any guru clear this up for me please - I'm getting all confused about directives and instructions.
I was pretty happy when I learnt to programme pic's that directives (#Define) controlled the assembler and instructions (decfsz) controlled the MC.
Now I'm coming across mpasm code with 'IF/ELSE' and 'WHILE' type directives that are actively part of the programme - rather than controlling how it is assembled. For example in a macro:
Somemacro macro somevar
IF someVar == 1
bsf GPIO, 1
ELSE
bcf GPIO, 1
ENDIF
endm
I didn't think asm had an IF or WHILE instruction! Assuming asm does, when would I use these rather than simulating them with decfsz and btfss etc.? IF and WHILE loops are obviously much easier to read and understand in a block of asm, but are they as efficient as simulation through pic instructions?
Efficiency is quite important in my current code (hence choice of asm rather than C) as my current project acts as a slave for a bespoke protocol (similar to I2C) translating it to standard I2C, so all work needs to be done between bespoke protocol packets as there is no way of pausing transmission.
Last edited: