Re: Lowering RAMTOP without a reset
Posted: Sat Mar 10, 2012 12:04 am
Ähmm can I use this trick vice versa to let big programs run on my 1k Zeddy at home ?
Set RAMTOP up and type CLEAR ?
Set RAMTOP up and type CLEAR ?
Discussion forums for users of the Sinclair 8-bit range of computers - ZX80, ZX81, ZX Spectrum, Z88, clones...
https://sinclairzxworld.com/
Code: Select all
2 SAVE "SMALLDFILE"
3 LET D=16389
5 GOSUB 1000
10 POKE D,76
15 POKE D-1,255
20 GOSUB 1000
30 PRINT "PRESS: A(=NEW) AND NEWLINE"
999 STOP
1000 PRINT PEEK D*256+PEEK (D-1)-16384
1010 RETURN
Yes, as long as you use M!cro$oft's virtual memory system for your ZX81. Guaranteed to make it run faster*. Don't forget to set up your page file.PokeMon wrote:Ähmm can I use this trick vice versa to let big programs run on my 1k Zeddy at home ?
Set RAMTOP up and type CLEAR ?
Great routine.Andy Rea wrote: ↑Wed Jan 11, 2012 6:16 pm i just wrote a routine that copies the entire current stack to the new stack location, it is safe to call it from basic using a RAND USR xxx and as long as your new stack location is above STKEND (the calculator stack) it should work just fine.
might not be the quickest, but since as my program needs to return to basic along with the value in BC i needed to ensure that the other items on the stack got executed too.Code: Select all
STACK_MOVE: OUT ($FD),A ;TURN OFF NMI'D ;INTS SHOULD ALREADY BE DISABLED LD HL,-4 ADD HL,SP ;GET THE SP LD D,H LD E,L ;PUT IN DE LD HL,($4002) ;GET err-sp OR A ;CLEAR CARRY FLAG SBC HL,DE ;SHOULD HAVE NUMBER OF BYTES IN CURRENT STACK LD B,H LD C,L ;INTO BC LD DE,28282 LD (16388),DE ;NEW RAMTOP DEC DE ;DE PTR READY TO RECIEVE COPY OF STACK LD HL,$7FFF LDDR ;COPY STACK TO NEW LOCATION LD HL,28278 LD ($4002),HL ;NEW err_sp LD H,D LD L,E INC HL LD SP,HL OUT ($FE),A
Andy
Well - this routine is not to recommend as it works only if there is no overlap between source and target buffer. To move a memory block from higher to lower address you should use LDIR instead of LDDR as LDDR may overwrite some copied data if both buffers overlap. For moving a memory block up, LDDR is typically used. Both methods are robust against possible buffer overlap. Of course, the pointers DE and HL have to be adjusted properly.mrtinb wrote: ↑Wed Mar 08, 2017 1:45 pmGreat routine.Andy Rea wrote: ↑Wed Jan 11, 2012 6:16 pm i just wrote a routine that copies the entire current stack to the new stack location, it is safe to call it from basic using a RAND USR xxx and as long as your new stack location is above STKEND (the calculator stack) it should work just fine.
might not be the quickest, but since as my program needs to return to basic along with the value in BC i needed to ensure that the other items on the stack got executed too.Code: Select all
STACK_MOVE: OUT ($FD),A ;TURN OFF NMI'D ;INTS SHOULD ALREADY BE DISABLED LD HL,-4 ADD HL,SP ;GET THE SP LD D,H LD E,L ;PUT IN DE LD HL,($4002) ;GET err-sp OR A ;CLEAR CARRY FLAG SBC HL,DE ;SHOULD HAVE NUMBER OF BYTES IN CURRENT STACK LD B,H LD C,L ;INTO BC LD DE,28282 LD (16388),DE ;NEW RAMTOP DEC DE ;DE PTR READY TO RECIEVE COPY OF STACK LD HL,$7FFF LDDR ;COPY STACK TO NEW LOCATION LD HL,28278 LD ($4002),HL ;NEW err_sp LD H,D LD L,E INC HL LD SP,HL OUT ($FE),A
Andy
This lowers the RAMTOP. If I want to raise the RAMTOP again, could I just replace LDDR with LDIR?
You can read something more detailed here; moving down
LD DE,end_buffernew
LD HL,end_bufferold
LD BC,buffersize
LDDR
;moving up
LD DE,start_buffernew
LD HL,start_bufferold
LD BC,buffersize
LDIR