--_002_201174202112039149techmanPC_ Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable According to the Hitech manual for v9.80 as Bob says for inline assembler=20 the following is correct. Excerpt from page 92 of the manual. unsigned int var; void main(void) { var =3D 1; #asm // like this... BCF 0,3 BANKSEL(_var) RLF (_var)&07fh RLF (_var+1)&07fh #endasm However if the function is written in assembler and called from a C=20 statement, things get a little more complicated. From page 89. The following are guidelines that must be adhered to when writing a routine= =20 in a C-callable assembly routine. ? Select, or define, a suitable psect for the executable assembly code ? Select a name (label) for the routine using a leading underscore=20 character ? Ensure that the routine?s label is globally accessible from other modules ? Select an appropriate equivalent C prototype for the routine on which=20 argument passing can be modelled ? Ensure any symbol used to hold arguments to the routine is globally=20 accessible ? Optionally, use a signature value to enable type checking when the=20 function is called ? Write the routine ensuring arguments are read from the correct location,= =20 the return value is loaded to the correct storage location before returning, if=20 appropriate ? Ensure any local variables required by the routine have space reserved by= =20 the appropriate directive ? Use bank selection instructions and mask addresses of symbols ? If the assembly routine calls other C functions or assembly routines,=20 ensure the compiler is aware of this using the appropriate directives. Page 91 has, (aspic.h is a Hitech header file for assembly functions). #include GLOBAL _add,?_add ; make _add globally accessible SIGNAT _add,8298 ; tell the linker how it should be called FNSIZE _add,0,4 ; this required 4 bytes of params; no autos ; everything following will be placed into the mytext psect psect mytext,local,class=3DCODE,delta=3D2 ; our routine to add to ints and return the result _add: ; params are loaded by the calling function; ; we access them here using the special symbol BANKSEL (?_add) ; select the bank of this object MOVF BANKMASK(?_add+2),w ; take the LSB of the second param ADDWF BANKMASK(?_add),f ; add to the LSB of the first param BTFSC STATUS,0 ; check for carry INCF BANKMASK(?_add+1),f ; handle carry MOVF BANKMASK(?_add+3),w ; take the MSB of the second param ADDWF BANKMASK(?_add+1),f ; add to the MSB of the first param ; the result is already in the required location so we can ; just return immediately RETURN Colin -- cdb, colin@btech-online.co.uk on 4/07/2011 =20 Web presence: www.btech-online.co.uk =20 =20 Hosted by: www.justhost.com.au =20 =20 This email is to be considered private if addressed to a named individual= =20 or HR department, and public if addressed to a blog, forum or news=20 article. =20 =20 =20 --_002_201174202112039149techmanPC_ Content-Type: text/plain; name="ATT00001.txt" Content-Description: ATT00001.txt Content-Disposition: attachment; filename="ATT00001.txt"; size=208; creation-date="Mon, 04 Jul 2011 03:28:03 GMT"; modification-date="Mon, 04 Jul 2011 03:28:03 GMT" Content-Transfer-Encoding: base64 LS0gDQpodHRwOi8vd3d3LnBpY2xpc3QuY29tIFBJQy9TWCBGQVEgJiBsaXN0IGFyY2hpdmUNClZp ZXcvY2hhbmdlIHlvdXIgbWVtYmVyc2hpcCBvcHRpb25zIGF0DQpodHRwOi8vbWFpbG1hbi5taXQu ZWR1L21haWxtYW4vbGlzdGluZm8vcGljbGlzdA0K --_002_201174202112039149techmanPC_-- .