Inferno #05
30 апреля 2004

For Coderz - Small programmers' tricks.

<b>For Coderz</b> - Small programmers' tricks.
                  Etudes


     1. Increment of 32-bit number


    Done as follows:

       INC (HL), HL

      JR Z, $ -2
... And all:) And, as you can see, the procedure
universal - for 16/32/64/nn..-razryadnyh
numbers - if the passage through zero is guaranteed not to 
happen. (It is in this form fragment is useful for counting 
passage of a piece of software.) 

   Decrement under the same conditions realizable tsya 
complicated: 

       XOR A

       CP (HL)

       DEC (HL)

       INC HL

      JR NC, $ -3

    Or, if the likely passage through zero:

       SCF

       LD B, 4; number of bytes in the number of

       LD A, (HL)

       SBC A, 0

       LD (HL), A

       INC HL

      DJNZ $ -5

    And the growth rate for the same case:

       SCF

       LD B, 4; number of bytes in the number of

       LD A, 0

       ADC A, (HL)

       LD (HL), A

       INC HL

      DJNZ $ -5

   Zero can be recorded in C, if it is not in
other registers. INC HL in special cases
You can replace or at INC L INC H.


   In the register, as you can imagine,
 both operations look even simpler:

     increment: decrement:

       INC HL LD A, H

       LD A, H OR L

       OR L DEC HL

       JR NZ, $ +3 JR NZ, $ +3

      INC DE DEC DE



     2. How to avoid unnecessary INCBIN'ov


   You know, how can a alasme podgruzit
file one INCBIN'om in two different places? A
maybe more? :) I just needed this for Pro Tracker'a: Player on 
my drive is a whole, but in memory it must

razrezan.A be done so with the help of feasting to the memory 
through the braces: 

       ORG kuda_kopirovat, str_kuda_otkuda

       DISP otkuda_kopirovat

       DUP dlina/16

       DW {$}

       DW {$}

       DW {$}

       DW {$}

       DW {$}

       DW {$}

       DW {$}

       DW {$}

       EDUP

      ENT

   Page Memory otkuda_kopirovat and
page kuda_kopirovat "should be the same page" str_kuda_otkuda.

   I've tried all the options grouping DW:
through DUP'REPEAT / UNTIL, by enumerating
{$},{$+ 2}, etc., tried to change the $ a variable, but it 
turned out that the above option is the fastest. In addition, 
it is shorter, than {$},{$+ 2} ... :) The speed at 3.5 MHz -

about 1.5 kilobytes per second. For comparison, the rate of
DS - about 8 kbytes / sec.



         3. One important note


   It turned out the alignment of the boundary section (256 
bytes), which I described in the ZX-Guide, obsolete. In the new 
alasmah  admissible even shorter design:


      DS .(-$)

   Her whole trick is that the DS 0 none
does not:)

   Alignment on an even byte in this case is written as:

      DS - $ '1

    A byte alignment at a multiple of 8:

      DS - $ '7
etc.

   But the alignment of the nearest address
 significant byte is equal to # F0:

      ORG $ +15 / 256 <8 + # F0

    or

      ORG $ +15' # FF00 + # F0
(Generally, $ + a '# FF00 + b, where a = 255-b)



  4. Control memory assembly


   You never had to make in the source control memory overflow 
for program? In order for oversized

Compilation display an some sort of message? Usually it is done 
through IF, in which there is a comparison. A

Comparison of the syntax alasma - is subtraction, and check the 
top bit. But not '# 8000, as one might think, but ...

<1'1. Much shorter:) Author - Capry.

   Now, when our condition in the IF to perform (check its 
working can be artificially extending the program for what some 
DS'ami) to display a message. This makes DISPLAY. And then you 
can (but not required) and abort the compilation - it is

make the directive INCBIN with some
wild-file name.


                         A. Coder 03/08/2004




Other articles:

CacheVox - The code for import and subsequent playback of digital music from floppy disks.

For Coderz - RAYCASTING - make yourself a little DOOM'a. Tracing algorithm 3D maze in the game WOLF.

Inferno - O magazine.

DIY - Fits the mouse from the Amiga to the ZX Spectrum.

Softinka - an overview screen wrappers for ZX Spectrum.

Inferno - The authors and editorial contacts.

Gameland - description of the game Stronghold (Bastion).

Softinka - Package CacheVox v1.0 to import and play digital music from floppy disks.

Interview - an interview with Disabler'om - coder, artist and zhelezyachnikom from Rostov-on-Don.

Others - Bugs writing to floppy disks. Causes and methods of struggle.

Gameland - Short description of the problems the game Dune: Imperia 2.

Inferno - Errors in the previous numbers.

For Coderz - Small programmers' tricks.

Spectrum - compressed data format on the ZX Spectrum.

Gameland - the game Hexagonal Filler.

Softinka - Hrum 3.5i - the fastest LZ-extractor with the bit stream.

DIY - Production of the tail for the mouse.

Iron - We investigate the chip K561IE10A.

Iron - We investigate the chip KR1533IE7.

Iron - We investigate the chip K561TL1. .

Softinka - display compressor Laser Compact 4.0.

Inferno - Letters to the Editor.

Softinka - Compressor texts MS Pack 01.96.

Inferno - On the shell.

Softinka - the benefits archiver Rar.

Softinka - Packer RGB images Powerful Code Decreaser v6.2.

Likbez - What are the plus and minus voltage.

Likbez - How does the protection of the circuit elements.

For Coderz - Nuances Raycasting-a.

Softinka - Real Information Packer 0.2x - one of the most powerful compressor on the ZX.

For Coderz - autobuild program. Optimize the assembly process.

Inferno - Intro.

Others - The results of the survey.

Others - The Compo. On the survey.

About Spectrum - thinking about the future of the Spectrum.

Iron - Once again, the protection circuits KR1818VG93.


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

Similar articles:
Feedback - contact the publisher.
Our News - ZX-Weekday city of Perm.
From the Editor - On the future of newspapers

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