Skip to content

Docs: the DSP div step leaves half the quotient for a 48-bit dividend - #1938

Merged
repeat98 merged 3 commits into
repeat98:mainfrom
Jacobphono:docs/dsp-div-half-quotient
Nov 21, 2026
Merged

repeat98 merged 3 commits into
repeat98:mainfrom
Jacobphono:docs/dsp-div-half-quotient

Conversation

@Jacobphono

Copy link
Copy Markdown
Contributor
  • What was wrong or hard: The DSP56300 div step is a fractional divide. With a 48-bit dividend's high word in a1 and low word in a0, carry cleared (andi #$fe,ccr) and 24 div x0,a steps, a0 holds floor((dividend / 2) / divisor), not floor(dividend / divisor). Nothing in the guides says so. While building Ghost Cut (Ghost Cut 0.1.0-experimental (draft): a tempo-synced microlooper on FX2 #1935) its tempo-synced loop lengths silently came out half as long until the table held 2N (see the TABLE comment in sdk/drafts/ghost-cut/ghost_cut_ref.py on that branch).
  • What this changes: One line under Traps in docs/module-guides/effects.md: the half quotient, and the two ways to get N / D (shift the dividend left once with asl a, or store 2N). sdk/octabam/AGENTS.md is untouched. Changelog: changelog/2026-11-21-dsp-div-half-quotient.md.
  • How I checked it: The behaviour was measured in dsp_host on Ghost Cut's loop length and matches the fractional arithmetic (a 47-bit fraction over a 23-bit fraction leaves a 23-bit quotient, one bit short of the integer one). Could a check catch it instead? No: storing N or 2N is a semantic choice, so no source gate can tell which quotient a module meant. What caught it is the module's own reference model compared sample for sample with dsp_host, which the line points to. npm run pr:ready is Ready.
  • Tested on a unit: Not tested on a unit: a guide line only, no built package or base changes.
  • Edge cases: none, because no built package or base changes.
  • What the guides lacked or got wrong, and where I fixed it: the effects guide lacked this trap; this PR adds it in docs/module-guides/effects.md.

🤖 Generated with Claude Code

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions github-actions Bot added the documentation Improvements or additions to documentation label Nov 21, 2026
@repeat98

Copy link
Copy Markdown
Owner

Thanks for pulling this into the effects guide. Could you scope the shortcut to the positive operands used by Ghost Cut and say that doubling the dividend still has to leave the fractional quotient in range? The DSP56300 manual’s DIV entry requires a nonzero divisor and a dividend whose fractional magnitude is smaller than the divisor’s. Without that qualifier, the line reads as a recipe for any 48-bit input. DSP56300 Family Manual, DIV

@repeat98
repeat98 marked this pull request as ready for review November 21, 2026 16:24
@repeat98
repeat98 merged commit ece55d6 into repeat98:main Nov 21, 2026
21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants