Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > sci.electronics.design > #380971
| From | Martin Brown <|||newspam|||@nezumi.demon.co.uk> |
|---|---|
| Newsgroups | sci.electronics.design |
| Subject | Re: OT: table CALL does not work |
| Date | 2015-10-10 09:56 +0100 |
| Organization | Aioe.org NNTP Server |
| Message-ID | <mvajso$ai9$1@speranza.aioe.org> (permalink) |
| References | <TGURx.175753$WK.81663@fx10.iad> <pan.2015.10.09.22.32.36.258000@nowhere.invalid> <oa3Sx.3124$CV7.2368@fx30.iad> |
On 10/10/2015 08:32, Robert Baer wrote: > Nobody wrote: >> On Fri, 09 Oct 2015 12:36:18 -0700, Robert Baer wrote: >> >>> setup: >>> MOVLW Low(tab1) >>> ADDWF ptrlo,W ; add pointer to W >>> MOVLW High(tab1) >>> BTFSC STATUS,C >>> INCF PCLATH,F ; W=1 >>> CALL tab1 ;;*REMoving this, one sees 0x00 0xFF 0x01 >>> repeating >> >> Here, W contains High(tab1), PCLATH contains zero. > * Yes, that is the way i see it also. > >> >> If you can ensure that the table doesn't cross a page boundary, it >> suffices to use: >> >> MOVLW High(tab1) >> MOVWF PCLATH >> MOVF ptrlo,W >> CALL tab1 >> >> In the most general case, you have to allow for the fact that tab1 might >> not even be on the same 2k super-page as the target RETLW instruction, >> meaning that PCLATH needs different values for the CALL and the computed >> goto, which basically means that the calculation needs to be moved into >> the table routine. E.g. >> >> MOVLW High(tab1) ; far call to tab1 >> MOVWF PCLATH >> CALL tab1 >> >> ... >> >> tab1: >> MOVLW High(tab1_data) >> ADDWF ptrhi,W >> MOVWF PCLATH >> >> MOVLW Low(tab1_data) >> ADDWF ptrlo,W >> BTFSC STATUS,C >> INCF PCLATH,F >> >> MOVWF PCL,F >> >> tab1_data: >> RETLW ... >> > * I have noted that, and it looks nice for a presumed look-up "anywhere". > BUT.. > The "gotcha" is nothing is pushed on the stack, so WTH does the > program go after the RETURN/RETLW? > And can one rely on the unknown/undefined stack contents/ > > My goal is to have a number of 1K look-up tables entry at 0x0100 > sections. For heavens sake! *Single step* the failing code in a PIC *emulator* and watch exactly what happens at the critical point. Get the basic version I posted working first and then modify it to use pages!!!! Crash and burn with obfuscated code is no way to run a circus. You could probably get away with a toy hobby board that just supplied power to the device and a LED to flash PICAXE or whatever. You have already wasted several multiples of the tools cost in your time. -- Regards, Martin Brown
Back to sci.electronics.design | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
OT: table CALL does not work Robert Baer <robertbaer@localnet.com> - 2015-10-09 12:36 -0700
Re: OT: table CALL does not work "P E Schoen" <paul@pstech-inc.com> - 2015-10-09 18:00 -0400
Re: OT: table CALL does not work Robert Baer <robertbaer@localnet.com> - 2015-10-10 00:19 -0700
Re: OT: table CALL does not work Nobody <nobody@nowhere.invalid> - 2015-10-09 23:32 +0100
Re: OT: table CALL does not work Robert Baer <robertbaer@localnet.com> - 2015-10-10 00:32 -0700
Re: OT: table CALL does not work Martin Brown <|||newspam|||@nezumi.demon.co.uk> - 2015-10-10 09:56 +0100
Re: table CALL does not work "P E Schoen" <paul@pstech-inc.com> - 2015-10-10 18:38 -0400
Re: table CALL does not work Martin Brown <|||newspam|||@nezumi.demon.co.uk> - 2015-10-12 09:10 +0100
Re: OT: table CALL does not work Nobody <nobody@nowhere.invalid> - 2015-10-11 22:50 +0100
Re: OT: table CALL does not work Robert Baer <robertbaer@localnet.com> - 2015-10-11 23:23 -0700
Re: OT: table CALL does not work Martin Riddle <martin_ridd@verizon.net> - 2015-10-11 00:27 -0400
Re: OT: table CALL does not work Martin Riddle <martin_ridd@verizon.net> - 2015-10-11 00:33 -0400
Re: OT: table CALL does not work Robert Baer <robertbaer@localnet.com> - 2015-10-11 13:37 -0700
Re: OT: table CALL does not work Martin Riddle <martin_ridd@verizon.net> - 2015-10-11 20:54 -0400
Re: OT: table CALL does not work Robert Baer <robertbaer@localnet.com> - 2015-10-11 13:35 -0700
Re: OT: table CALL does not work bitrex <bitrex@de.lete.earthlink.net> - 2015-10-11 16:44 -0400
Re: OT: table CALL does not work Martin Brown <|||newspam|||@nezumi.demon.co.uk> - 2015-10-12 18:12 +0100
csiph-web