Annotation of researchv10no/cmd/PDP11/crt/auldiv.s, revision 1.1

1.1     ! root        1: / Unsigned long quotient
        !             2: 
        !             3: .globl auldiv
        !             4: .globl csv, cret
        !             5: auldiv:
        !             6:        jsr     r5,csv
        !             7:        tst     6.(r5)
        !             8:        bne     hardldiv
        !             9:        mov     8.(r5),r3
        !            10:        bmi     hardldiv
        !            11:        mov     4(r5),r1
        !            12:        mov     2(r1),r2
        !            13:        mov     (r1),r1
        !            14:        bmi     hardest
        !            15:        clr     r0
        !            16:        div     r3,r0
        !            17:        mov     r0,r4           /high quotient
        !            18:        mov     r1,r0
        !            19:        mov     r2,r1
        !            20:        div     r3,r0
        !            21:        bvc     1f
        !            22:        sub     r3,r0           / this is the clever part
        !            23:        div     r3,r0
        !            24:        tst     r1
        !            25:        sxt     r1
        !            26:        add     r1,r0           / cannot overflow!
        !            27: 1:
        !            28:        mov     4.(r5),r2
        !            29:        mov     r4,(r2)+
        !            30:        mov     r0,(r2)
        !            31:        jmp     cret
        !            32: 
        !            33: / The divisor is known to be >= 2^15 so only 16 cycles are needed.
        !            34: hardldiv:
        !            35:        mov     4.(r5),r0
        !            36:        mov     2(r0),r2
        !            37:        mov     (r0),r1
        !            38:        clr     r0
        !            39:        mov     6.(r5),r3
        !            40:        mov     $16.,r4
        !            41: 1:
        !            42:        clc
        !            43:        rol     r2
        !            44:        rol     r1
        !            45:        rol     r0
        !            46:        cmp     r3,r0
        !            47:        bhi     3f
        !            48:        blo     2f
        !            49:        cmp     8.(r5),r1
        !            50:        blos    2f
        !            51: 3:
        !            52:        sob     r4,1b
        !            53:        br      1f
        !            54: 2:
        !            55:        sub     8.(r5),r1
        !            56:        sbc     r0
        !            57:        sub     r3,r0
        !            58:        inc     r2
        !            59:        sob     r4,1b
        !            60: 1:
        !            61:        mov     4.(r5),r3
        !            62:        clr     (r3)+
        !            63:        mov     r2,(r3)
        !            64:        jmp     cret
        !            65: 
        !            66: / The dividend is known to be >= 2^31 so 32 cycles are needed.
        !            67: hardest:
        !            68:        mov     4.(r5),r0
        !            69:        mov     2(r0),r3
        !            70:        mov     (r0),r2
        !            71:        clr     r1
        !            72:        clr     r0
        !            73:        mov     $32.,r4
        !            74: 1:
        !            75:        clc
        !            76:        rol     r3
        !            77:        rol     r2
        !            78:        rol     r1
        !            79:        rol     r0
        !            80:        cmp     6.(r5),r0
        !            81:        bhi     3f
        !            82:        blo     2f
        !            83:        cmp     8.(r5),r1
        !            84:        blos    2f
        !            85: 3:
        !            86:        sob     r4,1b
        !            87:        br      1f
        !            88: 2:
        !            89:        sub     8.(r5),r1
        !            90:        sbc     r0
        !            91:        sub     6.(r5),r0
        !            92:        inc     r3
        !            93:        sob     r4,1b
        !            94: 1:
        !            95:        mov     4.(r5),r0
        !            96:        mov     r2,(r0)+
        !            97:        mov     r3,(r0)
        !            98:        jmp     cret

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.