ZX Format #07: Improvements in Turbo Assembler 1.1 for ZX Spectrum

STORM

TURBO ASSEMBLER

Version 1.1

music by MIDISOFT
(C) X-TRADE GROUP

The embryonic state lasted a long time. But the dazzling moment came when we were finally able to write programs in a way that satisfies us almost one hundred percent. Even if it was at the cost of two months of effort.
We hope you will like what we have done, although we did it guided by our own desires.

We present to you the second version. The first was a "trial run" in this area.
The hardest part was coding the new version in ZXASM 3.0 (we lacked INCLUDE), but now all subsequent versions will be written based on the previous ones.

Differences_from_version_1.0

- Fixed known bugs
- Changed screen size from 32*22 to 40*20
- Added INCLUDE
- Added a full-fledged line editor
- There is a possibility to change colors (see Memory distribution)
- Changed priorities of arithmetic/logical operations

So, what do we have now:

Editor

√ Text scrolling in frame! (1/50 sec)
√ PAGE UP, PAGE DOWN in five frames.
√ Search in a thousand lines per second.
√ Evil tokenized text format.
Text size XAS /1.2
- ZXASM/2
- ALASM/1.4
- TASM4/1.5
√ Block operations on arbitrarily marked lines. (when unloading text, the marking is preserved).
√ Text window size 40*20 characters, each character cell 6*6 pixels.
√ Line length in memory up to 40 characters.
√ Syntax checking during input.
√ Auto-marking of the line.
√ Possibility of a shortened set (LD, JR do not require input).
√ SCROLL UP, SCROLL DOWN functions.
√ Built-in IMPORT FROM DISK and EXPORT TO DISK (to/from text format).

Compiler

√ Compilation time XAS /1.2
ZXASM/2
ALASM/1.4
TASM4/1.5
√ Any number of operators in a line.
√ Any number of operands for one operator.
√ Arithmetic with priority compliance.
√ 22 arithmetic, logical, and special operations.
√ Labels up to seven characters long.
√ Total number of labels about 1536 (11.5 Kb buffer, each label occupies 3+LABEL_LENGTH bytes.)
√ During compilation, line duplication is possible
√ Possibility of placing code at an address that does not match ORG.
√ Naturally, INCBIN/INCLUDE.
√ Compilation speed is little dependent on the total number of labels.
√ Speed increase due to pre-calculated/translated numbers.
√ Support for undocumented commands.
√ Built-in macro commands like LD BC, HL.

Miscellaneous

√ Directory cache for INCBIN/INCLUDE.
√ Fast disk procedures.
√ Text recognition on the page in case of restart.
√ Autoload STS on startup.

Memory_distribution

Initially, it was planned to use expanded memory, but there was not enough time, and therefore it turned out that the user has very little memory left.

Free banks 0, 1, 2, 3, 5, 7.

The first 4k of bank 3 cannot be destroyed, after that it can be (the label table will be destroyed).

The user can destroy bank 1, but upon returning to the environment, it will be destroyed by the editor, it is where font/scrolling is depacked/decrunched. Use this bank for this same purpose.

Bank 6 contains text, bank 3 - a piece of body and labels, and bank 4 contains the body of the Asm.

Bank 7 contains STS, but its screen area is also destroyed by the editor (don’t think badly, the first screen is never turned on!).

The user does not have access to area #40-#5F (bank 5). Object code cannot be placed there. Code compiled at these addresses can be placed at another address and sent to area #40-#5F by the user's program. Use ORG with an address offset.

Banks 0 and 2 are fully accessible.

Asm destroys BASIC areas #5B00-#5BFF, #5E00-#5EFF.

When starting/returning to the environment, RAMTOP must be set to 24575, otherwise you will get 4 OUT of memory, 0:1.

For returning, USR 23600 or OUT 32765, 20:USR 49152 is used.

On startup, the 48th mode is set with open pages.

STS 5.1a should be written immediately after STORM - it does not bother itself with climbing into the directory.

ROM is not used, you can remove it, but it won’t read from the disk. ;) TR-DOS is still used (5.03/04 only).

