03-09-2025, 05:30 AM
(This post was last modified: 03-09-2025, 05:32 AM by Dale Yarker.)
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.
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.