gbdk-2020 | GameBoy Development Kit |
| download: https://git.y1.nz/archives/gbdk.tar.gz | |
| README | Files | Log | Refs | LICENSE |
gbdk-lib/libc/asm/mos6502/_divsint.s
1 ;-------------------------------------------------------------------------
2 ; _divsint.s - routine for division of 16 bit signed int
3 ;
4 ; Copyright (C) 1998, Ullrich von Bassewitz
5 ; Copyright (C) 2022, Gabriele Gorla
6 ;
7 ; This library is free software; you can redistribute it and/or modify it
8 ; under the terms of the GNU General Public License as published by the
9 ; Free Software Foundation; either version 2, or (at your option) any
10 ; later version.
11 ;
12 ; This library is distributed in the hope that it will be useful,
13 ; but WITHOUT ANY WARRANTY; without even the implied warranty of
14 ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 ; GNU General Public License for more details.
16 ;
17 ; You should have received a copy of the GNU General Public License
18 ; along with this library; see the file COPYING. If not, write to the
19 ; Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston,
20 ; MA 02110-1301, USA.
21 ;
22 ; As a special exception, if you link this library with other files,
23 ; some of which are compiled with SDCC, to produce an executable,
24 ; this library does not by itself cause the resulting executable to
25 ; be covered by the GNU General Public License. This exception does
26 ; not however invalidate any other reasons why the executable file
27 ; might be covered by the GNU General Public License.
28 ;-------------------------------------------------------------------------
29
30 .module _divsint
31
32 ;--------------------------------------------------------
33 ; exported symbols
34 ;--------------------------------------------------------
35 .globl __divsint
36 .globl ___sdivmod16
37
38 ;--------------------------------------------------------
39 ; local aliases
40 ;--------------------------------------------------------
41 .define res "___SDCC_m6502_ret0"
42 .define den "__divsint_PARM_2"
43 .define rem "___SDCC_m6502_ret2"
44 .define s1 "___SDCC_m6502_ret4"
45 .define s2 "___SDCC_m6502_ret5"
46
47 ;--------------------------------------------------------
48 ; code
49 ;--------------------------------------------------------
50 .area _CODE
51
52 __divsint:
53 jsr ___sdivmod16
54 lda *res+0
55 ldx *res+1
56 pha
57 lda *s1
58 eor *s2
59 bpl pos
60 pla
61 jmp ___negax
62 pos:
63 pla
64 rts
65
66 ___sdivmod16:
67 stx *s1
68 jsr _abs
69 pha
70 lda *__divsint_PARM_2+1
71 sta *s2
72 bpl skip
73 sec
74 lda #0x00
75 sbc *__divsint_PARM_2+0
76 sta *__divsint_PARM_2+0
77 lda #0x00
78 sbc *__divsint_PARM_2+1
79 sta *__divsint_PARM_2+1
80 skip:
81 pla
82 jmp ___udivmod16
83
This webpage is intended to be an accessible preview of this repository. To get a fuller picture, clone it and use the git CLI.