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

📄 scale_vr.asm

📁 VCP201_CODE is a FPGA source code.
💻 ASM
字号:
;==========================================================================
; File Name : scale_vr.asm
;
; Rev:   Date:    Author:     Reason:
;==========================================================================
;------------------------------------------------------------
; Name : 
; Parm : 
; Retn : 
; Desc :  adjustment & table lookup
;------------------------------------------------------------
adjust_vr:
        movf    xaxis_null,W
        movwf   vr_null
        movf    xaxis_val,W
        movwf   vr_value

       	call    adj_axis

        movwf   offset
        call    table_look

        movwf   xaxis_val

;--------Y
        movf    yaxis_null,W
        movwf   vr_null
        movf    yaxis_val,W
        movwf   vr_value

        call    adj_axis

        movwf   offset
        call    table_look

        movwf   yaxis_val
        
;-------------Z
        movf    zaxis_null,W
        movwf   vr_null
        movf    zaxis_val,W
        movwf   vr_value

        call    adj_axis

        movwf	offset
	call	table_look        

        movwf   zaxis_val

;-----------R
        movf    raxis_null,W
        movwf   vr_null
        movf    raxis_val,W
        movwf   vr_value

        call    adj_axis

        movwf	offset
	call	table_look        

        movwf   raxis_val
       
        
        return

;---------------------------------------
; Name : adj_axis
; Parm : W, vr_null, vr_scale
; Retn : W: adjusted and scaled axis value
; Desc : 
;---------------------------------------------------
adj_axis:
        subwf   vr_null,W       ; null - value
        btfsc   STATUS,C
        goto    adj_axis2

        movf    vr_null,W       ; null < value
        subwf   vr_value,W
        movwf   hi_byte

        movlw   0x7f
        movwf   lo_byte
        call    umul

        movlw   0xff
        movwf   vr_value
        movf    vr_null,W
        subwf   vr_value,W
        bsf	STATUS,RP0
        movwf   divisor
        bcf	STATUs,RP0

        call    udiv
        movlw   0x80
        addwf   lo_byte,W

        return

adj_axis2:
        clrw                    ; null = 0
        subwf   vr_null,W
        btfss   STATUS,Z
        goto    adj_axis3
        movlw   0x80
        return

adj_axis3:
        movlw   0x80            ; null > value
        movwf   lo_byte
        movf    vr_value,W
        movwf   hi_byte
        call    umul

        movf    vr_null,W
        bsf	STATUS,RP0
        movwf   divisor
        bcf	STATUS,RP0
        call    udiv
        movf    lo_byte,W
        
        return  


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; table lookup procedure
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
table_look:
	bsf	STATUS,RP0
       	movf    PCLATH,W
        movwf   pclath_save2    ; save PCLATH
        bcf	STATUS,RP0

	bcf	f_vr_ex_127
	
	btfss	offset,7	; > 127 ?
	goto	offset_less_127	; No
	
	movf	offset,W
	sublw	d'255'		; offset=255-offset
	movwf	offset
	bsf	f_vr_ex_127
	
offset_less_127:	
	movlw	d'38'
	subwf	offset,W	; < 38
	movwf	offset
	btfss	STATUS,C
	clrf	offset
	
        movlw   HIGH vr_table
        movwf   PCLATH

        movf    offset,W
        call    VR_table

	btfsc	f_vr_ex_127
	sublw	d'255'		; 255 - offset
offset_less_half:	
        movwf   offset

	bsf	STATUS,RP0
        movf    pclath_save2,W
        movwf   PCLATH
        bcf	STATUS,RP0

        movf    offset,W

        return


⌨️ 快捷键说明

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