Page 1 of 1

Re: Beginner's ASM Tutorial: Multiplatform Z80 ASM development videos... with vampires!

Posted: Thu May 10, 2018 1:58 am
by Wall_Axe
ohh you mean '9 and 9' in 2 nibbles
this does make outputting numbers to the screen a lot easier

Re: Beginner's ASM Tutorial: Multiplatform Z80 ASM development videos... with vampires!

Posted: Thu May 10, 2018 4:34 pm
by AndyC
Wall_Axe wrote: Thu May 10, 2018 1:58 am ohh you mean '9 and 9' in 2 nibbles
this does make outputting numbers to the screen a lot easier
Yup. BCD is very handy when it comes to numbers you display on screen.

Re: Beginner's ASM Tutorial: Multiplatform Z80 ASM development videos... with vampires!

Posted: Thu May 24, 2018 2:01 pm
by RMartins
keith56 wrote: Sun Mar 11, 2018 7:18 am It's quite curious how the different systems use the shadow registers
in my game, I use DI/EI when I use the shadow registers in a normal loop, but two EXX 'es and DI/EI are pretty much the same speed as a PUSH/POP, so there's rarely any cases it's worthwhile.
it seems interrupt handlers on most do not alter them, but the CPC does, I wonder what the 'best' way to use them overall is?
I believe you are not equating all the variables here, and mixing a few concepts.

DI/EI (4T/4T), just controls if maskable interrupts are enabled or not.
Nothing to do with preserving register contents. You can still receive an NMI in the middle of the loop.

NOTE: This is one of the reasons, why assembly tricks using the stack register (SP) and PUSH/POP can be dangerous on machines that have support for NMIs. Any ZX Spectrum can have NMIs being generated, by an external interface, like DivMMC for example.

EX Af, Af' (4T)
EXX (4T)
These are used to SWAP between the register banks, they do not save anything anywhere.

These were designed/created for REAL TIME applications, where time spent inside an interrupt routine is crucial, and must be very low, so these systems, usually, reserve the shadow registers, to be used inside the interrupt routine, to avoid having to backup the registers before using them.
This obviously reduces the number of register you can use in regular programming.

PUSH RR/ POP RR (11T/10T)
These actually, allow you to save the registers on stack, or somewhere else you might move the stack to.
However, to save the registers, and then restore them, you will need a lot of operations:

Code: Select all

PUSH AF
PUSH BC
PUSH DE
PUSH HL

... do the interrupt magic here

POP HL
POP DE
POP BC
POP AF
For the same registers, that you use EX AF, AF and EXX, you will need:
4 * 11T + 4 * 10T = 44 + 40 = 88T

Which is a lot different from 4 + 4 = 8T, for the Swap instructions.

NOTE: I did not include PUSH/POP for IX and IY, to be fair on the comparison.

Re: Beginner's ASM Tutorial: Multiplatform Z80 ASM development videos... with vampires!

Posted: Thu May 24, 2018 6:41 pm
by RMartins
Just a correction, for the Swap instructions, we need 4 instructions, not 2:

Code: Select all

EX AF, AF'
EXX

... do the interrupt magic here

EX AF, AF'
EXX
Which is ( 4 + 4 ) + ( 4 + 4 ) = 16T
Still a long way from the 88T for the PUSH/POP solution.

Re: Beginner's ASM Tutorial: Multiplatform Z80 ASM development videos... with vampires!

Posted: Sun Oct 28, 2018 12:27 pm
by g0blinish
RMartins wrote: Thu May 24, 2018 6:41 pm Just a correction, for the Swap instructions, we need 4 instructions, not 2:

Code: Select all

EX AF, AF'
EXX

... do the interrupt magic here

EX AF, AF'
EXX
Which is ( 4 + 4 ) + ( 4 + 4 ) = 16T
Still a long way from the 88T for the PUSH/POP solution.
unsafe solution. If you are using music player into interrupt, alt pairs may changed