Adventurer #08: Experience Exchange: Long Integer Operations Guide

Article authors

Mentioned people

(C) Maximum/INTEGER

LONG ??? What is it?

This denotes long numbers on PC and AMIGA. That is, these are numbers that lie in the range from 0 to 4294967295, for which 4 (four) bytes in memory are allocated. In this article, I will teach you how to operate with such numbers. And why is this needed? For example, you are writing a game in which there are parameters such as money, gold, etc. As is often the case, the amount of money in such games is much more than 65535. This is where LONG numbers come in handy... So, we have the number 12,000,000. In Long, it looks like this: #00B71B00 In assembly, it should be written like this: long_num DW #00B7, #1B00 The format for specifying any Long number: ... LD HL,#00B7 EXX LD HL,#1B00 ... That is, in HL the higher part of the number, and in HL' its lower part.

Addition of two Long numbers

You just need to add the lower parts, and then, considering the C flag, add the higher parts: L_ADD ADD HL,DE EXX ADC HL,DE EXX RET At the input of the procedure: HL and HL' - the first number, in DE and DE' - the second number. At the output: HL and HL' the sum of the two numbers.

Subtraction of two Long numbers

Here it is roughly the same: L_SUB AND A SBC HL,DE EXX SBC HL,DE RET The parameters are the same as for L_ADD.

Printing Long numbers

To print the number, we need to recode it from Long to ASCII codes, which is done by the following procedure: L_PR LD IX,L_TAB; see below LD A,10 ; number of 10 digits L_PR0 EX AF,AF' EXX LD E,(IX+0); high word from the table. LD D,(IX+1) EXX LD E,(IX+2); low word from the table. LD D,(IX+3) LD A,'0'-1 L_PR1 CALL L_SUB ; subtract until INC A ; the C flag is set JR NC,L_PR1; CALL L_ADD ; restore the number LD (BC),A ; to the buffer INC BC INC IX INC IX INC IX INC IX EX AF,AF' DEC A JR NZ,L_PR0; all numbers RET ; ...

;number table:

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 HL and HL' is the number, and in BC the address of the buffer 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 16 INC HL DJNZ LOOP RET

BUFF DS 10

Input of Long number.

More precisely, not input, but conversion of the number from ASCII codes to Long format. This can be applied as follows:

... LD HL,BUFF ... CALL INPUT ; Enter the number LD HL,BUFF CALL L_DC ...

At the input of the procedure: HL - the address of the buffer where the number is located:

BUFF DB "212042067" DB 0 ; End marker i.e. code "9"

After the call, HL and HL' will contain the number.

L_DC PUSH HL LD B,0 L_DC1 LD A,(HL) ; Count how many CP "0" ; digits we have 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 ; Reset EXX ; new LD HL,0 ; number EXX L_DC3 LD A,B ; have we done everything? LD DE,0-4 AND A RET Z ; no! EXX DEC A ; using the table LD IX,L_TAB+36 JR Z,L_DC4 ; find ADD IX,DE ; the needed DEC A ; digit JR Z,L_DC4 ; 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 ; ah, found LD E,(IX) ; take what LD D,(IX+1) ; we will EXX ; add LD E,(IX+2) ; to LD D,(IX+3) ; the new number LD A,(BC) ; what number do you have? INC BC L_DC5 CP "0" ; until "zero" JR Z,L_DC3 CALL L_ADD ; add the digit DEC A JR L_DC5

Well, I have already given quite a lot of information about Long, so use it for your health... I hope this article will help someone. I also want to remind you that such numbers have already been successfully used by the well-known Slava Mednonogov in his UFO. I have not encountered such a method anywhere else yet.

* * *

