PIC assembly programming

Status
Not open for further replies.
$ stands for the current address...

So
GOTO $ + 1 means, Goto the next line
GOTO $ + 3 means, Go 3 lines ahead (skip 2)...

and GOTO $ is an endless loop, cause it keeps going to the same adress
 
aniketrane said:
what does "$" signify in assembly code. e.g code are

goto $;

or

goto $+1;

It's in the MPASM help file, '$' means the current address, so 'GOTO $' is an endless loop, 'GOTO $+1' is like a NOP, but takes 2 cycles rather than one - so can be quite handy.

GOTO $-1 (or other minus numbers) is probably most useful, it saves you having to use a label for a jump - like this:

Code:
        BTFSS Dummy, 1
        GOTO $-1

Instead of:

Code:
Loop BTFSS Dummy, 1
        GOTO Loop

It appears in some of my tutorials, and I explain it there.
 
comparing...

how 'bout in comparing?
what are the different syntax and/or techniques can be used in comparing?
of course still in pic assembly!
 
just comparing numbers?
Well, the pic is a risc µC, so there aren't any instructions that allow direct comparison of 2 variables, so you'll have to use tricks to get it done (as with any risc based system)

For example, if you want to see if number1 is bigger then number2 you just subtract number1 from number2 and if the borrow flag is set (a flag that indicates the result went below 0 and 'rolled over' back to 255) then number1 was bigger

To see if 2 numbers are the same you can XOR them, if they are the same then the result is 0
 
For comparing, have a look on the PICList, there are loads of advice and routines for different comparisons.
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…