System - description of the macro assembler-debugger ALASM128/512 v2.8.

ZX User #02
┌───────┐
                           │SYSTEM│
                           └───────┘


     Shadow macro assembler-debugger ALASM128/512 v2.8
        Brief description of functionality.

                      Contents:
    1. MEMORY ALLOCATION
    2. COLD START
    3. ASSEMBLY ENVIRONMENT COMMANDS
    4. EDITOR COMMANDS
    5. ASSEMBLY DIRECTIVES
    6. COMPILER ERRORS
    7. IN THE NEXT VERSIONS

════════════════════════════════ ════════════════════════════════

    1. MEMORY ALLOCATION
   ALASM allows you to work simultaneously with several texts,
located in different user memory pages. Transition
from editing one page to another is done by entering
teams
PAGE [page]
from the assembler working line. Number of texts that can
process ALASM depends only on the amount of computer memory.
    Pages in assembler are numbered according to the maximum value mask.
value output to port #7FFD for page switching.

──────────────────────────────── ────────────────────────────────
──────────────────────────────── ────────────────────────────────

    2. COLD START
   When you run the assembler from TR-DOS, the screen is cleared and
is the author's introduction, after which a memory test is carried out
by the two most significant and three least significant bits of port #7FFD. Its results
are displayed on the screen as XXX kb maskXX. The numbers indicate
how much memory is available to the assembler on your computer and what
Write port bits #7FFD control access. According to these bits, the mass
The operand of the PAGE instruction is specified.
   Below the memory test is HELP containing a list of commands
assembler and its editor. The hotkeys for these commands are removed
to title mode. Below it is suggested to press CS/0 to start
SETUP or for more information. The SETUP menu allows you to
Let you change the visual and configuration parameters of the work
assembler and, if desired, write them to disk. All changes
entered into SETUP are written directly to the body of the candy bar
assembler "alasm.C". Functions for starting SETUP or obtaining additional
This information is only available during a cold start.
   After the corresponding message, pressing any key will result in
Det to clear the screen and exit to the working line of the assembler.

──────────────────────────────── ────────────────────────────────
──────────────────────────────── ────────────────────────────────

    3. ASSEMBLY ENVIRONMENT COMMANDS
   The assembler environment has its own command system, most
Most of which are compatible with TASM2.0 commands.
    A list of these commands can be obtained on the screen by pressing
"H" (HELP) keys. You can enter the required command by pressing la-
the capital letter that is part of this command.
In this case, the entered command is displayed in the working line, afterwhich, if necessary, waits for the input of operands or, depending
depending on the destination, confirm by pressing ENTER.
   After entering the command, it is duplicated in the working screen and executed.
no doubt. If the operands are incorrect, the corresponding
message.
   The execution of any command can be interrupted by pressing BREAK.
   If the result of executing a command may be lost
text, then if it has been changed, a request is displayed to save it -
Note: File has been changed. Save(Y/N)?
   The assembler environment command system includes:

Help
Format: HELP
Displays a list of commands available in the assembler and editor.
The HELP command contains no operands and does not require confirmation.
by pressing ENTER.

Quit
Format: QUIT [address][,page]
Exit from assembler. If the parameters are not specified,
the exit goes through the bottom of the stack, otherwise
unconditional transition to the specified address. Page parameter
output to port #7FFD with bit 4 set (default sets -
Xia 0). The parameters "address" and "page" can be used
labels or arithmetic expressions containing them are used.

Debug
Format: DEBUG
Exit to STS debugger. If there is no monitor on page 7
a corresponding message is displayed. If before entering this code
mand the text was compiled, then into the debug address pointer
monitor will record the address of the last ORG. At the same time, by typing
inSS/5 debugger, you will be able to debug your pro-
gram by observing the names of tags by their addresses on the screen.

Run
Format: RUN [address][,page]
Performs the same actions as the QUIT command, but first
carries on the stack the return address to the resident assembler module,
which allows you to return to assembler from the running program
by RET command. By default, the "address" parameter takes the value
the last ORG directive, and the "page" parameter is 0.

Work
Format: WORK [filename[.ext]]
Loading a file into the current working page.
The default extension is "H".
"filename" can be a mask. In this case there will be
the first file that satisfies it is loaded.
If the "filename" parameter is not entered, then the user
is given the opportunity to select a file from the current directory
disk by selecting it with the cursor from the list of files that appears
at the top of the screen.

