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

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

unix.superglobalmegacorp.com

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