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

📄 q15toq0.asm

📁 TI的digital motor control lib的源代码。了解TI的编程规范
💻 ASM
字号:
;=====================================================================================
; File name:        Q15TOQ0.ASM                    
;                    
; Originator:	Digital Control Systems Group
;			Texas Instruments
;
; Description:                                 
; Convert Q15 number to the Q0 number by the following formular:
;                  Q0 = Q15*scaler 
; where scaler is the Q0 number.
;=====================================================================================
; History:
;-------------------------------------------------------------------------------------
; 9-15-2000	Release	Rev 1.0
;================================================================================
; Applicability: F240,F241,C242,F243,F24xx.  (Peripheral Independent).
;================================================================================
; Routine Name: Q Converter                            Routine Type: C Callable
;
;
;  C prototype : int q15toq0(int q15,int scale);  
;================================================================================
;
;        Frame Usage Details:
;     step   |      a      |      b       |      c      |     d     
;____________|_____________|______________|_____________|_____________
;     FR0  	 |   scaler    |      q0      |             |     
;
;================================================================================
                .def        _q15toq0
;================================================================================
__q15toq0_framesize 	.set 0001h
;================================================================================
_q15toq0:            
     	POPD	*+									; Keep return address
       	SAR  	AR0,*+								; Keep old frame pointer (FP)
       	SAR   	AR1,*								; Keep old stack pointer (SP)
       	LARK  	AR0,__q15toq0_framesize 	 		; Load AR0 with frame size	
       	LAR   	AR0,*0+,AR0							; AR0->FP0 (new FP), ARP=AR0
;================================================================================
       	SBRK	#3		; ARP=AR0, AR0->FR0-3 (1st argument)	
;----------------------------------------------------------------------------------
		SETC	SXM		; Turn sign extension mode on
						; ARP=AR0, AR0->q15
;----------------------------------------------------------------------------------
		SETC	OVM		; Set overflow mode
						; ARP=AR0, AR0->q15
;----------------------------------------------------------------------------------
 		SPM     0       ; Reset product mode
       					; ARP=AR0, AR0->q15 
;----------------------------------------------------------------------------------
		LT     	*-		; TREG = q15
						; ARP=AR0, AR0->scaler			
;----------------------------------------------------------------------------------
      	LACC   	*+ 		; ACC = scaler 
      					; ARP=AR0, AR0->q15
;----------------------------------------------------------------------------------
 		ADRK   	#3  	; ARP=AR0, AR0->FR0
;----------------------------------------------------------------------------------
      	SACL   	*       ; FR0 = scaler
      					; ARP=AR0, AR0->FR0 
;----------------------------------------------------------------------------------
       	MPY    	*      	; PREG = q15*scaler  (Q15)
       					; ARP=AR0, AR0->FR0
;----------------------------------------------------------------------------------
		PAC				; ACC = q15*scaler  (Q15)
       					; ARP=AR0, AR0->FR0
;----------------------------------------------------------------------------------
    	SFL				; ACC = q15*scaler  (Q16)
       					; ARP=AR0, AR0->FR0
;----------------------------------------------------------------------------------       	
       	SACH	*  		; FR0 = q0 = q15*scaler  (Q0)
       					; ARP=AR0, AR0->FR0
;----------------------------------------------------------------------------------
		LACL	*,AR1	; ACC = q0 = q15*scaler  (Q0)
						; ARP=AR0, AR0->FR0, ARP=AR1 		
;----------------------------------------------------------------------------------
_q15toq0_exit:
       	;MAR     *,AR1   ; can be removed if this condition is met on
       	;                ; every path to this code. (i.e., ARP=AR1 here)

        CLRC	OVM
        CLRC	SXM

        SBRK 	#(__q15toq0_framesize+1)
        LAR  	AR0,*-
        PSHD	*
        
        RET
       



⌨️ 快捷键说明

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