Catalog
Format: CATALOG [mask]
The default is "*.*" (all files).
Displays the disk directory.
The mask format is defined as follows:
"?" sign determines what can be in a given position
any character. The "*" sign determines that, starting from this position,
all characters can take arbitrary values. Upon reaching
delimiter ("." or end of line) is assumed to be
the rest of the line is filled with SPACE characters.

nUmbers
Format: NUMBERS [parameter]
Changenumber system of displayed numeric information. "Pair-
meter" is one of two expressions: "DEC" or "HEX".
     
Name
Format: NAME newfilename[.ext]
Change the file name to a new one.
The default extension is "H".
"newfilename" - new file name.

Print
Format: PRINT [bytes list]
Outputs the current text to the ZX-LPRINT port, having previously output
the specified list of bytes. Bytes are separated by commas.

Edit
Format: EDIT [filename]
Go to editing the file in the current page. In case
if the "file name" parameter is specified, a file with that name is loaded
is transferred to the current page. If the file is not found on the disk,
a new file with the entered name is created on the current page.

Merge
Format: MERGE filename
Loading a text file in ALASM format at the end of the current file.
The "file name" parameter is required.

counT
Format: COUNT arithmetic expression
Evaluates the specified arithmetic expression. Re-
The calculation result is displayed in decimal and hexadecimal
systems. The parameters of an arithmetic expression can be
labels and their high and low bytes are used.

sYmbol
Format: SYMBOL [mask]
Displays a list of marks that satisfy the "mask" condition.
The command is executed only if it has been executed before.
compilation has been carried out. Labels can be displayed as an attribute
the following messages:
number - The label value determined whencompilation;
NoDef - The label was not defined, but was used;
Macro - The label represents the name of the macro definition block;
Wrong - The label format is not defined due to compilation errors.

Assembly
Format: ASSEMBLE
Compiles the text in the current page, starting from the first
howl lines. During the compilation process, the number of
compiled strings to control machine hangs.
When compilation is complete, the following messages are displayed on the screen:
 Symbols: AAAAA-BBBBB
The indicated difference represents the amount of free memory
on the page reserved for the table of labels. In case the table
labels are distributed over different pages, the AAAAA parameter indicates
the address of the last entry in the POST SYMBOLS PAGE, and the BBBBB parameter is
in SYMBOL LIST PAGE;
 Time= XXX.XX
This number represents the exact time it took to compile the text from
accurate to hundredths of a second.

Save
Format: SAVE
The current file is written to disk. If a file with such
name already exists on the disk, it is deleted without additional
requests.

Info
Format: INFO
Displays the version number, a list of system page numbers
memory and listing files located in the entire memory of the computer
computer at the time the command is issued.

paGe
Format: PAGE [page number]
Goes to the page specified as the "page" parameter.
Until the next change to the PAGE command parameter, the specified page
tsa becomes current and that's itcommands for current pages will be
be performed on it.

──────────────────────────────── ────────────────────────────────
──────────────────────────────── ────────────────────────────────

    4. EDITOR COMMANDS
    When entering the editing window, the screen is split into two parts:
editing window and information line, which displays
page number of the current file, its name, amount of free space
memory in this page and the number of bytes transferred to the pocket
(if this number is not 0). The same line provides the supply
cha service commands for serving text.
    During the editing process, the user has access to service tools.
text service mands, however, unlike the assembler environment,
the result of their execution is not displayed on the screen in the form of text
message, but is controlled by the user himself.
List of ALASM assembler editor commands:

Quit
Format: Q
Exit from the editor to the assembler environment.

Begin
Format: B
Go to the beginning of the text.

End
Format: E
Go to the end of the text.

Search
Format: SEARCH [character string]
Search for a string of characters in text. The search starts from the position following
following the current cursor position and continues until the end of the current
hundred. When the search is stopped, it can be continued by entering
combinations SS/I, and if such a command is given after the end of the last
next line of text, the search will start from the beginning.
If the character string parameter is notspecified, it will be used
the string entered last time.

sYmbol
Format: SYMBOL [label name]
Search for a description of a label by text. When searching, it is assumed that
The first character of the label name is at position zero.
Properties - similar to SEARCH.

coDe
Format: CODE XXX>[character code]
Installing a character with an arbitrary code at the cursor position, typing
on the keyboard. When you enter a command, the character code appears,
located at the current cursor position and is asked to replace
him to another. If parameter is ignored, no action
will not be produced.

Restore
Format: R
Copies the contents of the pocket to the cursor position. Line, on
which the cursor is located appears first after the content
pocket After this operation, the permission flag is reset to
filling your pocket.

Clear
Format: C
Cleaning the pocket.

