6. | ^
- Arithmetic instruction
- NOP AND OR XOR ADD SUB AD2 SR RR SL RL RL8 CLR MOV
- Load immediate instruction
- MVI
- DMA command
- DMA DMAH
- JUMP instruction
- JMP
- LOOP BOTTOM instruction
- BTM LPS
- END command
- END ENDI
pseudo-instruction
- EQU (=) ……………… Used to define a label.
- ORG ...... Specifies the starting address where the instruction will be placed.
- ENDS ……………… If placed at the end of the program, it will be ignored thereafter.
- IF <number/label>
... If the calculation result of the number or label is other than 0, then assemble up to ELSE or ENDIF.
- IFDEF< label> ...... If the label is defined at the front, then ELSE or ENDIF will be assembled.
The nesting level for IF and IFDEF is up to 16. )
(1) When copying the contents of internal RAM 0 of the DSP to internal RAM 1.
; ------- sample (1) start -------
COPY_SIZE = 12 ; Copy size
RAM0_ADR = $00 ; Copy source address
RAM1_ADR = $00 ; Copy destination address
MOV RAM0_ADR,CT0 ; Set the copy source address of RAM0
MOV RAM1_ADR,CT1 ; Set the copy destination address of RAM1
MOV COPY_SIZE-1,LOP ; Set transfer size - 1 to LOP register
LPS ; Execute 1-instruction loop
MOV MC0,MC1 ; Transfer from RAM0 to RAM1
ENDI
; ------- sample (1) end -------
(2) When calculating 2 x 3 + 4 x 5. (RAM0 x RAM1 + RAM0 x RAM1 = RAM2) (Sample 2b is an optimized version of 2a.)
; ------- sample (2a) start -------
RAM0_ADR = $00 ; 2, 4 Storage address first
RAM1_ADR = $00 ; 3, 5 Storage address first
RAM2_ADR = $00 ; Result storage address
MOV RAM0_ADR,CT0 ; Set RAM0 address
MOV RAM1_ADR,CT1 ; Set RAM1 address
MVI #2,MC0 ; Set "2" to RAM0
MVI #3,MC1 ; Set "3" to RAM1
MVI #4,MC0 ; Set "4" to RAM0
MVI #5,MC1 ; Set "5" to RAM1
MOV RAM0_ADR,CT0 ; Set the address of RAM0
MOV RAM1_ADR,CT1 ; Set the address of RAM1
MOV RAM2_ADR,CT2 ; Set the address of RAM2
MOV MC0,X ; Transfer data from RAM0 to RX
MOV MC1,Y ; Transfer data from RAM1 to RY
MOV MUL,P ; Store the integration results of RX and RY in PH,PL
MOV MC0,X ; Transfer data from RAM0 to RX
MOV MC1,Y ; Transfer data from RAM1 to RY
CLR A ; Set "0" to ACH,ACL
AD2 MOV ALU,A ; Store the addition result of PH,PL and ACH,ACL in ACH,ACL
MOV MUL,P ; Store the integration result of RX and RY in PH,PL
AD2 MOV ALL,MC2 ; Store the addition result of PH, PL and ACH, ACL in RAM2
ENDI
; ------- sample (2a) end -------
; ------- sample (2b) start -------
RAM0_ADR = $00 ; 2, 4 Storage address first
RAM1_ADR = $00 ; 3, 5 Storage address first
RAM2_ADR = $00 ; Result storage address
MOV RAM0_ADR,CT0
MOV RAM1_ADR,CT1
MVI #2,MC0
MVI #3,MC1
MVI #4,MC0
MVI #5,MC1
MOV RAM0_ADR,CT0
MOV RAM1_ADR,CT1
MOV MC0,X MOV MC1,Y MOV RAM2_ADR,CT2
MOV MC0,X MOV MUL,P MOV MC1,Y CLR A
AD2 MOV MUL,P MOV ALU,A
AD2 MOV ALL,MC2
ENDI
; ------- sample (2b) end -------
(3) When calculating movement processing for a matrix. (RAM0×RAM1=RAM2)
/M00 M01 M02 M03\ /100x\ /M00 M01M02 M03\
| M10 M11 M12 M13 || 010y | → | M10 M11M12 M13 |
\M20 M21 M22 M23/ | 001z | \M20 M21M22 M23/
\0001/
; ------- sample (3) start -------
DATA_TOP = $10000 >> 2 ; External memory address is in 4-byte units
MAT_SIZE = $0C ; Array size
RAM0_ADR = $00 ; Start address for storing X, Y, Z movement amount
RAM1_ADR = $00 ; Array work address
RAM2_ADR = $00 ; Original array address
; (Transfer the array with the movement amount set from external memory to RAM0)
;
MVI DATA_TOP,RA0
MOV RAM0_ADR,CT0
DMA D0,MC0,#$02
;
; (Copying the array to be operated from RAM2 to RAM1)
MOV RAM2_ADR,CT2
MOV RAM1_ADR,CT1
MOV MAT_SIZE-1,LOP
LPS
MOV MC2,MC1
WAITING:
JMP T0,WAITING
;
; (Execute array calculation)
MOV RAM0_ADR,CT0
MOV RAM1_ADR,CT1
MOV MC0,X MOV MC1,Y
MOV MC0,X MOV MUL,P MOV MC1,Y CLR A
AD2 MOV MC0,X MOV MUL,P MOV MC1,Y MOV ALU,A MOV RAM0_ADR,CT0
AD2 MOV MUL,P MOV MC1,Y MOV ALU,A MOV #1,RX
AD2 MOV MC0,X MOV MUL,P MOV MC1,Y MOV ALU,A MOV RAM2_ADR+3,CT2
AD2 MOV MC0,X MOV MUL,P MOV MC1,Y CLR A MOV ALL,MC2
AD2 MOV MC0,X MOV MUL,P MOV MC1,Y MOV ALU,A MOV RAM0_ADR,CT0
AD2 MOV MUL,P MOV MC1,Y MOV ALU,A MOV #1,RX
AD2 MOV MC0,X MOV MUL,P MOV MC1,Y MOV ALU,A MOV RAM2_ADR+7,CT2
AD2 MOV MC0,X MOV MUL,P MOV MC1,Y CLR A MOV ALL,MC2
AD2 MOV MC0,X MOV MUL,P MOV MC1,Y MOV ALU,A MOV RAM0_ADR,CT0
AD2 MOV MUL,P MOV MC1,Y MOV ALU,A MOV #1,RX
AD2 MOV MUL,P MOV ALU,A MOV RAM2_ADR+11,CT2
AD2 MOV ALL,MC2
ENDI
; ------- sample (3) end -------
that's all
▲ Back | Forward ▼
★ HARDWARE Manual ★ SCU User's Manual