📄 jack_longmul.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 Mul **
SMUL:: tst MANT1hh
brmi SMUL1n
tst MANT2hh
brpl UMUL ; both are Pos, normal
rcall NEGMANT2 ; Acc1+, Acc2-, Negate Acc2
SMUL1a: rcall UMUL ; Normal Mul
rjmp NEGMANT1 ; Negate Results
SMUL1n: rcall NEGMANT1
tst MANT2hh
brpl SMUL1a
;* both are '-', Neg 2 & fall through to normal UMUL
rcall NEGMANT2
;** Unsigned 32bit Mul **
;** Acc1 *= Acc2 **
UMUL:: rcall tstzero1 ; speeds things Up
breq UMULX ; if Acc1 == 0, return
rcall tstzero2 ; if Acc2 == 0
brne UMULOK
clr MANT1 ; if this code is to big, delete it
clr MANT1m
clr MANT1h
clr MANT1hh
ret
UMULOK: clr QUOT
clr QUOTm
clr QUOTh
clr QUOThh
clr temp
ldi count,32
UMULLP: lsl QUOT
rol QUOTm
rol QUOTh
rol QUOThh
rol MANT1
rol MANT1m
rol MANT1h
rol MANT1hh
brcc UMUL1
add QUOT,MANT2
adc QUOTm,MANT2m
adc QUOTh,MANT2h
adc QUOThh,MANT2hh
adc MANT1,temp ; add 0+Carry
adc MANT1m,temp
adc MANT1h,temp
adc MANT1hh,temp
UMUL1: dec count
brne UMULLP
mov MANT1,QUOT
mov MANT1m,QUOTm
mov MANT1h,QUOTh
mov MANT1hh,QUOThh
UMULX: ret
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -