Block save / load
Re: Block save / load
DEC DE does not set any flag.
Re: Block save / load
my z80 asm is rusted
then 2 bytes more needed to set flags
BUT
a trick can be to put in the saved code, in the exact memory position of the target "call IN_BYTE", a call with the low address of the routine to be started, and then, when the load loop will overwrite this part, the call will be to 0x43 + this low byte... probably this was your suggestion some post before!! (PS: I've seen and confirm, just you used "ret", while this with "call rewrite" might save another two additional bytes at the expense of having a starting address in the 0x43xx area -> with 11 bytes load loop we are at 1013 byte of useful load! )
Last edited by marste on Fri May 03, 2024 6:02 am, edited 6 times in total.
Re: Block save / load
Then the new code looks like this (corrected also an error in preparing hl):
Code: Select all
MEMORY_END equ 0x4400 ; 1k
SET_FAST equ 0x2E7 ; ROM routines
IN_BYTE equ 0x34C ; /
GET_BITS equ 0x385 ; /
START:
call SET_FAST ; load operations to be managed in FAST mode
ld hl, 0x4400 ; cleanup and put stack at the very end of memory
ld sp, hl ; /
ld hl, LOAD_LOOP ; relocate loader to end of memory
ld de, 0x4400 + LOAD_LOOP - RELOCATE_END ; /
push de ; /
ld bc, RELOCATE_END - LOAD_LOOP ; /
ldir ; _/
pop hl ; the inital GET-BIT ret will be inside the loop
inc hl ; skipping the first call IN_BYTE to avoid
inc hl ; timeout problems
inc hl ;
push hl ; return address for the GET-BIT (that will load a full byte)
ld hl, 0x4000 ; start loading data at 4000h
ld c, $01 ; prepare (for ROM) an eight counter 00000001
ld b, $00 ; and set counter to 256
WAIT: ; wait signal to avoid ROM timeout
ld a, $7F ; read tape bit
in a, ($FE) ; /
rla ; test tape bit.
jp C, GET_BITS ; if detected go to GET-BIT (return will be in the load loop)
jp WAIT ; else loop back infinitely
LOAD_LOOP: ; this 11 bytes block will be relocated at the end of the memory
call IN_BYTE ; ROM routine IN-BYTE loads a byte
ld (hl), c ; insert assembled byte in memory
inc hl
jr LOAD_LOOP ; loop until the loaded code will overwrite the "call IN_BYTE"
; with the target address that need to be 0x43xx (just lower byte will be load)
db 0, 0, 0, 0 ; stack space (for the call and push de inside IN_BYTE)
RELOCATE_END: ; end of the relocated block (this label will be at 0x440)
Last edited by marste on Sat May 04, 2024 10:38 am, edited 7 times in total.
Re: Block save / load
PS: for the conversion of an assembled file to an audio file the program here can be used: viewtopic.php?f=6&t=4023
Just use the "-80" parameters (the output should not contain the filename) and do not pass a ".p" file (rename in case to something else) since the intelligent extension detection has unfortunately priority on the parameter.
To recap: pass to the converter a binary file long 1016 bytes with the last instruction (3 bytes) be a call to the address of the label to start the program that should be in the 0x43xx area. The program at this point is still in "FAST" mode.
Just use the "-80" parameters (the output should not contain the filename) and do not pass a ".p" file (rename in case to something else) since the intelligent extension detection has unfortunately priority on the parameter.
To recap: pass to the converter a binary file long 1016 bytes with the last instruction (3 bytes) be a call to the address of the label to start the program that should be in the 0x43xx area. The program at this point is still in "FAST" mode.