[zxspectrum] Re: [zxspectrum] [zxspectrum] Re: [zxspectrum] [zxspectrum] Re: [zxspectrum] Re: [zxspectrum] Re: [zxspectrum] [zxspectrum] Re: [zxspectrum] Re: [zxspectrum] Re: [zxspectrum] Re: [zxspectrum] PCTAPOD può essere utile?
- From: Malantrucco Carlo <carlo.malantrucco@xxxxxxxxx>
- To: ZX Freelist Spectrum <zxspectrum@xxxxxxxxxxxxx>
- Date: Mon, 26 Aug 2019 18:53:05 +0200
Il giorno 25 ago 2019, alle ore 21:22, Enrico Maria Giordano
<e.m.giordano@xxxxxxxxxxxxxxx> ha scritto:
Per te non è poi così arabo, visto che riesci sempre a trovare qualcosa di
interessante.
Continuando la pesca a strascico nel mare arabo, mi sono imbattuto in questa
routine nel disassemblato della ROM 2.2 del Discovery. Può essere utile?
Carlo
THE 'LOAD, SAVE, VERIFY AND MERGE' COMMAND ROUTINES
The A register holds the first character after the keyword,
(T-ADDR) holds 0 for SAVE, 1 for LOAD, 2 for VERIFY and 3 for
MERGE. The length of the file is the length of the data + 7,
since the first 7 bytes are used to store header apart from the
filename. In case of SAVE, the channel should be opened for
output and create, in all other cases just for input. The
routine uses large parts of the tape-routine in the Spectrum
ROM, so sufficient room for the stack is needed.
029D LD_SA_ETC CP +2A Is it '*'?
JP NZ,016D,CONTSIG_2 Signal the error if not.
RST 0018,TEST_RUN Run-time or checking?
JR Z,02AB,LD_SA_2 Skip if checking.
LD BC,+0022 Make 34 bytes room, for 2
RST 0010,CAL_SPEC headers.
DEFW +0030,BC_SPACES
02AB LD_SA_2 PUSH IX Store 128K register.
PUSH DE Store start of the room.
RST 0020,NEXT_CHAR Point to the next char.
CALL 053A,CHK_CHAN Find a channel + next char
CALL 062F,CD_TO_STK Copy code to stack:
DEFW +0652,SA_DATA test parameters.
DEFW +0109 (length)
LD IX,+0071 IX := start of code + 113.
ADD IX,DE
LD (IX-26),+C9 Put a RET at relative
address 069D.
LD A,+C3 1FC3 = UNSTACK_Z.
CALL 0319,STOREADDR Store this address in
INC IX stead of 1BEE (CHECK_END)
LD A,+1F in order to keep the stack
CALL 0319,STOREADDR also when checking syntax.
POP IX IX := start of headers.
CALL 0656,EXEC_STK Execute the code.
02D4 LD_SA_3 EX (SP),IX Stack header-start, fetch
PUSH HL 128K register.
CALL 050E,CHK_END Store start for LOAD, SAVE
POP HL etc while testing for the
end of the statement.
LD (K-CUR),HL Store HL, since K-CUR is
POP IX also moved when creating a
PUSH HL channel.
LD B,(IX+0C) BC := length of datablock.
LD C,(IX+0B)
RST 0010,CAL_SPEC Stack BC.
DEFW +2D2B,STACK_BC
RST 0028,FP_CALC len data
DEFB +09 (lengthbyte)
DEFB +34,stk-data len data,7 (len file-info)
DEFB +40
DEFB +B0, exponent +00
DEFB +00, +07, (+00, +00)
DEFB +0F,addition len data + len file-info
DEFB +38,end-calc file-size
LD A,(T-ADDR) Fetch the command type.
AND A Was it 'SAVE'?
PUSH AF (store the command type)
LD A,+05 Signal: output, create.
JR Z,02FE,LD_SA_4 Step if 'SAVE'.
LD A,+02 Signal: input.
02FE LD_SA_4 LD HL,+0000 HL := record-length.
CALL 06A9,OPEN_CHAN Now open the channel.
POP AF Restore command type.
POP DE DE := start of data.
LD HL,(STK-END) Has the startaddress been
SBC HL,DE shifted due to the crea-
LD HL,(WORKSP) tion of a channel?
EX DE,HL Then use the saved value
JR C,0314,LD_SA_5 instead.
LD HL,(K-CUR)
0314 LD_SA_5 CALL 06F4,SAVE_CHAN Now execute the command.
JR 0368,CLOSE_CHN And close the channel.
Store the address of UNSTACK_Z rather than CHECK_END into the
correct locations in the stackcode, otherwise the stack will be
severely corrupted when checking syntax, which will cause a
system crash. The location are (relative) 069A, 06AE, 06FA, 0716
and 072F.
0319 STOREADDR LD (IX-29),A
LD (IX-15),A
LD (IX+37),A
LD (IX+58),A
LD (IX+6C),A
RET
Other related posts:
- » [zxspectrum] Re: [zxspectrum] [zxspectrum] Re: [zxspectrum] [zxspectrum] Re: [zxspectrum] Re: [zxspectrum] Re: [zxspectrum] [zxspectrum] Re: [zxspectrum] Re: [zxspectrum] Re: [zxspectrum] Re: [zxspectrum] PCTAPOD può essere utile? - Malantrucco Carlo