home *** CD-ROM | disk | FTP | other *** search
/ Loadstar 2 / 002.d81 / p_p_s#1 < prev    next >
Text File  |  2022-08-26  |  2KB  |  132 lines

  1.        PEEK/POKE/SYS -- Part I
  2.        ==== ==== ===    ==== =
  3.  
  4.          by:  Joel Ellis Rea
  5.  
  6.  
  7.    This series is designed for people
  8.  
  9. who are familiar with BASIC program-
  10.  
  11. ming, and would like to learn more a-
  12.  
  13. bout the memory locations that can be
  14.  
  15. used with the PEEK function, and the
  16.  
  17. POKE and SYS statements.
  18.  
  19.    Beginners, listen up...
  20.  
  21.    A PEEK works like this:
  22.  
  23. 'LET W = PEEK(1024)' sets the variable
  24.  
  25. W equal to the contents of memory
  26.  
  27. location 1024.
  28.  
  29.    A POKE works like this:
  30.  
  31. 'POKE 1025,W' sets memory location
  32.  
  33. 1025 equal to the value of the
  34.  
  35. variable W, which must be within the
  36.  
  37. range 0 to 255.
  38.  
  39.    A SYS works like this:
  40.  
  41. 'SYS 49152' attempts to execute
  42.  
  43. machine language code starting at
  44.  
  45. memory location 49152.
  46.  
  47.               ------
  48.  
  49. Well, that's all the easy stuff.  What
  50.  
  51. follows is usually very technical, so
  52.  
  53. pay close attention.
  54.  
  55.               ------
  56.  
  57.    The 64's memory consists of 65,536
  58.  
  59. bytes (1K = 1,024;  64K = 64 * 1,024 =
  60.  
  61. 65,536), some of which is ROM (Read-
  62.  
  63. Only Memory) which cannot be changed,
  64.  
  65. some is I/O (Input/Output) Chip Regis-
  66.  
  67. ters which control hardware functions
  68.  
  69. of the machine, and most is RAM (Ran-
  70.  
  71. dom-Access Memory), which can be writ-
  72.  
  73. ten to, and which "forgets" its con-
  74.  
  75. tents when the power is turned off.
  76.  
  77.  
  78.    The PEEK function can read RAM, ROM
  79.  
  80. and most I/O.  The POKE statement can
  81.  
  82. write to RAM and many I/O locations.
  83.  
  84. The SYS statement transfers control to
  85.  
  86. a machine-language subroutine located
  87.  
  88. in ROM or RAM.
  89.  
  90.  
  91.    This month, we will cover five of
  92.  
  93. the most important locations in the
  94.  
  95. whole 64, locations 0 - 4.
  96.  
  97.  
  98. --------------------------------------
  99. Location:  0       Hexadecimal:  $0000
  100.  
  101. Official Label:  D6510      Type:  I/O
  102.  
  103. Useful BASIC commands:  None
  104.  
  105.  
  106.    This byte MUST be kept at its nor-
  107.  
  108. mal value (such that PRINT PEEK(0) AND
  109.  
  110. 63 prints 47) in order for the 64 to
  111.  
  112. be able to function correctly.  It is
  113.  
  114. the Data Direction Register for the
  115.  
  116. 6510 processor's On Board Bi-direc-
  117.  
  118. tional I/O port (Location 1).  Its
  119.  
  120. bits determine which of the 6 I/O port
  121.  
  122. lines are input and which are output.
  123.  
  124. The normal value means that bits 0-3
  125.  
  126. and 5 are output (1) and bit 4 is in-
  127.  
  128. put (0).
  129.  
  130. --------<continued in part 2>---------
  131.              <x to exit>
  132.