CPU for you - a procedure for quickly drawing a point. Undocumented commands of the Z80 processor.

Faultless #05
 ┌─────────────────── ───────────────────┐
  │Section:CPU for you;                   │
  │Article: Point output and new instructions;│
  │Text: B. Stanislav.                   │
  └─────────────────── ───────────────────┘

 IN THIS SECTION WE WILL TALK ABOUT SUCH NOT-
  AN EFFECT OF LITTLE IMPORTANCE FOR MANY, AS FAS-
  THIRD POINT OUTPUT. THIS EFFECT WAS WRITTEN
  BY ME, I.E. BY ACTIVATOR AND PROVIDED BY
  AS AN ARTICLE FOR THE MAGAZINE * THE FAULTLESS *.

   TEXT OF THE EFFECT ITSELF AS SUCH
  WAS WRITTEN IN TASM 4.0 (XLD) ASSEMBLY.

 ATTENTION! INSERT THIS EFFECT ONCE -
               SOLVED ONLY WITH AGREEMENT
               RESEARCH OF THE AUTHOR (ACTIVATOR).
 So, let's get down to the program itself:

ORG 25000
          LD (STACK+1),SP
  BEGIN LD SP,TABL
          POP HL
          POP DE
          LD A,E
          CP#FF
          JR NZ,NEXT
          LD HL,TABL
          LD (BEGIN+1),HL
          JR BEGIN
   NEXT LD (HL),A
          LD (CLS+1),HL
          LD (BEGIN+1),SP
   STACK LD SP,0
          RET
   CLS LD HL,0
          XOR A
          LD(HL),A
          RET
   TABL DEFW #8000
 Now some explanations:

 In the first line we remember the value
  stack, then we loaded the SP register
  addresssigns (how to build it, there will be
  described further), by the POP HL team we
  received the screen address in HL using the POP command
  DE - offset in DE, now take the value
  this offset in A, checked at the end,
  if not the end, then display the point with the command
  LD (HL), A; write the value in the CLS label
  entering the screen address for the CLS point, recording
  put the following address of the sign in BEGIN,
  we restore the value of STACK and RET.
   And if it’s the end, then we write down the beginning
  address of the sign in the BEGIN label and do
  transition to it, and then the same
  cycle.
   Now let's talk about how the sign is built.
  First comes the screen address, and then the offset
  tion, for example:
 DEFW #4000
                DEFW #8080
                DEFW #4000
                DEFW #1010
                ....

 Now I will give an example of a program that
  Paradise is building a sign from a sign written -
  Noah in BASIC with the following program:

 10 LET ADR=30000
   20 FOR N=0 TO 2*PI STEP PI/50
   30 POKE ADR,88+80*SIN N:POKE (ADR+1),76
      +70*COS N
   40 LET ADR=ADR+2:NEXT N
 If you want to see what kind of
  yourself, then on line 35 you write:

 35 PLOT PEEK ADR,PEEK (ADR+1)

 After writing the plate to memory, its size
  will be 50*2, i.e. 100 bytes.Now the translation of the BASIC tablet into a table
  personal message we need:

