So... you don't ever pass a parm in W? Does the linker tell you that W is getting trashed on every goto or call? I must be missing something... And the linker uses W(!) and two instructions prior to the call to access 8k of address space rather than leaving W alone and using one instruction to address within 2k, two for 4k, or 3 for 8k? PCL goto or call --- ----------- xxx XX XXXXXXXX 8K 0xx XX XXXXXXXX 8K 00x XX XXXXXXXX 2K Boy am I going to miss the PAGE and RETP instructions if I move from the Scenix SX to the Microchip '877. BTY, Did anyone else get signed up for the seminar in August at the Rancho Bernardo Raddison? The http://buy.microchip.com website working for a while and did accept my registration. Its F'd up now but phone registrations are accepted. Special offer of an ICD for $80 (I think) with seminar registration. Kelly and I are trying to get a tailgate party together before or after the seminar so if you are in the San Diego area please let us know that you will come drink some microbrew (or soda) and say hello! --- James Newton mailto:jamesnewton@geocities.com 1-619-652-0593 -----Original Message----- From: pic microcontroller discussion list [mailto:PICLIST@MITVMA.MIT.EDU]On Behalf Of Quitt, Walter Sent: Friday, April 14, 2000 11:16 To: PICLIST@MITVMA.MIT.EDU Subject: Re: Program over 1k with a 16F877 In response to the question at the end of this post: "Does the linker produce the same efficient code?" My latest MPLAB project produces the following from the .lst file for a 16F877 using the XCALL macro: Error[151] C:\WINDOWS\DESKTOP\WALT\KEYER\MAIN.ASM 44 : Operand contains unresolvable labels or is too complex Error[151] C:\WINDOWS\DESKTOP\WALT\KEYER\MAIN.ASM 50 : Operand contains unresolvable labels or is too complex But produces the following with PAGESEL directive: 001973 3019 MOVLW 0x19 PAGESEL IO 001974 008a MOVWF 0xa 001975 217e CALL 0x17e call IO This is how I call routines because I write totally (almost) relocatable code. Do you hear the drum beat of relocatable code? A careful review of the 16f87x data sheet page 26 of DS30292B should show that you can address any routine anywhere with in the 8K data space this way. The same can be accomplished with: MOVLW HIGH (SUBROUTINE_NAME) MOVWF PCLATH CALL LOW (SUBROUTINE_NAME) This produces EXACTLY the same in my project as shown: 001976 3019 MOVLW 0x19 movlw HIGH IO 001977 008a MOVWF 0xa movwf PCLATH 001978 2181 CALL 0x181 call LOW IO The above is something I saw long ago in some MChip literature. You really don't need to worry where any routine is in the 16F87x if you call with one of the two above methods. If you are always in the same page then just use a CALL instruction. If you write big programs (me) then always calling in the above manner saves a lot of grief. Using relocatable code structure also keeps me from worrying about having to figure out where to load stuff via the org statement (generally.) So linker or not choose your method. "That's all I have to say about that." -Walt... -----Original Message----- From: Thorsten Klose [mailto:Thorsten.Klose@GMX.DE] Sent: Thursday, April 13, 2000 3:28 PM To: PICLIST@MITVMA.MIT.EDU Subject: Re: Program over 1k with a 16F877 To wrap around the problem I wrote two macros which produce smaller code than the "lgoto" and "lcall" macros from MPASM. They are for 1k devices but can be easily extended for 2k PICs (only 4 cases to check) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - XGOTO MACRO label if label & 0x800 bsf PCLATH, 3 else bcf PCLATH, 3 endif goto label ENDM XCALL MACRO label LOCAL testlabel testlabel: if label & 0x800 bsf PCLATH, 3 else bcf PCLATH, 3 endif call label if testlabel & 0x800 bsf PCLATH, 3 else bcf PCLATH, 3 endif ENDM - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Does the linker produce the same efficient code? Best Regards, Thorsten. -- _____________________________________________ _/ uC-Stuff for MIDI at http://go.to/uCApps /_______ / Music is aesthetisized frequency (Klaus Schulze) / ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~