⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 jack_longdiv.s

📁 ICCAVR中所有的库函数源码
💻 S
字号:
; ** FAST long arithmetic Routines for Atmel AVR RISC **
; ** (C) 1998, 1998, by Jack Tidwell <jackt@igalaxy.net> **
; ** These routines may be used for personal and educational
; **      purposes only, and are free to download.
; ** Any commercial usage must have my written permission **
; ** This version written for Richard Mann @ ImageCraft
; I'll try to make it smaller someday.
;
; **** I debuged this one Richard, it seems to work well

	.include "long.h"

;** Signed 32bit Division **
SDIV::  tst     MANT1hh  ; test MSBit (b31) for Sign
        brmi    SDIV1n
        tst     MANT2hh
        brpl    UDIV     ; both are Pos, normal
        rcall   NEGMANT2 ; Acc1+, Acc2-, Negate Acc2
SDIV1a: rcall   UDIV     ; Normal Div
        rjmp    NEGMANT1 ; Negate Results
SDIV1n: rcall   NEGMANT1
        tst     MANT2hh
        brpl    SDIV1a
;*      both are '-', Neg 2 & fall through to normal UDIV
        rcall   NEGMANT2
;** Straight 32bit Unsigned ACC1/ACC2 **
UDIV::  rcall   tstzero2        ; test for Div/0
        breq    DIVZERO
        rcall   tstzero1
		; change from UDIVX to UDIVy, rfm
        breq    UDIVy           ; save lots of time!
        clr     QUOT
        clr     QUOTm
        clr     QUOTh
        clr     QUOThh
        lsl     MANT1
        rol     MANT1m
        rol     MANT1h
        rol     MANT1hh
        ldi     count,32
UDIVLP: rol     QUOT
        rol     QUOTm
        rol     QUOTh
        rol     QUOThh
        cp      QUOT,MANT2
        cpc     QUOTm,MANT2m
        cpc     QUOTh,MANT2h
        cpc     QUOThh,MANT2hh
        brlo    UDIV2
        sub     QUOT,MANT2
        sbc     QUOTm,MANT2m
        sbc     QUOTh,MANT2h
        sbc     QUOThh,MANT2hh
        sec
        rjmp    UDIV3
UDIV2:  clc
UDIV3:  rol     MANT1
        rol     MANT1m
        rol     MANT1h
        rol     MANT1hh
        dec     count
        brne    UDIVLP
UDIVX:  ret
UDIVy:	clr	QUOT	; rfm, clear off quot too incase this is from mod32 call
		clr QUOTm
		clr QUOTh
		clr QUOThh
DIVZERO: ; Richard, put your error(MessageHere) 
        ret

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -