@web-font-path: "roboto-debian.css";
v2.2.0 (RP2040)
Loading...
Searching...
No Matches
pico_divider

Optimized 32 and 64 bit division functions accelerated by the RP2040 hardware divider. More...

## Files

file | divider.h
| High level APIs including combined quotient and remainder functions for 32 and 64 bit accelerated by the hardware divider.

## Functions

int32_t | div_s32s32 (int32_t a, int32_t b)
| Integer divide of two signed 32-bit values.
static int32_t | divmod_s32s32_rem (int32_t a, int32_t b, int32_t *rem)
| Integer divide of two signed 32-bit values, with remainder.
divmod_result_t | divmod_s32s32 (int32_t a, int32_t b)
| Integer divide of two signed 32-bit values.
uint32_t | div_u32u32 (uint32_t a, uint32_t b)
| Integer divide of two unsigned 32-bit values.
static uint32_t | divmod_u32u32_rem (uint32_t a, uint32_t b, uint32_t *rem)
| Integer divide of two unsigned 32-bit values, with remainder.
divmod_result_t | divmod_u32u32 (uint32_t a, uint32_t b)
| Integer divide of two unsigned 32-bit values.
int64_t | div_s64s64 (int64_t a, int64_t b)
| Integer divide of two signed 64-bit values.
int64_t | divmod_s64s64_rem (int64_t a, int64_t b, int64_t *rem)
| Integer divide of two signed 64-bit values, with remainder.
int64_t | divmod_s64s64 (int64_t a, int64_t b)
| Integer divide of two signed 64-bit values.
uint64_t | div_u64u64 (uint64_t a, uint64_t b)
| Integer divide of two unsigned 64-bit values.
uint64_t | divmod_u64u64_rem (uint64_t a, uint64_t b, uint64_t *rem)
| Integer divide of two unsigned 64-bit values, with remainder.
uint64_t | divmod_u64u64 (uint64_t a, uint64_t b)
| Integer divide of two signed 64-bit values.
int32_t | div_s32s32_unsafe (int32_t a, int32_t b)
| Unsafe integer divide of two signed 32-bit values.
int32_t | divmod_s32s32_rem_unsafe (int32_t a, int32_t b, int32_t *rem)
| Unsafe integer divide of two signed 32-bit values, with remainder.
divmod_result_t | divmod_s32s32_unsafe (int32_t a, int32_t b)
| Unsafe integer divide of two unsigned 32-bit values.
uint32_t | div_u32u32_unsafe (uint32_t a, uint32_t b)
| Unsafe integer divide of two unsigned 32-bit values.
uint32_t | divmod_u32u32_rem_unsafe (uint32_t a, uint32_t b, uint32_t *rem)
| Unsafe integer divide of two unsigned 32-bit values, with remainder.
divmod_result_t | divmod_u32u32_unsafe (uint32_t a, uint32_t b)
| Unsafe integer divide of two unsigned 32-bit values.
int64_t | div_s64s64_unsafe (int64_t a, int64_t b)
| Unsafe integer divide of two signed 64-bit values.
int64_t | divmod_s64s64_rem_unsafe (int64_t a, int64_t b, int64_t *rem)
| Unsafe integer divide of two signed 64-bit values, with remainder.
int64_t | divmod_s64s64_unsafe (int64_t a, int64_t b)
| Unsafe integer divide of two signed 64-bit values.
uint64_t | div_u64u64_unsafe (uint64_t a, uint64_t b)
| Unsafe integer divide of two unsigned 64-bit values.
uint64_t | divmod_u64u64_rem_unsafe (uint64_t a, uint64_t b, uint64_t *rem)
| Unsafe integer divide of two unsigned 64-bit values, with remainder.
uint64_t | divmod_u64u64_unsafe (uint64_t a, uint64_t b)
| Unsafe integer divide of two signed 64-bit values.

## Detailed Description

Optimized 32 and 64 bit division functions accelerated by the RP2040 hardware divider.

Additionally provides integration with the C / and % operators

## Function Documentation

