How to resolve the algorithm Address of a variable step by step in the Commodore BASIC programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Address of a variable step by step in the Commodore BASIC programming language

Table of Contents

Problem Statement

Demonstrate how to get the address of a variable and how to set the address of a variable.

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Address of a variable step by step in the Commodore BASIC programming language

Source code in the commodore programming language

100 REM ALLOCATE ALL VARS FIRST SO THEY DON'T MOVE
110 X=123:Y=456:PX=0:PY=0:I=0:T=0
120 PRINT "BEFORE:X="XCHR$(20)",Y="Y
130 PX=POINTER(X):PY=POINTER(Y)
140 REM VARS ARE STORED IN RAM BANK 1
150 BANK 1
160 FOR I=0 TO 6
170 : T = PEEK(PY+I)
180 : POKE PY+I,PEEK(PX+I)
190 : POKE PX+I,T
200 NEXT I
210 PRINT "AFTER: X="XCHR$(20)",Y="Y


100 X=PEEK(71)+256*PEEK(72):PX=X:X=123
110 Y=PEEK(71)+256*PEEK(72):PY=Y:Y=456
120 PRINT "BEFORE:X ="XCHR$(20)", Y ="Y
130 FOR I=0 TO 6
140 : T = PEEK(PY+I)
150 : POKE PY+I,PEEK(PX+I)
160 : POKE PX+I,T
170 NEXT I
180 PRINT "AFTER: X ="XCHR$(20)", Y ="Y


  

You may also check:How to resolve the algorithm S-expressions step by step in the REXX programming language
You may also check:How to resolve the algorithm Best shuffle step by step in the Action! programming language
You may also check:How to resolve the algorithm Magnanimous numbers step by step in the C programming language
You may also check:How to resolve the algorithm Loops/Infinite step by step in the D programming language
You may also check:How to resolve the algorithm Least common multiple step by step in the Mathematica/Wolfram Language programming language