1;--------------------------------------------------------------------------
2;  fps16x162slong.S - convert fixed16x16 to signed char
3;
4;  Copyright (C) 2004, Vangelis Rokas <vrokas AT otenet.gr>
5;
6;  This library is free software; you can redistribute it and/or modify it
7;  under the terms of the GNU General Public License as published by the
8;  Free Software Foundation; either version 2, or (at your option) any
9;  later version.
10;
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
14;  GNU General Public License for more details.
15;
16;  You should have received a copy of the GNU General Public License
17;  along with this library; see the file COPYING. If not, write to the
18;  Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston,
19;   MA 02110-1301, USA.
20;
21;  As a special exception, if you link this library with other files,
22;  some of which are compiled with SDCC, to produce an executable,
23;  this library does not by itself cause the resulting executable to
24;  be covered by the GNU General Public License. This exception does
25;  not however invalidate any other reasons why the executable file
26;  might be covered by the GNU General Public License.
27;--------------------------------------------------------------------------
28
29	radix dec
30
31;--------------------------------------------------------
32; public variables in this module
33;--------------------------------------------------------
34	global ___fps16x162slong
35
36;--------------------------------------------------------
37;	Equates to used internal registers
38;--------------------------------------------------------
39STATUS	equ	0xfd8
40WREG	equ	0xfe8
41FSR0L	equ	0xfe9
42FSR1L	equ	0xfe1
43FSR2L	equ	0xfd9
44POSTDEC1	equ	0xfe5
45PREINC1	equ	0xfe4
46PLUSW2	equ	0xfdb
47PLUSW1	equ	0xfe3
48PRODL	equ	0xff3
49PRODH	equ	0xff4
50
51
52; Internal registers
53.registers	udata_ovr	0x0000
54r0x00	res	1
55r0x01	res	1
56r0x02	res	1
57r0x03	res	1
58
59
60S_fps16x162slong____fps16x162slong	code
61___fps16x162slong:
62
63	movlw	0x04
64	movff	PLUSW1, PRODL
65
66	movlw	0x03
67	movf	PLUSW1, w
68
69	clrf	PRODH
70	clrf	FSR0L
71
72	btfss	PRODL, 7
73	bra	@1
74
75	bcf	PRODL, 7
76	comf	WREG, f
77	comf	PRODL, f
78	comf	PRODH, f
79	comf	FSR0L, f
80
81	incfsz	WREG, f
82	bra	@1
83	incfsz	PRODL, f
84	bra	@1
85	incfsz	PRODH, f
86	bra	@1
87	incf	FSR0L, f
88
89@1:
90	return
91
92	end
93