4.5 Instruction Descriptions (C to DTB)

CALL Call Subroutine
Syntax:{label:}CALLlit24
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:1101111nnnnnnnnnnnnnnnnnnnnnnn10
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:1AddressLabelInstruction Comment
0x804000 - CALL _CHECK_FAIL; Calls function in address 0x805000(_CHECK_FAIL)
. . .
0x805000_CHECK_FAILMOV.l SR, W6; _CHECK_FAIL SubRoutine
. . . CP w6, w7
. . . . . .
Before executionAfter execution
PC0x804000PC0x805000
w150x4500w150x4504
Data @45000x0000Data @45000x804004
SR0x00000000SR0x00000000
CALLCall Indirect Subroutine
Syntax:{label:}CALLWns
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:1101011UUUUUssssUUUUUUUUUUUU1110
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:
  1. If Wns[31:24] !=8’h00, an address error trap will be initiated.
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:1AddressLabelInstruction 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 executionAfter execution
PC0x804000PC0x805000
W00x805000PC0x805000
w150x4500w150x4504
Data @45000x0000Data @45000x804004
SR0x00000000SR0x00000000
CLR Clear Accumulator
Syntax: {label}CLRA
B
Operands:None
Operation:0 → ACC(A or B)
Status Affected:OA,SA or OB,SB
Encoding:0111001AUUUU1100
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

ACCA0x00_0012_3412_4524_1234ACCA0x00_0000_0000_0000_0000
CLRClear f
Syntax:{label:}CLR.bf
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:1010011LffffffffffffffffffffB101
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:
  1. Same flow as any other file operation with D-bit (opcode[2]) set to 1.
  2. Accessible file address space is 1MB.
I-Words:1
Cycles:1
Example 1:

CLR.B RAM200 ; Clear RAM200 (Byte mode)

Before Instruction

After Instruction

RAM2008009RAM2008000
SR0000SR0000
Example 2:

CLR WREG ; Clear WREG (Word mode)

Before Instruction

After Instruction

WREG0600WREG0000
SR0000SR0000
CLRWDTClear Watchdog Timer
Syntax:{label:}CLRWDT
Operands:None
Operation:0 → WDT Reg
Status Affected:None
Encoding:0111001UUUUU0101
Description:Clear the WatchDog Timer register.
I-Words:0.5
Cycles:1
COMComplement Ws
Syntax:{label:}COM.bWs,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:S111100LddddsssspppqqqUUUUUUBU00
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

W02301W02302
W12400W12401
Data 23005607 Data 23005607
Data 2400ABCD Data 2400ABA9
SR0000SR0008 (N = 1)
Example 2:

COM W0, [W1++] ; COM W0 and store to [W1] (Word mode)

; Post-increment W1

Before Instruction

After Instruction

