[ASM-BASIC TUTO] How to diet the VARS while saving...

Anything Sinclair ZX Basic related; history, development, tips - differences between BASIC on the ZX80 and ZX81
Post Reply
User avatar
XavSnap
Posts: 1940
Joined: Sat May 10, 2008 4:23 pm
Location: 'Zx81 France' Fb group.

[ASM-BASIC TUTO] How to diet the VARS while saving...

Post by XavSnap »

Hi,

If you had to save a string variable, and you want clear all other values...
Just save the DEST BASIC system variable in the VARS memory, and copy the array after a CLEAR.

Code: Select all

1 REM [ASM:     \
  LD HL,(16402)|\
  LD (16507),HL|\
  LD A,(HL)    |\
  LD B,0       |\
  LD C,A       |\
  RET ]

10 DIM A$(5,5)
15 DIM B$(5,5)
20 LET H=0
25 LET E=0
30 LET L=0
35 LET O=0

40 FOR A=1 TO 5
50 LET A$(A)="HELLO"
60 LET B$(A)="WORLD"
70 NEXT A

130 DIM C$(5,11)
140 FOR A=1 TO 5
150 LET C$(A)=A$(A)+" "+B$(A)
160 NEXT A

165 REM SAVE "MYP1"

# RETRIEVE C$ MEMORY OFFSET (FIST CHAR)
170 LET C$(1,1)=CHR$ USR 16514

191 STOP

# TYPE CONT

195 REM SAVE DIET PROGRAM WHITH JUST C$(5,11)
200 CLEAR
300 DIM C$(5,11)

#PREVIOUS OFFSET (FROM)
305 LET A=PEEK (16508)*256+PEEK (16507)

# TARGET (TO NEW OFFSET)
310 LET C$(1,1)=CHR$ USR 16514
400 LET B=PEEK (16508)*256+PEEK (16507)

410 FOR D=A TO A+5*11-1 
420 POKE B,PEEK D
425 LET B=B+1
430 NEXT D

9000 SAVE "MYP2"

9100 FOR A=1 TO 5
9110 PRINT C$(A)
9120 NEXT A

Code: Select all

 # VB81 XuR [MYP2.P] 
 # 
 # 16514/16524 : 4082/408C
1 REM [DEC:\
 42, 18, 64, 34,123, 64,126,  6,  0, 79,201 ]
MYP2.P
(1.61 KiB) Downloaded 87 times
Setup C$ at the end of the VARS to avoid to erase it with the new variable data.

Have fun.
Xavier ...on the Facebook groupe : "Zx81 France"(fr)
Post Reply