ZX Format #02: IS-DOS: Command Line and Text Editor Restart

Section "How It’s Done?" No 2

V. Eliseev
IS-DOS Command Line Monitor and Restart of Text Editor #6E smbgt

Hello, dear readers of ZX Format! I hope that those of you who decided to try your hand at programming in the IS-DOS environment found it interesting to read about the internal structure of the system utility gmen.com, which was discussed in the first issue of the magazine. Today we will continue our study of IS-DOS restarts, so to speak, through live examples and will consider in general terms the use of the restart of text editor #6E smbgt using the utility mon.com as an example. The utility mon.com is well known to every IS-DOS user, as it organizes the dialogue between the user and the system and inputs all the main commands. It allows you to receive input from the keyboard and edit the text of the command being entered, and upon pressing ENTER, it sends it to the system, executing the command specified in the text. For entering and editing the command text in the monitor, restart #6E smbgt is used, which represents a functionally complete module of the text editor with a maximum line length of 256 bytes. Let's look at the program text:

;****************************************

;Example of using the text editor IS-DOS #6E smbgt

;Command line monitor mon.com
;source text with comments

ORG #5D64

;****************************************

;start of the program, finding the address of the command line buffer using restart #45 g_com - a special memory area used to send commands to the system, and placing it on the stack

START LD C,#45 ;define address
RST #10 ;of command line
EXX ;buffer (in HL)
PUSH HL ;address - on stack

;****************************************

;initialization of the program, preparation of the working window, buffer, etc.

;subroutine for clearing the buffer

CLBUF LD B,#7F ;length of the buffer

CLBUF1 LD (HL),#20 ;initialization
INC HL ;of the buffer
DJNZ CLBUF1 ;of the command line

;opening a window for the editor
;first, we determine the current colors based on the contents of system variables, so that the window does not stand out against the general background, and place them in the window vector.

LD IX,WIND ;address of the window vector
;of the editor

LD C,#72 ;define address
RST #10 ;of the screen vector
EXX ; (in HL)

LD A,(HL) ;read colors
;of the current screen
LD (IX+4),A ;input current
;colors into the
;editor window vector

;draw the window

LD C,#61 ;initialize window
RST #10

;initialize the cursor

CURINI SBC HL,HL ;reset HL
LD C,#6B ;set
RST #10 ;cursor coordinates

POP HL ;in HL - address
;of the command
;line buffer

;****************************************

;input and edit command

;set parameters for the editor - width
;of the window and byte of the status register - and call the editor

LD A,#2A ;width of the edit window
LD DE,#0B00 ;status register

;the byte of the status register defines the default settings of the editor:

; byte 0=0 - lowercase letters
; 1 - uppercase letters
; byte 1=0 - Latin case
; 1 - Russian case
; byte 2=0 - text mode
; 1 - pseudographic mode
; byte 3 must be equal to 1

LD BC,#036E ;call smbgt #6E
RST #10

;the smbgt restart accepts any characters from the keyboard, as well as independently processes control keys for moving the cursor and Delete; upon pressing ENTER, editing is completed and exit occurs, while the length of the entered string is contained in register A. Exit is also possible using the keys CS+9, CS+SS, SS+A, SS+SPACE, SS+ENTER, while the key code that triggered the exit from the editor is returned in register A.

RET C ;exit on error
;input-output

;if CS+9, CS+SS, SS+A,
;SS+SPACE, SS+ENTER are pressed, then

JR NZ,EXIT ;exit on refusal

;check - is the buffer empty?

AND A ;check ZERO flag
JR Z,START ;jump to start
;if buffer is empty

;***************************************

;process the contents of the buffer

PUSH HL ;remember address
;of command line buffer
LD D,E ;clear D
LD E,A ;in E - length of string
ADD HL,DE ;determine address
;of the first free
;buffer cell
LD (HL),#0D ;add ENTER

EX (SP),HL ;place in stack
;address of the end of the buffer
;of the command line,
;and in HL - the start
PUSH HL ;place address
;of the start of the command
;line in the stack above
;the end address

LD B,(HL) ;save the first
PUSH BC ;character of the command line

PUSH IX ;save the address
;of the window vector

;passing the name and parameters of the entered
;command to the IS-DOS interpreter
XOR A ;set A=0
LD C,#44 ;call exebat #44
RST #10

;restoration of the contents of registers

POP IX ;window vector
POP BC ;first character of the command line
POP HL ;address of the start of the command line
POP DE ;address of the end of the command line

;***************************************

;processing the result of command execution
;and restoring the buffer contents for
;editing in case of error

RET C ;exit on serious
;error exebat

LD A,#20 ;in A - space code
LD (DE),A ;"fill" ENTER in
;the command line buffer
LD (HL),B ;restore
;the first character in
;the command line buffer
PUSH HL ;remember in stack
;the address of the command line buffer

JR NZ,CURINI ;on error in command line
;return with saving the string text
;for correction

JR CLBUF ;correct return
;with clearing the buffer
;from the executed
;string

;****************************************

;exit on refusal

EXIT LD (HL),#0D ;place ENTER in
;the start of the command line buffer
XOR A ;set flags
;on exit:
;Z=1, C=0
LD A,#F4 ;set code
;of internal command
;of the shell (analog
;shel1 #81 with saving positions
;of the cursor on both
;panels)
RET

;****************************************

;data area of the program

;window vector:

