
Basic Data Operation

This is a basic data operation. It represents a fundamental action on a basic data type.
You may see other such operations in the Basic Data Operations category, or:


Integer Operations
Arithmetic |
Comparison
Boolean Operations
Bitwise |
Logical
String Operations
Concatenation |
Interpolation |
Comparison |
Matching
Memory Operations
Pointers & references |
Addresses




In systems programing it is sometimes required to place language objects at specific memory locations, like I/O registers, hardware interrupt vectors etc.



Task

Show how language objects can be allocated at a specific machine addresses.

Since most OSes prohibit access to the physical memory if it is not mapped by the application, as an example, rather than a physical address, take the address of some existing object (using suitable address operations if necessary).



For example:

   create an integer object
   print the machine address of the object
   take the address of the object and create another integer object at this address
   print the value of this object to verify that it is same as one of the origin
   change the value of the origin and verify it again


 0  DEF  FN P(A) =  PEEK (A) +  PEEK (A + 1) * 256
 100 :
 110  REM CREATE AN INTEGER OBJECT
 120 :
 130 I$ =  CHR$ (42)
 140  POKE 236, PEEK (131)
 150  POKE 237, PEEK (132)
 160  PRINT "HERE IS AN INTEGER    : " ASC (I$)
 200 :
 210  REM PRINT THE MACHINE ADDRESS OF THE OBJECT
 220 :
 230  PRINT "ITS ADDRESS IS        : " FN P( FN P(236) + 1)
 300 :
 310  REM TAKE THE ADDRESS OF THE OBJECT AND CREATE ANOTHER INTEGER OBJECT AT THIS ADDRESS
 320 :
 330 O$ =  CHR$ (0)
 340  POKE 250, PEEK (131)
 350  POKE 251, PEEK (132)
 360  POKE  FN P(250) + 1, PEEK ( FN P(236) + 1)
 370  POKE  FN P(250) + 2, PEEK ( FN P(236) + 2)
 400 :
 410  REM PRINT THE VALUE OF THIS OBJECT TO VERIFY THAT IT IS SAME AS ONE OF THE ORIGIN 
 420 :
 430  PRINT "COMPARE OTHER INTEGER : " ASC (O$)
 500 :
 510  REM CHANGE THE VALUE OF THE ORIGIN AND VERIFY IT AGAIN
 520 :
 530  POKE  FN P( FN P(236) + 1),69
 540  PRINT "NEW INTEGER VALUE     : " ASC (I$)
 550  PRINT "COMPARE OTHER INTEGER : " ASC (O$)