## div_s32s32()

int32_t div_s32s32 | ( | int32_t | a,
|  | int32_t | b )

Integer divide of two signed 32-bit values.

Parameters

  a | Dividend
  b | Divisor

Returns
  quotient

## div_s32s32_unsafe()

int32_t div_s32s32_unsafe | ( | int32_t | a,
|  | int32_t | b )

Unsafe integer divide of two signed 32-bit values.

Parameters

  a | Dividend
  b | Divisor

Returns
  quotient

Do not use in interrupts

## div_s64s64()

int64_t div_s64s64 | ( | int64_t | a,
|  | int64_t | b )

Integer divide of two signed 64-bit values.

Parameters

  a | Dividend
  b | Divisor

Returns
  Quotient

## div_s64s64_unsafe()

int64_t div_s64s64_unsafe | ( | int64_t | a,
|  | int64_t | b )

Unsafe integer divide of two signed 64-bit values.

Parameters

  a | Dividend
  b | Divisor

Returns
  Quotient

Do not use in interrupts

## div_u32u32()

uint32_t div_u32u32 | ( | uint32_t | a,
|  | uint32_t | b )

Integer divide of two unsigned 32-bit values.

Parameters

  a | Dividend
  b | Divisor

Returns
  Quotient

## div_u32u32_unsafe()

uint32_t div_u32u32_unsafe | ( | uint32_t | a,
|  | uint32_t | b )

Unsafe integer divide of two unsigned 32-bit values.

Parameters

  a | Dividend
  b | Divisor

Returns
  Quotient

Do not use in interrupts

## div_u64u64()

uint64_t div_u64u64 | ( | uint64_t | a,
|  | uint64_t | b )

Integer divide of two unsigned 64-bit values.

Parameters

  a | Dividend
  b | Divisor

Returns
  Quotient

## div_u64u64_unsafe()

uint64_t div_u64u64_unsafe | ( | uint64_t | a,
|  | uint64_t | b )

Unsafe integer divide of two unsigned 64-bit values.

Parameters

  a | Dividend
  b | Divisor

Returns
  Quotient

Do not use in interrupts

## divmod_s32s32()

divmod_result_t divmod_s32s32 | ( | int32_t | a,
|  | int32_t | b )

Integer divide of two signed 32-bit values.

Parameters

  a | Dividend
  b | Divisor

Returns
  quotient in low word/r0, remainder in high word/r1

## divmod_s32s32_rem()

int32_t divmod_s32s32_rem | ( | int32_t | a,
|  | int32_t | b,
|  | int32_t * | rem )

inline static

Integer divide of two signed 32-bit values, with remainder.

Parameters

  | a | Dividend
  | b | Divisor
  [out] | rem | The remainder of dividend/divisor

Returns
  Quotient result of dividend/divisor

## divmod_s32s32_rem_unsafe()

int32_t divmod_s32s32_rem_unsafe | ( | int32_t | a,
|  | int32_t | b,
|  | int32_t * | rem )

Unsafe integer divide of two signed 32-bit values, with remainder.

Parameters

  | a | Dividend
  | b | Divisor
  [out] | rem | The remainder of dividend/divisor

Returns
  Quotient result of dividend/divisor

Do not use in interrupts

## divmod_s32s32_unsafe()

divmod_result_t divmod_s32s32_unsafe | ( | int32_t | a,
|  | int32_t | b )

Unsafe integer divide of two unsigned 32-bit values.

Parameters

  a | Dividend
  b | Divisor

Returns
  quotient in low word/r0, remainder in high word/r1

Do not use in interrupts

## divmod_s64s64()

int64_t divmod_s64s64 | ( | int64_t | a,
|  | int64_t | b )

Integer divide of two signed 64-bit values.

Parameters

  a | Dividend
  b | Divisor

Returns
  quotient in result (r0,r1), remainder in regs (r2, r3)

## divmod_s64s64_rem()

int64_t divmod_s64s64_rem | ( | int64_t | a,
|  | int64_t | b,
|  | int64_t * | rem )

