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

  1.        PEEK/POKE/SYS -- Part 4
  2.        ==== ==== ===    ==== =
  3. --------------------------------------
  4. Location:  2       Hexadecimal:  $0002
  5. Official Label:  none       Type:  RAM
  6. Useful BASIC commands:  PEEK-POKE-SYS
  7.  
  8.  
  9.    The Programmer's Reference Manual
  10.  
  11. says that this byte is "Unused".  A
  12.  
  13. pre-release version of the manual says
  14.  
  15. "DO NOT USE!".  I don't know why.
  16.  
  17. Location 2 is not used by the BASIC
  18.  
  19. or Kernal.  It normally contains a
  20.  
  21. Zero (0 - BRK instruction).  Thus, it
  22.  
  23. could be used as a free zero-page
  24.  
  25. location in your own machine language
  26.  
  27. programs, but this is not recommended
  28.  
  29. for the following reason:  Since the
  30.  
  31. BRK instruction acts like a software
  32.  
  33. interrupt, it is nice to be able to
  34.  
  35. produce one from BASIC.  With a guar-
  36.  
  37. anteed BRK at location 2, all you need
  38.  
  39. to do is SYS 2.  Normally, this resets
  40.  
  41. the VIC-II chip and the Screen Editor,
  42.  
  43. clearing the screen (just like RUN/
  44.  
  45. STOP-RESTORE!).  But with, say, HESMON
  46.  
  47. or some other monitor installed, a BRK
  48.  
  49. instruction allows quick entry into
  50.  
  51. the monitor from BASIC.
  52.  
  53.  
  54. --------------------------------------
  55. Locations:  3&4    Hexadecimal:  $0003
  56. Official Label:  ADRAY1      Type: RAM
  57. Useful BASIC commands:  PEEK, POKE
  58.  
  59.  
  60.    ADRAY1 is a two-byte Jump Vector.
  61.  
  62. A Jump Vector is simply the address of
  63.  
  64. a routine that is called by an indi-
  65.  
  66. rect JMP instruction to the vector it-
  67.  
  68. self.  Because the JMP is indirect,
  69.  
  70. the machine-language routine called is
  71.  
  72. at the contents of the vector, not the
  73.  
  74. vector itself.  It is like saying, 'Go
  75.  
  76. to my desk, look at the sheet of paper
  77.  
  78. there, and on that paper you will find
  79.  
  80. Mr. Smith's address.' instead of say-
  81.  
  82. ing, 'Go to this address to find Mr.
  83.  
  84. Smith: '.  The sheet of paper is anal-
  85.  
  86. ogous to a Jump Vector.  It contains
  87.  
  88. the address of the destination.  Be-
  89.  
  90. cause the Vector is in RAM, it can be
  91.  
  92. changed to allow a user-written rou-
  93.  
  94. tine to be substituted for the normal
  95.  
  96. routine.
  97.  
  98.  
  99.    ADRAY1 is a vector to the subrou-
  100.  
  101. tine at $B1AA that converts the float-
  102.  
  103. ing point (real) number last used into
  104.  
  105. a two-byte integer in the .A and .Y
  106.  
  107. registers (.Y is the low byte).  This
  108.  
  109. is used mostly by user-written USR()
  110.  
  111. functions.  BASIC itself does not use
  112.  
  113. this vector.  It is there so that a
  114.  
  115. USR() function can use that routine to
  116.  
  117. convert its argument, even in future
  118.  
  119. versions of Commodore 64 BASIC, when
  120.  
  121. the routine itself might have been
  122.  
  123. moved.  The ADRAY1 vector will NOT be
  124.  
  125. moved!
  126.  
  127. -----------<end of article>-----------
  128.              <x to exit>
  129.