📄 sram.asm
字号:
********************************************************************************/
* SRAMFUNCTION.ASM v1.00 */
* 版权(c) 2000- 北京合众达电子技术有限责任公司 */
* 设计者: 钱建良 */
********************************************************************************/
* File: sramfunction.asm
* Function: Check RAM *
* Input: AR0--Start Address
* AR1--Length
* R1 --Data Width
* Output: OK--If OK.
* Fail-- If Fail.
.global _checkram
.global _sramfill
.global _wavedataset
.copy "c3x.inc"
.ref dastate
.ref dabuf
.ref DA0dataBuffer
.data
chk_data: .word chk_word
vc33mms .word C3x_MMR
okp: .word ok
failp: .word fail
ok: .word 'O','K'
fail: .word 'F','a','i','l'
chk_word: .set 0AC3553CAH
FP .set AR3 ; FP is AR3
.text
********************************************************************************
* *
* 函数定义:checkram *
* 功 能:将数据data写入addr所指定的Sram单元,并校验写是否正确 *
* * *
* 入口参数:AR2 ---- 地址addr,Amsb~A0 *
* *
* R2 ---- length *
* 出口参数:R0 检测结果的地址 *
* 好:“OK” *
* 不好:“FAIL” *
* *
* *
* 资源使用:AR1,AR2,R2 *
* *
********************************************************************************
_checkram:
.if .REGPARM = 0 ;standard runtime model
PUSH FP ;save the old FP
LDI SP,FP ;point to top of stack
LDI *-FP(2),AR2 ;load the first argument to ar2
LDI *-FP(3),R2 ;load the secont argument to r2
.endif ;both runtime models
.if .BIGMODEL
PUSH DP
LDP chk_data,DP
.endif
PUSH ST
PUSH AR1
PUSH AR2
PUSH R2
PUSHF R2
;为系统加入1个等待
LDI @vc33mms,AR1
PUSH R2
LDI (INT_RDY+WAIT_1+BANK_8M),R2
STI R2,*+AR0(STRB0)
LDI @chk_data,R0
POP R2
LDI R2,AR1
PUSH AR2
fill: STI R0,*AR2++
DBU AR1,fill
POP AR2
LDI @chk_data,R0
LDI R2,AR1
PUSH AR2
check: LDI *AR2++,R2
XOR R0,R2
BNZ chk_fail
NOP
DBU AR1,check
LDI @okp,AR1
POP AR2
LDI *AR1++,R0
STI R0,*AR2
LDI *AR1++,R0
STI R0,*+AR2(1)
LDI 1,R0
POPF R2
POP R2
POP AR2
POP AR1
POP ST
.if .REGPARM = 0 ;standard runtime model
POP FP ;restore FP
.endif
.if .BIGMODEL
POP DP
.endif
RETS
chk_fail: LDI @failp,AR1
POP AR2
LDI *AR1++,R0
STI R0,*AR2
LDI *AR1++,R0
STI R0,*+AR2(1)
LDI *AR1++,R0
STI R0,*+AR2(2)
LDI *AR1++,R0
STI R0,*+AR2(3)
LDI 0,R0
POPF R2
POP R2
POP AR2
POP AR1
POP ST
.if .BIGMODEL
POP DP
.endif
.if .REGPARM = 0 ;standard runtime model
POP FP ;restore FP
.endif
RETS
********************************************************************************
* *
* 函数定义:sramfill *
* 功 能:将数据data写入addr所指定的Sram单元,并校验写是否正确 *
* * *
* 入口参数:AR2 ---- 地址addr,Amsb~A0 *
* R3 ---- 要填的数据 *
* R2 ---- length *
* 出口参数:R0 检测结果的地址 *
* 好:“OK” *
* 不好:“FAIL” *
* *
* *
* 资源使用:AR1,AR2,R2 *
* *
********************************************************************************
_sramfill:
.if .REGPARM = 0 ;standard runtime model
PUSH FP ;save the old FP
LDI SP,FP ;point to top of stack
LDI *-FP(2),AR2 ;load the first argument to ar2
LDI *-FP(3),R2 ;load the secont argument to r2
LDI *-FP(4),R3 ;load the third argument to r3
.endif ;both runtime models
.if .BIGMODEL
PUSH DP
LDP chk_data,DP
.endif
PUSH ST
PUSH AR1
PUSH AR2
PUSH R2
PUSH R3
;为系统加入1个等待
PUSH AR1
PUSH R2
LDI @vc33mms,AR1
LDI (INT_RDY+WAIT_1+BANK_8M),R2
STI R2,*+AR0(STRB0)
POP R2
POP AR1
LDI R2,AR1
fills: STI R3,*AR2++
DBU AR1,fills
;为系统加入0个等待
PUSH AR1
PUSH R2
LDI @vc33mms,AR1
LDI (INT_RDY+WAIT_1+BANK_8M),R2
STI R2,*+AR0(STRB0)
POP R2
POP AR1
POP R3
POP R2
POP AR2
POP AR1
POP ST
.if .BIGMODEL
POP DP
.endif
.if .REGPARM = 0 ;standard runtime model
POP FP ;restore FP
.endif
RETS
********************************************************************************
* *
* 函数定义:_wavedataset *
* 功 能:将数据data写入addr所指定的Sram单元,并校验写是否正确 *
* * *
* 入口参数:无 *
* 出口参数:R0 检测结果的地址 *
* 好:“OK” *
* 不好:“FAIL” *
* *
* *
* 资源使用:AR1,AR2,R2 *
* *
********************************************************************************
_wavedataset:
.if .REGPARM = 0 ;standard runtime model
PUSH FP ;save the old FP
LDI SP,FP ;point to top of stack
.endif ;both runtime models
.if .BIGMODEL
PUSH DP
LDP chk_data,DP
.endif
PUSH ST
PUSH AR1
PUSH AR2
PUSH AR0
PUSH R2
PUSHF R2
PUSH R3
PUSHF R3
;为系统加入1个等待
LDI @vc33mms,AR1
LDI (INT_RDY+WAIT_1+BANK_8M),R2
STI R2,*+AR0(STRB0)
;读数据缓冲区的第一个数据:判断是第N通路
LDI @dabuf,AR1
;是第N通路
LDI *AR1++,R2
AND 0FH,R2
PUSH R2
;取N通路的状态空间的首址
LDI @dastate,AR2
MPYI 04H,R2
ADDI R2,AR2
;取N通路的缓冲区的首址
LDI @DA0dataBuffer,AR1
POP R2
MPYI 01000H,R2
ADDI R2,AR1
;把第N通路缓冲区的首址写入DA状态区
LDI AR1,R3
STI R3,*AR2++
;把第N通路下一个要转换的地址写入DA状态区
STI R3,*AR2++
;把第N通路的数据长度写入DA状态区
LDI @dabuf,AR1
LDI *AR1++,R2
LDI *AR1++,R2
STI R2,*AR2++
;把第0通路的剩下的数据长度写入DA状态区
STI R2,*AR2++
;写数据
LDI @dabuf,AR1
LDI *AR1,R3
;取N通路的缓冲区的首址
LDI @DA0dataBuffer,AR2
MPYI 01000H,R3
ADDI R3,AR2
LDI *AR1++,R2
;取长度
LDI *AR1++,R2
LDI R2,AR0
fill0: LDI *AR1++,R2
STI R2,*AR2++
DBU AR0,fill0
;为系统加入1个等待
LDI @vc33mms,AR1
LDI (INT_RDY+WAIT_1+BANK_8M),R2
STI R2,*+AR0(STRB0)
POPF R3
POP R3
POPF R2
POP R2
POP AR0
POP AR2
POP AR1
POP ST
.if .BIGMODEL
POP DP
.endif
.if .REGPARM = 0 ;standard runtime model
POP FP ;restore FP
.endif
RETS
.end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -