Bottleneck
Alone Coder
There was not enough memory for self-compilation.
Of course, you could immediately connect
RAM from address zero. But its operating system
there was no system, instead of file opera─
tions there were still plugs, and inCP/Mprogram
this size would not fit (strange,
that there are no versionsCP/Mwith shadow arrangement─
IBDOSandBIOS,this is technically possible).And
It would be problematic for me to debug the program─
frame in an unfamiliar system. Besides, ho─
we wanted to make at least one version for ours
darling48K.
I decided to debug inTR-DOSby writing─
knowledge of a certain layer that implements the file─
new sequential access system. Chu─
you suggested that it was possible to fit into48K
you just need to work on optimization.
02/27/2017 - command keys added
lines for compilation in different modes and
for assembly. And a little optimization─
tion. Size58481 bytes, and assembly language
the file took 510 kilobytes. At this rate
even a floppy disk is not enough.
02/28/2017 - I just corrected the manual.
03/03/2017 - instead of time stamps tee─
pa_lll generated the correct labels
in the body of the commands. The assembler file has been shortened─
up to438 kilobytes. Code size after not─
which optimizations -56643 bytes.
03/04/2017 - the code generator has the most
popular texts are highlighted in procedures.Asse─
The mbler file was reduced to380 kilobytes.
Code size51183 bytes.
03/06/2017 - reduced the number of parameters
in procedures and did the analysis viamatch
(eating a word immediately when it matches
expected). Code size49036 bytes.
In general, approaches to building a parser without
rightcontext:
# readword + compile_value
# read_compile_value
# match_value (makes readword if successful)
03/08/2017 - idea: instead of a separate 8-
bit context store byte in low order
byte of ordinary registers, and the accumulator is
use only as a proxy to access
it (remember whether a copy is loaded into it and
whose).
03/09/2017 - some unused parts were removed─
created procedures and variables. We improve
code generator according to yesterday's idea, for─
one is removedOR A in conditions if the flags are already
exposed.
The main part of the compiler (withoutmain.c,
but withnedodefs.h ):
*.c (8), *.h (3):
188271
5700 lines
*.asm (including system procedure plugins)
332639 (ftokenized: 294874)
14398 lines
compiled by IAR: 32944 bytes;
compiled by SDCC 3.6.0: 39801byte;
compiled by NedoLang: 42956 bytes.
03/10/2017 - non-standard ones added
comments ;; at the beginning of the line - for C
these are not comments. This is how everything is formatted
debug output calls.36241 bytes. Then
there is a compiler that fits into the address simple─
space48K. The assembler almost fits into 64K
with labels. It is necessary to shorten the assembler or
tags. Or better yet, both. But for now as─
the assembler cannot assemble itself,
because the compiler does not haveenum and switch
..case , and in the assembler there is no gluing of labels.
03/13/2017 - made enum.
03/15/2017 - byte indexes allowed
in arrays, so as not to transform again─
put them inUINT.
03/16/2017 - access to non-volume is allowed
revealed byte constants through
+_CONSTNAME. Addedtemporary directories
for dumping program compilation results─
ram.
03/17/2017 - made a switch and gluing
marks in assembler. Label table size
when assembling the compiler, it was reduced from
40K to38K. At the same time, all file names have been shortened─
up to 8 characters.
03/20/2017 - shortened the names of the changes─
nyh and procedures. The label table is less than35K.
03/22/2017 - I also shortened the names and
nesting. The label table is now smaller
31K. Added commandsINC, DEC.
03/23/2017 - a few more abbreviations -
assembler with labels is already smaller40K. Started
write a file library.
03/24/2017 - made a file library
and startup source code in assembler, began
real debugging in the emulator:
┌────────────────────────── ──────────────┐
1)
to the compileryou need to open t when compiling─
string lations?
this:
- asmstr ONLY in do_asm
- emitvarstr_tword in emitvarstrz
no, the compiler does everything correctly!
this assembler should be able to compile like this─
put the text in quotes!
2)
readquotes worked (dec c), let's go to
asmstr
asm is disabled by default, edit startup
all asm commands worked
doesn't seem to detect //
or l
cpl
jp z
error in emitinvb - you need fused=false
3)
then there is an error in fopen - b is not equal to 0
4)
then ld l,FCB.fn was skipped in flushdesc
5)
then in flush when selecting sectors number
sectors are not written to the descriptor
(firstsector) and in cursector - write to 0
6)
first sector ferr screwed up fvar, first
sector fasm screwed up ferr (secwritten update─
I was in the wrong place, a!=0)
7)
there are a lot of errors:
all ld [],a, ld [],hl are empty (auto labels
correct)
missing branch eat_variable.b
(t = t|_T_ARRAY)
8)
can't seem to find any variables
strcp (bb86),lbltype (8f29),addvar (8faf)
look correct in fasm file
c279 - lblbufnot compiled correctly
_lblbuf[_lblbufindex]=+(CHAR)(+(BYTE)len);
writes a, which is not assigned:
LD DE,[addvar.len.]
LD[HL],A
but after pokeb (where used before
this a) _rproxy = 0x00!!!
error in emitpokeb - with (hl) everything was written─
where a.
9)
fasm, ferr torn off
incorrect sizes of some of the first blocks
(lastlen was not reset)
10)
assembler crashes on the first token
because there is no cmdpeek before jp (hl)
11)
now hangs at the end of the file, i.e. didn't hit
in case _ASMTOKEN_EOF:
{goto endloop;/**exit!!!*/}
the switch table is all filled with default!!!
because asmloop.J0 labels are generated,
and in the table without J
but cannot be glued. with number
corrected
12)
is now reset at the end
org.f ends up with 44 bytes instead of 4
5 errors in the first line (comment 709a
could not process) and further errors in 2903
and further (also comments)
the beginning of bin.f matches, but the length is #1656
instead of #160c
discrepancy with #14a3 - extra #c9 etc.
it was because of a comment
";when reading, length 0 is absent
files or file length 0 (length in sectors
maybe any)"
13)
UNTIL
((_token==+_ASMTOKEN_ENDCOMMENT)||_waseof)
compiled into
LD A,[_token.]
LD E,_ASMTOKEN_ENDCOMMENT.
SUB E
LD L,0
JR NZ,$+2+1
DEC L
LD A,[_waseof.]
OR L
JP C,asmloop.y
because above comparison is in parameter
functions were without parentheses and “optimized─
elk" at the 1st level of expression nesting.
corrected
14)
everything compiled correctly, but was reset
made protection against "optimization" of comparisons
at the first level of nesting in assignment─
tions and challenges (the initial level is nested─
put the news higher there)
15)
at the end it falls out with an error and spoils
BASIC, even after one pass
instead of ex af,af' it turns out ex (sp),hl
(tokenized and exported correctly─
but)
sp and af codes match - need to check
second register in ex
fixed it
16)
still crashes at the end with an error
not assigned hl'=10072!
17)
ld (de),a was assembled incorrectly
(tokenized and exported correctly─
but)
the error was reg instead of oldreg
18)
;increase block number (after flushdesc!)
;bugs if last block <256
manual flush is not yet possible
0. getting started (first save):
- create a new descriptor
- save the data there
- save the descriptor
- block++ (now the descriptor is invalid─
until we create a new one)
1. add a lot of data until the block
will be filled
2. block is filled:
- save the descriptor
- block++ (now the descriptor is invalid─
until we create a new one)
3. add some data
4. close:
- create a new descriptor
- save the data there
- save the descriptor (maybe with
non-circular length)
- block++ (now the descriptor is invalid─
until we create a new one)
(then savedesc is called again, but
we can't)
prohibited calling savedesc in fclose at 0
recorded sectors
└────────────────────────── ──────────────┘
03/25/2017 - compiler, tokenizer,
assembler and detokenizer work on
Speccy. Currently called without parameters
(they are strictly prescribed in the startup).
* * *
How to build a project?
- more files get into the assembler than
to the compiler, because another standard is added─
complex multiplication-division procedures and files with
variables
- or only two files will end up in the assembler─
la - glued code (withgluing mill─
dart procedures) and glued variables,
or just one stitched code
If you just paste the tokenizer into the com─
peeler, it will be too greasy (especially
especially by tags)
- you can remove the inline assembler and zasta─
to include tokenized assemblies─
ry files. Then the compiler will simply
output tokenized asm instead of tex─
that
reader will be common to the compiler and then─
kenizator (and supports comments)
- then reader should write a comment in
non-tokenized assembly text and in
tokenized equally
- or non-tokenized assembler
the text does not exist, then comments/errors─
bki should know about this too! Tokenized─
make comments/errors at the levelemitter?
(the compiler may not output errors in
ferr, and output directly to ASM)
For files with variables, you can generate─
ritincludein each, but you need to know the model
memory (suddenly you need to separate commands and
data!)
Share your thoughts about the article