4.5 Instruction Descriptions (C to DTB)
CALL | Call Subroutine | |||||||
---|---|---|---|---|---|---|---|---|
Syntax: | {label:} | CALL | lit24 | |||||
Operands: | lit24 ∈ [0 ... 16MB] | |||||||
Operation: | (PC) + 4 → PC, (8’b0, PC[23:2]) → TOS[31:2]; 2’b00 → TOS[1:0], (W15) + 4 → W15, lit24 → PC[23:0]; NOP → Instruction Register | |||||||
Status Affected: | None | |||||||
Encoding: | 1101 | 111n | nnnn | nnnn | nnnn | nnnn | nnnn | nn10 |
Description: | Subroutine call to any address within all of executable memory address space. A call to either a 32-bit or 16-bit instruction is permitted. The long word aligned return address (PC+4) is pushed onto the system stack. The 24-bit value ‘lit24’ is then loaded into the PC (the opcode does not store the LSb which is always 1’b0). The ‘n’ bits form the target address. Note: The (byte) PC address is always either word or long word aligned. The opcode does not store the LSb because it is always 1’b0. | |||||||
I-Words: | 1 | |||||||
Cycles: | 1 |
Example:1 | Address | Label | Instruction | Comment | |
---|---|---|---|---|---|
0x804000 | - | CALL _CHECK_FAIL | ; Calls function in address 0x805000(_CHECK_FAIL) | ||
. . . | |||||
0x805000 | _CHECK_FAIL | MOV.l SR, W6 | ; _CHECK_FAIL SubRoutine | ||
. . . | CP w6, w7 | ||||
. . . | . . . | ||||
Before execution | After execution | ||||
PC | 0x804000 | PC | 0x805000 | ||
w15 | 0x4500 | w15 | 0x4504 | ||
Data @4500 | 0x0000 | Data @4500 | 0x804004 | ||
SR | 0x00000000 | SR | 0x00000000 |
CALL | Call Indirect Subroutine | |||||||
---|---|---|---|---|---|---|---|---|
Syntax: | {label:} | CALL | Wns | |||||
Operands: | Wns ∈ [W0...W14] | |||||||
Operation: | (PC) + 2 → PC, (8’b0, PC[23:2]) → TOS[31:2]; 2’b00 → TOS[1:0], (W15)+4 → W15, Wns[23:0] → PC[23:0]; NOP → Instruction Register. | |||||||
Status Affected: | None | |||||||
Encoding: | 1101 | 011U | UUUU | ssss | UUUU | UUUU | UUUU | 1110 |
Description: | Indirect subroutine call of any instruction address (16-bit or 32-bit) within program memory using a computed call PS (word) address. The long word aligned return address (PC+4) is pushed onto the system stack. The 24-bit value (Wns[23:0]) is then loaded into the PC[23:0]. Wns must therefore contain a PS byte address. The value of Wns[0] is ignored, and PC[0] is always set to 1’b0. The ‘s’ bits specify the source register. Note:
| |||||||
I-Words: | 1 | |||||||
Cycles: | 2 Note: The call target instruction fetch is not executed if an exception is pending, making effective instruction execution time one cycle. |
Example:1 | Address | Label | Instruction | Comment | |
---|---|---|---|---|---|
0x803FFC | - | MOV.l #_CHECK_FAIL, W0 | |||
0x804000 | - | CALL W0 | ; Calls function in address 0x805000(_CHECK_FAIL) | ||
. . . | |||||
0x805000 | _CHECK_FAIL: | MOV.l SR, W6 | ; _CHECK_FAIL SubRoutine | ||
. . . | CP w6, w7 | ||||
. . . | . . . | ||||
Before execution | After execution | ||||
PC | 0x804000 | PC | 0x805000 | ||
W0 | 0x805000 | PC | 0x805000 | ||
w15 | 0x4500 | w15 | 0x4504 | ||
Data @4500 | 0x0000 | Data @4500 | 0x804004 | ||
SR | 0x00000000 | SR | 0x00000000 |
CLR | Clear Accumulator | |||||||||
---|---|---|---|---|---|---|---|---|---|---|
Syntax: {label} | CLR | A | ||||||||
B | ||||||||||
Operands: | None | |||||||||
Operation: | 0 → ACC(A or B) | |||||||||
Status Affected: | OA,SA or OB,SB | |||||||||
Encoding: | 0111 | 001A | UUUU | 1100 | ||||||
Description: | Clear the specified accumulator (A or B). The ‘A’ bit selects the accumulator to clear. | |||||||||
I-Words: | 0.5 | |||||||||
Cycles: | 1 |
Example 1: | CLR A; Clear ACCA | ||||||||
---|---|---|---|---|---|---|---|---|---|
Before Instruction | After Instruction | ||||||||
ACCA | 0x00_0012_3412_4524_1234 | ACCA | 0x00_0000_0000_0000_0000 |
CLR | Clear f | |||||||
---|---|---|---|---|---|---|---|---|
Syntax: | {label:} | CLR.b | f | |||||
CLR{.w} | ||||||||
CLR.l | ||||||||
Operands: | f ∈ [0 ... 1MB] | |||||||
Operation: | 0x00000000 → file register for long operation 0x0000 → file register for word operation 0x00 → file register for byte operation | |||||||
Status Affected: | None | |||||||
Encoding: | 1010 | 011L | ffff | ffff | ffff | ffff | ffff | B101 |
Description: | Clear the file register. The ‘L’ and ‘B’ bits select operation data width. The ‘f’ bits select the address of the file register. Note:
| |||||||
I-Words: | 1 | |||||||
Cycles: | 1 |
Example 1: | CLR.B RAM200 ; Clear RAM200 (Byte mode) | |||||||||
---|---|---|---|---|---|---|---|---|---|---|
Before Instruction | After Instruction | |||||||||
RAM200 | 8009 | RAM200 | 8000 | |||||||
SR | 0000 | SR | 0000 |
Example 2: | CLR WREG ; Clear WREG (Word mode) | |||||||||
---|---|---|---|---|---|---|---|---|---|---|
Before Instruction | After Instruction | |||||||||
WREG | 0600 | WREG | 0000 | |||||||
SR | 0000 | SR | 0000 |
CLRWDT | Clear Watchdog Timer | |||||||
---|---|---|---|---|---|---|---|---|
Syntax: | {label:} | CLRWDT | ||||||
Operands: | None | |||||||
Operation: | 0 → WDT Reg | |||||||
Status Affected: | None | |||||||
Encoding: | 0111 | 001U | UUUU | 0101 | ||||
Description: | Clear the WatchDog Timer register. | |||||||
I-Words: | 0.5 | |||||||
Cycles: | 1 |
COM | Complement Ws | |||||||
---|---|---|---|---|---|---|---|---|
Syntax: | {label:} | COM.b | Ws, | Wd | ||||
COM.bz | [Ws], | [Wd] | ||||||
COM{.w} | [Ws++], | [Wd++] | ||||||
COM.l | [Ws--], | [Wd--] | ||||||
[++Ws], | [++Wd] | |||||||
[--Ws], | [--Wd] | |||||||
Operands: | Ws ∈ [W0 ... W15]; Wd ∈ [W0 ... W15] | |||||||
Operation: | (Ws) → Wd | |||||||
Status Affected: | Z, N | |||||||
Encoding: | S111 | 100L | dddd | ssss | pppq | qqUU | UUUU | BU00 |
Description: | Compute the 1’s complement of the contents of the source register Ws and place the result in the destination register Wd. The ‘S’ bit selects instruction size. The ‘L’ and ‘B’ bits select operation data width. The ‘s’ bits select the source register. The ‘d’ bits select the destination register. The ‘p’ bits select the source addressing mode. The ‘q’ bits select the destination addressing mode. | |||||||
I-Words: | 1 or 0.5 | |||||||
Cycles: | 1 |
Example 1: | COM.B [W0++], [W1++] ; COM [W0] and store to [W1] (Byte mode) ; Post-increment W0, W1 | |||||||||
---|---|---|---|---|---|---|---|---|---|---|
Before Instruction | After Instruction | |||||||||
W0 | 2301 | W0 | 2302 | |||||||
W1 | 2400 | W1 | 2401 | |||||||
Data 2300 | 5607 | Data 2300 | 5607 | |||||||
Data 2400 | ABCD | Data 2400 | ABA9 | |||||||
SR | 0000 | SR | 0008 | (N = 1 ) |
Example 2: | COM W0, [W1++] ; COM W0 and store to [W1] (Word mode) ; Post-increment W1 | |||||||||
---|---|---|---|---|---|---|---|---|---|---|
Before Instruction | After Instruction | |||||||||
W0 | D004 | W0 | D004 | |||||||
W1 | 1000 | W1 | 1002 | |||||||
Data 1000 | ABA9 | Data 1000 | 2FFB | |||||||
SR | 0000 | SR | 0000 |
COM | Complement f | |||||||
---|---|---|---|---|---|---|---|---|
Syntax: | {label:} | COM.b | f | {,Wnd} | {,WREG} | |||
COM.bz | ||||||||
COM{.w} | ||||||||
COM.l | ||||||||
Operands: | f ∈ [0 ... 64KB]; Wnd ∈ [W0 ... W14] | |||||||
Operation: | (f) → destination designated by D | |||||||
Status Affected: | Z, N | |||||||
Encoding: | 1101 | 100L | dddd | ffff | ffff | ffff | ffff | BD01 |
Description: | Compute the 1’s complement of the contents of the file register and place the result in the destination designated by D. If the optional Wnd is specified, D=0 and store result in Wnd; otherwise, D=1 and store result in the file register. The ‘L’ and ‘B’ bits select operation data width. The ‘D’ bit selects the destination. The ‘f’ bits select the address of the file register. The ‘d’ bits select the Working register. | |||||||
I-Words: | 1 | |||||||
Cycles: | 1 |
Example 1: | COM.b RAM200 ; COM RAM200 (Byte mode) | |||||||||
---|---|---|---|---|---|---|---|---|---|---|
Before Instruction | After Instruction | |||||||||
RAM200 | 80FF | RAM200 | 8000 | |||||||
SR | 0000 | SR | 0002 | (Z) |
Example 2: | COM RAM400, WREG ; COM RAM400 and store to WREG ; (Word mode) | |||||||||
---|---|---|---|---|---|---|---|---|---|---|
Before Instruction | After Instruction | |||||||||
WREG | 1211 | WREG | F7DC | |||||||
RAM400 | 0823 | RAM400 | 0823 | |||||||
SR | 0000 | SR | 0008 | (N = 1 ) |
CP | Compare Wb with Ws, Set Status Flags | |||||||
---|---|---|---|---|---|---|---|---|
Syntax: | {label:} | CP.b | Wb, | Ws | ||||
CP{.w} | [Ws] | |||||||
CP.l | [Ws++] | |||||||
[Ws--] | ||||||||
[++Ws] | ||||||||
[--Ws] | ||||||||
Operands: | Wb ∈ [W0 ... W15]; Ws ∈ [W0 ... W15] | |||||||
Operation: | (Wb) - (Ws) | |||||||
Status Affected: | C, N, OV, Z | |||||||
Encoding: | S011 | 110L | wwww | ssss | pppU | UUUU | UUUU | BU00 |
Description: | Compute (Wb) - (Ws), then set flags but do not store result. Equivalent to SUB instruction (without a destination result write). The ‘S’ bit selects instruction size. The ‘L’ and ‘B’ bits select operation data width. The ‘w’ bits select the Wb source register. The ‘s’ bits select the Ws source register. The ‘p’ bits select the source addressing mode. | |||||||
I-Words: | 1 or 0.5 | |||||||
Cycles: | 1 |
Example 1: | CP.B W0, [W1++] ; Compare [W1] with W0 (Byte mode) ; Post-increment W1 | |||||||||
---|---|---|---|---|---|---|---|---|---|---|
Before Instruction | After Instruction | |||||||||
W0 | ABA9 | W0 | ABA9 | |||||||
W1 | 2000 | W1 | 2001 | |||||||
Data 2000 | D004 | Data 2000 | D004 | |||||||
SR | 0000 | SR | 0009 | (N, C = 1 ) |
Example 2: | CP W5, W6 ; Compare W6 with W5 (Word mode) | |||||||||
---|---|---|---|---|---|---|---|---|---|---|
Before Instruction | After Instruction | |||||||||
W5 | 2334 | W5 | 2334 | |||||||
W6 | 8001 | W6 | 8001 | |||||||
SR | 0000 | SR | 000C | (N, OV = 1 ) |
CPB | Compare Wb with Ws with Borrow, Set Status Flags | |||||||
---|---|---|---|---|---|---|---|---|
Syntax: | {label:} | CPB.b | Wb, | Ws | ||||
CPB{.w} | [Ws] | |||||||
CPB.l | [Ws++] | |||||||
[Ws--] | ||||||||
[++Ws] | ||||||||
[--Ws] | ||||||||
Operands: | Wb ∈ [W0 ... W15]; Ws ∈ [W0 ... W15] | |||||||
Operation: | (Wb) - (Ws) - (C) | |||||||
Status Affected: | C, N, OV, Z | |||||||
Encoding: | S011 | 111L | wwww | ssss | pppU | UUUU | UUUU | BU00 |
Description: | Compute (Wb) - (Ws) - (C), then set flags but do not store result. Equivalent to SUBB instruction without a destination result write. The Z bit is “sticky” (can only be cleared). The ‘S’ bit selects instruction size. The ‘L’ and ‘B’ bits select operation data width. The ‘w’ bits select the Wb source register. The ‘s’ bits select the Ws source register. The ‘p’ bits select the source addressing mode. | |||||||
I-Words: | 1 or 0.5 | |||||||
Cycles: | 1 |
CPB | Compare Ws with lit13 with Borrow, Set Status Flags | |||||||
---|---|---|---|---|---|---|---|---|
Syntax: | {label:} | CPB.b | Ws, | lit13 | ||||
CPB{.w} | [Ws], | |||||||
CPB.l | [Ws++], | |||||||
[Ws--], | ||||||||
[++Ws], | ||||||||
[--Ws], | ||||||||
Operands: | Ws ∈ [W0 ... W15]; lit13 ∈ [0 ... 8191] (32-bit opcode); lit4 ∈ [0 ... 15] (16-bit opcode)1 | |||||||
Operation: | (Ws) - lit13 - (C) or (Ws) - lit4 - (C)1 Note: The literal is zero-extended to the selected data size of the operation | |||||||
Status Affected: | C, N, OV, Z | |||||||
Encoding: | S011 | 101L | kkkk | ssss | pppk | kkkk | kkkk | BU00 |
Description: | Zero-extend literal then compute (Ws) - literal - (C). Set flags but do not store result.
The Z bit is sticky (can only be cleared). The ‘L’ and ‘B’ bits select operation data width. The ‘p’ bits select the source addressing mode. The ‘s’ bits select the source register. The ‘k’ bits provide the literal operand. lit13[12:0] = Opcode[12:4], Opcode[23:20] lit4[3:0] = Opcode[23:20] | |||||||
I-Words: | 1 or 0.5 | |||||||
Cycles: | 1 |
CP | Compare Ws with lit13, Set Status Flags | |||||||
---|---|---|---|---|---|---|---|---|
Syntax: | {label:} | CP.b | Ws, | lit13 | ||||
CP{.w} | [Ws], | |||||||
CP.l | [Ws++], | |||||||
[Ws--], | ||||||||
[++Ws], | ||||||||
[--Ws], | ||||||||
Operands: | Ws ∈ [W0 ... W15]; lit13 ∈ [0 ... 8191] (32-bit opcode); lit4 ∈ [0 ... 15] (16-bit opcode)1 | |||||||
Operation: | (Ws) - lit13 (32-bit opcode) or (Ws) - lit4 (16-bit opcode)1 Note: The literal is zero-extended to the selected data size of the operation | |||||||
Status Affected: | C, N, OV, Z | |||||||
Encoding: | S011 | 100L | kkkk | ssss | pppk | kkkk | kkkk | BU00 |
Description: | Zero-extend literal as necessary, then compute (Ws) - literal. Set flags but do not store result. The Z bit is sticky (can only be cleared). The ‘L’ and ‘B’ bits select operation data width. The ‘p’ bits select the source addressing mode. The ‘s’ bits select the source register. The ‘k’ bits provide the literal operand. lit13[12:0] = Opcode[12:4], Opcode[23:20] lit4[3:0] = Opcode[23:20] | |||||||
I-Words: | 1 or 0.5 | |||||||
Cycles: | 1 |
CPB | Compare Wb with lit16 with Borrow, Set Status Flags | |||||||
---|---|---|---|---|---|---|---|---|
Syntax: | {label:} | CPB.b | Wb, | lit16 | ||||
CPB{.w} | ||||||||
CPB.l | ||||||||
Operands: | Wb ∈ [W0 ... W15]; lit16 ∈ [0 ... 65535] | |||||||
Operation: | (Wb) - lit16 - (C) | |||||||
Status Affected: | C, N, OV, Z | |||||||
Encoding: | 1100 | 011L | wwww | kkkk | kkkk | kkkk | kkkk | B110 |
Description: | Compute (Wb) - lit16 - (C), set flags but do not store result. The Z bit is “sticky” (can only be cleared). The ‘L’ and ‘B’ bits select operation data width. The ‘w’ bits select the source register. The ‘k’ bits provide the literal operand. | |||||||
I-Words: | 1 | |||||||
Cycles: | 1 |
CP | Compare f with Ws, Set Status Flags | |||||||
---|---|---|---|---|---|---|---|---|
Syntax: | {label:} | CP.b | f, | Ws | ||||
CP{.w} | ||||||||
CP.l | ||||||||
Operands: | f ∈ [0 ...64KB]; Ws ∈ [W0 ... W15] | |||||||
Operation: | (f) - (Ws) | |||||||
Status Affected: | C, N, OV, Z | |||||||
Encoding: | 1010 | 101L | ssss | ffff | ffff | ffff | ffff | BU01 |
Description: | Compute (f) - (Ws), set flags but do not store result. Equivalent to SUBWF instruction with a stack sink destination ([W15]). The ‘L’ and ‘B’ bits select operation data width. The ‘f’ bits select the address of the file register. The ‘s’ bits select the Working register. | |||||||
I-Words: | 1 | |||||||
Cycles: | 1 |
CP0 | Compare f with Zero, Set Status Flags | |||||||
---|---|---|---|---|---|---|---|---|
Syntax: | {label:} | CP0.b | f | |||||
CP0{.w} | ||||||||
CP0.l | ||||||||
Operands: | f ∈ [0 ... 1MB] | |||||||
Operation: | Long: (f) - 0x0000000 Word: (f) - 0x0000 Byte: (f) - 0x00 | |||||||
Status Affected: | C, N, OV, Z | |||||||
Encoding: | 1010 | 100L | ffff | ffff | ffff | ffff | ffff | BU01 |
Description: | Compute (f) minus zero value for selected data size, set flags but do not store result. The C bit is always set, and OV is always cleared by this operation. The ‘L’ and ‘B’ bits select operation data width. The ‘f’ bits select the address of the file register. Accessible file address space is 1 MB. | |||||||
I-Words: | 1 | |||||||
Cycles: | 1 |
Example 1: | CP0.B RAM100 ; Compare RAM100 with 0x0 (Byte mode) | |||||||||
---|---|---|---|---|---|---|---|---|---|---|
Before Instruction | After Instruction | |||||||||
RAM100 | 44C3 | RAM100 | 44C3 | |||||||
SR | 0000 | SR | 0009 | (N, C = 1 ) |
Example 2: | CP0 0x1FFE ; Compare (0x1FFE) with 0x0 (Word mode) | |||||||||
---|---|---|---|---|---|---|---|---|---|---|
Before Instruction | After Instruction | |||||||||
Data 1FFE | 0001 | Data 1FFE | 0001 | |||||||
SR | 0000 | SR | 0001 | (C = 1 ) |
CPB | Compare f with Ws with Borrow, Set Status Flags | |||||||
---|---|---|---|---|---|---|---|---|
Syntax: | {label:} | CPB.b | f, | Ws | ||||
CPB{.w} | ||||||||
CPB.l | ||||||||
Operands: | f ∈ [0 ...64KB]; Ws ∈ [W0 ... W15] | |||||||
Operation: | (f) - (Ws) - (C) | |||||||
Status Affected: | C, N, OV, Z | |||||||
Encoding: | 1010 | 110L | ssss | ffff | ffff | ffff | ffff | BU01 |
Description: | Compute (f) - (Ws) - (C), set flags but do not store result. Equivalent to
SUBBWF instruction with a stack sink destination write ([W15]). The Z bit is “sticky” (can only be cleared). The ‘L’ and ‘B’ bits select operation data width. The ‘f’ bits select the address of the file register. The ‘s’ bits select the Working register. | |||||||
I-Words: | 1 | |||||||
Cycles: | 1 |
CP | Compare Wb with lit16, Set Status Flags | |||||||
---|---|---|---|---|---|---|---|---|
Syntax: | {label:} | CP.b | Wb, | lit16 | ||||
CP{.w} | ||||||||
CP.l | ||||||||
Operands: | Wb ∈ [W0 ... W15]; lit16 ∈ [0 ... 65535] | |||||||
Operation: | (Wb) - lit16 | |||||||
Status Affected: | C, N, OV, Z | |||||||
Encoding: | 1100 | 010L | wwww | kkkk | kkkk | kkkk | kkkk | B110 |
Description: | Compute (Wb) - lit16, set flags but do not store result. The ‘L’ and ‘B’ bits select operation data width. The ‘w’ bits select the source register. The ‘k’ bits provide the literal operand. | |||||||
I-Words: | 1 | |||||||
Cycles: | 1 |
CTXTSWP | CPU Register Context Swap Literal | |||||||
---|---|---|---|---|---|---|---|---|
Syntax: | {label:} | CTXTSWP lit3 | ||||||
Operands: | lit3 ∈ [0 ... 7] | |||||||
Operation: | Switch CPU register context to context defined by lit3 lit3 → SR.CTX[2:0] | |||||||
Status Affected: | None | |||||||
Encoding: | 0111 | 001U | Ukkk | 0110 | ||||
Description: | This instruction will force a CPU register context switch from the current context to the target context defined by value lit3. If supported, coprocessor contexts will also be switched accordingly.
A context switch will update the Current Context Identifier (SR.CTX[2:0]) to reflect the new active CPU register context. The ‘k’ bits select the target register context. | |||||||
I-Words: | 0.5 | |||||||
Cycles: | 2 |
CTXTSWP | CPU Register Context Swap Ws | |||||||
---|---|---|---|---|---|---|---|---|
Syntax: | {label:} | CTXTSWP Wns | ||||||
Operands: | Wns ∈ [W0 ... W14] | |||||||
Operation: | Switch CPU register context to context defined in Wns[2:0] 1 Wns[2:0] → SR.CTX[2:0] | |||||||
Status Affected: | None | |||||||
Encoding: | 1101 | 100U | UUUU | ssss | UUUU | UUUU | UUUU | U110 |
Description: | This instruction will force a CPU register context switch (W0 through W7) from the current context to the target context defined by the contents of Wns[2:0]. Supported register contexts in any instantiated coprocessors will also be switched. A context switch will update the Current Context (SR.CTX[2:0]) to reflect the new active CPU register context. The ‘s’ bits select the source register. Note:
| |||||||
I-Words: | 1 | |||||||
Cycles: | 2 |
DEC | Decrement f | |||||||
---|---|---|---|---|---|---|---|---|
Syntax: | {label:} | DEC.b | f | {,Wnd} | {,WREG} | |||
DEC.bz | ||||||||
DEC{.w} | ||||||||
DEC.l | ||||||||
Operands: | f ∈ [0 ... 64KB]; Wnd ∈ [W0 ... W14] | |||||||
Operation: | (f) - 1 → destination designated by D | |||||||
Status Affected: | C, N, OV, Z | |||||||
Encoding: | 1101 | 011L | dddd | ffff | ffff | ffff | ffff | BD01 |
Description: | Subtract one from the contents of the file register and place the result in the destination designated by D. If the optional Wnd is specified, D=0 and store result in Wnd; otherwise, D=1 and store result in the file register. The ‘L’ and ‘B’ bits select operation data width. The ‘D’ bit selects the destination. The ‘f’ bits select the address of the file register. The ‘d’ bits select the Working register. | |||||||
I-Words: | 1 | |||||||
Cycles: | 1 |
Example 1: | DEC.B 0x200 ; Decrement (0x200) (Byte mode) | |||||||||
---|---|---|---|---|---|---|---|---|---|---|
Before Instruction | After Instruction | |||||||||
Data 200 | 80FF | Data 200 | 80FE | |||||||
SR | 0000 | SR | 0009 | (N, C = 1 ) |
Example 2: | DEC RAM400, WREG ; Decrement RAM400 and store to WREG ; (Word mode) | |||||||||
---|---|---|---|---|---|---|---|---|---|---|
Before Instruction | After Instruction | |||||||||
WREG | 1211 | WREG | 0822 | |||||||
RAM400 | 0823 | RAM400 | 0823 | |||||||
SR | 0000 | SR | 0000 |
DEC2 | Decrement f by 2 | |||||||
---|---|---|---|---|---|---|---|---|
Syntax: | {label:} | DEC2.b | f | {,Wnd} | {,WREG} | |||
DEC2.bz | ||||||||
DEC2{.w} | ||||||||
DEC2.l | ||||||||
Operands: | f ∈ [0 ... 64KB]; Wnd ∈ [W0 ... W14] | |||||||
Operation: | (f) - 2 → destination designated by D | |||||||
Status Affected: | C, N, OV, Z | |||||||
Encoding: | 1101 | 111L | dddd | ffff | ffff | ffff | ffff | BD01 |
Description: | Subtract two from the contents of the file register and place the result in the destination designated by D. If the optional Wnd is specified, D=0 and store result in Wnd; otherwise, D=1 and store result in the file register. The ‘L’ and ‘B’ bits select operation data width. The ‘D’ bit selects the destination. The ‘f’ bits select the address of the file register. The ‘d’ bits select the Working register. | |||||||
I-Words: | 1 | |||||||
Cycles: | 1 |
DISICTL | Disable Interrupts Control Literal | |||||||
---|---|---|---|---|---|---|---|---|
Syntax: | {label:} | DISICTL | lit3 | { ,Wd} | ||||
{ ,[Wd]} | ||||||||
{ ,[Wd++]} | ||||||||
{ ,[Wd--]} | ||||||||
{ ,[++Wd]} | ||||||||
{ ,[--Wd]} | ||||||||
Operands: | lit3 ∈ [0 ... 7]; Wd ∈ [W0 ... W15] | |||||||
Operation: | Disable interrupts at or below IPL threshold (IPLT[2:0]) defined by lit3 Setting lit3 = 0 will enable all interrupt levels up to and including those at SR.IPL[2:0]. If Wd declared, zero extended prior IPLT[2:0] → Wd[31:0] | |||||||
Status Affected: | None | |||||||
Encoding: | 1101 | 110U | dddd | UUUU | UUUq | qqUU | Ukkk | 0W10 |
Description: | This instruction disables interrupts at or below the IPL threshold (IPLT[2:0]) defined by lit3, effective starting from the subsequent instruction. Traps cannot be inhibited by this instruction. The current DISICTL 3-bit IPLT is memory mapped (DISIIPL.IPLT[2:0]) and can be read by the user at any time. A write to DISIIPL will have no effect. In addition, the IPLT established prior to DISICTL execution may be optionally written to destination Wd if a destination is declared (W = 1). The prior IPLT[2:0] is zero extended to 32-bits prior to being written. If a destination operand is not declared, nothing will be written (W = 0). This facilitates nesting of DISICTL and/or DISICTLW instructions. The ‘W’ bit determines if a destination write is required. The ‘k’ bits are an unsigned literal that specifies the DISICTL IPL threshold. The ‘d’ bits select the destination register. The ‘q’ bits select the destination addressing mode. Note: SR.IPL[2:0] is not modified by this instruction. | |||||||
I-Words: | 1 | |||||||
Cycles: | 1 |
DISICTL | Disable Interrupts Control Wns | |||||||
---|---|---|---|---|---|---|---|---|
Syntax: | {label:} | DISICTL | Wns | { ,Wd} | ||||
{ ,[Wd]} | ||||||||
{ ,[Wd++]} | ||||||||
{ ,[Wd--]} | ||||||||
{ ,[++Wd]} | ||||||||
{ ,[--Wd]} | ||||||||
Operands: | Wns ∈ [W0 ... W14]; Wd ∈ [W0 ... W15] | |||||||
Operation: | Disable interrupts at or below IPL threshold (IPLT[2:0]) defined by Wns[2:0] Wns[2:0] = 0 will enable all interrupt levels If Wd declared, zero extended prior IPLT[2:0] → Wd[31:0] | |||||||
Status Affected: | None | |||||||
Encoding: | 1101 | 110U | dddd | ssss | UUUq | qqUU | UUUU | 1W10 |
Description: | This instruction disables interrupts at or below the IPL threshold (IPLT[2:0]) defined by the LS 3-bits of source Wns (remaining MSbs of Wns are ignored), effective starting from the subsequent instruction. Traps cannot be inhibited by this instruction. The current DISICTLW 3-bit IPLT is memory mapped (DISIIPL.IPLT[2:0]) and can be read by the user at any time. A write to DISIIPL will have no effect. In addition, the IPLT established prior to DISICTL execution may be optionally written to destination Wd if a destination is declared (W = 1). The prior IPLT[2:0] is zero extended to 32-bits prior to being written. If a destination operand is not declared, nothing will be written (W = 0). This facilitates nesting of DISICTL(W) instructions. This instruction can be used (optionally in conjunction with DISICTLR) to control the impact of system interrupts. The ‘W’ bit determines if a destination write is required. The ‘s’ bits select the source register. The ‘d’ bits select the destination register. The ‘q’ bits select the destination addressing mode. Note: SR.IPL[2:0] is not modified by this instruction. | |||||||
I-Words: | 1 | |||||||
Cycles: | 1 |
DIVF | Signed Fractional 16/16 and 32/16 Divide | |||||||
---|---|---|---|---|---|---|---|---|
Syntax: | {label:} | DIVF.w | Wm | Wn | ||||
DIVF.l | ||||||||
Operands: | Wn ∈ [W0 ... W14]; Wm ∈ [W0 ... W13] | |||||||
Operation: | DIVF.w (16/16): Wm[15:0] = Dividend, Wn[15:0] = Divisor: Wm << 16; 16’b0 → Wm[15:0]; Wm / Wn → 16’b0, Wm[15:0]; Remainder → 16’b0, W(m+1)[15:0] DIVF.l (32/16); Wm[31:0] = Dividend, Wn[15:0] = Divisor: Wm / Wn → 16’b0, Wm[15:0]; Remainder → 16’b0, W(m+1)[15:0] | |||||||
Status Affected: | C, N, OV, Z | |||||||
Encoding: | 1110 | 100L | wwww | ssss | UUUU | UUUU | UUUU | 1011 |
Description: | Iterative, signed fractional 32-bit (or 16-bit) by 16-bit divide to a 16-bit quotient and a 16-bit remainder, both of which are zero-extended prior to being written to Wm and W(m+1), respectively. The sign of the remainder will be the same as that of the dividend. The 16-bit by 16-bit divide scales the dividend to become a 32-bit fractional value prior to executing the divide.
This instruction must be executed six times to generate the correct quotient and remainder. This may only be achieved by executing a REPEAT with an iteration count of five (i.e. 5+1 iterations in all) and the DIVF.x instruction as its target. The REPEAT loop may be interrupted at any iteration boundary.
C is modified as per the divide algorithm.
Z is set if the remainder is clear. Z is cleared otherwise.
N is set if the remainder is negative. N is cleared otherwise.
OV is set if the divide will result in an overflow. The quotient and remainder will be deterministic but meaningless.
The ‘w’ bits select the source (dividend) register. The ‘s’ bits select the source (divisor) register. Note:
| |||||||
I-Words: | 1 | |||||||
Cycles: | 6 |
Example:1 | Address | Label | Instruction | Comment | |
---|---|---|---|---|---|
0x804000 | - | REPEAT #5 | ; Execute DIV 5 times. | ||
0x804004 | - | DIVF.l w4, w8 | ;Fractional Divide contents of W4 bycontents of W5 | ||
Before execution | After execution | ||||
w4 | 0x1001 | w4 | 0x2000 | ||
w8 | 0x4000 | w8 | 0x4000 | ||
w5 | 0x0000 | w5 | 0x0001 | ||
SR | 0x00000000 | SR | 0x00000000 |
DIVFL | Signed Fractional 32/32 Divide | |||||||
---|---|---|---|---|---|---|---|---|
Syntax: | {label:} | DIVFL | Wm | Wn | ||||
Operands: | Wn ∈ [W0 ... W14]; Wm ∈ [W0 ... W13] | |||||||
Operation: | 32/32; Wm = Dividend, Wn = Divisor: Wm / Wn → Wm[31:0]; Remainder → W(m+1)[31:0] | |||||||
Status Affected: | C, N, OV, Z | |||||||
Encoding: | 1110 | 101U | wwww | ssss | UUUU | UUUU | UUUU | 1011 |
Description: | Iterative, signed fractional 32-bit by 32-bit divide to a 32-bit quotient and a 32-bit remainder. The sign of the remainder will be the same as that of the dividend. This instruction must be executed ten times to generate the correct quotient and remainder. This may only be achieved by executing a REPEAT with an iteration count of nine (i.e. 9+1 iterations in all) and the DIVFL instruction as its target. The REPEAT loop may be interrupted at any iteration boundary. C is modified as per the divide algorithm. Z is set if the remainder is clear. Z is cleared otherwise. N is set if the remainder is negative. N is cleared otherwise. OV is set if the divide will result in an overflow. The quotient and remainder will be deterministic but meaningless. The ‘w’ bits select the source (dividend) register. The ‘s’ bits select the source (divisor) register. Note:
| |||||||
I-Words: | 1 | |||||||
Cycles: | 10 |
DIVS | Signed Integer 16/16 and 32/16 Divide | |||||||
---|---|---|---|---|---|---|---|---|
Syntax: | {label:} | DIVS.w | Wm, | Wn | ||||
DIVS.l | ||||||||
Operands: | Wn ∈ [W0 ... W14], Wm ∈ [W0 ... W13] | |||||||
Operation: | DIVS.w (16/16): Wm[15:0] = Dividend, Wn[15:0] = Divisor: {16{Wm[15]}}, Wm[15:0] → Wm[31:0]; Wm / Wn → 16’b0, Wm[15:0]; Remainder → 16’b0, W(m+1)[15:0] DIVS.l (32/16); Wm[31:0] = Dividend, Wn[15:0] = Divisor: Wm / Wn → 16’b0, Wm[15:0]; Remainder → 16’b0, W(m+1)[15:0] | |||||||
Status Affected: | C, N, OV, Z | |||||||
Encoding: | 1110 | 100L | wwww | ssss | UUUU | UUUU | UUUU | 0011 |
Description: | Iterative, signed integer 32-bit (or 16-bit) by 16-bit divide to a 16-bit quotient and a 16-bit remainder, both of which are zero-extended to 32-bits prior to being written to Wm and W(m+1), respectively. The sign of the remainder will be the same as that of the dividend. The 16-bit by 16-bit divide sign-extends the dividend prior to executing the divide. This instruction must be executed six times to generate the correct quotient and remainder. This may only be achieved by executing a REPEAT with an iteration count of five (i.e. 5+1 iterations in all) and the DIVS instruction as its target. The REPEAT loop may be interrupted at any iteration boundary. C is modified as per the divide algorithm. Z is set if the remainder is clear. Z is cleared otherwise. N is set if the remainder is negative. N is cleared otherwise. OV is set if the divide will result in an overflow. OV is cleared otherwise. The quotient and remainder will be deterministic but meaningless. The ‘L’ bit selects 32-bit or 16-bit dividend size. The ‘w’ bits select the source (dividend) register. The ‘s’ bits select the source (divisor) register. Note:
| |||||||
I-Words: | 1 | |||||||
Cycles: | 6 |
Example:1 | Address | Label | Instruction | Comment | |
---|---|---|---|---|---|
0x804000 | - | REPEAT #5 | ; Execute DIV 5 times. | ||
0x804004 | - | DIVS.l w4, w8 | ;Divide contents of W4 bycontents of W5 | ||
Before execution | After execution | ||||
w4 | 0x3000 | w4 | 0x013B | ||
w8 | 0x27 | w8 | 0x27 | ||
w5 | 0x0000 | w5 | 0x0003 | ||
SR | 0x00000000 | SR | 0x00000000 |
DIVSL | Signed Integer 32/32 Divide | |||||||
---|---|---|---|---|---|---|---|---|
Syntax: | {label:} | DIVSL | Wm, | Wn | ||||
Operands: | Wn ∈ [W0 ... W14], Wm ∈ [W0 ... W13] | |||||||
Operation: | 32/32; Wm = Dividend, Wn = Divisor: Wm / Wn → Wm; Remainder → W(m+1) | |||||||
Status Affected: | C, N, OV, Z | |||||||
Encoding: | 1110 | 101U | wwww | ssss | UUUU | UUUU | UUUU | 0011 |
Description: | Iterative, signed integer 32-bit by 32-bit divide to a 32-bit quotient and a 32-bit remainder. The sign of the remainder will be the same as that of the dividend. This instruction must be executed ten times to generate the correct quotient and remainder. This may only be achieved by executing a REPEAT with an iteration count of nine (i.e. 9+1 iterations in all) and the DIVSL instruction as its target. The REPEAT loop may be interrupted at any iteration boundary. C is modified as per the divide algorithm. Z is set if the remainder is clear. Z is cleared otherwise. N is set if the remainder is negative. N is cleared otherwise. OV is set if the divide will result in an overflow. OV is cleared otherwise. The quotient and remainder will be deterministic but meaningless. The ‘w’ bits select the source (dividend) register. The ‘s’ bits select the source (divisor) register. Note:
| |||||||
I-Words: | 1 | |||||||
Cycles: | 10 |
DIVU | Unsigned Integer 16/16 and 32/16 Divide | |||||||
---|---|---|---|---|---|---|---|---|
Syntax: | {label:} | DIVU.w | Wm, | Wn | ||||
DIVU.l | ||||||||
Operands: | Wn ∈ [W0 ... W14], Wm ∈ [W0 ... W13] | |||||||
Operation: | DIVU.w (16/16); Wm[15:0] = Dividend, Wn[15:0] = Divisor: 16’b0 → Wm[31:16]; Wm / Wn → 16’b0, Wm[15:0]; Remainder → 16’b0, W(m+1)[15:0] DIVU.l (32/16); Wm[31:0] = Dividend, Wn[15:0] = Divisor: Wm / Wn → 16’b0, Wm[15:0]; Remainder → 16’b0, W(m+1)[15:0] | |||||||
Status Affected: | C, N, OV, Z | |||||||
Encoding: | 1110 | 100L | wwww | ssss | UUUU | UUUU | UUUU | 0111 |
Description: | Iterative, unsigned integer 32-bit (or 16-bit) by 16-bit divide to a 16-bit quotient and a 16-bit remainder, both of which are zero-extended to 32-bits prior to being written to Wm and W(m+1), respectively. The 16-bit by 16-bit divide also zero extends the dividend prior to executing the divide. This instruction must be executed six times to generate the correct quotient and remainder. This may only be achieved by executing a REPEAT with an iteration count of five (i.e. 5+1 iterations in all) and the DIVU instruction as its target. The REPEAT loop may be interrupted at any iteration boundary. C is modified as per the divide algorithm. Z is set if the remainder is clear. Z is cleared otherwise. N is always cleared. OV (DIVU.w) is always cleared because an overflow is not possible. OV (DIVU.l) is set if the divide will result in an overflow. OV is cleared otherwise. The ‘L’ bit selects 32-bit or 16-bit dividend size. The ‘w’ bits select the source (dividend) register. The ‘s’ bits select the source (divisor) register. Note:
| |||||||
I-Words: | 1 | |||||||
Cycles: | 6 |
DIVUL | Unsigned Integer 32/32 Divide | |||||||
---|---|---|---|---|---|---|---|---|
Syntax: | {label:} | DIVUL | Wm, | Wn | ||||
Operands: | Wn ∈ [W0 ... W14], Wm ∈ [W0 ... W13] | |||||||
Operation: | 32/32; Wm = Dividend, Wn = Divisor: Wm / Wn → Wm; Remainder → W(m+1) | |||||||
Status Affected: | C, N, OV, Z | |||||||
Encoding: | 1110 | 101U | wwww | ssss | UUUU | UUUU | UUUU | 0111 |
Description: | Iterative, unsigned integer 32-bit by 32-bit divide to a 32-bit quotient and a 32-bit remainder. This instruction must be executed ten times to generate the correct quotient and remainder. This may only be achieved by executing a REPEAT with an iteration count of nine (i.e. 9+1 iterations in all) and the DIVUL instruction as its target. The REPEAT loop may be interrupted at any iteration boundary. C is modified as per the divide algorithm. Z is set if the remainder is clear. Z is cleared otherwise. N is always cleared. OV is always cleared because an overflow is not possible. The ‘w’ bits select the source (dividend) register. The ‘s’ bits select the source (divisor) register. Note:
| |||||||
I-Words: | 1 | |||||||
Cycles: | 10 |
DTB | Decrement, Test and Branch | |||||||
---|---|---|---|---|---|---|---|---|
Syntax: | {label:} | DTB | Wn, | Label | ||||
Operands: | Wn ∈ [W0 ... W14]; Label is resolved by the linker to a signed word offset (slit16) | |||||||
Operation: | Wn = Wn - 1; If (Wn != 0 [see text]) then { If slit16 = 1 then skip next (16-bit) instruction Else if (slit16 = 2 && next_op[31] = 1) then skip next (32-bit) instruction Else (PC+4) + 2*slit16 → PC } Else No branch | |||||||
Status Affected: | None | |||||||
Encoding: | 1011 | 100U | ssss | nnnn | nnnn | nnnn | nnnn | UU01 |
Description: | Decrement Wn[31:0] and write result back to Wn (see note 2). Test Wn[31:0] after decrement and branch to target address if Wn[31:0] != 0. Do not branch when Wn[31:0] = 0. When utilized as a code block loop counter where DTB is located at the end of the loop, DTB will iterate the loop (i.e., branch) Wn times and will exit the loop with Wn = 0x0000_0000 (see note 2). If the branch condition is met, then the instruction will either skip the next 16-bit or 32-bit instruction, or it will branch to any size of instruction with a forward or backward range of 64KB. If the 2’s complement byte offset value ‘2*slit16’ (the PC offset) equals two, the conditional branch will execute as a conditional skip of one 16-bit instruction. This instruction will be speculatively executed as not skipped until such time that the branch decision can be determined. If the 2’s complement byte offset value ‘2*slit16’ (the PC offset) equals four and the instruction after the branch is a 32-bit opcode (see note), the conditional branch will execute as a conditional skip of that 32-bit instruction. This instruction will be speculatively executed as not skipped until such time that the branch decision can be determined. If requirements for a conditional skip are not met, the 2’s complement byte offset value ‘2*slit16’ is added to the PC to create a new PS word address. Since the PC will have incremented to fetch the next instruction, the new address will be (PC+4) + 2*slit16. Branch prediction is based on the direction of the branch. If the branch is backwards (negative), it will be predicted as taken. If the branch is forwards (positive), it will be predicted as not taken. The two instructions that follow the branch will then be speculatively executed in the predicted path until such time that the actual branch decision can be assessed. A correctly predicted branch will continue instruction execution in the same path unabated. An incorrectly predicted branch will abort the speculatively executed instructions and start execution from the correct path. The ‘n’ bits are a signed literal that specifies the number of PS words offset from (PC+4). Note:
| |||||||
I-Words: | 1 | |||||||
Cycles: | 1 (2 or 3) Note: The taken branch target instruction fetch is not executed if an exception is pending, making effective instruction execution time one cycle. |
Example:1 | Address | Label | Instruction | Comment | |
---|---|---|---|---|---|
0x804000 | MOV.l #8, w6 | ;Update loop counter | |||
0x804004 | _START_BUTTERFLY: | MOV.l #1, W4 | ;Start of loop | ||
0x804008 | - | SL.l w4, w6, w4 | |||
0x80400C | - | . . . | |||
. . . | - | . . . | |||
0x804040 | - | DTB W6, _START_BUTTERFLY | ;Branch to 0x804004 if w6 != 0 |