Xreplace
Format: REPLACE line1 line2
Starting from the position next to the current cursor position,
The text "line1" is searched. Once it is discovered,
the message "REPLACE(Y/N/G)?" is displayed. If the answer is "Y", the current
"line1" is replaced by "line2" and the search continues.
If the answer is "N", the search continues without replacement. When answering "G"
all encountered expressions "line1" will be replaced with "line2"
without additional requests. At any moment of the team's work
execution can be interrupted by pressing BREAK (CS/SPACE).

Line
Format: LINE line numberPlaces the cursor on the line with the specified number. Strings
numbered from zero to the end of the text in increments of 1 per
each line.

    When editing text, the user has access to the following functions:
called by pressing two keys simultaneously. These features
speed up work in the editor and have no operands:
SS/I - search continuation;
SS/D - switching between Russian and Latin input registers
       basic information. The register change is indicated
       changing the cursor;
SS/Q - deletes the current line. When running this command
       the removed stroma is automatically transferred to the pocket, but
       only if he was not busy with other information
       mation;
SS/W - insert an empty line. The current line is shifted incrementally;
SS/E - copy current line to pocket. After this command
       the cursor moves to the next line;
CS/1 - tabulation;
CS/2 - insert a space at the cursor position. Rest of the line
       moves to the right;

──────────────────────────────── ────────────────────────────────
──────────────────────────────── ────────────────────────────────

    5. ASSEMBLY DIRECTIVES
    When writing the compiler, the Author adhered to a set of guidelines
tive adopted in TASM3.0. Directives not present in the above
creation, selected in accordance with international practice
How to write Assembler language compilers, i.e. with the help
lantern andEnglish-Russian dictionary.
List of ALASM compiler directives and their descriptions:

1.
        ORG address[,page]
Setting the compilation address. Default parameter is "page"
is set equal to 0. As information about the current address of the company
For epilation, the "$" symbol can be used, which is equivalent to
connection to a reserved variable containing the address of the first
byte of the command in which the access occurred.
Example:
        ORG #7D19
        LDIR
;LDIR is written to address #7D19
        ORG #C069,#84
        INDR
;INDR is written to address #C069 in page #84 of the 512th memory
──────────────────────────────── ────────────────────────────────
2.
EQU label value
Sets the label to a value equivalent to the "value" parameter.
Example:
SCREEN EQU #4000 ;SCREEN=#4000
ATTRS EQU #5B00 ;ATTRS=#5B00
SCR_LEN EQU ATTRS-SCREEN ;SCR_LEN=#1B00
──────────────────────────────── ────────────────────────────────
3. Operations for selecting the high and low bytes of a word:
NUMB1 EQU #1234
NUMB2 EQU #ABCD
STBMLB EQU .NUMB1*256+'NUMB2 ;STBMLB=#ЗЧAB
MLBSTB EQU 'NUMB1*256+.NUMB2 ;MLBSTB=#12CD
;Try to avoid dividing by 256 to get the high byte
;necessary word, since division takes 280 times longer
;time than just the high byte allocation operation
        DEFB 'NUMB2
;Exactly equivalent, but much faster than
        DEFB NUMB2/256
;When specifying a byte valuemarks the low byte is allocated
;automatically
        DEFB.NUMB1
;equivalent
        DEFB NUMB1
;therefore it is mainly used for
        DEFW.NUMB1
──────────────────────────────── ────────────────────────────────
4.
        DISP address
Setting the address where the program should run.
        ENT
Assigning the program's work address to the current compilation address.
Example:
SCREEN EQU #4000
        ORG #8000
        LD HL,BEGIN ;Forward to screen area 
        LD DE,SCREEN ;and start the standby program
        LD BC,END-BEGIN ;[A] interrupts
        LDIR
        CALL SCREEN
        D.I.
        HALT
BEGIN DISP SCREEN
MARKA DEC A
        HALT
        JP NZ,MARKA ;JP - not by chance
        RET
       ENT
END
──────────────────────────────── ────────────────────────────────
5.
        INCLUDE "filename"[,page]
Including an additional text block in the compiled file,
recorded on the disc under the name "file name". At the same time, the specified
the file is loaded into the page specified by the "page" parameter
(default - current). After compiling the included
block, compilation continues from the line following this one
directives. The peculiarity of this directive is that the file
specified in it will not boot from disk if it is already found
appears on the required page.
Example:
        LDIR
        INCLUDE "TOKENIZE",1OTDR
        INCLUDE "ALASM2"
        HALT