Integer divide of two signed 64-bit values, with remainder.

Parameters

  | a | Dividend
  | b | Divisor
  [out] | rem | The remainder of dividend/divisor

Returns
  Quotient result of dividend/divisor

## divmod_s64s64_rem_unsafe()

int64_t divmod_s64s64_rem_unsafe | ( | int64_t | a,
|  | int64_t | b,
|  | int64_t * | rem )

Unsafe integer divide of two signed 64-bit values, with remainder.

Parameters

  | a | Dividend
  | b | Divisor
  [out] | rem | The remainder of dividend/divisor

Returns
  Quotient result of dividend/divisor

Do not use in interrupts

## divmod_s64s64_unsafe()

int64_t divmod_s64s64_unsafe | ( | int64_t | a,
|  | int64_t | b )

Unsafe integer divide of two signed 64-bit values.

Parameters

  a | Dividend
  b | Divisor

Returns
  quotient in result (r0,r1), remainder in regs (r2, r3)

Do not use in interrupts

## divmod_u32u32()

divmod_result_t divmod_u32u32 | ( | uint32_t | a,
|  | uint32_t | b )

Integer divide of two unsigned 32-bit values.

Parameters

  a | Dividend
  b | Divisor

Returns
  quotient in low word/r0, remainder in high word/r1

## divmod_u32u32_rem()

uint32_t divmod_u32u32_rem | ( | uint32_t | a,
|  | uint32_t | b,
|  | uint32_t * | rem )

inline static

Integer divide of two unsigned 32-bit values, with remainder.

Parameters

  | a | Dividend
  | b | Divisor
  [out] | rem | The remainder of dividend/divisor

Returns
  Quotient result of dividend/divisor

## divmod_u32u32_rem_unsafe()

uint32_t divmod_u32u32_rem_unsafe | ( | uint32_t | a,
|  | uint32_t | b,
|  | uint32_t * | rem )

Unsafe integer divide of two unsigned 32-bit values, with remainder.

Parameters

  | a | Dividend
  | b | Divisor
  [out] | rem | The remainder of dividend/divisor

Returns
  Quotient result of dividend/divisor

Do not use in interrupts

## divmod_u32u32_unsafe()

divmod_result_t divmod_u32u32_unsafe | ( | uint32_t | a,
|  | uint32_t | b )

Unsafe integer divide of two unsigned 32-bit values.

Parameters

  a | Dividend
  b | Divisor

Returns
  quotient in low word/r0, remainder in high word/r1

Do not use in interrupts

## divmod_u64u64()

uint64_t divmod_u64u64 | ( | uint64_t | a,
|  | uint64_t | b )

Integer divide of two signed 64-bit values.

Parameters

  a | Dividend
  b | Divisor

Returns
  quotient in result (r0,r1), remainder in regs (r2, r3)

## divmod_u64u64_rem()

uint64_t divmod_u64u64_rem | ( | uint64_t | a,
|  | uint64_t | b,
|  | uint64_t * | rem )

Integer divide of two unsigned 64-bit values, with remainder.

Parameters

  | a | Dividend
  | b | Divisor
  [out] | rem | The remainder of dividend/divisor

Returns
  Quotient result of dividend/divisor

## divmod_u64u64_rem_unsafe()

uint64_t divmod_u64u64_rem_unsafe | ( | uint64_t | a,
|  | uint64_t | b,
|  | uint64_t * | rem )

Unsafe integer divide of two unsigned 64-bit values, with remainder.

Parameters

  | a | Dividend
  | b | Divisor
  [out] | rem | The remainder of dividend/divisor

Returns
  Quotient result of dividend/divisor

Do not use in interrupts

## divmod_u64u64_unsafe()

uint64_t divmod_u64u64_unsafe | ( | uint64_t | a,
|  | uint64_t | b )

Unsafe integer divide of two signed 64-bit values.

Parameters

  a | Dividend
  b | Divisor

Returns
  quotient in result (r0,r1), remainder in regs (r2, r3)

Do not use in interrupts