Okay, I have a new theory about the BCD string operations.
Let's assume that it uses the internal loop counter, and the loop counter always counts down, but it always counts down by one.
So to initialize the loop counter, we'd use (CL+1)>>1 Because we can only read a whole byte. So if CL==1, 2>>1 = 1 byte. If CL==2, 3>>1 = also 1 byte. And so on.
(255+1)>>1 overflows to 0, and (0+1)>>1 is also 0. My guess is that the loop counter is decremented before it is checked against 0, so when initialized to 0 it underflows. But the loop counter is internally16 bits. So maybe the instructions don't run forever - the validator has an instruction timeout of 100,000 cycles, but if we're running through the whole 65k of a loop counter we could be going for a ride of over a million cycles.
EDIT:
Aaand there we go. CL=255 terminated after 1,441,867 cycles.
Code:
01441867 [401FF:00100] M:... I:... P:.. PASV T1 [90909090] |
01441868 [401FF:00100] M:... I:... P:.. PASV T1 F[909090 ] q-> 90 | NOP @ [F0104]
01441869 [401FF:00100] M:... I:... P:.. PASV T1 [909090 ] |
01441870 A:[F0108:F0108] M:... I:... P:.. CODE T1 [909090 ] |
Not quite sure where we arrive at that exact figure. V20 documentation states that execution time is 19n, which would put us at 1,245,165. 1441867 is extremely close to 22n. Could the documentation have the wrong cycle counts?
Code:
01441821 A:[1FFFE:1FFFE] M:... I:... P:.. MEMR T1 [90909090] |
01441822 [1FFFE:3FFFE] DS M:R.. I:... P:.. MEMR T2 [90909090] |
01441823 [1FFFE:3FF00] DS M:R.. I:... P:.. PASV T3 r-> 00 [90909090] |
01441824 [1FFFE:3FF00] DS M:... I:... P:.. PASV T4 [90909090] |
01441825 [1FFFE:3FF00] M:... I:... P:.. PASV T1 [90909090] |
01441826 [1FFFE:3FF00] M:... I:... P:.. PASV T1 [90909090] |
01441827 [1FFFE:3FF00] M:... I:... P:.. PASV T1 [90909090] |
01441828 A:[401FE:401FE] M:... I:... P:.. MEMR T1 [90909090] |
01441829 [401FE:001FE] ES M:R.. I:... P:.. MEMR T2 [90909090] |
01441830 [401FE:00100] ES M:R.. I:... P:.. PASV T3 r-> 00 [90909090] |
01441831 [401FE:00100] ES M:... I:... P:.. PASV T4 [90909090] |
01441832 [401FE:00100] M:... I:... P:.. PASV T1 [90909090] |
01441833 [401FE:00100] M:... I:... P:.. PASV T1 [90909090] |
01441834 [401FE:00100] M:... I:... P:.. PASV T1 [90909090] |
01441835 [401FE:00100] M:... I:... P:.. PASV T1 [90909090] |
01441836 [401FE:00100] M:... I:... P:.. PASV T1 [90909090] |
01441837 A:[401FE:401FE] M:... I:... P:.. MEMW T1 [90909090] |
01441838 [401FE:00100] ES M:.A. I:... P:.. MEMW T2 [90909090] |
01441839 [401FE:00100] ES M:.AW I:... P:.. PASV T3 <-w 00 [90909090] |
01441840 [401FE:00100] ES M:... I:... P:.. PASV T4 [90909090] |
01441841 [401FE:00100] M:... I:... P:.. PASV T1 [90909090] |
01441842 [401FE:00100] M:... I:... P:.. PASV T1 [90909090] |
01441843 A:[1FFFF:1FFFF] M:... I:... P:.. MEMR T1 [90909090] |
It certainly looks like one iteration is 22 cycles.