Insanity #07
17 августа 2000

Influence team OUTD to carry flag - Ivan Roshchin discovers nedokumenirovanye vozomzhnosti processor Z80.

<b>Influence team OUTD to carry flag</b> - 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:

Light Future News - news as a sign of the time: about prestoyaschem CC'2000, last ASCII, etc.

LFG Assembly'2000 - Training before SS'2000 (a story of Perm party).

tea and mere mortals - CyberJack shows on your fingers how to write a simple game.

Last Weekend - the history of Izhevsk printed newspaper for the Spectrum: ZX Weekend.

Influence team OUTD to carry flag - Ivan Roshchin discovers nedokumenirovanye vozomzhnosti processor Z80.

Clive Sinclair - Pages from the life of the creator of the Spectrum: Clive Sinclair.

Steelworkers Spectrum - the story of today's routine of Western firms, once producing games for the Spectrum.

with the bat on the world - Reflections on "The Spectrum would die only if the latter goes spektrumist.

Legend of nowhere - Orc'a monologue on the theme "At the scene of chaos ... Again: Who said that?"

Mania & Fobia - The final diagnosis INSTantsiY.

Da Real Life VS Computing - "... we were sitting at their computers, and life there peshochkom past us jumped Skokie.

Insanity Jokez - Collected okolostsenovyh anecdotes.

Cybernetic Punk Culture - Hollywood in virtual reality.

Kraftwerk - Techno culture: "the story of how an electronic music became the music of our time. "


Темы: Игры, Программное обеспечение, Пресса, Аппаратное обеспечение, Сеть, Демосцена, Люди, Программирование

Similar articles:
Iron - a beginner: Lessons from soldering.
Likbez - a full disassembler ROM (part 26).

В этот день...   5 May