Contents of the publication: Adventurer #08

  • От автора - Shaitan
    Technical details of a new program interface for ZX Spectrum. Discusses improvements and features like scrolling and color change. Provides keyboard and button navigation instructions.
  • От автора
    Introduction by the author and editorial team details.
  • Presentation
    The article presents a software installer for creating autorun disks and introduces a new adventure game created with QUILL by Dr. Laser.
  • Presentation of TRICK Software
    The article presents TRICK, a new software for program protection developed by Eternity Industry, and discusses its beta and commercial versions. The author, Alexander Kalinin (aka Paracels/EI), addresses previous shortcomings in the software and emphasizes its improved interface. It includes purchase details for the software and invites readers to request it.
  • Presentation
    The article provides a detailed user manual for HELP_Z80, a free utility for ZX Spectrum that serves as an electronic guide for Z80 microprocessor commands. It outlines how to load and use the software, including command explanations, search functions, and integration with assemblers. Additionally, it includes memory distribution, operational features, and references for further reading.
  • Interface
    The article discusses reader feedback on the magazine's interface, addressing concerns about pricing and software trends in the ZX Spectrum community. It features a letter from a reader expressing thoughts on game pricing and the declining number of users on the platform. Additionally, there are discussions on software developments and user engagement.
  • Interface
    The article shares the author's experiences after purchasing an Amiga, comparing it with a PC, and discussing its usability for games, graphics, and music, while noting some software limitations.
  • Interface
    The article discusses user support issues faced by hardware manufacturers SCORPION and NEMO for ZX Spectrum devices. It critiques SCORPION for poor customer service despite being a market leader, while praising NEMO for responsive support. The author expresses concerns about the overall market direction for ZX Spectrum hardware.
  • Interface
    Article discusses the future of the Spectrum platform, addressing user demographics, software production challenges, and hardware evolution possibilities.
  • Interface
    Article discusses the frustrations of a Speccy user regarding hardware issues, the challenges of modern computing, and the dedication to maintaining the Speccy platform.
  • Interface
    Статья рассматривает жизнь и судьбы пользователей ZX Spectrum, включая личные воспоминания автора о друзьях и их взаимодействии с компьютерами.
  • System
    The article reviews various software for ZX Spectrum, including text editors, audio players, and graphic utilities. It provides independent opinions on their features and usability, highlighting both strengths and weaknesses. The piece emphasizes the evolution and improvement of software tools available for this classic platform.
  • Overview of Games
    Overview of notable games for ZX Spectrum, highlighting their graphics, sound, and gameplay mechanics. Each entry includes a brief summary and rating. Recommended for fans of retro gaming.
  • Review of Demos
    The article reviews demo versions of various games, highlighting their potential and unique features. It emphasizes the scarcity of such releases in the market and evaluates the quality and gameplay mechanics of selected titles. The author shares insights into the progress and expectations for future full versions of these games.
  • Guests
    The article discusses the formation and activities of the Eternity Industry group, its members, projects, and future plans for releases and competitions.
  • Гости - Dr. John
    An interview with Felix from Virtual Brothers discusses his transition from ZX Spectrum to PC, development of the game 'Winnie the Pooh', and future plans.
  • Guests
    Interview with the musicians Mарат and Демон from the band 'Disgust', discussing their musical evolution, influences, and perspectives on life and creativity.
  • Promotion
    The article provides a detailed manual for the game 'ENCYCLOPEDIA of WAR', explaining army selection, unit types, and battle mechanics.
  • Promotion
    The article provides a walkthrough for the game, detailing necessary items and strategies for progressing through various challenges, including dealing with dinosaurs and navigating villages.
  • Promotion
    Статья представляет собой обзор arcade adventure игры 'ELOPEMENT' от Omega HG, выделяя ее особенности и советы по прохождению.
  • Promotion
    Статья описывает текстовую адвентюру 'Остров тьмы' на QUILL, предлагая советы для игроков. Упоминаются механики и персонажи, включая загадки и взаимодействия. В конце представлена карта острова.
  • Promotion of 'Knightmare'
    The article describes the game 'Knightmare', detailing its commands, gameplay mechanics, and initial quests. Players control a knight who must interact with characters and solve puzzles to progress. It serves as a manual for navigating the game's environment and objectives.
  • Experience Exchange
    The article critiques the adventure game 'Island of Darkness' by Paul Moskow, highlighting its illogical design, lack of detailed item descriptions, and absence of helpful hints for players.
  • Experience Exchange
    The article provides a detailed manual for enhancing the ZX ASM 3.0 assembler, introducing debugging features and functionalities for better program execution control on ZX Spectrum.
  • Experience Exchange
    The article describes a phenomenon observed with the ZX Spectrum video controller, where switching between two screens can create unexpected visual artifacts. It outlines a specific program that demonstrates this effect through rapid screen toggling. The author discusses the implications and potential applications of this behavior.
  • Обмен опытом - Иван Рощин
    The article is a programming guide on porting the 'iris.ss' screen saver effect from Dos Navigator to ZX Spectrum, including source code and modification tips.
  • Обмен опытом - Иван Рощин
    Description of the OPEN_W procedure to create window borders. Includes details on customization of symbols and dimensions. Utilizes PRSYM for symbol printing.
  • Обмен опытом - Maximum
    Introduction to long integer operations for game development on ZX Spectrum, including addition, subtraction, and conversion to ASCII.
  • Experience Exchange
    The article discusses the customization of the ART STUDIO graphic editor by creating additional modules that enhance its functionality, including features like music playback and cursor coordinates display.
  • Experience Exchange
    The article describes a program developed to improve the visual quality of a pixel-by-pixel moving attribute message on ZX Spectrum. It provides details on the implementation, including the use of data arrays for motion trajectory and image rendering. The program includes comments for easier understanding and can be modified for different effects.
  • Оттяг
    The article features humorous sketches and commentary on various aspects of life and technology, including anecdotes about a fictional character's experience with a Pentium processor.
  • Pharmacist Test
    The article presents humorous tests designed to identify whether someone is a real pharmacist or a fraud, featuring situational questions and scoring to gauge knowledge of pharmacy.
  • Oddities and Self-Reflection in 'Оттяг'
    The article 'Оттяг' presents a humorous and critical self-reflection of the author, exploring various life experiences and quirks that highlight his unusual personality traits.
  • Humorous Quiz: Assess Your Sense of Humor
    The article presents a humorous quiz to assess one's sense of humor and sexual attitudes through various situational questions, revealing absurd and comedic perspectives.
  • Student Types Quiz
    The article presents a humorous quiz to determine what kind of student you are, ranging from a party animal to a diligent scholar. It features a series of questions regarding typical student activities and responses. The results categorize students based on their score, from carefree to nerdy.
  • How to Properly Torture Windows 95 - Maximum
    Статья описывает иронический подход к установке и эксплуатации операционной системы Windows 95, включая способы ее 'мучения' и троллинга. В тексте используются гиперболизированные примеры взаимодействия с ОС для создания комичного эффекта. Это развлекательный материал с элементами юмора.
  • Ottyag
    The article is a humorous narrative featuring Winnie the Pooh and his friends returning to the Hundred Acre Wood, where their carefree life turns chaotic. It describes their antics, including drinking and misadventures, as they reunite and encounter various challenges. The story showcases the characters' personalities and interactions in a comedic light.
  • Novella
    The article describes a humorous novella featuring Corporal Johnlan recounting his first military mission and his interactions with a young grandchild over beers.
  • Novella
    Novella recounts an adventurous escape from a Glot base using a vintage spacecraft, highlighting the protagonist's encounters and clever maneuvers.
  • Novella
    The article describes a whimsical story about two hedgehogs, Pukhly and Zaraza, who, after a strange event, develop wings and must navigate their new reality. The story blends fantasy and humor as the characters face unexpected changes and challenges. This is a novella showcasing imaginative storytelling.
  • News
    The article discusses recent updates from Rybninsk related to the FunTop party, detailing contributions from various individuals and teams for the 'Adventurer' magazine and demo competitions.
  • News
    Статья сообщает о событиях в сообществе Спектрумистов Ярославля, включая информацию о разработчиках программного обеспечения и их текущих проектах.
  • Advertisement
    The article is a collection of advertisements and announcements related to ZX Spectrum, inviting collaboration from programmers, artists, and musicians, and detailing how to acquire the journal and software.