ecanregdoublerw.asm

来自「自己编写的dsp2812的小程序,大家看看,希望对大家有帮助.」· 汇编 代码 · 共 33 行

ASM
33
字号
;; C callable assembly function for performing a double-read or double-write:
; Retunrs read value in memory (pointed by XAR5)
               
		.global _CanDoubleRead
_CanDoubleRead:
        ; XAR4 -> StorePtr
        ; XAR5 -> RegPtr
        PUSH  ST1                       ; Save status register on stack
        SETC  INTM                      ; Disable interrupts
        MOVL  ACC,*XAR5                 ; Read CAN Register
        SBF   _CanDoubleRead10,NEQ      ; Test If Zero (Comment to disable second-read)
        MOVL  ACC,*XAR5                 ; If Zero, Read Again (Comment to disable second-read)
_CanDoubleRead10:
        MOVL  *XAR4,ACC                 ; Store value 
        POP   ST1                       ; Restore status register
        LRETR
 
        .global _CanDoubleWrite
_CanDoubleWrite:
        ; XAR4 -> RegPtr
        ; XAR5 -> LoadPtr
        PUSH  ST1                       ; Save status register on stack
        SETC  INTM                      ; Disable interrupts
        MOVL  ACC,*XAR5                 ; Load ACC with value to write
        MOVL  *XAR4,ACC                 ; Store value in register twice
        NOP							; Writes to the MBR by the CAN module takes 4 cycles. 
        NOP							; The 4 NOPs are needed to ensure that the consecutive
        NOP							; writes do not fall within this 4-cycle period.
        NOP
        MOVL  *XAR4,ACC                 ; Store value in register twice (Comment to disable second-write)
        POP   ST1                       ; Restore status register
        LRETR

⌨️ 快捷键说明

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