>-----Original Message----- >From: piclist-bounces@mit.edu [mailto:piclist-bounces@mit.edu] >Sent: 13 June 2005 11:01 >To: piclist@mit.edu >Subject: [PIC] Error messages when inserting Assembler code into C > > >I am trying to insert some assembler code into my C code. The >micro I use is a PIC18F8720 with the HI-TECH compiler. I am >using a global variable that is accessed in C and assembler >and unless I use near RAM I can not get most assembler >instructions to work. > >char varib; >void func(void) >{ >#asm > > movff wreg,_varib //works fine > addwf _varib //does not compile is this line is added > >#endasm >} > >When I compile I get this message: >Fixup overflow referencing psect bigbss (loc 0x19E28 >(0x19DD6+82), size 1, value 0xB67) > >The varib variable is stored at 0xB67 so I thought it may be a >banking problem. If anyone can be of help it will be greatly >appreciated. Once you start adding inline assembler into your C code you lose the advantages that the compiler gives you such as portability and in the PIC's case automatic handling of data memory banking. If you really need to do this, you will have to manipulate the bank select register yourself. The reason that the first instruction works ok is that movff takes a 12bit address for it's operands so no banking instructions are required. The code below should compile ok: char varib; void func(void) { #asm movff wreg,_varib ; no bank switching required movlb _varib shr 8 ; set bank using high order bits of _varib address addwf _varib & 0xFF ; use lower 8 bits of _varib address in operand #endasm } Regards Mike ======================================================================= This e-mail is intended for the person it is addressed to only. The information contained in it may be confidential and/or protected by law. If you are not the intended recipient of this message, you must not make any use of this information, or copy or show it to any person. Please contact us immediately to tell us that you have received this e-mail, and return the original to us. Any use, forwarding, printing or copying of this message is strictly prohibited. No part of this message can be considered a request for goods or services. ======================================================================= -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist