Welcome to this little bit of documentation about the Motorola DSP 56001 that can be found in the Falcon 030. This text contains : 1. The Registers. 2. The Memory organization. 3. The Instruction set. 4. The XBios commands. 5. How to interface with the DSP without TOS (I haven't written that yet. Need help for it). This text is for the Dnt-Paper and other interested people. It is a pre-release version and may not be distributed yet. The text is written by AvIvA of DFS (Dead Fish Society). I wish you a lot of fun coding this little beastie. Mention me in your demos! :) 1. Registers : 23 0 23 0 ------------------------------------ | X0 | X1 | ------------------------------------ 47 X 0 ------------------------------------ (Y register looks the same) 23 8 7 0 23 0 23 0 ----------------------------------------------------------- XXXXXXXXXXXXXXXX| A2 | A1 | A0 | ----------------------------------------------------------- XXXXXXXXXXXXXXXX55 A 0 ----------------------------------------------------------- (B register looks the same) XXXXX : Means nothing when writing, but when reading, this contains the extension! All memory address(ing) registers (Rn, Nn, Mn), Loop Counters (LA and LC), Program Counter (PC) and on-chip system stack (SSH and SSL) look like this: 23 16 15 0 ---------------------------------- | EEEEEEEE | Register n | ---------------------------------- EEEEE : Means nothing when writing, zero when reading. The following registers are available for memory addressing : Address Register (Rn : n = 0 to 7) Offset Regsiter (Nn : n = 0 to 7) Modifier Register (Mn : n = 0 to 7) Hardware loop registers : Loop Address (LA) Loop Counter (LC) On-chip system stack memory : High : SSH 0 to 15 Low : SSL 0 to 15 SSH8 : Writes PC on JSR SSL8 : Writes SR on JSR SSH9 : Reads only PC on RTS SSH12 : Reads/Writes to/from LA on REP or DO_LOOP SSL12 : Reads/Writes to/from LC on REP or DO_LOOP Operating Mode Register (OMR): 23 8 7 6 5 4 3 2 1 0 ----------------------------------------- | EEEEEEEEEEEEE |EA|SD|EE|EE|EE|DE| M | ----------------------------------------- EA : External Memory Access Mode - 0 : None - 1 : Waitstates SD : Stop delay - 0 : 64k - 1 : 8 clock cycles delay on STOP DE : Data ROM enable - 0 : RAM - 1 : ROM M : Operating Mode - 00 : Single Chip non expanded - 01 : Special Bootstrap (56001 only) - 10 : Normal Expanded - 11 : Development Expanded Status Register (SR) : ------------------------------------------------- | MR | CCR | ------------------------------------------------- 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 ------------------------------------------------- |LF|EE|T |EE| S | I |EE|L |E |U |N |Z |V |C | ------------------------------------------------- LF : Loop Flag T : Trace Mode S : Scaling Mode - 00 : No Scaling - 01 : Scale Down (Right Shift) - 10 : Scale Up (Left Shift) - 11 : Reserved I : Interrupt Mask (IPL0 - IPL3) L : Limit (latching overflow bit) E : Extension - 0 : A1/B1 is 0 or $FF U : Unnormalized N : Negative Z : Zero V : Overflow C : Carry Stack Pointer Register (SP) 23 6 5 4 3 2 1 0 ------------------------------ | EEEEEE |UF|SE| P0 - 4 | ------------------------------ UF : Underflow Flag SE : Stack Error Flag P0 - 4 : Stack Location (1 - 15) Notes : 111110 : Stack underflow condition after double PULL 111111 : Stack underflow condition 000000 : Stack empty after Reset (PULL causes underflow) 000001 : Stack location 1 001111 : Stack location 15 010000 : Stack overflow condition 010001 : Stack overflow condition after double PUSH 2. MEMORY ORGANISATION : 2.1. X Memory (16k ): $0000 - $00FF : Internal memory. $0100 - $01FF : ROM tangens table or external RAM $0200 - $3FFF : External RAM $FFC0 - $FFFF : On-Chip periphery 2.2. Y Memory (16k ): $0000 - $00FF : Internal memory. $0100 - $01FF : Rom sinus-tables or external RA< $0200 - $3BFF : External RAM $3C00 - $3FFF : TOS routines (for loading etc. ) 2.3. P Memory (32k ): $0000 - $01FF : Internal Memory or 32 * 24bit bootstrap ROM and 64 * 24 bit Interrupt commands. $0200 - $7FFF : External program RAM (overlaps X and Y memory) 3. The DSP56001 instruction set: The following abbreviations have been used in the descriptions of the commands : #n : 6-bit value (immediate). #x : 8-bit value (sometimes also 24-bit, eg. with MOVE) #X : 12-bit Value. X : 48-bit X and y register. X0 : 24-bit X0/X1/Y0 and Y1 register ea : register pointed memory (Rn)-Nn;(Rn)+Nn;(Rn)-;(Rn)+;(Rn);(Rn+Nn);-(Rn) pp : 6-bit-absolute lower address aa : 6-bit-absolute upper address ar : All registers (though for a couple of commands some registers may not be used. Try! :) ) X0;X1;Y0;Y1;A0;A1;A2;B0;B1;B2;A;B;Rn;Nn;Mn;SR;OMR;SP;SSH;SSL ;LA;LC + : Add or substract(-) for MAC/MACR/MPY/MPYR Condition Codes : CC/HS : Carry Clear / Higher Same : C = 0 CC/LS : Carry Set / Lower : C = 1 EC : Extension CLear : E = 0 EQ : Equal : Z = 1 ES : Extension Set : E = 1 GE : Greater Equal : N XOR V = 0 GT : Greater Than : Z + (N XOR V) = 0 LC : Limit Clear : L = 0 LE : Less Equal : Z + (N XOR V) = 1 LS : Limit Set : L = 1 LT : Less Than : N XOR V = 1 MI : Minus : N = 1 NE : Not Equal : Z = 0 NR : Normalized : Z + ((NOT U) AND (NOT E))= 1 PL : Plus : N = 0 NN : Not Normalized : Z + ((NOT U) AND (NOT E))= 0 Command : ABS D Parallel- Move? : Yes D : Accumulator. Description : This command turns the value currently in the Accumulator into an absolute value using 2's complement. Command : ADC S,D Parallel- Move? : Yes S : 48bit source value. D : Accumulator. Description : The value S is added with the Carry and put into the Acc. This is for 96-bit-addition (double precision). Command : ADD S,D Parallel- Move? : Yes S : Acc., X or X0, for 56bit, 48bit and 24bit adding respectively. D : Accumulator. Description : S is added to the accumulator. Command : ADDL S,D Parallel- Move? : Yes S : Accumulator D : Accumulator Description : The accumulator is shifted left and added to the accumulator. Command : ADDR S,D Parallel- Move? : Yes S : Accumulator D : Accumulator Description : The accumulator is shifted right and added to the accumulator. Command : AND S,D Parallel- Move? : Yes S : X0 Description : Logical AND on 24 bits. Changes only A1/B1 Command : ANDI S,D Parallel- Move? : No S : #x D : MR, CCR, OMR Description : Logical AND with direct data for Control Registers. Command : ASL D Parallel- Move? : Yes D : Accumulator Description : Left shift accumulator Command : ASR D Parallel- Move? : Yes D : Accumulator Description : Right shift accumulator Command : BCHG S,D Parallel- Move? : No S : #n D : ea, pp, aa, ar Description : Test and change n'th bit in ea,pp,aa or ar. Command : BCLR S,D Parallel- Move? : No S : #n D : ea, pp, aa, ar Description : Test and clear n'th bit in ea, pp, aa or ar. Command : BSET S,D Parallel- Move? : No S : #n D : ea, pp, aa, ar Description : Test and set n'th bit in ea, pp, aa or ar. Command : BTST S,D Parallel- Move? : No S : #n D : ea, pp, aa, ar Description : Test n'th bit in ea, pp, aa or ar. Command : CLR D Parallel- Move? : Yes D : Accumulator Description : D : Clear accumulator. Command : CMP S1,S2 Parallel- Move? : Yes S1 : A, X0 S2 : A Description : Compare S1 with S2 and set condition codes. Command : CMPM S1,S2 Parallel- Move? : Yes S1 : A,X0 S2 : A Description : Compare absolute value (56 bit, extended if necessary). Command : DIV S,D Parallel- Move? : Yes S : X0 D : A Description : Divide MODULO stepwise (?). To get a complete division, this must be repeated 24 times. Command : DO S,D Parallel- Move? : No S : #X<,ea,aa,ar D : Label Description : Repeat S-times the commands between this one and label. Jumps are not allowed to be the last command in the loop. The last command has restrictions and NOP's may be needed. Command : ENDDO Parallel- Move? : No Description : End hardware loop. Command : EOR S,D Parallel- Move? : Yes S : X0 D : Accumulator Description : Exclusive OR (24 bits) Command : ILLEGAL Parallel- Move? : No Description : Illegal command, causes interrupt. Command : Jcc D Parallel- Move? : No D : Label Description : Conditional jump based on flag registers. Command : JCLR #n,S,D Parallel- Move? : No S : ea, aa, ar, pp D : Label Description : Jump to label when the n'th bit is cleared. Command : JMP D Parallel- Move? : No D : Label Description : Unconditional jump to label Command : JScc D Parallel- Move? : No D : Label Description : Conditional jump to subroutine. Command : JSCLR #n,S,D Parallel- Move? : No S : ea, aa, pp, ar D : Label Description : Jump to subroutine if n'th bit is cleared. Command : JSET #n.S,D Parallel- Move? : No S : ea, aa, ar, pp Description : Jump if n'th bit is set. Command : JSR D Parallel- Move? : No D : Label Description : Jump to subroutine. Command : JSSET #n,S,D Parallel- Move? : No S : ea, aa, ar, pp D : Label Description : Jump to subroutine if n'th bit is set. Command : LSL D Parallel- Move? : Yes D : Accumulator Description : Logical shift left accumulator (A1/B1). Fills with zeros, bit 47 in carry bit. Command : LSR D Parallel- Move? : Yes D : Accumulator Description : Logical shift right accumulator (A1/B1). Fills with zeros, bit 24 in carry-bit. Command : LUA ea,D Parallel- Move? : No D : Rn, Nn Description : Calculate and adapt address. Command : MAC +S1,S2,D Parallel- Move? : Yes S1,S2 : X0 D : Accumulator. Description : Signed multiply, result added/substracted to/from accumulator. Command : MACR +S1,S2,D Parallel- Move? : Yes S1,S2 : X0 D : Accumulator Description : Rounded signed multiplay, result added/substracted to/from Accumulator. Command : MOVE S,D Parallel- Move? : No S : ea, aa, ar, #x D : ea, aa, ar Description : Copy. Rn and Nn aren't updated until next cycle. This command is equal to a parallel move with NOP. Command : MOVEC S,D Parallel- Move? : No S : ea, aa, ar, #x D : ea, aa, ar Description : Copy from/to controlregister Command : MOVEM S,D Parallel- Move? : No S : ea, aa, ar, #x D : ea, aa, ar Description : Copy from/to program memory (eg. P:ea). Command : MOVEP S,D Parallel- Move? : No S : ea, aa, ar, #x D : ea, aa, ar Description : Copy from/tp periphery. Command : MPY +S1,S2,D Parallel- Move? : Yes S1,S2 : X0 D : Accumulator Description : Signed multiply, result in Accumulator. Command : MPYR +S1,S2,D Parallel- Move? : Yes S1,S2 : X0 D : Accumulator Description : Rounded signed multiply, result in Accumulator. Command : NEG D Parallel- Move? : Yes D : Accumulator Description : Negate Accumulator Command : NOP Parallel- Move? : Syntax : NOP Description : No operation. Command : NORM S,D Parallel- Move? : No S : Rn D : Accumulator Description : Normalise Accumulator. Rn holds the amount of shifts; positive=right. Command : NOT D Parallel- Move? : Yes D : Accumulator Description : Negate accumulator. Command : OR S,D Parallel- Move? : Yes S : X0 D : Accumulator Description : Logical OR Command : ORI S,D Parallel- Move? : No S : #x D : MR, CCR, OMR Description : Logical OR with a constant. Command : REP D Parallel- Move? : No D : ea,aa,ar,#X Description : Repeat next command only. Same limitations as with hardware loop (LOOP). Command : RESET Parallel- Move? : No Description : Software reset of whole On-Chip Periphery. Command : RND D Parallel- Move? : Yes D : Accumulator Description : Round Accumulator (depends on scaling mode). Command : ROL D Parallel- Move? : Yes D : Accumulator. Description : Rotate-left Accumulator (24 bit A1/B1) Command : ROR D Parallel- Move? : Yes D : Accumulator Description : Rotate-right Accumulator (24bit A1/B1) Command : RTI Parallel- Move? : No Description : Return from interrupt routine. Command : RTS Parallel- Move? : No Description : Return from subroutine. Command : SBC S,D Parallel- Move? : Yes S : X D : Accumulator Description : Long substraction with carry-bit (56bit). Command : STOP Parallel- Move? : No Description : Stop processor and go in low-power standby mode. Command : SUB S,D Parallel- Move? : Yes S : A,X,X0 D : Accumulator Description : Substract 24, 48 or 56 bit. Command : SUBL S,D Parallel- Move? : Yes S,D : Accumulator Description : Logical shift left and substract (eg. for fast division in FFT routines). Command : SUBR S,D Parallel- Move? : yes S,D : Accumulator Description : Logical shift right and substract. Command : SWI Parallel- Move? : No Description : Software interrupt (IPL3). Command : Tcc S,D (S1,D1) Parallel- Move? : No S : Accumulator S1 : R1 D : Accumulator D1 : Rn Description : Conditional Copy. S1 and D1 are optional. Command : TFR S,D Parallel- Move? : Yes S : A,X0 D : Accumulator. Description : Copy 56-bit Register Command : TST S Parallel- Move? : Yes S : Accumulator Description : Test accumulator (sets SR register) Command : WAIT Parallel- Move? : No Description : Wait for an interrupt. 4. THE BIOS COMMANDS : The commands are given in their assembly form (ASM rulez! heh heh). The C form can be derived easily from this and can be read also in headerfiles. XBIOS 96 Dsp_DoBlock move.l size_out,-(sp) pea data_out move.l size_in,-(sp) pea data_in move.w #96,-(sp) trap #14 add.l #18,sp (not sure about this, can't use lea here, right?) Data_in and Data_out are pointers to buffers. Size_in and Size_out contain the number of DSP words to send (DSP word is 3 bytes on Falcon). If no data is expected from DSP, Size_in should be zero. The same goes for Size_out. 64kb is the max value. I'm only giving you this routine for transfer now. I may include more later. The now following XBios calls are for DSP program management, and therefore pretty important. XBIOS 104 Dsp_Lock move.w #104,-(sp) trap #14 addq.l #2,sp d0 : -1 if DSP is locked by another program. 0 if DSP is free. XBIOS 105 Dsp_Unlock move.w #105,-(sp) trap #14 addq.l #2,sp This is to unlock the Dsp again. Don't forget to do this when you leave your program! XBIOS 106 Dsp_Available pea yavailable,-(sp) pea xavailable,-(sp) move.w #106,-(sp) trap #14 lea $A(sp),sp The longwords pointed to by xavail and yavail will contain the amount of free X and Y memory space. XBIOS 107 Dsp_Reserve move.l yreserve,-(sp) move.l xreserve,-(sp) move.w #107,-(sp) trap #14 lea $A(sp),sp You need to reserve memory before you can have TOS load your program into DSP. The amount of mem may of course not exceed the available memory. If you don't reserve enough memory, XBIOS 108 will refuse your program. XBIOS 108 Dsp_LoadProg pea buffer move.w ability,-(sp) pea filename move.w #108,-(sp) trap #14 lea $C(sp),sp This nice command will load and execute a .lod file in the DSP. Buffer and filename are pointers. The buffer size depends on the program size in the following way : 3 * (#prog+data words + (3 * #blocks in program) ) For ability, look at XBIOS 113 XBIOS 109 Dsp_ExecProg move.w ability,-(sp) move.l codesize,-(sp) pea codeptr move.w #109,-(sp) trap #14 lea $C(sp),sp This call puts a program into the DSP and executes it. It wants the program in binary format in memory, at the position pointed to by codeptr. Again, codesize must not exceed the reserved amount of memory and for ability, look at XBIOS 13. XBIOS 111 Dsp_LodToBinary pea buffer,-(sp) pea filename,-(sp) move.w #111,-(sp) trap #14 lea $A(sp),sp This sort-of does the first part of XBIOS 108. The filename is a .lod file again, and the buffer must be big enough to contain a binary version of the program. It is then ready for XBIOS 109. d0 contains the actual size of the created binary. XBIOS 113 Dsp_RequestUniqueAbility move.w #113,-(sp) trap #14 addq.l #2,sp d0 will contain your own unique ability number. Hurray! :) This should be enough to get you going. Try to get some programming examples, and check out the HARDWARE.TXT, and you are ready for just about anything! Good luck! P.S. I may get into this and do much more docs (maybe even a whole book on the Falcon etc. ). If you got idea's, original examples (on anything from sample to graphics to DSP programming) and you want to share them with me and others, well... send them to DNT_CREW! They'll publish them and give them to me. Bye! XBIOS