Optron #30
03 сентября 1999

Likbez - Assembler view from afar: What shift?

<b>Likbez</b> - Assembler view from afar: What shift?
       Assembler - a view from afar


               Continued.

    Beginning at | | 20, 21, 24, 25, 28, 29

{} Infarh, 1999


              Teams shift


             What is the shift?


  The meaning of the shift is that all the bits in a byte, 
without changing its position relative to each other, move left 
or right. A zavsimosti in the type of command bits, leaving the 
edge of the "byte may appear on the opposite side (cyclic 
shifts) or lost in the abyss (the shifts are simple or 
noncyclic). 


  Example.

  Applicable to the number of


                % 01100010

cyclic shift to the right.

  The result will be the number of


                % 00110001


  And using a simple shift to the left, we obtain


                % 1100010?


  The "?" means that the bits received state, know in advance, 
and depending the type of team, state flags, etc.




       Teams shift battery


  There are four teams offset bits
the battery:


  RLCA

  RLA

  RRCA

  RRA


  The second letter is eloquent testimony to the shear 
direction. Teams "RLCA" and "RLA" shift the contents of the "A"

left, "RRCA" and "RRA" - right. And if
mnemonics is a letter "C", then this
indicates participation in the operation carry flag CY.

  For greater clarity, we illustrate
the execution of such commands.



        CY <7 6 5 4 3 2 1 0 <



  As seen from privedennoy scheme, under the "RLCA" is a cyclic
shift bits of battery left. Bits occupying the leftmost 
position (D7), goes to the place of the extreme right (D0) and 
copied to the carry flag "CY", and other bits are simply 
shifted to the left. It can be successfully applied to inspect 
the contents extreme bits:



       LD A,% 10011010

       RLCA

       JR C, MET

       ...
MET


  The above code fragment is quite
suitable for use. Naturally, load "A" is not so obvious, 
otherwise what's the point in checking? But the point is that 
if a bit older battery will "1", the processor will make the 
transition to the label "MET", thereby denying the performance 
fragment of the program's designated in our example of an 
ellipsis. 

  And now - the team "RLA":



         CY <7 6 5 4 3 2 1 0 <



  Here is a cyclical Swig battery
right. Unlike "RLCA" here carry flag is also involved in the 
work providing its content as

More than one bit for the shift.


  Example.

  If the "A" is the number of


                % 01101010,

and the carry flag is set, then after the execution of "RLA" to 
"A" will find the number of 


                % 11010101,

and the flag "CY" will be thrown down.


  But shifts in the opposite direction:



         > 7 6 5 4 3 2 1 0> CY



        > 7 6 5 4 3 2 1 0> CY



  As you can see, the commands "RRCA" and "RRA" completely 
identical to the previously considered for except the shear 
direction. 



         Command shift registers

            general-purpose


  We have considered the action to the battery. But all the 
other registers as "not remain disadvantaged in this regard. 
Even Conversely, the commands for them even more.


  There are, for example, a group of commands:


  RLC s

  RL s

  RRC s

  RR s


  They "s" stands for


        "(HL)", "(IX + d)", "(IY + d)"

or one of the registers:


    "A", "B", "C", "D", "E", "H", "L"


  In all other respects are similar to those Komad
that relate to "A": "RLC s", "RL s"
perform shift "s" to the left, "RRC s", "RR s"
- Right. Carry Flag is involved in an operation the same way.


  We now consider the "SLA s" and "SRL s":



        CY <7 6 5 4 3 2 1 0 <0



       0> 7 6 5 4 3 2 1 0> CY



  These commands are very common, because In addition to the 
shift to the left or right they fill the vacated seat znacheiem 
zero, therefore, can regarded as multiplication and division by

two, respectively.


  And finally, the command "SRA s":



          > 7 6 5 4 3 2 1 0> CY



  It can be considered as an operation "division by two with a 
sign." In the shift involved only 7 LSBs, and the senior 
remains unchanged. 

  But do not think that's all! There is
more ...



             Shift nibbles


  He performed on "RLD" and "RRD". These commands are not used 
very often. Be Maybe you do not have access

him. But, nonetheless, consider them all
as necessary. Thus, the scheme:



                               v

       7 ... 4 3 ... ... 4 0 7 3 ... 0

               ^ ^

         A (HL)



               v

       7 ... 4 3 ... ... 4 0 7 3 ... 0

                        ^ ^

         A (HL)


  As you can see in the work involved
at the same time as "A", and "(HL)". Exchange
between them takes place in groups of 4 bits,
and senior 4-bit accumulator remain izmneny.


   Example.

   If the battery contains a byte


                % 11010010,

and the address "HL" is stored bytes


                % 01111001,

after the execution of a command "RLD" in the battery will be 
the number of 


                % 11010111,

and "HL" will address byte


                % 10010010


  Team "RRD" is the same,
Except, of course, shift direction,
As can be seen in the diagram.

  And, of course, consider such an important
part of any assembly instructions, how ...



      Effect of shift commands to the flags



        Mnemonic Flags

        operation

                    C Z P / V S N H


          RL s x x P x 0 0

          RR s x x P x 0 0

          RLC s x x P x 0 0

          RRC s x x P x 0 0

          RLA x. . . 0 0

          RRA x. . . 0 0

          RLCA x. . . 0 0

          RRCA x. . . 0 0

          RLD. x P x 0 0

          RRD. x P x 0 0



  That's all the influence!

  All the notation in the table should be
You know from past lessons. The only new sign - "s", but about 
it was mentioned above. 


          To be continued ...







Other articles:

Non Possumus - a critical point in the Field of ZX-carts.

ZX-waggons - Overview of electronic media: ZX-Pilot in 1931, Born Dead 0A, 0B, Nicron 109, Don News 8, C-Net Week 19, Polesie 9.

Likbez - Assembler view from afar: What shift?

Lit. Page - Three gay letters: feedback to the newspaper.

Feedback - Feedback from readers of the newspaper.

Advertising - Advertisements and announcements ...

Category X - Novella for "Black Crow" - do not brag iduchi to host.

Hobby - Bonsai.

four kilobytes - With the start of the new school year!


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

Similar articles:
Parallel measurements - Review of PC-demoscene.
Interview - An Interview with CC'000. LEGENDARY BORN DEAD CREW.
Forum - As for the new DOS and BIOS settings for the Spectrum.
Inferno - On the shell.

В этот день...   21 November