Search found 6 matches

by wsimms
Tue Jan 07, 2025 10:40 pm
Forum: Programming
Topic: A 6502 divide routine
Replies: 18
Views: 4908

Re: A 6502 divide routine

The worst cases in the divide routine that I have presented occur, ironically enough, when the divisor is a power of two. And the worst of the worst occurs when the divisor is 1 and the dividend is 32767. This case requires almost 2000 cycles to produce the result. For this reason, it seems ...
by wsimms
Fri Jan 03, 2025 4:49 am
Forum: Programming
Topic: A 6502 divide routine
Replies: 18
Views: 4908

Re: A 6502 divide routine

I have instrumented both my divide routine and the routine from BigDumbDinosaur to see how they compare in terms of time required...In tabular form:

Avg # cycles Min # cycles Max # cycles
wsimms divide: 198 81 1713
BigDumbDinosaur divide: 868 863 947
The shift-and-subtract method I use tends to ...
by wsimms
Thu Jan 02, 2025 10:44 pm
Forum: Programming
Topic: A 6502 divide routine
Replies: 18
Views: 4908

Re: A 6502 divide routine

I have instrumented both my divide routine and the routine from BigDumbDinosaur to see how they compare in terms of time required. The results are interesting, in my opinion.

When both dividend and divisor range from 1 to 4096, for a total of 16,777,216 divisions, my routine takes an average of 198 ...
by wsimms
Wed Jan 01, 2025 3:13 pm
Forum: Programming
Topic: A 6502 divide routine
Replies: 18
Views: 4908

Re: A 6502 divide routine

I want to present an integer division routine I have come up with...
Welcome to 6502-land. ... Anyhow, here’s a 16-bit division routine I concocted many years ago.
This was helpful. I wrote a wrapper program to call my routine and yours to compare the results and let them go over all dividends ...
by wsimms
Tue Dec 31, 2024 4:02 pm
Forum: Programming
Topic: A 6502 divide routine
Replies: 18
Views: 4908

Re: A 6502 divide routine

drogon wrote:
Interesting. Thanks. I'll have a look next year ...

However I think the JMP L0 at the very end might ought to be JMP L2 ?
You are correct. I have edited it.
by wsimms
Tue Dec 31, 2024 3:04 pm
Forum: Programming
Topic: A 6502 divide routine
Replies: 18
Views: 4908

A 6502 divide routine

I want to present an integer division routine I have come up with. I have to imagine the algorithm is already well known, but I am too lazy to go find the prior art. The reason I am presenting this algorithm is because it seems to be common sentiment online that 6502 divide routines are difficult to ...