At the first launch, DeMSPacking and clearing of the 48th memory occur.

On entry/exit, SWAPPING with pages occurs, do not be disturbed by the forced slowdown (30 cycles/byte, however.).

Upon exit, the first bank and STS$ are cleared. If anyone wants to break the scroller or printer (8 characters 6*6 in one pass - it can't be faster), please make an effort to reach them or pull them out of the viewer.

If glitches are noticed, I would like to hear and see about them, because colorful squares are so beautiful!..

By the way, about colors. You can change some colors in the editor (only ink) using DiskDoctor!
To carry out such violence, you need to write the following values in the first 2 bytes of the Basic block (where the line number is stored):

0th byte 1st byte
00 AB CDEF
^^
└─ =0 ! (otherwise Basic skips the line)

B Ink Purpose
"─
0 A - Border color
0 B - Line editor color
C D - Text color
E F - Marking color
"─
0B0INK - Resulting attribute
| brightness

* What a perversion, huh? *

Editor

The interface is optimized for fast operation (under these words lies a lack of memory, and the most ordinary human laziness).
All work is thus done using hotkeys.

On the screen we have:
- Status line

INS/OVR - No comments
BIG/SML
RUS/LAT

EXT/ALT - Change virtual menu - you will understand later.
RES/SET - Marking mode - (see below)

LINE, COL, FREE - Speak for themselves

- Text window
- Message area
- Line editor area
- Name of the edited file + junk

* !A:FILENAME
│││
││└ Current disk drive
│└─ Marking presence indicator
└── Text change indicator

Keys in text editing mode:

CS/1 edit Scroll up
CS/2 caps lock Scroll down
CS/3 true video Page up
CS/4 inv. video Page down
CS/5 left Left
CS/6 down Down
CS/7 up Up
CS/8 right Right
CS/9 graphics Delete at cursor
CS/0 back space Kill (to all.)
SS/W Insert/replace
SS/A stop CAPS LOCK
SS/Q To the beginning of the line
SS/E To the end of the line
SS/I Continue search
CS/ENTER Mark line
SS/ENTER Delete line
SS/SPACE RUS/LAT

CS/SS ext command prefix of the editor
CS/SPACE break prefix of external command

Keys in line editor:

SS+Q/E Home/End
SS+SPACE RUS/LAT
SS+A CAPSLOCK
DOWN Clear line
EDIT Change disk drive
EXT, BREAK Cancel

Commands_are_divided_into_two_groups:

- Editor commands (EXT).
Entered after pressing EXTEND.

- External (alternative) (ALT)
Entered after pressing BREAK.

Editor commands:

Begin Mark the beginning of the block.
End Mark the end of the block.
BlK mode Set block marking mode:
SET in the specified block lines are marked.
RES in the specified block unmarks all lines.
Copy Copy all marked blocks to the location indicated by the cursor.
Delete Delete all marked blocks.
Move Move all marked blocks to the location indicated by the cursor. (uses COPY '& DEL, there was no time for better.)
uNmark Unmark all block markings.
Search Search.
neXt Find next.
Replace Find and replace.
Query:
Y - replace
N - skip
A - replace all
Q - quit

Undo Restore the line to the state it was in before editing. If you merged any number of lines with DEL or BACK SPACE commands, or erased lines consecutively using ss+enter, everything is restored.
Assemble Compile the program. If there are no errors and the program is small, you won’t have time to notice anything. Errors are output in batches of 20 lines and waiting for a key press. Space - exit the compiler. A second pass is made if there are no errors in the first pass.
Jump Jump to the line with number N.
Inspect Calculator.

Movements:

extent To the beginning of the text.
extent To the end of the text.
-extent > To the next marked line.
extent < To the previous marked line.

External commands:

Load Load text
Save Save text
Cat Catalog
Merge Add text to the end and subsequent marking.
save Blk Save block (it must be the only one, otherwise an error message will be issued).
save Obj Save compiled program. Saves the block from the minimum to the maximum address at which the code was generated. You can use ORG in any number and order.
Zap text Clear text.
Quit Exit to BASIC.
imporT Convert from text format to tokenized. Loads the source from disk. Unclear or too long is marked in the block and marked with ";", unclear commands are perceived as labels.
was: INCLUDE "THRASH"
became: JR INCLUDE,"THRASH"
implied: INCL "THRASH", as well as "DOOM" and "DEATH".
eXport Convert to text format. Writes to disk. No tabs. At the end of the line #0D. End of text marker is not placed.
Assemble Compile the program.
Debug Call STS.
Return - RETURN TO ASM
Run Launch the compiled program. Return by RET or OUT (#7FFD),#14:JP #C0

Questions not answered above:

Some errors are displayed on the border.

Blue - Current line longer than 40 characters (format limitation)
Red - Syntax error
Yellow - Insufficient memory
Green - Internal error

It may occur, for example, if you import not text, but, for example, a code block. If repeated entry does not help, you should reload Asm. You may not be able to recover the text.

It is no secret that working through TR-DOS resembles sadomasochism. Therefore, fast disk procedures are used in Asm, consequently, happy owners of a hard drive are severely disappointed.

Text integrity check is currently absent (a fast CRC will be available), so do not forget to save in time. If you have not saved and for some reason everything hangs, there is a chance that upon reloading Asm will miraculously find the survived text.

Compiler

GENERAL FORMAT OF A LINE:

[label] [cmd.+oper.] : [cmd.+oper.] ;REM

All fields are optional.

Label up to seven characters long.

In the label field, there may be an entry of the form:

.number

where number = 0-255, specifying the duplication of this line, 0=256 times.

A comment can be in any field.

Any number of operators is possible in a line (as many as fit in 40 characters..).

An operator can have an unlimited number of operands, for example:

ADD A,A,A,B,HL,DE = ADD A,A
ADD A,B
ADD HL,DE
PUSH BC,DE,HL = PUSH BC
PUSH DE
PUSH HL
JR NZ,LOOP,LOOP1 = JR NZ,LOOP
JR LOOP1
JR C,$+5,Z,$+20 = JR C,$+5
JR Z,$+20

DB ABC-$,LOOP-$ = DB ABC-$
DB LOOP-$

In the last two cases, $ is calculated correctly, and the commands on the left and right are absolutely equivalent).

The following tricks are allowed:

OUT (#FE) = OUT (#FE),A

OUT B,A,(#FE) = OUT (C),B ; only
- OUT (C),A ; unclear,
- OUT (#FE),A; why.

IN (#FE) = IN A,(#FE)

IN D,E,(#B7) = IN D,(C)
- IN E,(C)
- IN A,(#B7)

LD HL,BC etc = LD H,B
- LD L,C

LD BC,IX etc = LD B,HX
- LD C,LX

EX HL,DE = EX DE,HL

ADD DE,HL = EX DE,HL
- ADD HL,DE
- EX DE,HL

ADD DE,BC = We messed up, didn’t do it.
- We will fix it.

EXA = EX AF,AF

DB "@AEDFC825" = DB #AE,#DF,#C8,#25

DS 7,#AA,#BB = DB #AA,#BB,#AA,#BB
- DB #AA,#BB,#AA
- a total of seven bytes

DS 1,"@ABCD" = DB #AB,#CD
- .
- DB #AB
- a total of 1 byte.

DS 10 = 10 zeros

In subsequent versions of the compiler, it is planned to support macro commands of the form:

1. XI R,R(N)
Where X=ADD,SUB,AND,OR,XOR
R-Register or indirect cell
ADDI L,#20 == LD A,L:ADD A,#20:LD L,A

2. LD DD,R
LD BC,L == LD C,L:LD B,0

3. SUB HL,DD == OR A:SBC HL,DD

Well, and we will come up with something else.

EXPRESSIONS

Where syntax allows a number, any expression, immediate or defined EQU, can be used. This applies to all commands.

Counting occurs ignoring line breaks, an expression like 0-#20 = #FFE0.

If the syntax requires a word, the result is simply calculated.

If the syntax requires a byte, the result must be in the range #FF00-#00FF, i.e. 0-#20 will give #E0.

In the commands IN, OUT, IM and RST, a negative number is not allowed.

Signs requiring two operands (placed between them):

+ Addition
G - Subtraction
* Multiplication
/ Division
Remainder of division
& AND (bitwise on words)
! OR (bitwise on words)
| XOR (bitwise on words)
> Non-cyclic right shift by N
= greater than or equal, result = 0 or 1
< strictly less, result = 0 or 1
> strictly greater, result = 0 or 1
= equal, result = 0 or 1

Signs requiring one operand (placed after it):

[ high byte (N/256)
] low byte (N256)
^ rounding up to the greater or equal
#AE18=#AF00, #B700=#B700
` rounding down to the lesser or equal
#AE18=#AE00, #3D00=#3D00
~ NEG, subtracting variable from zero.
(The most interesting thing is that this sign cannot be entered from the keyboard :)

@ NOT, = 0 if not zero = 1 if zero ' multiply by 256

In a complex expression, parentheses are calculated first, then signs with the highest priority, then signs with lower priority, and so on to the minimum priority. For equal priorities, calculation goes left to right. Inside parentheses, the same applies (there are their own priorities). The maximum level of nesting of parentheses + priorities - 16. (recursive procedures are used, the stack is filled with intermediate results. Control of 16 levels is present, the system will not hang.)

If the entire expression needs to be enclosed in parentheses, it is necessary to use a notation like 0 + (expression), otherwise the parentheses will be perceived as an addressing method.

Priorities:

[ ] ^ ` ' 8
* / 7
~ 6

Contents of the publication: ZX Format #07

  • From the Authors
    Update on SMUC, distribution issues, and plans for future ZX Format issues. Authors address outdated SMUC info and distribution problems of ZF-6. Upcoming content includes game descriptions and new projects.
  • Аторы журнала
    Contact information and editorial team details for ZX-Format No.7. Provides mailing and electronic addresses, as well as contact phone numbers. Information on the availability of their website and specific contact instructions.
  • Содержание номера
    The article provides an overview of notable software releases on the St. Petersburg market for autumn. It also includes detailed descriptions of games, programming tips, and hardware projects. Interviews, philosophical tales, and reader letters enrich the issue.
  • Игрушки - Welcome
    An overview of software novelties for ZX Spectrum, including games like 'Los Angeles Drugs Bust' and 'Jungle Warfare'. Each game description provides insights into graphics, gameplay, and features. A variety of genres from action to strategy are covered, showcasing the diversity of software offerings.
  • Игрушки - Алешкин А.В.
    The article describes the game 'TAI-PAN' as an arcade-economic game set in the 19th-century East, focusing on trading and survival amidst pirates and danger. It details the gameplay mechanics, such as trading goods, managing finances, and navigating seas with different ships. Despite its engaging plot and interface, the game didn't achieve much popularity in Russia.
  • Игрушки - Soft
    A whimsical narrative in a fantastical world where colors converse with the Last, a character recounting tales of ancient humans, coders, and a mysterious past. The story explores themes of language, translation, and the creation of 'the Last' amidst fantastical beings like flying hippos and sea giraffes. It serves as a fictional narrative with humorous elements, blending science fiction with satire.
  • Игрушки - Alex ASP
    A parody on Tolkien's 'The Lord of the Rings' named 'Bored of the Rings' by Delta 4 is explored. The text references adaptations, humorous adventures of characters like Fordo and Bimbo, and differing versions from Delta 4 over the years. Anticipated prequels and correspondence excerpts with Delta 4's Fergus McNeill are mentioned.
  • Игрушки - Гил-Гелад
    The article provides a detailed guide on navigating the 3D Construction Kit interface for ZX Spectrum. It explains menu options for file management, game setup, and in-game conditions. Additionally, it covers object creation, editing, and logic implementation within the program.
  • Программистам - Дмитрий Рудовский
    The article concludes the description of BB commands and provides tips on their usage. It details the usage of the CLOCK command for time and alarm management on ZX Spectrum. Additionally, it explains the SORT command for array sorting and introduces new logical and mathematical functions.
  • Программистам - Angel
    Introduction to assembly programming for beginners, covering basic concepts and commands. Detailed explanation of processor registers and flags, with examples. Offers practical advice on transitioning from Basic to assembly language.
  • Программистам - GreenFort
    Discussion on fast calculations in assembler for tasks like vector graphics and astronomy. Describes procedures for binary division and multiplication, with examples for different byte sizes. Highlights the adaptability of these methods for increased precision.
  • Программистам - TP, Stinger
    Detailed technical description of the Mod file format for music composition on ZX Spectrum, focusing on structure and data offsets for title, instruments, and patterns.
  • Программистам - Research
    The article describes the capabilities and limitations of the Convert program, focusing on its use for converting images to the BMC format. It includes technical details about the program's functions, such as dithering methods, sprite and screen format output, and the removal of extraneous dots. Additionally, the article briefly discusses the source code of X-Color and its potential applications.
  • Обзор
    The article discusses the ENLiGHT'97 demo-party held in St. Petersburg on August 24, 1997, featuring platforms like Spectrum, Amiga, and PC. The event attracted around 1100 delegates, leading to overcrowding and technical issues, which caused the cancellation of the second day. Despite these issues, the event was generally enjoyable, and there is hope for another event in 1998.
  • Обзор
    Review of VideoFAIR exhibition in Manezh with highlights on video and audio equipment. Amiga-service and various companies showcased their technological advancements in video editing and broadcast systems. Notable innovations include 3D laser-scanned displays and professional audio solutions.
  • Железо - Nemo
    Discussion of KAY technology export to decentralize Spectrum production. Highlights potential benefits and challenges of local manufacturing. Emphasizes quality assurance and support systems.
  • Железо
    The article describes the development of a new Scorpion motherboard, focusing on enhancing graphics, speed, and compatibility with modern peripherals like IBM keyboards and mice. It introduces the GMX (Graphic Memory Extension) board, designed to upgrade existing Scorpion models to match the capabilities of the new motherboard. The GMX board offers significant improvements in memory, graphics, and processing speed, while maintaining compatibility with ZX Spectrum and Pentagon standards.
  • Железо
    The article provides a detailed overview of two popular audio amplifiers for ZX Spectrum users in St. Petersburg. It highlights the advantages and specifications of the 2 X 2W low-voltage amplifier and the 2 X 22W car amplifier. The article also includes a price list and ordering instructions through the 'Nemo' company.
  • Примьера
    The article describes the improvements and features of the Turbo Assembler version 1.1 for ZX Spectrum. It highlights the differences from version 1.0, such as bug fixes, screen size changes, and added features like line editor and syntax checking. It also details the memory allocation and provides a guide on using the editor and compiler functions.
  • Примьера - STS
    Description of the Riff Tracker MOD-editor for General Sound, its features, and functionalities. Provides detailed instructions on using editing and sample management. Notes on the current version limitations and expected improvements.
  • Примьера - Paul Atrides, Alex Noman
    Presentation of Oberon Creative Pack, consisting of ZX-WinWord and Sprite Cutter. ZX-WinWord is a text editor combining text and graphics with advanced features. Sprite Cutter allows sprite creation and manipulation in various formats.
  • Примьера
    Presentation of the second demo version of the game Headball by ZX-Masters, discussing its features and improvements since the first demo. The game offers two-player mode, four levels, three types of projectiles, various options, and computer difficulty settings. Availability of Turbo mode and enhanced synchronization and animation make it unique among other Spectrum games.
  • Интервью - Ruster
    Interview with Digital Reality about ongoing projects like DOOM and Paradise Lost. Discussion of challenges and progress in game development. Preview of their submissions for the ENLiGHT event.
  • Интервью - Ruster
    Interview with members of the newly formed group EXTREME. They work on demos for Spectrum and Amiga platforms and discuss their team members and activities. The interview also touches upon the state of the Amiga scene in Moscow.
  • Интервью - Борис Прытков
    Interview with Samara-based Spectrum enthusiasts discussing their achievements and challenges. Emphasis on community building and publication of Oberon magazine. Efforts to establish a Spectrum network and convert the game WALKER.
  • Интервью - Борис Прытков
    The article is an interview with members of the group Flash inc. discussing their projects for ZX Spectrum and PC, including a music editor with an innovative interface and a new multicolor graphic editor.
  • Интервью - Михаил Акимов
    Interview with Moscow-based group Progress discussing their current work on Spectrum demos, plans for future projects on Amiga, and opinions on the Russian demoscene.
  • Интервью - Михаил Акимов
    Interview with Felix about changes in the tech landscape, the enduring appeal of Amiga despite PC dominance, and his work on 'Winnie the Pooh - 2' for Spectrum.
  • Интервью - Ruster
    Interview with Slash about the ENLiGHT event, including sponsorship issues, attendee behavior, and the quality of music and demos. Discussion of the current state of the Spectrum and Amiga markets. Commentary on music trackers and the future of hardware development.
  • Интервью - Ruster
    Interview with V. Mednonogov after ENLiGHT'97 discussing impressions of the event, future of Spectrum, and his current project 'Black Raven'. Mednonogov shares his views on new hardware and software development and the importance of copyright. He also discusses his plans for upcoming projects and the challenges faced in game development.
  • Здесь был ты
    A satirical guide to gaining power and invisibility using magical rituals and Orbit gum.
  • Здесь был ты - Saggitarius
    A contemplative novella about a man's existential journey after encountering a mysterious individual offering a device called the Stop Crane. Through flashbacks, the protagonist reflects on his life, uniqueness, and his desire to break free from societal constraints. Ultimately, he faces the moral dilemma of using the Stop Crane to transcend time and existence.
  • Почта - Eagle Soft
    Critique of ZX-Spectrum software, highlighting the limitations of current programs and recommending the removal of outdated tools. Discussion on the limitations of assembly programs and the need for more efficient assemblers like M80. Evaluation of current music and graphic editors, with a focus on the redundancy of certain applications.
  • Почта
    Discussion of reader inquiries on ZX Format distribution and content. Responses include details on acquiring issues and technical insights on the KAY-256 computer. The magazine also addresses criticism of its market outlook article.
  • Почта
    This advertisement highlights XL Design Inc.'s software distribution campaign, offering games like 'Plutonia' and upcoming releases such as 'Mortal Kombat'. Mouse controllers are promoted with humorous selling points and pricing details. Studio LOGROS provides a wide range of software and peripherals, with options for local and remote purchases.
  • Разное - Александр Сысоев
    The article discusses the creation of an RPG game by the OBERON GROUP, inspired by 'Eye of Beholder'. It describes the game's humorous plot set in a distant galaxy and the battle against invaders on a planet named Agima. The team invites musicians, artists, coders, and scriptwriters for collaboration.
  • Разное - Viator
    The article describes the development of a new graphics editor called STATE OF THE ART for ZX Spectrum, aiming to improve upon existing editors like ART-STUDIO and ARTIST-2. The team AVALON, inspired by feedback from the SPECCY artist community, incorporates features from editors on Amiga and PC, while also addressing specific user requests. Key features include a user-friendly interface, enhanced magnify mode, advanced shape and window manipulation, and optimized performance.
  • Разное
    Discussion on enhancing consumer quality of Spectrum computers without altering their technical specifications. Suggestions include improving existing support, developing platform ideology, and structural changes. The article also touches on the potential of electronic books and their commercial viability.
  • Amiga Club - Максим Петров
    The article describes the author's admiration for the Amiga computer, emphasizing its aesthetic and technical merits compared to other platforms. It explores the author's programming experiences on Amiga, highlighting its efficiency and the impressive capabilities of its new hardware upgrades. The article concludes by reflecting on the unique community and passion of Amiga enthusiasts.