Development history of SamForth disassembled
Description of the page content
Development history of the SamForth disassembling project
2012-12-22
Version A-00 of SamForth2z80dasm. First tries to automatically create the data files needed by the disassembler. Symbols for word headers.
2012-12-23
Versions A-01 and A-02 of SamForth2z80dasm. New better method. Symbols for word headers. Symbols for system variables.
2012-12-26
Version A-03 of SamForth2z80dasm. Symbols for RST addresses and their vectors. Symbol for some discovered routines.
2012-12-27
The original code is STC (Subroutine Threaded Code), not DTC (Direct Threaded Code) as I wrote at first.
The following commands from the definition of VLIST
reveal that six bits are used for the word name length:
ld c,(hl) ;15ba
res 7,c ;15bb
res 6,c ;15bd
That means SamForth words can be 63 characters long.
2012-12-28
The dissasambled code was assembled back by the first time, with pyz80 and Pasmo. In the first case, the hexadecimal numbers format must be changed first (from the "h" suffix to the "&" prefix). The resulting code run perfectly.
New discoverings:
At 00C0h there is a jump table that holds many ROM addresses.
RST 8
calls ROM's RST 10
: prints char in A
to current stream.
RST 10
pushes HL
.
RST 18
pops HL
.
RST 20
pushes HL
and DE
.
RST 28
pops HL
and DE
.
RST 30
reports the error whose number is in A
; the error messages are in stored in the zone 10E1H - 117BH.
The routine at l117ch
does the init.
The routine at sub_1085h
prints a string (start in HL
, count in BC
).
The routine at l0e9dh
accepts keyboard input.
The routine at sub_1525h
gets the next word from the input stream; it's used by variable
, create
, :
, builds
, constant
...
The routine at sub_11a9h
saves HERE
and LATEST
variables; It's used by ;
, and at the end of create
, c,
, ,
, allot
, ;code
, variable
, constant
.
The routine at sub_11b6h
restores HERE
and LATEST
variables, sets STATE
to 0. This is the last routine before the dictionary.
In jr nz,l11c7h ;115f
ret nz
can be used instead. There are several minor improvementes like this one.
Words with the precedence bit (7th bit of the name length byte) set: :
, ;
, ;code
, code:
, cold
, ascii
.
Words with the 8th bit of the name length byte set: do
, +loop
, loop
, ."
, begin
, until
, if
, else
, endif
, then
, builds
, does
, while
, repeat
. That means the 8th bit is the "compile-state-only" bit!
The value of STATE
is 0 or 80h, as the following piece of code shows (there are more examples):
code_colon_cfa:
ld a,080h ;16ab
ld (STATE),a ;16ad
2012-12-29
Version A-04 of SamForth2z80dasm, with support for SamForth-B. SamForth-B disassembled.
2013-01-01
Start and exit routines disassembled. They are poked at 50000 and 50020 by the the BASIC loaders. Also the routine loaded by SamForth-A at 50040 has been disassembled.
2013-01-04
SamForth2z80dasm improved:
- Several new routines marked.
- Symbols file indentation fixed: it failed with labels exactly 30 chars long.
z80dasm2tidySamForth improved:
- Typo fixed.
- Headers finished.
- Bug fixed: the defb->defw byte order was wrong.
- The _name: symbols are not removed anymore, because they are needed to translate the links.
- The symbols of
JVSIN
's arguments are removed. - The link field addresses are converted to their corresponding symbols.
- Symbols for SAM's memory page registers.
- Some special cases fixed in the assembly.
- Word names are converted to
defm
.
2013-01-05
SamForth2z80dasm improved:
- Many new routines marked with symbols.
z80dasm2tidySamForth improved:
- Code divided into functions.
- New functions to add comments to the final source.
- Error messages are converted to
defm
. - Special cases fixed.
2013-01-06
SamForth2z80dasm improved:
- Return stack marked.
z80dasm2tidySamForth improved:
- All ROM routines are translated to symbols.
- All SamForth variables are commented with the descriptions found in the original documentation.
- All data zones (tib, pad and stacks) are converted to
defs
.
2013-01-07
SamForth2z80dasm improved:
- Fixed the address of
cls
in SamForth-A. - Several new routines marked.
- New symbols.
z80dasm2tidySamForth improved:
- Finished the comments of ROM routines.
- The contents of SamForth's variables are converted to symbols if needed.
- Every variant now defines only the required << abbr ROM />> routines.
2013-01-08
SamForth2z80dasm improved:
- Two
nop
unknown zones in SamForth-B are marked in order to convert them todefs
during the postprocessing. - Symbol for 0x0066 (the NMI routine), needed in SamForth-A.
z80dasm2tidySamForth improved:
- Two
nop
unknown zones in SamForth-B, marked during the preprocessing, - are converted to
defs
. - All padding
nop
above therst
addresses are removed; anorg
is put instead. - The format of the
rst
values is changed with the prefered hex prefix.
2013-01-20/23
Several improvements, mainly new routines understood and labelled while working on ForthCoupe.
2013-01-20
z80dasm2tidySamForth improved:
- Now double quotes are used to surround
defm
strings; single quotes are accepted by Pasmo but not by pyz80. - Type fixed in Z80Comments.
- The notation of the
."
word name is changed to be compatible with both pyz80 and Pasmo.
2013-01-21
SamForth2z80dasm improved:
- Fix:
jp_u_dot_header_end
renamed tojp_u_dot_code_field
. - Fix: the
call_rom_address_in_iy
symbol was not defined in SamForth-B. The routine exits, but it's not used. - New symbols:
compile_call_tos
,compile_call_de
,error_0x01_stack_empty
,error_0x02_stack_full
,call_push_hl
,return_from_basic
. - New symbols of the keybord input routine.
z80dasm2tidySamForth improved:
- New comments, on an useless
ret
after ajp
. - New comments, on an useless
jp jp_link_l
after ajp jp_link
. - New comment in SamForth-B, on the useless
call_rom_address_in_iy
routine (a remain from SamForth-A). - New comments on
sub_49e2h
(SamForth-B) andsub_0aaeh
(SamForth-A). - New comments on useless
pop de
beforeudgdef:
. - Fixed comment:
tempstk_fvar
is used by SamForth-B. - Removed comments on the words that return the address of stack manipulation code in SamForth-B (e.g.
push-hl
). - Fixed: regex that removes the first definition of
jsvin_rom_routine
. - New comment on the new
return_from_basic
label. - New comments on the
l59bah
label in SamForth-B. - New comment on the new
print_cr
label. - New comments on the usage of
tempstk_fvar
inudgdef
.
2013-01-22
SamForth2z80dasm improved:
New: block zones for all 0branch
.
z80dasm2tidySamForth improved:
- New comment on
corestore_fvar
. - New: Z80BranchsToSymbols().
2013-01-23
SamForth2z80dasm improved:
New names for unknown symbols: toggle_caps_lock
, toggle_insert_mode
.