W0D004W0D004
W11000W11002
Data 1000ABA9 Data 10002FFB
SR0000SR0000
COMComplement f
Syntax:{label:}COM.bf{,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:1101100LddddffffffffffffffffBD01
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

RAM20080FFRAM2008000
SR0000SR0002 (Z)
Example 2:

COM RAM400, WREG ; COM RAM400 and store to WREG

; (Word mode)

Before Instruction

After Instruction

WREG1211WREGF7DC
RAM4000823RAM4000823
SR0000SR0008 (N = 1)
CPCompare Wb with Ws, Set Status Flags
Syntax:{label:}CP.bWb,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:S011110LwwwwsssspppUUUUUUUUUBU00
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

W0ABA9W0ABA9
W12000W12001
Data 2000D004 Data 2000D004
SR0000SR0009 (N, C = 1)
Example 2:

CP W5, W6 ; Compare W6 with W5 (Word mode)

Before Instruction

After Instruction

W52334W52334
W68001W68001
SR0000SR000C (N, OV = 1)
CPBCompare Wb with Ws with Borrow, Set Status Flags
Syntax:{label:}CPB.bWb,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:S011111LwwwwsssspppUUUUUUUUUBU00
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
CPBCompare Ws with lit13 with Borrow, Set Status Flags
Syntax:{label:}CPB.bWs,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:S011101LkkkksssspppkkkkkkkkkBU00
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
CPCompare Ws with lit13, Set Status Flags
Syntax:{label:}CP.bWs,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:S011100LkkkksssspppkkkkkkkkkBU00
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
CPBCompare Wb with lit16 with Borrow, Set Status Flags
Syntax:{label:}CPB.bWb,lit16
CPB{.w}
CPB.l
Operands:Wb ∈ [W0 ... W15]; lit16 ∈ [0 ... 65535]
Operation:(Wb) - lit16 - (C)
Status Affected:C, N, OV, Z
Encoding:1100011LwwwwkkkkkkkkkkkkkkkkB110
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
CPCompare f with Ws, Set Status Flags
Syntax:{label:}CP.bf,Ws
CP{.w}
CP.l
Operands:f ∈ [0 ...64KB]; Ws ∈ [W0 ... W15]
Operation:(f) - (Ws)
Status Affected:C, N, OV, Z
Encoding:1010101LssssffffffffffffffffBU01
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
CP0Compare f with Zero, Set Status Flags
Syntax:{label:}CP0.bf
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:1010100LffffffffffffffffffffBU01
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

RAM10044C3RAM10044C3
SR0000SR0009 (N, C = 1)
Example 2:

CP0 0x1FFE ; Compare (0x1FFE) with 0x0 (Word mode)

Before Instruction

After Instruction

Data 1FFE0001Data 1FFE0001
SR0000SR0001 (C = 1)
CPBCompare f with Ws with Borrow, Set Status Flags
Syntax:{label:}CPB.bf,Ws
CPB{.w}
CPB.l
Operands:f ∈ [0 ...64KB]; Ws ∈ [W0 ... W15]
Operation:(f) - (Ws) - (C)
Status Affected:C, N, OV, Z
Encoding:1010110LssssffffffffffffffffBU01
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
CPCompare Wb with lit16, Set Status Flags
Syntax:{label:}CP.bWb,lit16
CP{.w}
CP.l
Operands:Wb ∈ [W0 ... W15]; lit16 ∈ [0 ... 65535]
Operation:(Wb) - lit16
Status Affected:C, N, OV, Z
Encoding:1100010LwwwwkkkkkkkkkkkkkkkkB110
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
CTXTSWPCPU 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:0111001UUkkk0110
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:1101100UUUUUssssUUUUUUUUUUUUU110
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:
  1. The contents of Wns[31:3] are ignored.
I-Words:1
Cycles:2
DECDecrement f
Syntax:{label:}DEC.bf{,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:1101011LddddffffffffffffffffBD01
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 20080FFData 20080FE
SR0000SR0009(N, C = 1)
Example 2:

DEC RAM400, WREG ; Decrement RAM400 and store to WREG

; (Word mode)

Before Instruction

After Instruction

WREG1211WREG0822
RAM4000823RAM4000823
SR0000SR0000
DEC2Decrement f by 2
Syntax:{label:}DEC2.bf{,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:1101111LddddffffffffffffffffBD01
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:} DISICTLlit3{ ,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:1101110UddddUUUUUUUqqqUUUkkk0W10
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:} DISICTLWns{ ,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:1101110UddddssssUUUqqqUUUUUU1W10
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
DIVFSigned Fractional 16/16 and 32/16 Divide
Syntax:{label:}DIVF.wWmWn
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:1110100LwwwwssssUUUUUUUUUUUU1011
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:
  1. The divisor is tested for zero during the first iteration. An attempt to divide by zero will initiate an arithmetic error trap during the first cycle of DIVF.x execution.
  2. Wn cannot share the same W-reg with Wm or W(m+1).
I-Words:1
Cycles:6
Example:1AddressLabelInstructionComment
0x804000 - REPEAT #5; Execute DIV 5 times.
0x804004 - DIVF.l w4, w8;Fractional Divide contents of W4 bycontents of W5
Before executionAfter execution
w40x1001w40x2000
w80x4000w80x4000
w50x0000w50x0001
SR0x00000000SR0x00000000
DIVFLSigned Fractional 32/32 Divide
Syntax:{label:}DIVFLWmWn
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:1110101UwwwwssssUUUUUUUUUUUU1011
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:
  1. The divisor is tested for zero during the first iteration. An attempt to divide by zero will initiate an arithmetic error trap during the first cycle of DIVFL execution.
  2. Wn cannot share the same W-reg with Wm or W(m+1).
I-Words:1
Cycles:10
DIVS Signed Integer 16/16 and 32/16 Divide
Syntax:{label:}DIVS.wWm,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:1110100LwwwwssssUUUUUUUUUUUU0011
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:
  1. The divisor is tested for zero during the first iteration. An attempt to divide by zero will initiate an arithmetic error trap during the first cycle of DIVS.x
  2. Wn cannot share the same W-reg with Wm or W(m+1).
I-Words:1
Cycles:6
Example:1AddressLabelInstruction Comment
0x804000 - REPEAT #5 ; Execute DIV 5 times.
0x804004 - DIVS.l w4, w8 ;Divide contents of W4 bycontents of W5
Before executionAfter execution
w40x3000w40x013B
w80x27w80x27
w50x0000w50x0003
SR0x00000000SR0x00000000
DIVSL Signed Integer 32/32 Divide
Syntax:{label:}DIVSLWm,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:1110101UwwwwssssUUUUUUUUUUUU0011
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:
  1. The divisor is tested for zero during the first iteration. An attempt to divide by zero will initiate an arithmetic error trap during the first cycle of DIVSL.
  2. Wn cannot share the same W-reg with Wm or W(m+1).
I-Words:1
Cycles:10
DIVU Unsigned Integer 16/16 and 32/16 Divide
Syntax:{label:}DIVU.wWm,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:1110100LwwwwssssUUUUUUUUUUUU0111
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:
  1. The divisor is tested for zero during the first iteration. An attempt to divide by zero will initiate an arithmetic error trap during the first cycle of DIVU.x
  2. Wn cannot share the same W-reg with Wm or W(m+1).
I-Words:1
Cycles:6
DIVUL Unsigned Integer 32/32 Divide
Syntax:{label:}DIVULWm,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:1110101UwwwwssssUUUUUUUUUUUU0111
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:
  1. The divisor is tested for zero during the first iteration. An attempt to divide by zero will initiate an arithmetic error trap during the first cycle of DIVUL.
  2. Wn cannot share the same W-reg with Wm or W(m+1).
I-Words:1
Cycles:10
DTBDecrement, Test and Branch
Syntax:{label:}DTBWn,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:1011100UssssnnnnnnnnnnnnnnnnUU01
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:
  1. Should the byte offset equal four and instruction after the branch is a 16-bit opcode, a branch will occur (over the next two 16-bit ops) if the condition is met.
  2. Execution of DTB when Wn = 0 will result in a loop count of 231.
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:1AddressLabelInstruction Comment
0x804000MOV.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