The LeapYear
#10
Arithmetic ops by powers of 2 can be done a bit faster by not using *, \ or MOD (likely you know of 2 them). For example:
X * 4 can be SHIFT LEFT X, 2
X \ 4 can be SHIFT RIGHT X, 2
X MOD 4 can be X AND 3

Those can be done in BASIC code so difference between BASIC and ASM timing may be made smaller.

MOD is a divide with the remainder returned instead of the quotient.
Your BASIC code can be quicker with MOD 100 and MOD 400 than 2 divides by 100 and 2 divides by 400.

In ASM the DIV instruction returns both quotient and remainder. 100 is not a power 0f 2, so had to divide by 100. The remainder used as MOD 100 and quotient used with X AND as MOD 400.

The 1,15 times faster for 1204 and 1201 shows how small the difference is between MOD and AND.

------------------------------------------------------

I think my ASM can be speeded up a tiny bit by removing 3 PUSHes and 3 POPs. (iJahr should stay in the stack, not be made a register variable.)
If PBDOS had $REGISTER NONE I'd have used it just to make sure. Also, "make it work first", then try reversible changes.
Reply


Messages In This Thread
The LeapYear - by Andy Dee - 03-07-2025, 04:09 PM
RE: The LeapYear - by Dale Yarker - 03-07-2025, 11:49 PM
RE: The LeapYear - by Andy Dee - 03-08-2025, 01:00 AM
RE: The LeapYear - by Dale Yarker - 03-08-2025, 08:50 AM
RE: The LeapYear - by Andy Dee - 03-08-2025, 11:57 AM
RE: The LeapYear - by Dale Yarker - 03-08-2025, 12:06 PM
RE: The LeapYear - by Andy Dee - 03-08-2025, 03:05 PM
RE: The LeapYear - by Andy Dee - 03-08-2025, 08:34 PM
RE: The LeapYear - by Andy Dee - 03-09-2025, 12:41 AM
RE: The LeapYear - by Dale Yarker - 03-09-2025, 05:30 AM
RE: The LeapYear - by Andy Dee - 03-09-2025, 05:01 PM
RE: The LeapYear - by Dale Yarker - 03-09-2025, 09:18 PM

Forum Jump:


Users browsing this thread: 3 Guest(s)