在这个文件中FILE: ADCDRV_5ch.asm
;=============================
ADCDRV_5ch_INIT .macro m,n,p,q,s
;=============================
_ADCDRV_5ch_RltPtrA .usect "ADCDRV_5ch_Section",2,1,1 ; output terminal 1
_ADCDRV_5ch_RltPtrB .usect "ADCDRV_5ch_Section",2,1,1 ; output terminal 2
_ADCDRV_5ch_RltPtrC .usect "ADCDRV_5ch_Section",2,1,1 ; output terminal 3
_ADCDRV_5ch_RltPtrD .usect "ADCDRV_5ch_Section",2,1,1 ; output terminal 4
_ADCDRV_5ch_RltPtrE .usect "ADCDRV_5ch_Section",2,1,1 ; output terminal 5
; publish Terminal Pointers for access from the C environment
.def _ADCDRV_5ch_RltPtrA
.def _ADCDRV_5ch_RltPtrB
.def _ADCDRV_5ch_RltPtrC
.def _ADCDRV_5ch_RltPtrD
.def _ADCDRV_5ch_RltPtrE
MOVL XAR2, #ZeroNet ; "ZeroNet" is address to a location initialised to 0
MOVW DP, #_ADCDRV_5ch_RltPtrA
MOVL @_ADCDRV_5ch_RltPtrA, XAR2 ; zero output terminal pointer
MOVL @_ADCDRV_5ch_RltPtrB, XAR2 ; zero output terminal pointer
MOVL @_ADCDRV_5ch_RltPtrC, XAR2 ; zero output terminal pointer
MOVL @_ADCDRV_5ch_RltPtrD, XAR2 ; zero output terminal pointer
MOVL @_ADCDRV_5ch_RltPtrE, XAR2 ; zero output terminal pointer
.endm
;--------------------------------------------------------------------------------
;=============================
ADCDRV_5ch .macro m,n,p,q,s
;=============================
MOVW DP, #_ADCDRV_5ch_RltPtrA ; Load Data Page
MOVL XAR0,@_ADCDRV_5ch_RltPtrA ; Load Rlt1 Data Page Pointer in XAR0
MOVL XAR1,@_ADCDRV_5ch_RltPtrB ; Load Rlt2 Data Page Pointer in XAR1
MOVW DP, #_AdcResult ; load Data Page to read ADC results
MOV ACC, @_AdcResult.ADCRESULT:m:<<12 ; read result
SUB ACC, #2048<<12 ; ACC = ADCRESULT - 2048
MOVL *XAR0,ACC ; store result in output pointer location
MOV ACC, @_AdcResult.ADCRESULT:n:<<12 ; read result
SUB ACC,#2048<<12 ; ACC = ADCRESULT - 2048
MOVL *XAR1,ACC
MOVW DP, #_ADCDRV_5ch_RltPtrC ; Load Data Page
MOVL XAR0,@_ADCDRV_5ch_RltPtrC ; Load Rlt1 Data Page Pointer in XAR0
MOVL XAR1,@_ADCDRV_5ch_RltPtrD ; Load Rlt2 Data Page Pointer in XAR1
MOVL XAR2,@_ADCDRV_5ch_RltPtrE
MOVW DP, #_AdcResult ; load Data Page to read ADC results
MOV ACC, @_AdcResult.ADCRESULT:p:<<12 ; read result
MOVL *XAR0,ACC ; store result in output pointer location
MOV ACC, @_AdcResult.ADCRESULT:q:<<12 ; read result
MOVL *XAR1,ACC ; store result in output pointer location
MOV ACC, @_AdcResult.ADCRESULT:s:<<12 ; read result
MOVL *XAR2,ACC ; store result in output pointer location
.endm
; end of file
有几个疑问不是很明白。麻烦工作人员给解答一下谢谢!
问题1:
_ADCDRV_5ch_RltPtrA .usect "ADCDRV_5ch_Section",2,1,1 ;
这个自定义段后面的两个1的作用是什么?
问题2:
MOVL XAR2, #ZeroNet ; "ZeroNet" is address to a location initialised to 0
这里的ZeroNet具体是指什么?它的作用是什么?
问题3:
MOV ACC, @_AdcResult.ADCRESULT:m:<<12 ; read result
SUB ACC, #2048<<12 ; ACC = ADCRESULT - 2048
第一句的_AdcResult.ADCRESULT:m:为什么要左移12位?
第二句 ADCRESULT - 2048是什么意思?为什么要减去2048?
谢谢!