;First LDIR will be compiled, then the text "TOKENIZE.H",
;loaded to page 1, then OTDR, then to current page
;the text "ALASM2.H" will be downloaded and compiled, after which
;the main file will be read from disk and compilation will continue
;from the HALT command.        
──────────────────────────────── ────────────────────────────────
6.
        MAIN "filename"[,page]
Specifies the main compilation file. The MAIN directive must be
the first executable directive of the slave file. 
Be careful with file names containing "." or
"*". It is better to replace them with the "?" symbol.
Example:
        MAIN "MAKEb?7",6
        LDIR
;After issuing the ASSEMBLE command, compilation is transferred
;program MAKEb*7, located on page 6,
;then the INCLUDE in it calls the slave
;a program consisting of a MAIN directive and an LDIR command.
;In included files, MAIN is ignored, so after assembly
;When LDIR is removed, you return to the main program and continue
;no compilation.
──────────────────────────────── ────────────────────────────────
7.
        INCBIN "filename"[,length]
Including a code block written in a compiled program
on disk under the name "file name" of size "length" bytes or
default from the catalog data.
Example:
        ORG #E000
        LD HL,SCRFILE
        LD DE,#4000
        LD BC,6144
        LDIRRET
SCRFILE INCBIN "SCRb?7",6144
;The file will be loaded to SCRFILE during the compilation process
;SCRb*7, which after launch will be transferred to the screen.
──────────────────────────────── ────────────────────────────────
8.
        DUP number
Left program bracket. Indicates the beginning of a block that is required
we need to compile "number" several times in a row
        EDUP
Right program bracket. Indicates the end of a repeatable block.
Example:
       DUP 32
        LDI
        LD A,B
        OR C
        JR Z,$+3 ;$ - address of the first byte of the compiled command
        LD(HL),D
       EDUP
;The block of text between DUP and EDUP will be compiled 32 times
──────────────────────────────── ────────────────────────────────
9.
        DEFM "character string"[,"character string"]
Reserving a character string.
Example:
        DEFM "There was a string of characters","VASYA"
──────────────────────────────── ────────────────────────────────
10.
        DEFB byte[,list of bytes]
Reserving a list of bytes
Example:
        DEFB "U",13,10,"butt",13,10,"was",13,10,"dog",13,10
──────────────────────────────── ────────────────────────────────
11.
        DEFW word[,list of words]
Reserving a list of words.
Example:
        DEFW ALASKA,BUFFER,12,#BD15,32767,.NUMB1
──────────────────────────────── ────────────────────────────────
12.
        DEFS number of repetitions[,list of bytes]
The list of bytes (default - 0) is copiedto the current computer address
lations. The number of cycles is equal to the "number of repetitions" parameter.
Example:
        LD SP,#5B00
        DEFS 8,#C5,#D5,#E5,#F5
;equivalent
;      DUP 8
;       PUSH BC
;       PUSH DE
;       PUSH HL
;       PUSH AF
;      EDUP
──────────────────────────────── ────────────────────────────────
──────────────────────────────── ────────────────────────────────


    6. When compiling the source text, errors may be generated
compilation time associated with programmer inattention.

  List of compile time errors
    assembler ALASM128/512
   0 - syntax error;
   1 - reserved;
   2 - reserved;
   3 - short transition is incorrect;
   4 - reserved;
   5 - reserved;
   6 - repeated description of the mark;
   7 - reserved;
   8 - reserved;
   9 - reserved;
   10 - compilation into ROM;
   11 - invalid operation;
   12 - incorrect MACRO operation;
   13 - not used;
   14 - system stack error;
   15 - disk error;

Fill time errors:
wrong short - incorrect reference to a label outside
              "short" field;
not defined - the label is not defined.

──────────────────────────────── ────────────────────────────────
──────────────────────────────── ────────────────────────────────

    7. IN THE NEXT VERSIONS
The current version of ALASMa is not the latest, since the pathsthe improvements are innumerable. The author will do his best
to make the assembler even more user-friendly.
List of improvements to expect in future versions in
first of all:
 - increase in compilation speed by more than 2 times;
 - ability to customize system data;
 - increased configuration capabilities;
 - support for extended memory mode on all types of machines;
 - recoding of yutsuken-yaverta;
 - increasing the density of text storage when saving
     compatibility of version formats from top to bottom;
 - conditional compilation directives;
 - macro operations and macro definitions;
 - displaying labels not only by name, but also by value;
 - RAMDISK for files loaded using INCBIN;
 - elimination of shortcomings associated with single-pass operation.

Share your thoughts about the article