Test case showing difference between local and global arrays
This commit is contained in:
7
Makefile
Normal file
7
Makefile
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
array.tap: array.bas
|
||||||
|
zxbc -o $@ -f tap -B -a $<
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -f array.tap
|
||||||
|
|
||||||
|
.PHONY: clean
|
30
array.bas
Normal file
30
array.bas
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
DIM global(5) AS UByte => { 47h, 4Ch, 4Fh, 42h, 41h, 4Ch }
|
||||||
|
|
||||||
|
subroutine()
|
||||||
|
STOP
|
||||||
|
|
||||||
|
SUB subroutine()
|
||||||
|
DIM local(4) AS UByte => { 4Ch, 4Fh, 43h, 41h, 4Ch }
|
||||||
|
refer(6, @global)
|
||||||
|
refer(5, @local)
|
||||||
|
END SUB
|
||||||
|
|
||||||
|
SUB refer(chars AS UByte, pointer AS UInteger)
|
||||||
|
DIM i AS UByte
|
||||||
|
REM Are we pointing to .array.__DATA__ ?
|
||||||
|
PRINT "If reference points to the DATA field ("; pointer;"): ";
|
||||||
|
FOR i = 0 TO chars - 1
|
||||||
|
PRINT CHR$(PEEK (pointer + i));" ";
|
||||||
|
NEXT i
|
||||||
|
PRINT
|
||||||
|
|
||||||
|
REM Are we pointing to .array, where pointer + 2 = data pointer?
|
||||||
|
pointer = PEEK(pointer + 2) + 256 * PEEK(pointer + 3)
|
||||||
|
PRINT "If reference points to pointer field ("; pointer;"): ";
|
||||||
|
FOR i = 0 TO chars - 1
|
||||||
|
PRINT CHR$(PEEK (pointer + i));" ";
|
||||||
|
NEXT i
|
||||||
|
PRINT
|
||||||
|
END SUB
|
||||||
|
|
||||||
|
37568
|
Reference in New Issue
Block a user