M.M.A/SPEED SO.
There was such a good printing machine in the world
magazine "ZX-REVIEW" ..... There was, but whatever it may be
It's unfortunate, but everything came out! And on the ashes
the last its circulation, remained
unpublished article, written by me
and Max Vasiliev especially for this
publications.
And although the following text was typed back in
first year 1997, he did not lose
that relevance and poignancy. So I decided
include this material in the latest issueBOTH
RON. Don't let the goodness go to waste!
Truth was one small problems
ka...... Text articles written language
"ZX-REVIEW" and for readers "ZX-REVIEW". es-
Basically everything had to be redone. Od-
However, since the prospect of a complete re-
writings articles me not at all not
seduced me, I decided to leave everything as it was.
So, let's "grief" for the untimely
the PRESENT that has left usSpectrum
magazine - "ZX-REVIEW"!
(C) MAXSOFT / SPEED CO.
(C) M.M.A / SPEED CO.
Samara 1997 a.d.
BOOT program in one sector.
Since the first computers with the system
TR-DOS , appeared in our country,
hackers and programmers never stop solving
great problem of our time: why, how
and what boot loader should I write??? Those
who is interested in question modern
boot-building, I will allow myself to refer to
an article devoted specifically to this topic, which
which was published in the third issue
Samara electronic magazine "OBERON".
In this article, using the example of writing
tion of the boot program, we will consider the issues
implementations ultra-short programs on as-
assembler, a also possibility rational
nal use stabilization procedures
dartnogo ROM and TR-DOS in similar programs
rammah.
It is worth noting that that attempts to create
there were already ultra-short boot loaders, and
quite successful. For example boot, write
sled Shi-soft' in 1992 occupied
two sectors and it worked quite well. I
fundamentally I'm not talking about the length in bytes,
since in connection with the use
network media information (floppy disks, and
as consequence, disk OS, for example
TR-DOS), the concept of program length in bytes,
clearly is replaced by the concept of length in
sectors. And in case your procedure
has size 260 bytes, and also if
it will occupy 460 bytes, anyway
when writing to disk the file will be organized
volume in two sectors. Thus, if
your program is closely related to DOS, has
meaning select its maximum size, multiple
size standard TR-DOS
sectors and in consequences try is-
use every byte (bit) of this volume
memory.
We slightly we've moved away from the topic, let's come back
to our boots! Another example of boot-zag
ruzchik in two sectors - this is the program
D. Pyankova SMALL VOOT,distributed IN-
FORKOM. As it is written in the description for this
program: "The main feature is the small
volume (2 sectors), thereby ensuring
"Fast loading is starting." Quite obvious
but that with a size of one sector loading
will be even faster, and the space on the disk is like this
boot takes almost no time at all. Vop-
polished exactly this one absolutely seemed
would crazy idea and two people took up the task at once
Marsky programmer.
Since the time this idea arose in my
(M.M.A) the head has already passed about one and a half
years Because at that time I wasn't enough
experienced in programming, then simply share
was overwhelmed by the thought of writing such a masterpiece
with other Samara programmers. In re-
As a result, in tough competition,
single-sector boot was not just written,
but it’s written so optimally that I’m afraid
readers of "ZX-REVIEW" will no longer be able to do anything
Bo optimize. Although, if you don't look
listing given below, but try
implement this idea, which is called with
"clean sheet", then perhaps you, dear
dear readers, you will be able to find some new
high, non-standard solutions. Another thing -
changing functional features...
Full boot disassembler with comments
for almost every command you will find in
end of the article. There is also a boot dump there
and notes on code block merging
and BASIC. We will continue the topic of changes
and let's see what and how you can change
this (basic) version of boot.
In this version control program
carried out with with the help of SINCLAIR
JOYSTICKand keys "Q", "A", "O", "P". Select
file- "0","ENTER",reading a new directory
ha - "SPACE". As you can see, control from
SINCLAIR joystick is somewhat unnecessary and when
If you wish, you can throw it out and insert it
anything else.
For example, a good effect will give a thickened
font!
Store additional character set in
memory - this is already three sectors (768 bytes),
yes and use the creation techniques
fonts usingstandard ROM
font, more than once described in the ZX-REVIEW, too
you can't - too too much bytes! Solution
should be non-standard and at the same time
simple. What if you first print on
everything on the screen in normal font, and then pro-
perform the following operation over the screen:
ORG 30000
LD HL,#4000
In HL - the starting address of the screenLOOP1 LD A, (HL)
Open the loop, load the contents into A (HL)
SRL A
Shift A to the right (or SLA A - to the left)
OR (HL)
Overlay A onto the original byte on the screen
LD (HL),A
Place the result on the screen
INC HL
Increase the address on the screen by one
LD A,H
Load to Avalue H,
SR #58
and see if it has reached the older one
attribute area bits (#5800)
JR NZ,LOOP1
Repeat the cycle if HL < #5800
RET Listing l
In principle, the procedure on listing l works
is capable, and occupies only 14 bytes. But
forultra-short boot and that's a lot!
Further improvement of the procedure can be
can be carried out by changing the principles
pa defines the end of the screen area.
The thickening algorithm itself is already optimal.
ORG 30000
LD HL,#57FF
In HL - the very last byte of the screen
LOOP1 LD A,(HL) We load the contents into A (HL)
RRCA
Shift via RRCA (shorter by one byte!)
OR (HL)
Overlay onto the original
LD (HL),A
Copy back to screen
DEC HL
Reduce HL *****
LD A,H
Check the contents of H at 0
OR A
JR NZ,LOOP1
If HL > #OOFF, then repeat the cycle
RET
Listing 2
In in this case, the bytes are counted from the bottom
up", and does not end with #4000, but pro-
goes through the entire ROM (there is, of course, nothing there)
th does not change) and reaches the address
#0100. Using this method, we save
two more winning bytes and we get the procedure
ru in 12 bytes length.Some inconvenience is that
that while the program "goes" through ROM, tra-
Quite a large number of cycles ticks away
processor and the user begins to replace
Let's see how you thicken the characters. With one
On the other hand, this even is not bad - it turns out
very interesting effect but if it's for you
I really don’t like it, then try
the following:
Immediately after the command DEC HL, marked in
previous listing, type:
BIT 6, N
Checking whether is installed or sixth bits in
address written in HL. If installed,
then we continue the cycle, otherwise we exit.
JR NZ,LOOP1
RET To understand how this condition works, let me explain:
that all those addresses that may be located
in the HL register when working with the screen, have
set sixth bit (#40 = %01000000),
a starting from addresses #ЗFFF ( #3F =
%00111111) this bit is reset. According to this
principle and the detection of the end of the
wound area. We didn't gain any bytes from this.
rali, but it works faster than ver-
this with checking H for 0. But is it possible to
more save more? Naturally, you can!
Look in the comments to the boota listing.
Everything there is built on the fact thatsubsequent
the procedure uses the data from the previous one.
If before calling the thickening procedure in
register L will contain the number #FF, then
we just need to download the remaining
half register - N.
Put inListing 2 instead of LD HL,#57FF
command LD H, #57 and do not forget that in re-
gistre L should be the number #FF, left-
new from the previous procedure. Here we are
beamed procedure in 11 bytes - quite
normal for our single-sector children-
now. That's justthe situation with the L register is not -
understandable. Do I need to download it at all?
If imagine, that in the L register we can
the moment of starting the procedure is absolutely
random number, then at the end of the work we
simply we will get non-thickened ones from one to
#FF bytes in the lower third of the screen in the lower
parts of each familiarity! But in ROM
font, as far as I remember, only a comma and
some characters use the bottom line
acquaintances. And since these symbols are named
files generally rarely occur, then
feel free leave exactly loaded only
register N.
ORG 30000
LD Н,#57
LOOP1 LD A,(HL)
RRCA
OR (HL)
LD (HL),A
DEC HL
BIT 6,Н
JR NZ,LOOP1
RET
Вот она - оптимизированная версия утолще-
ния всего экрана, которую вы,dear chi-
tatels, you can insert into our one-sector-
new boot instead of additional control
from SINCLAIR - joystick.
Our main goal was to show you how
you need think when writing a supercom-
compactcode. In addition, we want to throw out
power the idea of a single-sector boot on a brain-
howl assault on the entire country. This is in our heads
the idea has already reached its full optimum. But we
We will be very glad if any of the readers
lei will offer something new, interesting, from
whatever you want, as in the famous advertisement,
say: "FRESH...."!
And here is and the bootloader itself is one long
sector:
ORG #5D3B
AUTHOR EQU #5D52
FILE_Р EQU #5D52
;BASIC СТРОКА ДЛЯ ЗАПУСКА
DEFB #00,#01,#F8,#00,#Е7,#C3,#A7,#3A
DEFB #F9,#C0,#В0,#22,#32,#33,#39,#30
DEFB #35,#22,#3A,#ЕА,#3A,#F7,#22
;ИНФОРМАЦИЯ ОБ АВТОРЕ(НЕ МЕНЕЕ 8 СИМВОЛОВ)
DEFB 23,11,32,"MAXSOFT'96"
DEFB #22 ;КОНЕЦ BASIC-СТРОКИ
DEFB #D ;"СВОБОДНЫЙ" БАЙТ
;1 SECTOR ВООТ
;IDEA ВУ М.М.A SOFT/SPEED СО.
;CODED ВУ MAXSOFT/SPEED СО.
LD (IY+#53),#5
;SETTING PAPER COLOR IN A CELL (#SC8D)
;BORDER IS ALREADY INSTALLED FROM BASIC
NEW_DISK ;DISC READING
CALL #D6B ;SCREEN CLEANING
;OUTPUT DE=#0000,HL=#50E0,ВС=#1721
;LOADING THE DISK CATALOG FROM ADDRESS #6801
ADD HL, BC
LD BC,#905
PUSH HL CALL #3D13
;ПЕЧАТАЕМ ИНФОРМАЦИЮ ОБ АВТОРЕ
LD DE,AUTHOR
LD C,#D
CALL #203C
LD A,2
;ОТКРЫВАЕМ ПОТОК ПЕЧАТИ НА ЭКРАН
CALL #1601
РОР HL
LD D,Н
LD Е,L
SORT ;СОРТИРОВКА КАТАЛОГА
LD ВС,8
DEC (HL)
JR Z,NEXT_F ;СTЁРTЫЙ ФАЙЛ
INC (HL)
JR Z,END_SORT ;КОНЕЦ КАТАЛОГА
PUSH HL
ADD HL,ВС
LD A,(HL)
РОР HL
СР "В" ;ТИП ФАЙЛА
JR NZ,NEXT_F
PUSH HL
LD A,#20 ;ПЕЧАТЬ "ПРОБЕЛа"
RST #10
МАКЕ_FILE
LD A,(HL) ;ПЕЧАТЬ
RST #10 ;БУКВЫ
LDI ;И ЕЁ ПЕРЕНОС
JP РЕ,МАКЕ_FILE
;(ДЛЯ УПЛОТНЕНИЯ КАТАЛОГА)
LD HL,#70D1 ;СЧЁТЧИК ФАЙЛОВ
INC (HL)
LD A,(HL)
FILE_C
SUB 3
;ВЫЧИСЛЯЕМ, НАПЕЧАТАНО-ЛИ
;ТРИ ИМЕНИ ФАЙЛОВ В ОДНОЙ СТРОКЕ
JR Z,FILE_C1
JR NC,FILE_C
LD A,#20 ;НЕТ,НЕ НАПЕЧАТАНО
RST #10 ;-ПЕЧАТЬ "ПРОБЕЛа"
FILE_C1 ;ДА,НАПЕЧАТАНО
LD A,#20
RST #10
РОР HL
NEXT_F
LD C,#10 ;ПЕРЕХОДИМ
ADD HL,ВС ;К СЛЕДУЮЩЕМУ ФАЙЛУ
JR SORT
END_SORT ;КОНЕЦ СОРТИРОВКИ
NEW_CUR ;РЕГИСТР В=0
LD C,В
;РЕГИСТР С-СЧЁТЧИК ФАЙЛОВ
MOVE_CUR
LD HL,#57F5
LD DE,#В
XOR A
;РЕГИСТР A-ВРЕМЕННЫЙ СЧЁТЧИКMOVE_C1
LD В,3
MOVE_C2
ADD HL,DE
;ВЫЧИСЛЯЕМ ПОЗИЦИЮ КУРСОРА
СР C
JR Z,CURSOR
INC A
DJNZ MOVE_C2
DEC HL
JR MOVE_C1
CURSOR ;РИСУЕМ КУРСОР
LD В,#A
LD DE,(#70D3)
LD (#70D3),HL
LD A,5
CURSOR1
LD (DE),A
;СТИРАЕМ СТАРЫЙ КУРСОР
INC DE
LD (HL),#16
;РИСУЕМ НОВЫЙ КУРСОР
INC HL
DJNZ CURSOR1
LD HL,#5C08
;ОБНУЛЯЕМ СИСТЕМНУЮ ПЕРЕМЕННУЮ (LAST-KEY)
LD (HL),В
KEYS ;ОПРОС КЛАВИШ
LD A,(HL)
СР " "
;ПРОБЕЛ-ПЕРЕЗAЧИTЫВAНИЕ ДИСКА
JR Z,NEW_DISK
СР #D
;ENTER-ЗАПУСК ПРОГРАММЫ
JR Z,START_F
СР "0"
;0-ЗАПУСК ПРОГРАММЫ
JR Z,START_F
СР "7"
JR Z,L_RIGHT
СР "6"
JR Z,L__LEFT
СР "8"
JR Z,L__DOWN
СР "9"
JR Z,L____UP
OR #20
;ENABLE UPPER CASE FOR LETTERS
;POLLING LETTER KEYS INDEPENDENT OF
;MODE "CAPS"
SR "r"
JR Z,L_RIGHT
SR "about"
JR Z,L__LEFT
SR "a"
JR Z,L__DOWN
SR "q"
JR NZ,KEYS
L____UP ;КУРСОР ВВЕРХ
DEC C
DEC C
L__LEFT ;КУРСОР ВЛЕВО
DEC C
JP Р,MOVE_CUR
;КУРСОР НЕ ДОШЁЛ ДО НАЧАЛА КАТАЛОГА
LD ВС,(#70D1)
;КУРСОР - НА КОНЕЦ КАТАЛОГА
DEC C
JR MOVE_CUR
L__DOWN ;КУРСОР ВНИЗ
INC C
INC C
L_RIGHT ;КУРСОР ВПРАВО
INC C
LD A,(#70D1)
DEC A
СР C
JR NC,MOVE_CUR
;КУРСОР НЕ ДОШЁЛ ДО КОНЦА КАТАЛОГА
JR NEW_CUR
;КУРСОР - НА НАЧАЛО КАТАЛОГА
START_F ;ЗАПУСК ФАЙЛА
LD A,C
INC A
LD C,L ;РЕГИСТР L=8
LD HL,#67F9
;АДРЕС НАЧАЛА КАТАЛОГА МИНУС 8
ST_F1
ADD HL,ВС
;ВЫЧИСЛЯЕМ ПОЗИЦИЮ ИМЕНИ ФАЙЛА В КАТАЛОГЕ
DEC A
JR NZ,ST_F1
LD DE,FILE_Р
;ПЕРЕНОСИМ ИМЯ ФАЙЛА В BASIC
LDIR
JP #3D03
;ВЫХОДИМ В BASIC С ЗАПУСКОМ ФАЙЛА
Листинг 4
l. НАБРАТь ТЕКСТ ВООТ'A В АССЕМБЛЕРЕ.
2. ВЫЙТИ В BASIC. СТЕРЕТь ВСЕ BASIC-СТРО-
KI RELATING TO ASSEMBLER AND CREATE
OWN LINE LENGTH 248 BYTES, I.E. KO-
MANDA PRINT RACK 23869 MUST SHOW
248.IN THIS WAY, IT IS UNDESIRABLE TO USE
EDITOR'S BASIC 128.
3. RETURN B ASSEMBLER AND PRODUCE
ASSEMBLY.
4. EXIT BASIC AND SAVE BASIC-PROG
FRAME : RANDOMIZE USR 15619:REM:SAVE"1SBOOT"LINE 1
Regarding improvements and changes.
In the basic version of the boot, given in lis-
tuhre 4.available 1 free byte. Its use
use for additional services
possibilities practically unreal. But
really try to print the files
not in three columns, but in two, and then new and
new freed bytes will open you
opportunity for more and more new bells and whistles
within the same one sector dis-
kovy space.In general, if it turns out that we have completed
accurately optimized the idea of single-sector
boot's and readers will not be able to find
even an extra byte, we propose to arrange
competition for the most convenient and powerful seven-sec
tory loader. This boot is very convenient
that that can be located in unusable
used sectors of the zero track. In this
case it turns out that boot does not take
not a single sector on the disk.
K the same as if in one/two-sector
boot loaders are only about providing
baking the minimum service, then in boot
seven sectors longyou can use
and auto-reading of discs and beautiful effects
you in the background (stars, snow) and much more
other.
Р.S. And most importantly, remember: “Any procedure
can be further optimized to such an extent.
that it will consist of one command
NOP and and do everything. what from her
required."
This was such a good article..... However,
since we publish it electronically, and
not paper magazine, there is possibility
make your life a little lighten !
In the appendix to the magazine you will find two
to to use of the "single-sector-
new boot:
1SBOOT_М (version by MAXSOFT)
and
1SBOOT_Р (version by POLTERGEIST)
The version from MAXSOFT was described in detail
in read by you article, and version from
POLTERGEISTA about too mostly but with
other functional features. K
In addition, this version several
before and therefore programmed not-
many otherwise. How? You'll figure it out for yourself when
disassemble!
Well and for most inquisitive minds, on disk
written two files in editor format
ZX-WORD:
1S_boot+. (listing with comments)
and
1S_boot-. (listing without comments)
The first file is convenient for converting to
assemblers with editor for 64 characters in
line and with support for Russian font
alternative encoding. An example is:
th assembler is version of ALASM4X8,
in then time like TASM x.xx although it supports
lives 64 characters in a line, but "bummer-
appears" in Russian comments.
For all those who do not use ALASM,
intendedsecond listing. It lacks
There are comments in Russian and lengthy
per line does not exceed 42 characters.
This file can be directly loaded into
TASM 2.0, and with using the option Import
Tasm2.0 and in assemblers TASM 3.XX, TASM
4.0 (XLD), TASM 4.XX (RST#7).
How to convert text to other types
assemblers I I hope you will understand
yourself.
Good luck!
-═════════════ -
* * * * *
MUSIC VU: VISUAL/MS/XTM
Share your thoughts about the article