Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Cargas de Produndidad / Depth Charge
#9
How the heck is the compiled code faster than the ASM one? *blink*

I thought the ASM one was pretty optimal - I can't see how to do it faster. I must check that. Are you sure it's working correctly (if too fast) with it?

The ASM one does:

DI - disable interrupts. Just for a moment, it stops the clock. This means it can't tick mid measure. Technically it will lose a frame very very _very_ rarely, but in practice nobody would notice. It's a safety device to make all the bytes consistent while we read it.

LD DE, (23674) - The clock is at 23672,23763,23674. This loads D up with (23675) and E up with (23674). The contents of 23675 are redundant - it's a 3 byte clock, so we clear D with
LD D,0
LD HL, (23672) loads H with (23673) and L with (23672).
EI - Put interrupts back. We've got our numbers.
end ASM
Back to normal.

So all we've done is copy the clock bytes into DEHL (well, 0+E+H+L)
Since the function returns a uLong, which is 4 bytes in DEHL, it returns this number.

Boriel's peek method is technically not interrupt safe, by the way, though the probability of an interrupt hitting right in the middle of those small set of instructions is fairly low. That said, it's going to happen eventually.
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 3 Guest(s)