About this and that.
(C) Denis Tokarczuk (DWT)
As is known, recursion in programming
roving is the process of calling any
procedures “in themselves”. Example simple
that, but nevertheless fatal pekypcub-
new design:
NOP LABEL
CALL MARK
You can imagine what will happen
stack and the program will freeze forever.
Therefore, from recursive functions (subroutine
ram) it is necessary to provide an exit when
fulfillment of some condition.
When creating a shell for this number, I
used recursion in a rather original way
together with the stack.
The fact is that in the new standard
texts (ZXTTFv2.0) applied
tight"compressor". Koe-what codes
and character groups ASCII replaced with, as
I called them macros (although this is not exactly
true). So, for example, the code #7F "includes
"contains" four characters - "(C)", code
#19 "accommodates" 20 spaces, code
#F2 - "ZX", #F3 - "Time", #FA - "trum",
etc.
When writing a leaflet, a problem arose
ma - what is the best way to display these characters without
significant damage in relation to pa-
wrinkle and speed. At first I planned
perform two printing procedures, however, when
6x8 character format this results in
kilobytes of invaluable memory, since for
printing such characters is necessary both
at least four subroutines. This is because
that all the computer memory is broken
into cells of eight bits, a symbol is 6x8 in
width is 6 pixels, i.e. 6 bits, due
Why do you have to shift it four times?
symbol image for "squeezing"
them into "snippets" of bytes. Four because 6
bit * 4= 24 bits / 8 = 3 bytes (fifth
the symbol is, as it were, “aligned” and its
chats the same subroutine as the first one
vyy; sixth - the same as the second; and
etc.) If visually, it looks like
as follows:
1 character 2 character 3 character 4 character
───┬──── ───┬──── ────┬─── ────┬───
└─┐ └─┐ ┌┘ ┌─┘
└┐ │ │ ┌┘
┌─┴────┐───┴───┐───┴───┐───┴──┐
││010001│01│0100│0100│01│011110││
│└──────┘──│────┘────│──┘──────┘│
└──────────┼─────────┼──────────┘
1st byte │2nd byte│ 3rd byte
You understand that the designs
RLCA-RRCA-AND-OR simply inevitable. Although
some programmers to increase
output speeds were generated in several
ku fonts with "shifts" (see, for example -
example, in Deja Vu), but it's too painful-
Great price for that speed. I knew that c
my requirements for the shell, anyway
not to achieve “framework” and from the very beginning
I set a goal to write simply
quick scrolling. But that's not what we're talking about here.
I deliberately went a little off topic
recursion so that in the future everything will be
very clear.
So, as can be seen from the diagram above, for
output of a 6x8 character string is required 4
printing routines + uniform for all
symbol definition program. Last
deals with determining which character you are
drive, recognizes the return code from the program
frames in case of end of line. A in mine
case, this program should also
define the above codes"macros"
and in the case of "hit" it is on it -
print"with the following characters"corresponding
a piece of text from a special code that belongs to the code
no buffer. For clarity, I will cite the following:
juice (circuit) of the program that outputs
6x8 characters per screen:СУС . . .
CALL OPRSYM
. . .
программа печати 1-го символа
. . .
CALL OPRSYM
. . .
программа печати 2-го символа
. . .
CALL OPRSYM
. . .
программа печати 3-го символа
. . .
CALL OPRSYM
. . . program for printing the 4th character
. . .
JP SUS
As you guessed,OPRSYM is also
there is that same “single” program, o which
I already spoke about the second one.
And here are the ones that actually interest us:
"pieces" OPRSYM.
OPRSYM . . .
LD A,(HL) ;take the symbol code
. . .
SR #FF; in ZXTTFv2.0 #FF - code
;end of line
JP NZ,OPRSYM1 ;if not #FF -
;continue execution
;opinion
;Ifafter all, A=#FF, then:
OPRSYMW POP DE ;remove from stack
;address where to
;to return
;program after
;execute OPRSYM
RET
And here I would like to stop for
more detailed explanation. So how
you know, if we simply set RET,
then we would return to the symbol output program
vola to the place where they called OPRSYM
(or rather, the program would continue executing
program execution after CALL OPRSYM). But
since the end of the line was detected, then
we need to return from the program
output the line to the place where you got it from
called, but under no circumstances continued
program execution. For this and
POP DE is done, to sort of “remove”
performing character output and "nepeku-
"move" it (execution) into the program,
where the line output program was called.
In addition, the address "hit" inDE, to us
useful, but more on that later...
OPRSYM1 . . .
programs for various checks, not
those that interest us :)
. . .
ownership check program
these symbols to macros
. . .
JP NC,OPRSYMM ;if belongs to
;lives - move on
;on OPRSYMM
. . .
The program is also not of interest
us
. . .
RET
OPRSYMM is an output program"poppy"
poca". I also quote an excerpt from it here:
OPRSYMM . . .
HL Register Setup Program
to the beginning of the address, corresponding to
similar to the found macro
. . .
POP DE ;Interesting start-
;moose!
DEC DE
DEC DE
DEC DE
LD (OPRSMM0),DE
CALL 0
OPRSMM0 EQU $-2
PUSH DE
. . .
JP OPRSYM Before we begin the analysis in detail
above, I will say that the table, in
which contains the text of the "macro", has
the same structure as regular text
lines, that is, the end of each "macro"
denotes the code "#FF".
So, in order. Command POP DE we
"remove" the address where it should be returned -
Xia "process" if it terminates
commandRET. But we need it to indicate
did not call for a command after CALL, namely
on CALL! To do this, do it three times DEC
D.E. By the way, HL already contains the address
where the macro text is located.
Then we put DE into the cell where
is located CALL, by the way, the next one right away
after this “assignment” and perform re-
transition to further output of symbols. By
essentially we use oneprocedure"itself
in itself" for two tasks " nested one in
another."
And now the macro output has been completed.
Execution returned back to
inside the procedure OPRSYMM. And we need
keep printing the line...
But wait! How can we determine those
give the address where to return the procedure
OPRSYM, because the output must continue
after the macro is output...
Remember the procedure for exiting the program?
frames at the end of the line?.. Take a look
at her. What's there?
POP DE:RET!.. B DE y fits us
two paragraphs above the mentioned address! Te-
Now all we have to do is put it on the stack
(PUSH DE),restore registerHL,
indicating the address in the text,increase
it and calmly JP` roll on OPRSYM...
It turns out that POP DE:RET us too
served, one might say, two services!
- - -
And here's something else I was able to discover.
for yourself in the process of small experiments
cops. It turns out that the alternative AF`
is not spoiled by TR-DOS (unlike
BASIC48)! At least in the group of stan-
dart commands via #3D13. But even not-
depending on loyalty :) to AF` TR-DOS`a,
it seems possible to use 4-
clock EX AF,AF` instead of, say, 11-
clock PUSH AF, which in cases where
the register needs to be “remembered” for its further
the worst "damage" - looks like a good solution -
no!
- - -
Share your thoughts about the article