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

📄 qinv2.asm

📁 用DSPtms2407实现电力系统数据采集的程序
💻 ASM
字号:
 ;===========================================================
;
; File Name     :qinv2.asm
; 
; Originator    :Digital Control Systems Group 
;                Texas Instruments 
; 
; Description   :This file contain source code for finding the reciprocal of 
;                fixed point number, the result is in 16 bit
;               
; Date          : 7/11/2000
;==========================================================
; 
; 
; Routine Name  : Generic Function      
; Routine Type  : C Callable
; 
; Description   :
; int qinv2(int x) 
; Input format:  Signed number in Q(x) format (x<16)
; Output format: Signed number in Q(15-x) format (16 bit result)
; 
; Example 1: 
; Input format:  Signed Q15 format  (Fractional Number)
; Output format: Signed Q0  format 
;
; Example 2:
; Input format:  Signed Q0 format   (Integer Number)
; Output format: Signed Q15
;                                     
; Example 3: 
; Input format:  Signed Q5 format
; Output format: Signed Q10 format

;===========================================================
; Function Local Frame
;===========================================================
;   |_______|
;   |_______|<- Stack Pointer
;   |_______|<- Frame ptr       (FP) 
;   |_______|<- Old FP
;   |_______|<- Return Address of the Caller 
;   |_______|<- Formal parameter x in signed m.n format
;=============================================================

; Module definition for external referance
             .def   _qinv2
            
__inv2_frs .set 00001h          ; Local frame size for this routine         

_qinv2:
            POPD    *+              ; Store the Return Address in stack
            SAR     AR0,*+          ; Store the Caller's Frame Pointer
            SAR     AR1,*
            LAR     AR0,#__inv2_frs     
            LAR     AR0,*0+,AR2     ; Create Local frame for cos function
            
            SETC    OVM             ; To saturate ABS value of 0x8000 to 0x7fff                        
            SETC    SXM             
            
            LAR     AR2,#0FFFDh      
            MAR     *0+             ; Modify AR2 to point to x, which is in 16.0
            LACC    *,16,AR0        ; Load the input to the ACCH
            
            BCND    calculate,NEQ   ; If input is zero, return with 0
            LACC    #0000h
            B       return   
            
calculate:  BCND    positive, GT
            ABS                     ; Obtain the absolute value of x<0

positive:   SACH    *               ; Store |x|
            LACC    #01h,15         ; Load 1 in Q15

            RPT     #15
            SUBC    *               ; Perform the division to obtain the quotient
                        
            AND     #0ffffh
            
            SACL    *
            BIT     *,0,AR2
            BCND    isnot1,NTC
            LACC    #7fffh
    
isnot1:     BIT     *,0
            BCND    return,NTC
            NEG
            
return:     CLRC    OVM
            MAR     *,AR1           
            SBRK    #(__inv2_frs+1) ; Clear the local frame
            LAR     AR0,*-            ; Retrive Caller's frame pointer
            PSHD    *                 ; Push the return address to TOS
            RET                       ; Return to the caller
                       
            
            
                                    
            
            
                
            
            
            
            
                  

⌨️ 快捷键说明

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