DSP基础知识 (一) 20111128 -实验程序注释版

来源:互联网 发布:12c5a60怎么使用p4端口 编辑:程序博客网 时间:2024/06/07 07:57
;******************************************************************************
;Target:
; Test the effection of flag bits in ST0, ST1
;******************************************************************************




;----------- Const definition
STACK_ADDR .set0x0500 ;bottom of stack


.mmregs
.global main


;------------------------------------------------------------------------------
.text
main:
stm #STACK_ADDR, SP;set stack
stm #0x00a8, PMST;relocate Interrupt Vector Table
stm #0x0000, SWWSR;no software wait for all memory

;put a value for future use, *(0x2000) = 0xff80
stm #0x2000, AR2
st #0xff80, *AR2


;================================================
;test SXM
;watch A to understand sign extension
ssbx SXM
nop
ld *AR2, A
;------------------------
rsbx SXM
nop
ld *AR2, A
;================================================


;================================================
;test OVM
;watch A and B to understand saturation
ssbx SXM
ssbx OVM
ld #0x8000, 16, A ;A=#0x8000<<16
add #0x8000, 16, A ;A=A+#0x8000<<16
;------------------------
rsbx OVM
ld #0x7fff, 16, B
add #0x7fff, 16, B
;================================================


;================================================
;test C16
;watch B to understand 2-16 mode
ssbx OVM
ld #0x0001, 16, A
add #0x7fff, A
dst A, *AR2 ;*AR2=A
ld #0x0001, 16, A
or #0xffff, A
rsbx C16
nop
dadd *AR2, A, B ; B(39-16)=*AR2(31-16)+A(31-16)
;------------------------
ssbx C16
nop
dadd *AR2, A, B ; B=*AR2+A
;================================================


;================================================
;test FRCT
;watch B to understand fraction mode
ld #0x1234, 16, A
rsbx FRCT
nop
mpya *AR2 ; B=*AR2 *A(32-16),T=*AR2
;------------------------
ssbx FRCT
nop
mpya *AR2
;================================================


;================================================
;test TC
;watch TC to understand bit test operation and corresponding flags
bitf *AR2, #0x8000 ;TC=(*AR2 && #0x800)
nop
nop
;------------------------
bitf *AR2, #0x0001
nop
nop
;================================================


;================================================
;test C
;watch C to understand max & min operation and corresponding flags
ssbx SXM
ld #0x7fff, A
ld #0x8000, B
max A ;A=max(A,B)
nop
nop
;------------------------
min B
nop
nop
;================================================


;================================================
;test OVA, OVB
;watch OVA to understand overflow
ssbx SXM
rsbx OVA;clear overflow flag
ld #0x7fff, 16, A
add #0xffff, A
nop
nop
;------------------------
add #0x7fff, 16, A
nop
nop
;================================================


;================================================
;test SMUL
;watch A to understand multiply saturation
ssbx SXM
ssbx OVM
ssbx FRCT
ldm PMST, B ;B=PMST(处理器方式状态寄存器)
or #0x0002, B; B=B|#0x0002
stlm B, PMST ; PMST=B
ld #0xffff, A
stm #0x8000, T ;T=#0x800
st #0x8000, *AR2; *AR2=#0x8000
nop
nop
mac *AR2, A ; A=A+T*(*AR2)
nop
nop
;------------------------
ldm PMST, B ;B=PMST
and #0xfffd, B ;B=B&#0xfffd
stlm B, PMST
ld #0xffff, A
nop
mac *AR2, A
;================================================


dead_loop:
nop
nop
nop
nop
b dead_loop; PC(程序计数器)=dead_loop


;------------------------------------------------------------------------------
;Interrupt Vector Table, for simplicity Only RESET interrupt is defined
.sect ".vectors"
int_RESET:
b main ;b是跳转指令,PC载入制定指令的地址
nop
nop


.space 124*16


;end of lab1.s54