source: buchla-68k/orig/CLIBRARY/LDIV.S@ 9bf0f86

Last change on this file since 9bf0f86 was 3ae31e9, checked in by Thomas Lopatic <thomas@…>, 8 years ago

Imported original source code.

  • Property mode set to 100755
File size: 1.4 KB
RevLine 
[3ae31e9]1* ------------------------------------------------------------------------------
2* ldiv.s -- long division
3* Version 1 -- 1988-01-22
4* ------------------------------------------------------------------------------
5 .text
6*
7 .xdef _ldiv
8 .xdef ldiv
9*
10 .xdef _ldivr
11*
12ARG1 .equ 8
13ARG2 .equ 12
14*
15_ldiv:
16ldiv: link a6,#-2
17 movem.l d2-d7,-(a7)
18 clr.w d3
19 clr.l d5
20 move.l ARG1(a6),d7
21 move.l ARG2(a6),d6
22 bne ldiv1
23*
24 move.l #$80000000,_ldivr
25 move.l #$80000000,d0
26 divs #0,d0
27 bra ldiv11
28*
29ldiv1: bge ldiv2
30*
31 neg.l d6
32 addq.w #1,d3
33*
34ldiv2: tst.l d7
35 bge ldiv3
36*
37 neg.l d7
38 addq.w #1,d3
39*
40ldiv3: cmp.l d7,d6
41 bgt ldiv9
42*
43 bne ldiv4
44*
45 moveq.l #1,d5
46 clr.l d7
47 bra ldiv9
48*
49ldiv4: cmp.l #$10000,d7
50 bge ldiv5
51*
52 divu d6,d7
53 move.w d7,d5
54 swap d7
55 ext.l d7
56 bra ldiv9
57*
58ldiv5: moveq.l #1,d4
59*
60ldiv6: cmp.l d6,d7
61 bcs ldiv7
62*
63 asl.l #1,d6
64 asl.l #1,d7
65 bra ldiv6
66*
67ldiv7: tst.l d4
68 beq ldiv9
69*
70 cmp.l d6,d7
71 bcs ldiv8
72*
73 or.l d4,d5
74 sub.l d6,d7
75*
76ldiv8: lsr.l #1,d4
77 lsr.l #1,d6
78 bra ldiv7
79*
80ldiv9: cmp.w #1,d3
81 bne ldiv10
82*
83 neg.l d7
84 move.l d7,_ldivr
85 move.l d5,d0
86 neg.l d0
87 bra ldiv11
88*
89ldiv10: move.l d7,_ldivr
90 move.l d5,d0
91*
92ldiv11: tst.l (a7)+
93 movem.l (a7)+,d3-d7
94 unlk a6
95 rts
96*
97 .bss
98*
99_ldivr: .ds.l 1
100*
101 .end
Note: See TracBrowser for help on using the repository browser.