Skip to content

Optimizing Long Multiplication (expr.c) and Long Division (expr.c) - #1

Open
ManuelAndre123 wants to merge 10 commits into
ManuelAndre123:masterfrom
mdbergmann:master
Open

ManuelAndre123 wants to merge 10 commits into
ManuelAndre123:masterfrom
mdbergmann:master

Conversation

@ManuelAndre123

@ManuelAndre123 ManuelAndre123 commented May 14, 2026 •

Copy link
Copy Markdown
Owner

Optimization consists of removing the fetch of a value from the stack into register Dn to perform Long Multiplications or Long Divisions.

Original Long Multiplication (expr.c)

 68020+: original code
   move.l  (sp)+,d1
   move.l  (sp)+,d0
   muls.l  d1,d0
   move.l  d0,-(sp)

Suggested optimization

68020+: optimized code

   move.l  (sp)+,d0
   muls.l  (sp)+d0
   move.l  d0,-(sp)
   
 Long Division (expr.c)
~~~~~~~~~~~~~~~~~~~~~~
68020+: original code
   move.l  (sp)+,d1
   move.l  (sp)+,d0
   divs.l  d1,d0
   move.l  d0,-(sp)

Suggested optimization

68020+: optimized code

  move.l  (sp)+,d0
  divs.l  (sp)+,d0
  move.l  d0,-(sp)


 Gain in CPU-cycles and other remarks
------------------------------------------

68020 ~2 cycles saved 
68030 ~2 cycles saved
68040 ~1 cycle  saved
68060 0–1 cycle saved

Remarks
----------
Enhances code density.
Minimizes register usage, 1 register usage gained
Great for benchmarking since every cycle counts.

mdbergmann and others added 10 commits April 11, 2026 09:56
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Walks through how the emitted 68000 assembly has changed since the start
of the project, organised around the nine commits that materially shifted
the compiler's output (020 opt, codegen abstraction, FFP→IEEE, GCC→VBCC,
ATOM, object system, TYPECASE, TASKPROC, bounded strings).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants