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 - 07.03.2025, 16:09
RE: The LeapYear - by Dale Yarker - 07.03.2025, 23:49
RE: The LeapYear - by Andy Dee - 08.03.2025, 01:00
RE: The LeapYear - by Dale Yarker - 08.03.2025, 08:50
RE: The LeapYear - by Andy Dee - 08.03.2025, 11:57
RE: The LeapYear - by Dale Yarker - 08.03.2025, 12:06
RE: The LeapYear - by Andy Dee - 08.03.2025, 15:05
RE: The LeapYear - by Andy Dee - 08.03.2025, 20:34
RE: The LeapYear - by Andy Dee - 09.03.2025, 00:41
RE: The LeapYear - by Dale Yarker - 09.03.2025, 05:30
RE: The LeapYear - by Andy Dee - 09.03.2025, 17:01
RE: The LeapYear - by Dale Yarker - 09.03.2025, 21:18

Forum Jump:


Users browsing this thread: 2 Guest(s)