Adventurer #08
31 августа 1998

Exchange of experience - on how to operate in the assembly with the long numbers of type Long.

<b>Exchange of experience</b> - on how to operate in the assembly with the long numbers of type Long.
      (C) Maximum / INTEGER


        LONG??? What is it?



      So long numbers are indicated on the
PC and AMIGA. Ie a number lying in
range from 0 to 4294967295, which is given for the submission 
of four (4) byte of memory.


      In this article I will teach you how to operate with such 
numbers. And for what it is do you want? For example, you write 
a game in which there are options such as money, gold and

etc. As usual, the money in these games
is much larger than 65535. Here
here is something just and useful LONG tsiferki ...

      So, we have the number 12. 000. 00.
In Long, it looks like this: # 00B71B00

      In the same assembly is to recruit as follows:
long_num DW # 00B7, # 1B00

      The format of the job of every Long:

      ...

      LD HL, # 00B7

      EXX

      LD HL, # 1B00

      ...

      Ie in the highest part of HL, and
HL 'its lowest part.


        Addition of two Long numbers



      You just need to add lower part,
and then taking into account the C flag folded and older:
L_ADD

      ADD HL, DE

      EXX

      ADC HL, DE

      EXX

      RET

      At the entrance of the procedure: HL and HL '-
the first number in the DE and DE '- the second number.

      At the exit: HL and HL 'the sum of two numbers.

       The difference of two numbers Long



      Here, roughly the same:
L_SUB

      AND A

      SBC HL, DE

      EXX

      SBC HL, DE

      RET

      The parameters are the same as L_ADD.


           Print Long numbers



      To print the numbers we need to translate from Long to 
ASCII codes, which makes the following procedure:

L_PR LD IX, L_TAB; see below

          LD A, 10, the number of 10 characters
L_PR0 EX AF, AF '

          EXX

          LD E, (IX +0); st.slovo Table.

          LD D, (IX +1)

          EXX

          LD E, (IX +2); ml.slovo Table.

          LD D, (IX +3)

          LD A, '0 '-1
L_PR1 CALL L_SUB; count down until

          INC A; enable the flag C

          JR NC, L_PR1;

          CALL L_ADD; restore the number of

          LD (BC), A; in its buffer

          INC BC

          INC IX

          INC IX

          INC IX

          INC IX

          EX AF, AF '

          DEC A

          JR NZ, L_PR0; all the numbers

          RET; ...

; Table of numbers:

L_TAB DW # 3B9A, # CA00; 1000000000

          DW # 05F5, # E100; 100000000

          DW # 0098, # 9680; 10000000

          DW # 000F, # 4240, 1000000

          DW # 0001, # 86A0; 100000

          DW # 0000, # 2710, 10000

          DW # 0000, # 03E8; 1000

          DW # 0000, # 0064, 100

          DW # 0000, # 000A; 10

          DW # 0000, # 0001, 1


   Before calling in the HL and HL 'number, and in
BC buffer address for the number. Example:


          ORG # 6000

          LD HL, # FFFF

          EXX

          LD HL, # FFFF

          LD BC, BUFF

          CALL L_PR

          CALL 3435

          LD A, 2

          CALL 5633

          LD HL, BUFF

          LD B, 10
LOOP LD A, (HL)

          RST 1916

          INC HL

          DJNZ LOOP

          RET

BUFF DS 10


             Entering Long numbers.



   Or rather not enter, and the transformation of
of ASCII codes in Long format. Apply
This can be as follows:


          ...

          LD HL, BUFF

          ...

          CALL INPUT; Enter the number of

          LD HL, BUFF

          CALL L_DC

          ...


   At the entrance of the procedure: HL-address buffer
where the number of sitting:

BUFF DB "212042067"

          DB 0, ie, the end marker

                         ; Code "" 0 ">" 9 "



   After calling in the HL and HL 'is a number.

L_DC PUSH HL

          LD B, 0
L_DC1 LD A, (HL); calculate how much

          CP "0"; tsiferok from our

          JR C, L_DC2; number

          CP "9" 1

          JR NC, L_DC2

          INC B

          INC HL

          JR L_DC1
L_DC2 EXX

          POP BC; in BC it

          LD HL, 0; Clear

          EXX; new

          LD HL, 0; number

          EXX
L_DC3 LD A, B; all create one?

          LD DE ,0-4

          AND A

          RET Z; Nooo!

          EXX

          DEC A; using the table

          LD IX, L_TAB +36

          JR Z, L_DC4; find

          ADD IX, DE; desired

          DEC A; us

          JR Z, L_DC4; discharge

          ADD IX, DE; number

          DEC A

          JR Z, L_DC4

          ADD IX, DE

          DEC A

          JR Z, L_DC4

          ADD IX, DE

          DEC A

          JR Z, L_DC4

          ADD IX, DE

          DEC A

          JR Z, L_DC4

          ADD IX, DE

          DEC A

          JR Z, L_DC4

          ADD IX, DE

          DEC A

          JR Z, L_DC4

          ADD IX, DE

          DEC A

          JR Z, L_DC4

          ADD IX, DE
