# `divsl`

[M68K Documentation](https://asm-editor.specy.app/documentation/m68k.md) › [Instructions](https://asm-editor.specy.app/documentation/m68k/instruction.md)

Web page: https://asm-editor.specy.app/documentation/m68k/instruction/divsl

**Signed divide long, with remainder** · 68020

Category: Arithmetic

Divides a long by a long, signed, putting the quotient in one data register and the remainder in another.

Size .l · 68020 only: select `opt p=68020` before any code or data

## Flags

| Flag | Effect |
| --- | --- |
| X | not changed |
| N | undefined (do not rely on it) |
| Z | undefined (do not rely on it) |
| V | depends on the result |
| C | always 0 |

After a division that does not overflow, N and Z describe the quotient.

## Forms

- `divsl <ea>, Dr:Dq`
  - Source: Dn, (An), (An)+, -(An), d(An), d(An,Xn), abs, d(PC), d(PC,Xn), #imm (data)

## Operands

- [`<ea>`](https://asm-editor.specy.app/documentation/m68k/addressing-mode.md): An operand using one of the addressing modes listed for this form. The list determines whether it can be a register, memory or an immediate value. With `opt p=68020`, an allowed `d(An,Xn)` or `d(PC,Xn)` mode also permits the corresponding 68020 indexed and memory indirect forms. See [68020 addressing](https://asm-editor.specy.app/documentation/m68k/addressing-mode/68020.md).
- [`Dr:Dq`](https://asm-editor.specy.app/documentation/m68k/addressing-mode/register-pairs.md): A remainder register followed by a quotient register, for example `d2:d1`. For `divs.l` and `divu.l`, both supply the 64-bit dividend, high long first. For `divsl.l` and `divul.l`, only `Dq` supplies the 32-bit dividend. The quotient replaces `Dq` and the remainder replaces `Dr`.
- [`#imm`](https://asm-editor.specy.app/documentation/m68k/addressing-mode/immediate.md): An immediate value written after `#`: a number, character or label, such as `#10`, `#$FF` or `#'a'`. It must fit the operation’s size: byte `-128` to `255`, word `-32768` to `65535`, or long `-2147483648` to `4294967295`; signed and unsigned spellings are accepted.

## Description

In `divsl.l <ea>, Dr:Dq`, `Dq` supplies the dividend. The old value of `Dr` is not used. The quotient replaces `Dq` and the remainder replaces `Dr`. The remainder has the dividend’s sign: -7 divided by 2 gives quotient -3 and remainder -1.

Use different registers to keep both results. If `Dr` and `Dq` name the same register, only the quotient remains. This uses the same 32-bit dividend as the single-register form of [divs.l](https://asm-editor.specy.app/documentation/m68k/instruction/divs.md). The register-pair form of `divs.l` takes a 64-bit dividend instead.

A zero divisor raises a division-by-zero exception through vector 5 at `$14`. The only signed 32-bit quotient overflow, -2147483648 divided by -1, sets V and leaves the registers unchanged. Otherwise V is cleared and N and Z describe the quotient. C is cleared and X is unchanged.

## Example

```m68k
opt p=68020
* --- A quotient and a remainder of 32 bits ---
move.l #-100007, d2 ; the number to divide
divsl.l #10, d1:d2 ; d2 = -10000, and the remainder has its sign: d1 = -7
```
