📄 exp4c55_1.asm
字号:
*********************************************************************
* exp4c55_1.asm - An assembly program for C55x CCS simulator
* Representing different Q formats in Section 4.6.1
*
*********************************************************************
* Section allocation
*
.def x,y,init_q15, init_q1_14, init_q2_13
x .usect "vars",12 ; reserve 12 locations for x
y .usect "vars",3 ; reserve 3 locations for y
.sect "table"
;init_q15 .int 0.5*32768, 0.25*32768, 0.125*32768, 0.0625*32768
;init_q1_14 .int 0.5*16384, 0.25*16384, 0.125*16384, 0.0625*16384
;init_q2_13 .int 0.5*8192, 0.25*8192, 0.125*8192, 0.0625*8192
init_q15 .int 16384, 8192, 4096, 2048
init_q1_14 .int 8192, 4096, 2048, 1024
init_q2_13 .int 4096, 2048, 1024, 512
.text ; create code section
.def start ; label of the beginning of code
* Copy data to vector x using indirect addressing mode
start
BCLR C54CM ; set C55x native mode
BCLR AR1LC ; set AR1 in linear mode
BCLR AR2LC ; set AR2 in linear mode
BSET SXMD
BSET FRCT
BSET SATD
copy
AMOV #x,XAR1 ; XAR1 pointing to x0
AMOV #init_q15,XAR2 ; XAR2 pointing to table of data
RPT #11 ; repeat next instruction 12 times
MOV *AR2+,*AR1+ ; copy 12 data to x
* Add the first 4 data using direct addressing mode
add_q15:
AMOV #x,XDP ; XDP pointing to vector x0
.dp x ; notify assembler
MOV @x,AC0 ; AC0 <- x0
ADD @(x+1),AC0 ; add x1
ADD @(x+2),AC0 ; add x2
ADD @(x+3),AC0 ; add x3
* Write the result to memory location y
write
MOV AC0,*(#y) ; y <- AC0
add_q1_14:
MOV @(x+4),AC0 ; AC0 <- x4
ADD @(x+5),AC0 ; add x5
ADD @(x+6),AC0 ; add x6
ADD @(x+7),AC0 ; add x7
MOV AC0,*(#y+1) ; y+1 <- AC0
add_q2_13:
MOV @(x+8),AC0 ; AC0 <- x8
ADD @(x+9),AC0 ; add x9
ADD @(x+10),AC0 ; add x10
ADD @(x+11),AC0 ; add x11
MOV AC0,*(#y+2) ; y+2 <- AC0
end:
NOP
B end ; stop here
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -