source: buchla-68k/lib700/ldiv.s@ 0170798

Last change on this file since 0170798 was 4f508e6, checked in by Thomas Lopatic <thomas@…>, 7 years ago

Converted assembly language files.

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