09-22-2021, 07:45 PM
(This post was last modified: 09-22-2021, 07:45 PM by maeloterkim.)
Hi
In the normal basic of zx spectrum 48k there is a behaviour or trick like this
you can change the address of DEFADD variable
and after this you can copy bytes very fast Is like an assembler LDIR
I will explain more
you can have 2 variables A$ and B$ for example
every one of this variables can have 1000 bytes
when you do A$ = B$ the 1000 bytes of B$ are copied on A$
Normally DEFADD points to the beginning of the variables definitions
for example (invented numbers)
DEFADD_POINTER_ADDRESS ;;'' defadd initial definitions of variables
A$ begins on 30000 and have 1000 bytes of size
B$ begins on 32000 and have 1000 bytes of size
etc ...
The trick is that in BASIC we can change the DEFADD address and put any thing
for example we can do
CHANGED_DEFADD_POINTER_ADDRESS ;;'' CHANGED defadd initial definitions of variables
A$ begins on 16384 and have 256 bytes of size
B$ begins on 32000 and have 256 bytes of size
etc ...
This way we can do A$ = B$ and copy 256 very fast to the screen !!!
this is better explained here in spanish
https://blog.jafma.net/2020/03/16/effici...m-iv/#sp_5
and here in english
https://blog.jafma.net/2020/03/16/effici...m-iv/#en_5
and here a video in spanish explaining this trick
https://www.youtube.com/watch?v=VKJ2dePykdA
I tried this trick with compiled zx basic but is not working because seems
that string variables are not doing the same behavior that original ROM
In the normal basic of zx spectrum 48k there is a behaviour or trick like this
you can change the address of DEFADD variable
and after this you can copy bytes very fast Is like an assembler LDIR
I will explain more
you can have 2 variables A$ and B$ for example
every one of this variables can have 1000 bytes
when you do A$ = B$ the 1000 bytes of B$ are copied on A$
Normally DEFADD points to the beginning of the variables definitions
for example (invented numbers)
DEFADD_POINTER_ADDRESS ;;'' defadd initial definitions of variables
A$ begins on 30000 and have 1000 bytes of size
B$ begins on 32000 and have 1000 bytes of size
etc ...
The trick is that in BASIC we can change the DEFADD address and put any thing
for example we can do
CHANGED_DEFADD_POINTER_ADDRESS ;;'' CHANGED defadd initial definitions of variables
A$ begins on 16384 and have 256 bytes of size
B$ begins on 32000 and have 256 bytes of size
etc ...
This way we can do A$ = B$ and copy 256 very fast to the screen !!!
this is better explained here in spanish
https://blog.jafma.net/2020/03/16/effici...m-iv/#sp_5
and here in english
https://blog.jafma.net/2020/03/16/effici...m-iv/#en_5
and here a video in spanish explaining this trick
https://www.youtube.com/watch?v=VKJ2dePykdA
I tried this trick with compiled zx basic but is not working because seems
that string variables are not doing the same behavior that original ROM