ORG 26000
        LD IX,#8000
        LD HL,30000
        LD BC,100 ;STEP *2
   LOOP PUSH HL
        PUSH BC
        LD C,(HL)
        INC HL
        LD A,(HL)
        INC HL
        CALL 8880
        LD(IX),L
        LD (IX+1),H
        INC IX
        LD DE,TAB
        ADD A,E
        LD E,A
        LD A,(DE)
        LD(IX),A
        LD (IX+1),A
        INC IX
        POP B.C.
        POP HL
        INC HL
        INC HL
        DEC B.C.
        LD A,B
        OR C
        JR NZ,LOOP
        RET
 After translation, the table will be located
  to from address #8000 and size 200
  byte.(note:at the very end of the table
  you need to put 4 bytes of the #FF code.)
  Now the sign is ready for use.

   Now the most important thing is how long
  Is this point occupied by CLS?

   Let's do the math:

  command LD (STACK+1),SP takes 20
  clock cycles, but since it is used only
  just once, it can be discarded, then
  teams POP HL and POP DE take 10 each
  clock cycles respectively, command LD A,E-
  4 clock cycles, command CP #FF - 4 clock cycles, JR NZ -
  from 7 to 12 measures, LD (HL), A - 7 measures,
  LD (CLS+1),HL - 16 clock cycles,LD (ADR+1),SP-
  16 clock cycles, LD SP, and RET commands at once -
  multiplying dots can be put at the end,
  then they can alsodiscard -->
  total 10+10+4+4+7+7+16+16 = 74 clock cycles, without
  CLS'A, and with it 74+11+4+7 = 96 cycles,
  which is not so bad in programs where there is no
  we bypass some effect from the points and remain
  It doesn't last that long.

   In fact, this point, according to my ex-
  experiments have no more than 68 bars, and
  maximum number of points displayed per
  one interrupt, maybe about 1054!!!

   For any questions you may have, please contact
  Contact us by phone +8 (0572) 37-33-66,
  Stas (ACTIVATOR) or write to:

 Kharkov 310204
     L. Svoboda Ave. 46b, apt. 149
     Bazhenov S.O.

 -===-
 And now we would like to write to you
  undocumented commands that
  will surely interest any programmer
  the one who writes her programs:

 Avocet Z80/180 Assembler v2.24, #00562
     Chip=HD64180 1/31/97 16:38:47

 new 64180 instructions

 0001 ED 3C 001 TST A
  0002 ED 04 002 TST B
  0003 ED 0C 003 TST C
  0004 ED 14 004 TST D
  0005 ED 1C 005 TST E
  0006 ED 24 006 TST H
  0007 ED 2C 007 TST L
  0008 ED 34 008 TST (HL)
  0009 ED 64 AA 009 TST $AA

  000A ED 4C 010 MLT BC
  000BED 6C    011   MLT     HL
  000C ED 5C    012   MLT     DE
  000D ED 7C    013   MLT     SP

  000E ED 76    014   SLP

  000F ED 38 BB 015   IN0   A,    ($BB)
  0010 ED 00 BB 016   IN0   B,    ($BB)
  0011 ED 08 BB 017   IN0   C,    ($BB)
  0012 ED 10 BB 018   IN0   D,    ($BB)
  0013 ED 18 BB 019   IN0   E,    ($BB)
  0024 ED 20 BB 020   IN0   H,    ($BB)
  0025 ED 28 BB 021   IN0   L,    ($BB)

  Avocet  Z80/180 Assembler v2.24, #00562
     Chip=HD64180        1/31/97 16:38:47

  Test 180
  Test file for the 64180

  0016 ED 39 BB 022   OUT0  ($BB),  a
  0017 ED 01 BB 023   OUT0  ($BB),  b
  0018 ED 09 BB 024   OUT0  ($BB),  c
  0019 ED 11 BB 025   OUT0  ($BB),  d
  001A ED 19 BB 026   OUT0  ($BB),  e
  001B ED 21 BB 027   OUT0  ($BB),  h
  001C ED 29 BB 028   OUT0  ($BB),  l

  001D ED 83    029   OTIM
  001E ED 93    030   OTIMR
  001F ED 8B    031   OTDM
  0020 ED 9B    032   OTDMR

  0021 ED 74 FF 033   TSTIO   $ff

   И напоследок нам хотелось бы предоста-
  вить вам INTRO нашего журнала в форма-
  те TASM'а V3.0.Дерзайте,разбирайтесь в
  моем мусоре убогих кодов!
   И еще,все те,кто хотел бы опубликовать
  свои достижения в машинных кодах,пишите
  к нам в редакцию,мы с удовольствием
  опубликуем их.Адрес вы найдете в INTRO!
   В следующем номере ждите исходник выво-
  да линии,который приблизительно занимает
  600 тактов (линия в десятьlandmark)!

 * * *

Share your thoughts about the article