Deja Vu #09
13 ноября 1999

Coding - coding for Dummies: How does the "Boot" from the inside.

<b>Coding</b> - coding for Dummies: How does the
(C) SKL-KEEPER aka Kolesnikov
__________________________________________



         "Boot" - a look inside and

     possibility of improvement.



   In this my article, I want to touch
theme that have never touched, except for the ZX-Revue N: 5 / 
1994, and even then very sparingly and only in passing 
sovpadayusche with the named topic. There it was about 
auto-BASIC-line of machine code. Here I want to dwell on the 
theme of a broader, namely - a simple "boot", how does it work?


   The easiest, in my opinion, is
two-sector system "boot", developed by ShiSoft in 1993. So that 
a boot for sure there is a collection of any spektrumista. With 
him and begin. 

   I think I figured out well enough with how well it works, 
and what I hasten to share with colleagues. So ...


; Disassembler boot SHISOFT-1993 (one hour, Ty, who is thrown 
into the address 50015 ; (# C35F) and it starts with the same).

; BASICe In the first line is: RANDOMIZE
; USR VAL "15619": REM: SAVE "boot" LINE
; VAL "2"
; Second line has: RANDOMIZE USR VAL
, "23923"
; LOADER represents the following:


; ORG 23923
;
; PUSH HL; Must
;; Keep on HL
;; Stack!
; LD HL, METKA; How to make.
; LD DE, 50015, where to move.
; LD BC, 556; How many bytes.
; LDIR; Transfer.
; JP 50015; Start program.
; METKA DEFS 556


And then, finally, himself disassembler boot'a:


        ORG # C35F


BEGIN LD A, # 07

        LD (# 5C09), A; Installation ve
                           ; Quantities retarding
                           ; Between the LCD on
                           ; Zhatiem cells. and

                           ; Autorepeat.

        LD (# 5C0A), A; Ustan.perioda

                           , Auto-repeat.
; These settings are necessary for a more convenient, and Noah 
of the keyboard. It should in our ; Case immediately respond! ..


        CALL ATTR; Call n / prog.

                           ; Ustan.attrib.

                           , And CLS.

        XOR A

        LD (VAR_1), A; Zeroing ne
                           ; Variables.

        LD (VAR_2), A

        LD (NPROG), A

        OUT (# FE), A; BORDER 0.

        LD D, A; Nulev.dorozhka.

        LD E, A; Nulev.sektor.

        LD BC, # 0805; Read 8 sects.

        LD HL, BUFER; Address buffer

                           ; To read

                           ; Directory of the drive.

        CALL # 3D13

        LD IX, BUFER; In the IX-top

                           ; Buffer, where
                           ; Hoditsya assume
                           ; Culated directory

        LD DE, BUFER + # 800; In DE-address will
                           ; Schrieffer, where it will

                           ; Directory BASIC
                           ; Programs.
LAB_1 LD A, (IX + # 00); Address 1st prog
                           ; FRAMEWORK in kata.

        OR A

        JR Z, TEXTP; If the 1st character

                           ; File = 0, then

                           ; More files

                           No, it's on
                           ; Recent and go

                           , The label where

                           , Printed on

                           ; Pis below eq
                           ; Wound.

        CP # 01

        JR Z, LAB_2; If the 1st character

                           = 1, then it is erased

                           ; Th file transfer
                           ; Move on LAB_2.

        LD A, (IX + # 08); In akkum. address

                           ; File type.

        CP "B"; This is BASIC?

        JR Z, LAB_3; If so, ne
                           ; Transition by tag
LAB_2 PUSH IX; N / program

        POP HL; calculation of addresses

        LD BC, # 0010; the transition to the next

        ADD HL, BC; blowing titles.

        PUSH HL

        POP IX

        JR LAB_1; loops.

LAB_3 PUSH IX; Sub

                           ; Transfer of titles.

                           , Prog. in buffer

        POP HL

        LD BC, # 0008; length hazvaniya

                           - 8 bytes.

        LDIR; moved it.

        LD HL, NPROG; in cell NPROG

                           , Count the number of

                           ; BASIC-files.

        INC (HL); Adds

                           ; Unit.

        JR LAB_2; return to the

                           ; Top.

; Sub-print labels at the bottom of the screen.
; "SHISOFT-93:

TEXTP LD (DE), A; in the battery

                           And now zero.

        INC A; we add "1".

        LD (# 5C3C), A; Set Zero.

                           ; Bit of this system.

                           ; Perem.oznachaet

                           ; Conclusion to the case
                           ; Zhebny screen.

        LD A, # 16; Nachin.pechatat

        RST # 10; AT ...

        XOR A

        RST # 10, 0, ...

        LD A, # 09

        RST # 10, 9 ...

        LD B, # 0D; In the "B" - length

                           ; Inscriptions.

        LD DE, TEXT_; In DE-her address.
CYCL1 LD A, (DE); Take 1yu letter

        RST # 10; to publish it.

        INC DE; Go to the next
                           ; Blowing letter.

        DJNZ CYCL1; loops,

                           , Until all

                           ; Publish it.

        LD A, # 02; opens

        CALL # 1601; screen channel

        LD A, # 15; OVER ...

        RST # 10

        LD A, # 01; 1 ...

        RST # 10

        LD DE, BUFER + # 800, recorded in the DE

                           ; Address of the buffer

                           , Where the

                           ; BASIC-files.
LAB_4 LD C, # 03; three columns.
CYCL3 LD A, (DE)

        OR A; not zero?

        JR Z, LAB_6; If yes,

                           ; Went to LAB_6

        LD A, # 20; Space.

        RST # 10, print ...

        LD B, # 08; name length

                           ; Program.
CYCL2 LD A, (DE); Print this

        RST # 10; title.

        INC DE

        DJNZ CYCL2; Until Napa
                           ; Chat.

        LD A, # 20; Print gap

        RST # 10

        DEC C

        JR NZ, CYCL3

        LD A, # 0D; Code 13 - the end

        RST # 10; line.

        JR LAB_4; repeat again

LAB_5 LD A, (VAR_2)

        CALL LAB_7
LAB_6 LD A, (VAR_1)

        CALL LAB_7

        JR KLAWA


LAB_7 LD B, # 00
CYCL4 CP # 03; three columns?

        JR C, LAB_8; If less

                           ; Went to LAB_8.

        SUB # 03; Otherwise subtract

                           , Triple and 1

        INC B; uvelich.reg. "B"

        JR CYCL4; loops.

And A in the following sub productivity, reduces the 
calculation of the location of printing: LAB_8 SLA A; 
Arifm.sdvig 

                           ; Left.

        LD C, A; Remember that in

                           ; Case "C".

        SLA A; Just a couple of times

        SLA A; shift to the left.

        ADD A, C; added to the

                           ; The fact that the "C".

        LD C, A

        INC C

        LD A, # 16; AT ...

        RST # 10

        LD A, B; calculated positions

        RST # 10; print (columns
        LD A, C; ka, string).

        RST # 10

        LD A, # 14; INVERSE ...

        RST # 10

        LD A, # 01; 1 ...

        RST # 10

        LD B, # 08; name length
CYCL5 LD A, # 20; Space

        RST # 10; Print gap

        DJNZ CYCL5

        RET


; Sub poll the keyboard:
KLAWA LD A, (VAR_1); In these cells

        LD (VAR_2), A;-data about the position
                          ; Approximation cursor.

        LD HL, # 5C3B; in HL-e ne
                          ; Rem.FLAGS. 5th

                          ; Bit it establishes

                          ; Lebanon to

                          ; Pressing any

                          ; Simvol.klavishi

        RES 5, (HL); Reset 5 bits.

        HALT; wait sled.prer.

        BIT 5, (HL); Test 5 bits

        JR Z, KLAWA; If the fold. pressing

                          ; There, the team of "pro

                          ; Skakivaetsya.

        LD A, (# 5C08); Writes in A with
                          ; Derzhimoe LAST_K

        CP # 0D; That ENTER?

        JP Z, PUSK_; if not, coma.

                          ; Slips.

        SET 5, A; Set. 5 bits.

        CP "6" is "6"?

        JR Z, WLEWO

        CP "7" is "7"?

        JR Z, PRAWO

        CP "8" is "8"?

        JP Z, WNIZ_

        CP "9"; This is a "9"?

        JR Z, WWERX

        CP # 30; is zero?

        JP Z, PUSK_

        CP # 6F; This is the letter "o"?

        JP Z, WLEWO

        CP # 70; This "p"?

        JP Z, PRAWO

        CP # 71; This "q"?

        JP Z, WWERX

        CP # 61; It's "a"?

        JP Z, WNIZ_

        CP # 20; This is the gap?

        JP Z, BEGIN

        CP # 63; This is the letter "c"?

        JP Z, AGAIN
WLEWO LD HL, VAR_1

        LD A, (HL)

        OR A

        JR Z, KLAWA

        DEC (HL)

        JP LAB_5


PRAW LD A, (NPROG)

        DEC A

        LD HL, VAR_1

        CP (HL)

        JP Z, KLAWA

        INC (HL)

        JP LAB_5


WWERX LD HL, VAR_1

        LD A, (HL)

        OR A

        JP Z, KLAWA

        DEC A

        OR A

        JP Z, KLAWA

        DEC A

        OR A

        JP Z, KLAWA

        DEC A

        LD (HL), A

        JP LAB_5


WNIZ_ LD A, (NPROG)

        LD HL, VAR_1

        CP (HL)

        JP Z, KLAWA

        DEC A

        CP (HL)

        JP Z, KLAWA

        DEC A

        CP (HL)

        JP Z, KLAWA

        DEC A

        CP (HL)

        JP Z, KLAWA

        INC (HL)

        INC (HL)

        INC (HL)

        JP LAB_5


; If you press ENTER, then after a small, shoy training run 
selected prog; Rummy: PUSK_ LD A, # 15; OVER ...


        RST # 10

        XOR A; 0 ...

        RST # 10

        LD A, # 38, New Attributes

        CALL ATTR

        LD A, # 07; White BORDER.

        OUT (# FE), A

        LD A, (VAR_1); start calculation

                          ; Rooms start.

                          ; Program.

        RLC A; Vrasch.vlevo without

        RLC A; carry flag.

        LD C, A

        LD B, # 00

        LD HL, BUFER + # 800

        ADD HL, BC

        ADD HL, BC

        LD DE, # 5D4E; place in the 1st century
                          ; Robe BASICa where

                          ; Finds. name

                          ; "Boot".

        LD BC, # 0008; name length

        LDIR; Transfer BASIC

                          ;-Line.

        LD A, # 3A; This is the colon.

        LD (# 5D57), A; transfer it to the

                          ; BASIC-line.

        LD A, # F7; That - RUN.

        LD (# 5D4C), A; transfer it to the

                          ; 1yu BASIC-line

                          And instead of SAVE.
AGAIN XOR A; Zeroing Accum.

        LD (# 5C42), A; have brought 0 ne
        LD (# 5C44), A; belt, where

                          ; Line number

                          ; BASIC following.

                          ; Operator and

                          ; Number sled.vy
                          , Holds the operator
                          ; Operator RASIC.

        LD HL, # 0223, return change
        LD (# 5C09), HL; nennye early

                          ; Boot-and change
                          ; Nye.

        POP HL; Sohran.na stack

        RET


ATTR LD (# 5C8D), A; Constant ATT
                          ; Ributy.

        LD (# 5C48), A; Attrib.sluzhebn.

                          ; Screen.

        CALL # 0D6B; CLS

        RET


TEXT_ DEFB "1993 ShiSoft"
NPROG DEFB 0; Kolich.BASIC
                          ; Programs.
VAR_1 DEFB 0
VAR_2 DEFB 0
BUFER DEFB 0; It begins
                          ; Is directory

                          ; Drive.


   Well, to understand how it works.
I hope everyone all right?

   We now turn to the second part of my story ...:-)

   So, whether it has boot'a disadvantages? Yes, they can 
always be found, it would be a desire :-) Well, for example, 
why do we need to display himself "boot", if we can restart by 
pressing the space bar? AND yet: there are programs, consisting 
of two BASIC-loader. In this case, the second boot is not 
needed, it will only make a mess, and it would be advisable not 
to withdraw ... 

   Hence, the first task is: to include
in the program "boot" 'and filtering of all BASIC-files 
beginning with a lowercase letter or with a space (this is just 
in case). How to do it? Very simple: to include in the

disassembler following snippet:

        ...................

        CP # 01

        JR Z, LAB_2; If the 1st character

                           = 1, then it is erased

                           ; Th file transfer
                           ; Move on the L399.

        CP ""; This is the gap?

        JR Z, LAB_2; If so, re
                           ; Progress on the label.

        CP # 5B; if> = "Z", then

        JR NC, LAB_2; transition, because

                           And after "Z" are

                           ; Malenk.bukvy.

        LD A, (IX + # 08); In akkum. address

                           ; File type.

        CP "B"; This is BASIC?

        JR Z, LAB_3; If so, ne
        ...................

   To include this snippet, I think
Did you understand (I specifically left two
stitch the top and bottom of the main program.

   More ... Perhaps more to ubobno
Users will be if the font, which displays the names of 
programs, will not standatnym Spectrum, and "pokrasivshe. 
Please, here's another piece (the procedure formation of the 
font I pulled out of the program MINIBOOT 3.0: Well, very much 
like the font!): 

       .................

        LD (# 5C0A), A

        CALL ATTR; Call n / prog.

                           ; Ustan.attrib.

                           , And CLS.

        LD HL, 15360

        LD DE, FONT

        PUSH DE

        LD (23606), DE

        LD BC, 1024

        LDIR

        POP HL

        LD BC, 128
LAB2 PUSH BC

        INC HL

        INC HL

        INC HL

        LD B, 3
LAB1 LD D, (HL)

        LD A, D

        RLA

        OR D

        LD (HL), A

        INC HL

        DJNZ LAB1

        POP BC

        DEC BC

        INC HL

        INC HL

        LD A, B

        OR C

        JR NZ, LAB2

        ..............

   Only we must not forget that when we chose the program and 
press ENTER to run, you must return the value of CHARS

(In sub PUSK_):

        .................

        LD A, # 38

        CALL ATTR

        LD HL, 15360

        LD (23606), HL

        LD A, # 07

        ................

   Well, the last one. As you know, in the described boot'e 
control the cursor can be by right-Sinclair joystick and 
buttons QAOP, SPACE. You can add a poll cursor keys (in a 
subroutine with a nice name KLAWA). How do you can read in my 
article about the poll Keyboard section for Dummies "DEJA

VU.






Other articles:

Apperativchik - the entry of the authors.

Apperativchik - On the control of Deja Vu.

Apperativchik - Freebie number 2: pirates and hacked versions of the magazine.

Apperativchik - Dejavu Info: How to buy the magazine Deja Vu.

Topic - Swap: "From letters to parcels" as found in the city Spektrumistov.

Topic - Tusovka: CSP'99 - interview with Slack Den.

Topic - Tusovka: CSP'99 - an interview with the main coder'om young Novosibirsk group AREASoft

Topic - Tusovka: CSP'99 - interview with one of the publishers 'electronic journal Deja Vu' Daniel / Playgear Co. / Binary Dimension.

Topic - Tusovka: CSP'99 - interview with one of Rybinsk of Cav / Auryn.

Topic - Tusovka: CSP'99 - an interview with the father of Playgear cool uncle Ze Pagan.

Topic - Tusovka: CSP'99 - an interview with the main coder'om Flash and concurrently one of the founders of the group - Alex Rider.

Topic - Tusovka: CSP'99 - poll as the party was held in a nutshell, the general impression.

Topic - Tusovka: Legend of the way passed Crazy Siberian Party 1999.

drop of solder - HD discs: Finalization of the drive controller to work with HD-disks.

drop of solder - The decision PROBLEMS 1.2MB drive.

drop of solder - increase the amount of RAM up to 1024K on SPECCY option Taganrog 128K!

drop of solder - circuit programmer for chip-only memory (ROM).

drop of solder - a dot-matrix printers.

drop of solder - ISA-Spectrum: card inserted into the ISA slot is IBM, which is part or a complete computer ZX-Spectrum.

Software - demoscene: Obzor'ing demozov: 63 bit III, Jam, Anamnesis, 7 Up, 63 bit IV, DemoDyin, Napalm, Crapmo 2, Bunch of Arce, Devotion, WorkStop, Energy , Yes.

Software - Game Review: MIST: Monstrland Part Two, Bomb Lakes, Marbles, KluXer, 4x4 Puzzle, Soldiers, Boats.

Software - Gun Commander: User's Guide.

Coding - coding for Dummies: civilized way in TR-DOS.

Coding - coding for Dummies: More about one of the ways to survey the keyboard.

Coding - coding for Dummies: How does the "Boot" from the inside.

Coding - coding for Dummies: refine MINI BOOT V3.0.

Coding - how to print 42 characters per line (with trabutami), the procedure is quick print sprites with pixel precision.

Coding - Bystrai printing 64 characters per line.

Coding - Conversion of numbers from the stack calculator in the character string.

Coding - fast print 2x2 sprite familiarity, up to familiarity.

Coding - Hrust Library svobodnopasppostpanyaemaya library window procedure by means of eccentricity can be packaged and paspakovyvat VARIOUS data.

Coding - Error Handling TR-DOS when working through # 3D13.

Coding - a set of procedures for constructing the user interface.

Coding - pishim virus invisible to TR-DOS.

Another world - The illusion of safety: Terrifying tales of Windows security and the Internet (Part One).

Hall of Fame - 3 methods to distinguish pealny ZX Spectrum from emulyatopov.

Hall of Fame - the charter of the National Fund of the Spectrum (HFSP).

Hall of Fame - Reserves: an attempt to present the perfect ZX Spectrum.

Hall of Fame - boiling: "And there still alive Speccy, sympathy Boxing?" Reflections in hearing.

Hall of Fame - schA say number 1: optimization of procedures, the announcement of the magazine and the new arcade toy.

Hall of Fame - schA say number 1: disassembly and Serg'a Playgear, hacking calling card, the announcement Crazy Siberian Party '2000.

Hall of Fame - A brief history of the Kemerovo group Digital Life Group.

Seven and 1 / 2 - Student mythology.

Seven and 1 / 2 - April Fools' Day 2 (end).

Seven and 1 / 2 - fairy tales for children.

Seven and 1 / 2 - Features a national ruleza or pure Siberian project (the story of Crazy Siberian Party 1999).

Samples pen - memory: story of the game "Black Crow".

Samples pen - story, "Elixir of the Beast."

Samples pen - "Last Warrior".

Advertising - text ads and announcements.

Advertising - a graphical advertising and announcements.


Темы: Игры, Программное обеспечение, Пресса, Аппаратное обеспечение, Сеть, Демосцена, Люди, Программирование

Similar articles:
From the Editor - Credits: The authors of the magazine.
WINSOFT NEWS - LIME TREE continues to be published.
News - a little bit of news from SPECCY WORLD'a.

В этот день...   23 November