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

📄 muad32.asm

📁 PIC单片机的汇编源码合集,应用比较广泛,设计程序时可做子程序来用
💻 ASM
📖 第 1 页 / 共 2 页
字号:
;********************32位浮点数的乘法************************
           IFNDEF       MUAD32

            #DEFINE     MUAD32                                    
          
FPM32       MOVF        AEXP,W      ; test for zero arguments
            BTFSS       STATUS,Z
            MOVF        BEXP,W
            BTFSC       STATUS,Z
            GOTO        RES032        
M32BNE0     MOVF        AARGB0,W
            XORWF       BARGB0,W
            MOVWF       SIGN        ; save sign in SIGN
            MOVF        BEXP,W
            ADDWF       AEXP,F
            MOVLW       .127-1
            BTFSS       STATUS,C
            GOTO        MTUN32
            SUBWF       AEXP,F
            BTFSC       STATUS,C
            GOTO        SETFOV32    ; set multiply overflow flag
            GOTO        MOK32
MTUN32      SUBWF       AEXP,F
            BTFSS       STATUS,C
            GOTO        SETFUN32
MOK32       MOVF        AARGB0,W
            MOVWF       AARGB3
            MOVF        AARGB1,W
            MOVWF       AARGB4
            MOVF        AARGB2,W
            MOVWF       AARGB5      
            BSF         AARGB3,MSB  ; make argument MSB's explicit
            BSF         BARGB0,MSB
            BCF         STATUS,C
            CLRF        AARGB0      ; clear initial partial product
            CLRF        AARGB1
            CLRF        AARGB2
            MOVLW       D'24'
            MOVWF       TEMP        ;初使化循环计数器
MLOOP32     BTFSS       AARGB5,LSB  ; test next bit
            GOTO        MNOADD32
MADD32      MOVF        BARGB2,W
            ADDWF       AARGB2,F
                MOVF            BARGB1,W
                BTFSC           STATUS,C
                INCFSZ          BARGB1,W
                ADDWF           AARGB1,F
                MOVF            BARGB0,W
                BTFSC           STATUS,C
                INCFSZ          BARGB0,W
                ADDWF           AARGB0,F
MNOADD32        RRF             AARGB0,F
                RRF             AARGB1,F
                RRF             AARGB2,F
                RRF             AARGB3,F
                RRF             AARGB4,F
                RRF             AARGB5,F
                BCF             STATUS,C
                DECFSZ          TEMP,F
                GOTO            MLOOP32
                BTFSC           AARGB0,MSB               ; check for postnormalization
                GOTO            MROUND32
                RLF             AARGB3,F
                RLF             AARGB2,F
                RLF             AARGB1,F
                RLF             AARGB0,F
                DECF            EXP,F
MROUND32        BTFSC           FPFLAGS,RND
                BTFSS           AARGB2,LSB
                GOTO            MUL32OK
		BTFSS		AARGB3,MSB
                GOTO            MUL32OK
		INCF		AARGB2,F
                BTFSC           STATUS,Z
                INCF            AARGB1,F
                BTFSC           STATUS,Z
                INCF            AARGB0,F
                BTFSS           STATUS,Z                      ; has rounding caused carryout?
                GOTO            MUL32OK
                RRF             AARGB0,F                ; if so, right shift
                RRF             AARGB1,F
                RRF             AARGB2,F
                INCF            EXP,F
                BTFSC           STATUS,Z                      ; check for overflow
                GOTO            SETFOV32
MUL32OK         BTFSS           SIGN,MSB
                BCF             AARGB0,MSB		; clear explicit MSB if positive
                RETLW           0  
;**********************32位浮点数加减法******************************      
FPS32           MOVLW           0x80
                XORWF           BARGB0,F    
FPA32       MOVF        AARGB0,W    ; exclusive or of signs in TEMP
            XORWF       BARGB0,W
            MOVWF       TEMP
            CLRF        AARGB3      ; clear extended byte
            CLRF        BARGB3
            MOVF        AEXP,W      ; use AARG if AEXP >= BEXP
            SUBWF       BEXP,W
            BTFSS       STATUS,C
            GOTO        USEA32
            MOVF        BEXP,W                  ; use BARG if AEXP < BEXP
            MOVWF       AARGB5                                  ; therefore, swap AARG and BARG
            MOVF        AEXP,W
            MOVWF       BEXP
            MOVF        AARGB5,W
            MOVWF       AEXP
                MOVF           BARGB0,W
                MOVWF           AARGB5
                MOVF            AARGB0,W
                MOVWF           BARGB0
                MOVF            AARGB5,W
                MOVWF           AARGB0
                MOVF            BARGB1,W
                MOVWF           AARGB5
                MOVF            AARGB1,W
                MOVWF           BARGB1
                MOVF            AARGB5,W
                MOVWF           AARGB1
                MOVF            BARGB2,W
                MOVWF           AARGB5
                MOVF            AARGB2,W
                MOVWF           BARGB2
                MOVF            AARGB5,W
                MOVWF           AARGB2
USEA32          MOVF            BEXP,W                  ; return AARG if BARG = 0
                BTFSC           STATUS,Z
                RETLW           0x00
                MOVF            AARGB0,W
                MOVWF           SIGN                    ; save sign in SIGN
                BSF             AARGB0,MSB              ; make MSB's explicit
                BSF             BARGB0,MSB
                MOVF            BEXP,W                  ; compute shift count in BEXP
                SUBWF           AEXP,W
                MOVWF           BEXP
                BTFSC           STATUS,Z
                GOTO            ALIGNED32
                MOVLW           8
                SUBWF           BEXP,W
                BTFSS           STATUS,C                      ; if BEXP >= 8, do byte shift
                GOTO            ALIGNB32
                MOVWF           BEXP
                MOVF            BARGB2,W		; keep for postnormalization
                MOVWF           BARGB3
                MOVF            BARGB1,W
                MOVWF           BARGB2
                MOVF            BARGB0,W
                MOVWF                   BARGB1
                CLRF            BARGB0
                MOVLW           8
                SUBWF           BEXP,W
                BTFSS           STATUS,C                      ; if BEXP >= 8, do byte shift
                GOTO            ALIGNB32
                MOVWF           BEXP
                MOVF            BARGB2,W		; keep for postnormalization
                MOVWF                   BARGB3
                MOVF            BARGB1,W
                MOVWF                   BARGB2
                CLRF            BARGB1
                MOVLW           8
                SUBWF           BEXP,W
                BTFSS           STATUS,C               ; if BEXP >= 8, BARG = 0 relative to AARG
                GOTO            ALIGNB32
                MOVF            SIGN,W
                MOVWF           AARGB0
                RETLW           0x00
ALIGNB32        MOVF            BEXP,W                  ; already aligned if BEXP = 0
                BTFSC           STATUS,Z
                GOTO            ALIGNED32
ALOOPB32        BCF             STATUS,C                      ; right shift by BEXP
                RRF             BARGB0,F
                RRF             BARGB1,F
                RRF             BARGB2,F
                RRF             BARGB3,F
                DECFSZ          BEXP,F
                GOTO            ALOOPB32
ALIGNED32       BTFSS           TEMP,MSB                ; negate if signs opposite
                GOTO            AOK32
		COMF		BARGB3,F
		COMF		BARGB2,F
                COMF            BARGB1,F
                COMF            BARGB0,F
                INCF            BARGB3,F
                BTFSC           STATUS,Z
                INCF            BARGB2,F

⌨️ 快捷键说明

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