gtyler wrote: > Hi, I have a strange case of appearing NOP's :) > This is the assembly code I have written in MPLAB 6.4 > ie. what is in the .asm file: > > Line # > 22 addwf PCL,1,0 > 23 goto RS0 > 24 goto RS1 > 25 goto RS2 > 26 goto RS3 > 27 return > > But when I assemble it, I get this in the "Program Memory" file, this > is from the .hex file: > > Line# Address > 18 22 ADDWF 0xff9, 0x1, 0 > 19 24 GOTO 0x36 > 20 26 NOP > 21 28 GOTO 0x42 > 22 2A NOP > 23 2C GOTO 0x4c > 24 2E NOP > 25 30 GOTO 0x56 > 26 32 NOP > 27 34 RETURN 0 > > There are strange NOP's that it has added in every 4 memory > locations. Why does the Assembler do this? Because the GOTO instruction on an 18 family PIC takes 2 words. The encoding of the second word of all two word instructions is deliberately arranged so that it is a NOP when decoded as a single word instruction. This means nothing wierd happens when you accidentally jump to the second word of a two word instruction. > Is there any way to stop it doing this? No, since it's there for good reason. If your jump target is known to be close enough to the jump point, you can use the single word BRA instead of the two word GOTO instruction. ***************************************************************** Embed Inc, embedded system specialists in Littleton Massachusetts (978) 742-9014, http://www.embedinc.com -- http://www.piclist.com hint: The list server can filter out subtopics (like ads or off topics) for you. See http://www.piclist.com/#topics