Hi, Mario. As Klaus mentioned earlier, VTL02 has a version of BASIC's deek and doke, but it doesn't use absolute addressing, but rather indexes from the end address of the stored program, held in system variable
&.
So, if you want to read or write a single byte, you will need to write your own machine-language peek and poke using the system variables
> and
". Set
" to the address of your peek/poke handler, and call it with
>= ... it will be up to you how to handle the exchange of data between VTL02 and your routine. I'll think about it, and post my version.
If you can accept the limitations of VTL02's array facility (16-bit unsigned R/W only), you could try the following sample code, that allegedly writes a 16-bit value in
V to a two-byte location addressed by
A.
Code:
10 A=4096) Absolute memory address
20 V=12345) Value to store at address
100 )Print value stored at address A, then store V there
110 .=A/2) Check A for odd/even
120 .=%) Save the remainder
130 ,=&/2) Check & for odd/even
140 ,=%) Save the remainder
150 &=&-(.=,)+1) Adjust & up by 1 if necessary to align with A
160 ;=A-&/2) Calculate address offset
170 ?="Current value at ";
180 ?=A
190 ?=": ";
200 ?=:;)
210 ?=""
220 :;)=V) Store V at A
230 ?="New value at ";
240 ?=A
250 ?=": ";
260 ?=:;)
270 ?=""
280 &=.=,+&-1) Adjust & back down if necessary
If
& needs to be adjusted at run-time (because
A is even and
& is odd, or vice-versa), your program will gain one garbage byte at the end every time you use this routine, possibly confusing the program listing feature, but it should otherwise be relatively harmless, as far as I know. [edit: added code to self-adjust
& back down, making the previous sentence moot].
If you don't use the array facility or
#= while accessing I/O, you can simply do the following (but possibly only for target addresses above the end of your program):
Code:
10 A=4096) Absolute memory address
20 V=12345) Value to store at address
100 )Print value stored at address A, then store V there
110 .=&) Save &
120 &=A) Adjust & to point to A
130 ?="Current value at ";
140 ?=A
150 ?=": ";
160 ?=:0)
170 ?=""
180 :0)=V) Store V at A
190 ?="New value at ";
200 ?=A
210 ?=": ";
220 ?=:0)
230 ?=""
240 &=.) Restore &
Mike B.
P.S. I'm going to post this code completely untested, then check it ... I like to live on the edge!