1 ; -------------------------------------------------------------------------
2 ; _gptrget3.S - read three bytes pointed to by a generic pointer
4 ; Written By Raphael Neider, rneider@web.de (2005)
6 ; This library is free software; you can redistribute it and/or
7 ; modify it under the terms of the GNU Library General Public
8 ; License as published by the Free Software Foundation; either
9 ; version 2 of the License, or (at your option) any later version.
11 ; This library is distributed in the hope that it will be useful,
12 ; but WITHOUT ANY WARRANTY; without even the implied warranty of
13 ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 ; Library General Public License for more details.
16 ; You should have received a copy of the GNU Library General Public
17 ; License along with this library; if not, write to the
18 ; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 ; Boston, MA 02111-1307 USA.
21 ; In other words, you are welcome to use, share and improve this program.
22 ; You are forbidden to forbid anyone else to use, share and improve
23 ; what you give them. Help stamp out software-hoarding!
26 ; ------------------------------------------------------------------------
28 ; calling conventions:
29 ; 3 byte generic pointer is passed in via (WREG STK00 STK01).
30 ; The result is returned in (WREG (STK00 (STK01 (STK02)))).
32 ; unsigned char _gptrget (void *gptr);
33 ; unsigned char _gptrget1 (void *gptr);
34 ; unsigned int _gptrget2 (void *gptr);
35 ; void * _gptrget3 (void *gptr);
36 ; unsigned long _gptrget4 (void *gptr);
38 ; void _gptrput (void *ptr, unsigned char val);
39 ; void _gptrput1 (void *ptr, unsigned char val);
40 ; void _gptrput2 (void *ptr, unsigned int val);
41 ; void _gptrput3 (void *ptr, unsigned int val);
42 ; void _gptrput4 (void *ptr, unsigned long val);
45 include p16f_common.inc
53 select_routine __dataptrget3, __codeptrget3
54 ; invalid tag -- return 0x000000
62 movwf STK01 ; LSB in STK01
65 movwf STK00 ; 2nd byte in STK00
67 movf INDF, W ; MSB in WREG
71 pagesel __codeptrget1 ; might reside in different page
73 movwf STK02 ; temporarily store LSB
74 incfsz STK01,F ; increment low address byte
75 decf STK00,F ; undo increment of high address byte if low byte did not overflow
76 incf STK00,F ; increment high address byte
77 pagesel __codeptrget1 ; might reside in different page
79 movwf STK03 ; temporarily store 2nd byte
80 incfsz STK01,F ; increment low address byte
81 decf STK00,F ; undo increment of high address byte if low byte did not overflow
82 incf STK00,F ; increment high address byte
83 pagesel __codeptrget1 ; might reside in different page
85 movwf STK04 ; temporarily store MSB
87 movwf STK01 ; LSB in STK01
89 movwf STK00 ; 2nd byte in STK00
90 movf STK04, W ; MSB in WREG