Meneer_Jansen

Part 8. Turbo Macro Pro

Jul 3rd, 2020 (edited)
1,032
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 12.83 KB | None | 0 0
  1. .-------------------------------------------.
  2. ( P A R T 8 . T U R B O M A C R O P R O )
  3. `-------------------------------------------´
  4. general contents: pastebin.com/hmpJmurr
  5.  
  6.  
  7.  
  8.  
  9. o==========o
  10. | Contents |
  11. o==========o
  12.  
  13. A. TMP with and without a REU
  14. 1. General
  15. 2. Memory map
  16.  
  17. B. Status line & tips 'n hints
  18. 1. Status line
  19. 2. Tips/hints
  20.  
  21. C. A REU in general
  22.  
  23. D. BASIC ROM shadowing
  24.  
  25. E. The jump from 140_hex
  26.  
  27. F. TMP: REU banks and RAM
  28. 1. General
  29. 2. TMP's four states
  30.  
  31. G. Appendix: Set colors for TMP
  32.  
  33. X. References
  34.  
  35. -<>-<>-<>-<>-<>-<>-
  36.  
  37.  
  38.  
  39.  
  40.  
  41. o===============================o
  42. | A. TMP with and without a REU |
  43. o===============================o
  44.  
  45. 1. General
  46. ~~~~~~~~~~
  47. Turbo Macro Pro (TMP) is an Assembler that runs on the Commodore itself as well as on other platforms (cross assembler). There are two versions of TMP for the C64: with- and without REU support.
  48.  
  49. A REU is a RAM Expansion Unit. A real physical REU was quite rare because not many programs made use of it. However, nowadays a REU can be activated quite easily in Vice and there's a trick to use one on 'The C64'. Some modern cartridges, which are used instead of a floppy disk drive, also double as a REU (e.g. Ultimate-II Cartridge).
  50.  
  51. A C64 - and therefore TMP - cannot execute code from a REU. Data can only be copied or exchanged extremely fast between a REU and RAM. So TMP always uses RAM for your source code and it's own assembler (i.e. the "executable" machine language code). However, assembled source code is initially put in bank 0 of the REU.
  52.  
  53. When one exits TMP temporarily, to run the assembled program, then REU bank 0 and RAM are exchanged. This means that source code and TMP are back upped in bank 0 then.
  54.  
  55. The (executable) assembler code from TMP loads into RAM from 8000_hex onwards and extends under the shadow of BASIC ROM (which starts at A000_hex) all the way into upper free RAM (starting at C000_hex).
  56.  
  57. So when no REU is used one can (roughly) use RAM from 800_hex to 8000_hex (30 kB) for source code AND the assembled object (!). When a REU is used one can use the full 30 kB for source code (see further on). Additionally, one does not have to worry about assembled code overwriting TMP's executable or your source code (see further on), which frees up upper RAM and even RAM under the shadow of BASIC if one switches BASIC off.
  58.  
  59. 2. Memory map
  60. ~~~~~~~~~~~~~
  61. The memory map (without REU usage) is roughly like this:
  62.  
  63. ========================================================
  64. Pos Size | Pos Pos | Contents
  65. (kB) (kB) | (dec) (hex) |
  66. ========================================================
  67. 2 38 | 2048 0800 | Start of free RAM
  68. | |
  69. | |
  70. xx | xxxx xxxx | Start of compiled PRG you
  71. | | made in TMP (example)
  72. | |
  73. | |
  74. | |
  75. | |
  76. | |
  77. | |
  78. | |
  79. | |
  80. | |
  81. | |
  82. xx | xxxx xxxx | End of your TMP source code
  83. | |
  84. | |
  85. | |
  86. | |
  87. | 7FEB | Start of your TMP source code
  88. 32 | 32768 8000 | TMP itself
  89. | |
  90. 40 | 40960 A000 | End of free RAM
  91. _________________________________________________________
  92.  
  93. Note 1: you start TMP with SYS 32768 (= SYS 32*1024) (32768_dec = 8000_hex).
  94. Note 2: source code works its way "down" in memory (somewhat like the stack).
  95. Note 3: if a REU is used then the source code is compiled to REU bank 0 instead of RAM.
  96.  
  97.  
  98. o================================o
  99. | B. Status line & tips 'n hints |
  100. o================================o
  101.  
  102. 1. Status line
  103. ~~~~~~~~~~~~~~
  104. Example (no REU):
  105.  
  106. x:1 l:41 b:$7da6 in:c/l #:8 [style!]
  107.  
  108. Meaning: x-pos = row 1; y-pos = line 41; source code (bottom) ends at $7da6 (start = approx. $8000); insert mode c means "character insert" l means "line insertion"; device number = 8 (floppy drive); no REU is in use.
  109.  
  110. Another example (with REU):
  111.  
  112. turbo macro pro+reu v1.2 (512k)
  113. x:1 l:41 b:$7da6 in:c/l #:8 bank:0/1
  114.  
  115. Meaning line 1: the REU is 512 kB in siuze. If that says (0k) then no REU is detected.
  116. Meaning line 2: source/backup bank = 0; object bank = 1. The message line sometimes displays the size of the REU.
  117.  
  118. Hitting RUN/STOP toggles the status line between the default and a secondary one. Example:
  119.  
  120. lbl:5 /$ec7d-$fd30 src:$0800-$7cde
  121.  
  122. Meaning: current number of labels = 5 (only reliable after a compile); remaining free label memory = $EC7D to $FD30; remaining free memory = from $0800 to $7CDE (= end of TMP source code).
  123.  
  124. 2. Tips/hints
  125. ~~~~~~~~~~~~~
  126. - You cannot include binaries w/ the pseudo-op ".binary". That only works in the cross assembler version of TMP (which is called TMPx). You can, however, include source code from a file with pseudo-op ".include".
  127.  
  128. - No more than 40 characters per line can be in your source code.
  129.  
  130.  
  131. o=====================o
  132. | C. A REU in general |
  133. o=====================o
  134.  
  135. A REU can copy or exchange (swap) data between its memory banks of 64 kB and the Commodore's RAM extremely fast (a C64 can NOT read directly from the REU). The REU has 11 registers in which the settings for this are stored. Some read-only, some r/w. They can be accessed by the CPU via RAM registers DF00 to DF0A_hex (i.e. via the "I/O 2" area in RAM).
  136.  
  137. Bits 0 and 1 of DF01_hex determine if data is transferred to-, transferred from- or exchanged with the C64. One does that by defining (in the REU's registers) the starting addresses in REU and RAM and then the size of the data to be acted upon. If bit 4 in register DF01_hex is set to 0 then the (pending) action of a REU can be activated by a write action to FF00_hex (Kernal) [1].
  138.  
  139.  
  140. o========================o
  141. | D. BASIC ROM shadowing |
  142. o========================o
  143.  
  144. TMP places it's code under the shadow of BASIC ROM, which is of course switched out (else: impossible to run TMP). When you jump back and forth between BASIC and TMP then shadowing is set on and off (via RAM register 0001_hex). When you use TMP with a REU then you can safely assemble source code that places data under BASIC ROM, the location in RAM where your source code is (from 8000_hex downwards) and where TMP itself is (from 8000_hex upwards). This is because the object is assembled to bank 0, not to RAM. Only when one exits TMP (to test-run the assembled code) RAM is exchanged with (or back-upped to) bank 0.
  145.  
  146.  
  147. o==========================o
  148. | E. The jump from 140_hex |
  149. o==========================o
  150.  
  151. When one assembles source code and exits TMP to test run it (back arrow + 3 + s) then a little snipped of executable code is placed at 140_hex (= 320_dec) so one can jump back to TMP w/ "SYS 320". Notice that TMP's executable code is not in RAM anymore because it has been swapped with REU bank 0 so "SYS 32*1024" won't work.
  152.  
  153. RAM address 140_hex is the top of the processor stack. The code from $140 onwards gets executed as if it was a machine language program. That's "unusual" to say the least because that's not what the stack is meant for.
  154.  
  155. What does the code at 140_hex do? In short it copies data from REU bank 0 (i.e. TMP's executable) to RAM and then jumps to 8000_hex where TMP resides to execute it.
  156.  
  157. In detail the following is done. First ROM shadowing, the interrupt, CIA's etc. are all set to default. Then the start address in RAM and REU are set to 0800_hex and the REU bank is set to 0. Transfer length is set to F800 (i.e. transferring to end of RAM). Transfer type is set to: "from REU to C64". Then Kernal ROM and BASIC ROM are switched out (probably to prevent write errors). Finally via a load/write action to FF00_hex the transfer is started. Before jumping to 8000_hex ROM shadowing is set to default again.
  158.  
  159. Note: when you type "NEW" in BASIC then apparently the stack is re-set or cleared. Because after NEW the command to jump back to TMP (SYS 320) doesn't work anymore. The error message "?OUT OF MEMORY ERROR" is printed, which - among others - means that the stack is larger than FF (i.e. overflowed).
  160.  
  161.  
  162. o===========================o
  163. | F. TMP: REU banks and RAM |
  164. o===========================o
  165.  
  166. 1. General
  167. ~~~~~~~~~~
  168. TMP may use up to three REU banks (a bank is 64 kB).
  169.  
  170. Bank 0:
  171. Is always used. For the assembled object or for RAM backup (incl. a possible BASIC program). They are exchanged. RAM from 800_hex (start of RAM for BASIC prog) onwards and bank 0 are exchanged on entering and exiting TMP. So with a REU one can use all RAM from 800_hex onwards for an object.
  172.  
  173. Bank 1:
  174. Can be used for a backup of an assembled object. Use "#" (i.e. shift 3) to assemble.
  175.  
  176. Bank 2:
  177. Can be used as a safety backup of your source code. Press: "back arrow + R" (for the REU menu). Choose "b" for back up once and the source will be updated continuously/automatically. Swap it back in with "s". This is handy in case source code was overwritten after an exit from TMP. Works even after a hard reboot.
  178.  
  179. 2. TMP's four states
  180. ~~~~~~~~~~~~~~~~~~~~
  181. TMP in combination with a REU has roughly four different states which are described below (determined by using Super Snapshot's monitor):
  182.  
  183. a. Start/jump back to TMP (with source code):
  184. Bank 0: assembled object
  185. RAM : old BASIC prog, source code, TMP executable (note that this is
  186. trivial), no BASIC ROM.
  187. Remark: if your source code is very large then it will overwrite the BASIC
  188. prog. in RAM
  189.  
  190. b. TMP with source code compiled but not started (back arrow + 3):
  191. Bank 0: assembled object
  192. RAM : old BASIC prog, source code, TMP executable, no BASIC ROM.
  193.  
  194. c. Assembling source code and starting it (back arrow + 3 + s).
  195. Bank 0: backup of: old BASIC prog, source code, TMP executable.
  196. RAM : assembled object, BASIC ROM on.
  197. Remark: you cannot jump back via 8000_hex, use SYS 320 (140_hex).
  198.  
  199. d. Exiting TMP to BASIC (back arrow + 1).
  200. Bank 0: old BASIC prog., source code, TMP executable.
  201. RAM : old BASIC prog., source code, snippet of TMP executable
  202. (to jump back into TMP), BASIC ROM visible, no object.
  203. Remark: basically bank 0 gets copied to RAM, upon re-entering TMP
  204. changes to your BASIC program are gone.
  205.  
  206.  
  207. o=================================o
  208. | G. Appendix: Set colors for TMP |
  209. o=================================o
  210.  
  211. You can not set colors anymore from within TMP itself (see TMP website --> Docs --> Change log). There's a separate utility for this called:
  212.  
  213. TMPPREFS V1.2
  214.  
  215. Load and run it. Use use familiar TMP controls to load any existing TMP v1.2 binary (i.e. back arrow + l). It will ask: "overwrite prefs from loaded?". Answer yes. Once loaded, you can use these keys (BA = Back Arrow key):
  216.  
  217. BA + c = alter Color preferences, works like v1.1; you need to
  218. hit CTRL or CBM and a number key just like you were
  219. setting the current cursor color!
  220. BA + o = flip through color sets from some well known Options
  221. BA + j = alter Jumpback location
  222. BA + 7 = alter return tab (column that cursor sits after return)
  223.  
  224. Each change should be reflected in the example source screen. Once you're satisfied with your preferences, use BA + s to save the new binary (use a different filename!). Note that using this tool changes the defaults used by TMP; source codes you previously saved will still retain their own return/source tab settings and function key definitions, until you reset those and re-save those sources.
  225.  
  226. According to the TMP documentation on the internet these (still) are the keys:
  227.  
  228. 0 Edits the color used for $D020 (border).
  229. 1 Edits the color used for $D021 (background).
  230. 2 Edits the color used for the message line.
  231. 3 Edits the color used for the status line.
  232. 4 Edits the color used for regular source.
  233. 5 Edits the color used for source with a syntax error.
  234. 6 Edits the color used for source in the current marked block.
  235. s Edits the separator template
  236.  
  237. Use the "direct key combination" to set color! Use this table:
  238.  
  239. Black CTRL + 1 Organge C= + 1
  240. White CTRL + 2 Brown C= + 2
  241. Red CTRL + 3 Light red C= + 3
  242. Cyan CTRL + 4 Dark grey C= + 4
  243. Purple CTRL + 5 Gray C= + 5
  244. Green CTRL + 6 Light green C= + 6
  245. Blue CTRL + 7 Light blue C= + 7
  246. Yellow CTRL + 8 Light gray C= + 8
  247.  
  248.  
  249. o===============o
  250. | X. References |
  251. o===============o
  252.  
  253. [1] REU reference manual by Wolfgang Moser
  254. https://codebase64.org/lib/exe/fetch.php?media=base:csg8726techrefdoc-1.0.zip
  255.  
Add Comment
Please, Sign In to add comment