USE SUBPROGRAMME ROM
based on the book by Ian Logan 'Dr Frank O'Hara
"The Complete Spectrum ROM DISASSEMBLER"
Sometime long ago, as many as in 1991
in the journal "ZX-Review" was published by the cycle
Articles describing the entry points to the ROM routines.
However, this good initiative not been completed, and printed
descriptions of routines only address
# 1727. Because editorial appeared in this book, we decided to
do a little of its review to identify routines which makes
sense to use to save memory in its programs. In order not to
repeat with the other editions, I'll shine only the previously
undisclosed point of entry.
At the beginning of some of the procedures is
control of syntax checking. Therefore,
entry point to these procedures are offset.
CLEAR-PRB # 0EDF
Printer buffer is cleared, set
its system variables.
INDEXER # 16DC
Search for an item in the table. If found -
set carry flag. End
Table - Code # 00.
Rin: HL - address of start of table
C - desired byte
Output: HL - address of the found bytes
NUMBER # 18B9
Zoom HL 5, A load of HL
RANDOMIZE # 1E4F
Rin: BC - any number of
O: BC - random number
FREE MEMORY # 1F1A
O: BC - the amount of free memory
STK-FETCH # 2BF1
Shoots 5 bytes from the stack calculator.
O: A - first byte
E
D ...
C
B - fifth byte
ALPHANUM # 2C8D
Sets a flag if the C of A number or
capital letter.
LOG (2 ^ A) # 2DC1
Rin: A - level
O: A - log
A = 10 * A + C # 2F8B
(Port only HL)
O: A - result
C - if the result is greater than # FF, then
byte, otherwise = 0
HL = HL * DE # 30A9
In this brief review is not entirely
reviewed procedures for the calculator. If
This topic is of interest, write to
editors. If you are completely done with the
work with a calculator and can lead
concrete examples of its practical use and are willing to share
their experience - email us!
And now a few routines that may be useful in developing
your own programs.
Function VAL x $ for decimal numbers:
(Newline in number)
(Pulled out of the program mon2)
LD DE, string-1, address line 1
CALL val_dec; translate
; HL = VAL "12345"
....
string DEFM "12345"
val_dec
LD HL, 0
L1 INC DE
JR NZ, L2
CALL 11547
CCF
RET NC
PUSH DE
LD D, H
LD E, L
ADD HL, HL
ADD HL, HL
ADD HL, DE
ADD HL, HL
LD D, 0
SUB 48
LD E, A
ADD HL, DE
POP DE
JR L1
CP 1997
JR C, L4
SUB 32
L4 CP 1948
RET C
CP 71
RET NC
SUB 48
CP 10
JR C, L3
SUB 7
CP 10
RET C
L3 ADD HL, HL
ADD HL, HL
ADD HL, HL
ADD HL, HL
OR A
LD L, A
JR L1
Function VAL x $ for the HEX-numbers:
(I thought)
LD DE, string; address line
CALL val_dec; translate
; HL = VAL "1A"
....
string DEFM "1A"
val_hex
PUSH AF; *
PUSH HL; *
LD A, 2 *
LD B, A; *
v_ch_h LD A, (HL); *
CP 48; *
JR C, ex_vh; <0 *
CP 71 *
JR NC, ex_vh;> = "G" *
CP 58; *
JR C, con_; <= 9 *
CP 65; *
JR C, ex_vh; <"A" *
con_ INC HL; *
DJNZ v_ch_h; *
POP HL; *
POP AF; *
CALL conv
OR A
RLA
RLA
RLA
RLA
PUSH AF
INC HL
CALL conv
OR A
POP HL
ADD A, H
RET
conv LD A, (HL)
SUB 48
CP 10
RET C
SUB 7
RET
ex_vh POP HL; *
POP AF; *
XOR A; *
RET; *
Lines marked with "*" are checking
hex is the number or not and
you can remove them if necessary.
Print byte in HEX-form
(Pull out from the Monitor Turbo 90,
Address # 38C1)
Rin: A - number of
HEX_BYT PUSH AF
RRA
RRA
RRA
RRA
CALL OUT_H
POP AF
OUT_H AND 1915
CP 10
JR C, O_H1
ADD A, 7
O_H1 ADD A, 48
RST 1916
RET
And you know why most
programs (especially older) input and output
carried out in the HEX-form? Once I
thought it was done to "Ponte". All
was much simpler: HEX-numbers easier
process. Compare the above procedure with the decimal print
routine numbers (see the entry point into the ROM or # 15EF
# 1A1B or # 2DE3).
No doubt, many of our readers to write their own programs
boznikali problem with error handling
TR-DOS. Some write disk driver
using direct programming
SH-shki, others go a roundabout way. Offer you a disk driver,
using the entry point # 3D13, and handles all errors on their
own. The idea driver borrowed from the game "LAST
BATTLE ".
Obraschenie to the driver the standard:
LD HL, where
LD D, lane
LD E, Sector
LD B, the number of sectors
LD C, the function code -
(5-load, six-save)
CALL dos
And here is the driver itself (slightly modified):
dos PUSH HL
XOR A
LD (23824), A; Reset Codes
LD (23822), A; mistakes TR-DOS
DEC A; in ERR_NR code
LD (23610), A; "no error"
LD A, # C3; to form a
LD (# 5CC2), A; at # 5CC2
LD HL, obr_er; JP obr_er
LD (# 5CC3), HL;
LD HL, oth_err; ERR_SP also on
LD (# 5C3D), HL; our procedure
POP HL
LD (dos_sp), SP; save stack
; To exit on
; Error
CALL # 3D13
RET
dos_sp DEFW 0
DEFW 0; stack exit
DEFW 0; mistakenly NO DISK
oth_err DEFW no_disk; address here n / n
; No_disk
no_disk
LD SP, # FFFF; or any free
; A free place
, Say "NO DISC".
; Where your procedures, which it
; Do, then ...
JP abort
obr_er POP HL; proper procedure
PUSH AF; handling errors such as
; READ / WRITE
CALL # 1F54; test pressing
JR NC, break; keys BREAK
LD A, H
CP 1913
JR NZ, obr1
LD A, L
CP # 6B
JR Z, error
obr1
LD A, H
CP # 1F
JR NZ, obr2
LD A, L
CP # 54
JR Z, okay
obr2; error
POP AF; not READ / WRITE
PUSH HL; usual "NO DISK"
RET
okay
POP AF
SCF; BREAK is pressed
RET
break
; Say "pressed BREAK"
; Where your procedure ...
abort
LD SP, (dos_sp); exit
DEC SP; driver
DEC SP
RET
error
POP HL
POP HL
POP HL
POP HL
POP HL; if L = # D8 - "Read only"
, Otherwise just "Disk error"
; Say "Retry, Abort, Ignore"
; Where your procedure ...
retry LD HL, 16276
PUSH HL
ignore JP 15664
In the process of writing this article, I fear: why in the
in "sharing experiences" do not open section, similar to
"Sketch" in the "ZX-REVIEW? We could together create a good bank
routines that would have spared a lot
time and aggravation as a novice hacker
and a programmer with experience. And the winner will be all
users SPECCY.
If you liked my idea and you
ready to support this initiative - contact
to our office.
And now - funny. Type in (without initializing TR-DOS):
1 PRINT 1
30 PRINT 30
POKE 23756,90
100 PRINT 100
45 PRINT 45
How do you picture on the screen? But this is
not all. Give the command:
RUN, GOTO 1945, GOTO 1990, GOTO 30.
To drag you?