Insanity #07
17 августа 2000 |
|
Influence team OUTD to carry flag - Ivan Roshchin discovers nedokumenirovanye vozomzhnosti processor Z80.
- - - - - --- ---- - - - - --- --- - - - - - Influence on the team OUTD carry flag - - - - - --- ---- - - - - --- --- - - - - - $% Ivan Roshchin When writing a program it took me most optimally (by volume) to implement a data record in the first 11 Music coprocessor registers of the memory # 8000 - # 800A. At first I did it this way: LD HL, # 800A M1 LD BC, # FFFD OUT (C), L LD B, # BF OUTD BIT 7, L JR Z, M1 In the trace, I noticed that the last repetition of the cycle after the command flag OUTD C was equal to 1 (as in previous Repeat cycle he was dropped). Naturally, this fact was there also used for the optimization: LD HL, # 800A M1 LD BC, # FFFD OUT (C), L LD B, # BF OUTD JR NC, M1 I was wondering why this happens, and I decided More details to understand this question ... In the various references about the influence of team OUTD on flags written that, firstly, it sets a flag in the N, and Secondly, if as a result of the command register B reset, the flag Z = 1, otherwise it is 0. About the other flags said only that their values after executing the command does not defined. I assumed that the carry flag is set, when decreasing HL varies register H (as in the example above, When HL decreases with # 8000 to # 7FFF). During experiments it was confirmed, but under one condition: that the cell memory addressability HL, must not be 0. If there is 0 then C flag will always be reset. Knowledge of this particular Z80 can in some cases cut the program and reduce the time of its execution. Reduced above example illustrates this. Maybe someone is useful: it happens because that creating intro lacks all one or two of free bytes of memory ... By the way, at the same time it became clear that the flag N is set to 1 not always. Here, check for yourself: when HL = # 8000, (HL) = 0, BC = # BFFD, after the team OUTD N flag will be cleared. A fairly the same values of registers placed in the (HL), for example, # FF - and after OUTD this flag will be set. The experiments were performed on the original Z80 CPU ZiLOG firms and domestic counterparts KR1858VM1. These features of the Z80 is quite natural to use checking for the program under the emulator. Well, if you apply them to optimize their programs, be prepared to the fact that the emulator it will not work ... I understand that maybe someone has already conducted similar research, and for him I have written is not a secret (and certainly knew about it, developers Z80). But I am a information never met, and I decided to make it available public. ...
Other articles:
Similar articles:
В этот день... 21 November