L_DC4 DEC B; aha, found

          LD E, (IX); take what

          LD D, (IX +1); we

          EXX; add

          LD E, (IX +2); to

          LD D, (IX +3); a new number

          LD A, (BC); what is your number?

          INC BC
L_DC5 CP "0" until the "zero"

          JR Z, L_DC3

          CALL L_ADD; add the category of

          DEC A

          JR L_DC5


      Well all I have given already many
information about Long, so that the use
Health ...

      I hope that this article applies to someone
help. I also want to recall that such
numbers have already been successfully used over
Thank Mednonogov known in his UFO.
I'm more of such a method yet nowhere
met.


                  *







Other articles:

From the Author - help: New bugs in the new shell.

From the Author - the author: about the authors of the magazine.

Presentation - Content of the program: Installer to AUTORUN DISK v2. 0 adventyurnaya game Diamond.

Presentation - a program for protecting programs TRICK v1. 003b.

Presentation - HELP Z_80: User's Guide.

Interface - letters from readers: Black Raven, The Secret Game NEW DIZZY, On the errors of the game APOLLO, a new debugger Veros STS 6.2, How to beat the game Svyatogor.

Interface - PC vs Amiga: Is AMIGA RULEZ? First impressions neophyte.

Interface - support for producers of "iron" their "creations" after they (the creatures) get into the hands of users.

Interface - thinking out loud: "SPECCY computer for young people. If we have so many cool coders, why so little steep domestic soft'a?"

Interface - pens from CAV inc: "SPECCY it does not work, this rest is, even more than the rest, it's a lifestyle, and if by that you still manage to get the money. .. "

Interface - SPECCY pros and cons, Reflections Spy / Eternity Industry.

System - Overview of system programming: ZX-IBM Editor v1.5M, PPF v1.05, Multistudio v2.0p, Mods Player v2.0, Bitmap Viewer v2.0, Corrector v2.0, Storm v1.1, 866 v1.2, HRUM v3.5, TDU v1.0, HRUST v1.0, RLE-Compressor v1.21, Overlays Consul Commander.

Toy Review - An overview of new gaming software: Rabbit Jazzy, Quadrax, Komplex, Math of the day, Cue Boy, Zly Sen, Prva Aakcia, Outlaw, The Dark Empire, Gary Linekers.

Toy Review - Demos: Little Ghost, The Dark Empire, Worms, Smagli 3 Monster Land, Civilization, Mysteries of Captain Shelton.

Guests - Presentation of a group of Kovrova - Eternity Industry.

Guests - Filix about creating games Winnie The Pooh-2.

Guests - ekstremalschiki: new section which highlights aspects of the life and work of extreme Rybinsk musicians. Today, a visit Marat and Demon - stood at the origins of such well-known (in the narrow circles) team "Disgust".

Promotion - How to play the game Encyclopedia of WAR.

Promotion - the passing game Where time Stood Still.

Promotion - description of the game Elopement: back to the Earth.

Promotion - the passage of text adventyury Island of Darkness (Island Darkness).

Promotion - the passage of text adventyury Knightmare.

Exchange of experience - Russian glitches: The Island of Darkness Game (how NOT to write adventyurnye game).

Exchange of experience - Finalization ZX-ASM v3.0 by Ivan Roshchina.

Exchange of experience - Features video controller ZX Spectrum (for programmers).

Exchange of experience - Graphic effect IRIS (plasma).

Exchange of experience - the procedure output window frame.

Exchange of experience - on how to operate in the assembly with the long numbers of type Long.

Exchange of experience - Art Studio and the principle of open architecture (how to write their own modules to the editor).

Exchange of experience - The movement procedure of attribute labels in pixels (floating atrubuty).

Ottyag - A Tale of Pentium Pentiumovicha Pentiumova. 20 things you can do if your favorite team lost on the road. Toilet, as a measure of human values.

Ottyag - Test "Formatsevt, check for authenticity."

Ottyag - Test "You are not dumb ass."

Ottyag - The test "Do you have a sense of humor."

Ottyag - Test "Which of your student."

Ottyag - How to PROPERLY kill Windows'95.

Ottyag - Winnie the Pooh and all-all-all - 2.

Novella - Tales Corporal Djilali (the game Laser Squad).

Novella - Escape from Space (the game Elite).

Novella - Hedgehogs mutants.

News - News from the Rybinsk spektrumistov: Infosoft, Shrsoft, Surgeon, Chasm, Protecvision, Groboclone, Volume 4, Experience, Mr. Vano, Ant, Demon, Miguel, Veka, RDM, Auryn.

News - News from the Yaroslavl spektrmistov: Marchy, Kav Software, Nicolas Viper, Dr Shura, Harkonnen, MacKeymn, DJ Reason.

Advertising - advertising and announcements.


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

Similar articles:
Room with laughter - The triumph of progress.
Entry - the contents of rooms.
Bugs - On a glitch in the STS v5.1
Paradox'99 - Results Paradox'99.

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