WIND DEFB #00 ;X-coordinate of the window
DEFB #00 ;Y-coordinate of the window
DEFB #03 ;height of the window
DEFB #20 ;width of the window
DEFB %00101000 ;colors of the window
DEFB %11111111 ;shadow color #FF ;shadow is not displayed
DEFB #00 ;X-print position
DEFB #00 ;Y-print position

;****************************************

Author of the program - A. Leontiev
Comments - V. Eliseev
_________________________________________

Contents of the publication: ZX Format #02

  • IS-DOS
    Announcement of a school-ready hardware-software complex by Iskra Soft and Peters, featuring a networked computer class setup on ZX Spectrum with IS-DOS.
  • IS-DOS - Владимир Елисеев
    Explanation of command line monitor and text editor restart in IS-DOS using mon.com utility as an example.
  • IS-DOS
    Introduction to IS-DOS system utilities, covering functions like help, user menu, file viewing, editing, and file operations.
  • IS-DOS
    Detailed description of the eliminat.com program for freeing memory from resident tasks and drivers, featuring interactive mode and command-line keys. Specific channel numbers allocated for task and driver types. Includes usage options and color customization.
  • IS-DOS Window System - Владимир Елисеев
    Exploration of IS-DOS window system restarts for printing text in windows and absolute screen coordinates. Examples of restart implementations such as lwt, adrwt, lenwt, prstr, str, and lnstr. Continuation to cover auxiliary restarts in next issue.
  • Assembler
    Introduction to assembly language basics, focusing on flags, arithmetic operations, and register manipulation. Discusses addition, subtraction, and complex operations like multiplication and division through examples. Highlights specific assembly commands and their functions for ZX Spectrum.
  • Hardware
    Discussion of hardware modifications for Scorpion ZS-256-Turbo, including the implementation of a Turbo/Normal switch. Pros and cons of software-based switching methods. Advice on soldering and circuit adjustments.
  • Hardware
    Discussion of a new music add-on for ZX Spectrum by X-TRADE and HACKER STINGER, called 'ZX GENERAL SOUND', offering high-quality audio and minimal processor usage.
  • Hardware
    Discussion on hardware innovations and marketing strategies, focusing on mouse and keyboard interfaces for ZX Spectrum. Critique of competitor's misleading advertising and analysis of serial versus passive mouse technology. Author questions necessity and cost of advanced features.
  • Hardware
    Discussion of hardware acceleration methods for ZX Spectrum, focusing on turbo-modes and their effects on performance and compatibility.
  • Toys
    Fantasy tale about magical creatures battling human intrusion. Main character recruits allies for a quest to restore the land's former glory. Challenges include finding tools, overcoming obstacles, and reviving companions.
  • Toys
    Review of 'Carrier Command' game, focusing on its strategic and simulation aspects. Includes detailed gameplay mechanics, controls, and objectives. Highlights strategies for success and unique features like managing resources and autonomous systems.
  • Interview
    Interview with Sergey Zonov and Andrey Larchenko discussing their experience with microprocessors and ZX Spectrum development, including the creation of the Scorpion ZS 256 computer.
  • Information
    Contact information and staff list of ZX-Format No. 2 (1995) including editor, coders, and designers.
  • Information
    Editor's address to readers of ZX Format, discussing the positive feedback, past errors, and the quest for a cartoonist, with future plans for the magazine.
  • Information
    Discussion on the new interpretation of the 'PULLDOWN' window menu system for ZX Spectrum, focusing on interface updates and user interaction enhancements.
  • Information
    Discussion about companies illegally distributing ZX Format, emphasizing the benefits of purchasing official copies.
  • Competition
    The article discusses the lack of participation in ZX Format's competition, detailing the rules and prizes, and encourages readers to engage with new ideas.
  • Let's Relax
    A humorous account of a software vendor's challenges dealing with clueless customers, illustrating the nerve-wracking nature of his job.
  • Mailbox
    Overview of hardware components and prices for ZX Spectrum enthusiasts with ordering details.
  • Mailbox
    Reader letters section in ZX Format #02 discusses reader feedback, addresses issues with ZX Format features, and offers future improvements.
  • Premiere
    Guide to Digital Studio v1.12, a music editor for ZX Spectrum, including features, menu navigation, and the use of Digital Studio Compiler.
  • For Programmers
    Exploration of tools that extend the standard Basic 48, including Renumber for Basic 128, Trace & Speed, Blast Toolkit, and ZXeditor, highlighting their functionalities and utilities.
  • Various
    History of Amiga computer models and their evolution from A1000 to A4000/60T with specifications and unique features. Explanation of technical terms and differences between chip and fast memory. Mention of new developments like AGA chipset and models for different needs.
  • Miscellaneous
    The article presents upcoming ZX Spectrum software releases and reviews game innovations like 'Adventures of Winnie the Pooh' and 'UFO 2: Devils of the Abyss'. It highlights features, creators, and technical requirements. It also includes announcements from SOFTLAND and Cracked Masters Group.
  • Systems
    Discussion of creating music with Instrument 3.01, focusing on digitized sound. Analysis of program's capabilities and conversion from ASC Sound Master. Instructions for composition and conversion.
  • What's New
    Review of new ZX Spectrum games entering the St. Petersburg market in late 1995. Detailed game descriptions, memory requirements, controls, and music/graphics evaluations. Highlights include Night Hunter, Extreme, Grell & Falla, and more.