home *** CD-ROM | disk | FTP | other *** search
/ Oakland CPM Archive / oakcpm.iso / sigm / sigmv029.ark / SIGMLOG.006 < prev    next >
Encoding:
Text File  |  1984-04-29  |  28.0 KB  |  625 lines

  1. SIG/M VOLUME 6
  2.  
  3. 6502 SIMULATOR - REFERENCE DR. DOBBS 8/80
  4. 6502 ZAPPLE MONITOR
  5.  
  6.     SIZE    NAME        CONTENTS
  7.  
  8.         -CATALOG.006    CONTENTS OF SIG/M VOL. 6
  9.         ABSTRACT.006    DESCRIPTION OF EACH MODULE
  10.                 IN THE 6502 SIMULATOR
  11.  
  12. 6.1    11K    ZILASM.COM    6502 SIMULATOR
  13. 6.2     5K    ZX65.COM
  14. 6.3    98K    ZX65R.PRN
  15. 6.4    39K    ZX65R.ZSM
  16. 6.5    15K    ZXART.DOC
  17. 6.6     9K    ZXHINTS.DOC
  18. 6.7    23K    ZXLDR.PRN
  19. 6.8     7K    ZXLDR.ZSM
  20. 6.9     1K    ZXTAB1.DOC
  21. 6.10     1K    ZXTAB2.DOC
  22. 6.11     1K    ZXTAB3.DOC
  23. 6.12     1K    ZXTAB4.DOC
  24. 6.13     2K    CONCOD.LIB    CONTROL CODES FOR 6502 ZAPPLE
  25. 6.14     1K    ZAPMON.MOS    ZAPPLE MONITOR FOR 6502
  26. 6.15     5K    ZAPMON.HEX
  27. 6.16    11K    ZAP3.INS
  28. 6.17     3K    ZAP5.INS
  29. 6.18     3K    ZAP1.INS
  30.  
  31.     This disk contains the following files, as described briefly
  32. here:
  33.  
  34.  
  35. 1:    ZXART.DOC  This is the original text of the article which app-
  36.     eared in the August, 1980 edition of Dr. Dobb's Journal.
  37.  
  38. 2:    ZXTABx.DOC  These tables are also part of the text for the ar-
  39.     ticle.  ** NOTE:  Where addresses appear in these tables, they
  40.     pertain to a 32K byte system with standard 512 byte CBIOS. For
  41.     any other size system loaded just below CBIOS as described, the
  42.     first two digits of these addresses will be {CBIOS page minus
  43.     four}. I.E. for standard 32K, CBIOS page is 7EH. Subtract four
  44.     and the result is 7AH.
  45.  
  46. 3:    ZXHINTS.DOC  A little additional useful information on loading
  47.     and running ZX65.
  48.  
  49. 4:    ZX65R.ZSM  The Z80 source code for the interpreter. Version 2.1
  50.     is relocatable and must be linked with ZXLDR following assembly.
  51.  
  52. 5:    ZXLDR.ZSM  Source code for the system 'booter.' CP/M loads ZX65R
  53.     normally into the bottom of the TPA at 100H. ZXLDR finds CBIOS,
  54.     calculates and inserts the relocation offsets, and then boots
  55.     ZX65 up to high memory and jumps to it.  Version 2.1 must be lin-
  56.     ked with ZX65R following assembly for this to work.
  57.  
  58. 6:    ZX65R/XX.PRN and ZXLDR/XX.PRN  This is the listing output of the
  59.     assembler, showing system memory locations PRIOR TO RELOCATION.
  60.  
  61. 7:    ZX65.COM  Getting down to business...you should be able to
  62.     run this file immediately simply by typing 'ZX65' to the
  63.     CP/M prompt. 
  64. ZX65: Simulating a Micro                    Page 1
  65.  
  66.  
  67.     Having logged many hours of software development work on my Z80-
  68. based system, I recently decided that I was up to a particular challenge:
  69. using my system as a development tool for a totally different microprocessor;
  70. specifically, the 6502.  This decision, I must confess, was not altogether
  71. based on a burning lust for knowledge, but rather on a more practical re-
  72. quirement:  I had become involved in the development of a 6502-based device,
  73. and had no ready access to a 6502 development system.  I decided that a sim-
  74. ple cross-assembler wasn't good enough, and set out to write a 6502-to-Z80
  75. object code translator/simulator/interpreter.
  76.  
  77.     The program described here, which I have dubbed ZX65, is the result
  78. of my efforts to generate a software package to perform this task.  It is 
  79. useful not only for the intended purpose of software development, but also
  80. for the rewarding experience of exploring a whole new field of good soft-
  81. ware written for a processor other than one's own.
  82.  
  83.     ZX65 operates as an interpretive simulator; that is, a simulated
  84. 6502 CPU is maintained in system memory, and each encountered 6502 instru-
  85. ction is decoded and processed interpreter-fashion to properly act upon the
  86. simulated CPU registers.  The entire package resides in just over 4K Bytes
  87. of high system memory, leaving the remaining portion, including the all-im-
  88. portant (for 6502) base page, free for program and data storage.
  89.  
  90.  
  91.  
  92. ZX65: Simulating a Micro                    Page 2
  93.  
  94.  
  95. Note that CP/M* serves only as a loader and is not used thereafter.  In fact,
  96. while the program loads normally into CP/M's Transient Program Area, it imm-
  97. ediately relocates itself into high memory, overlaying both the CCP and the
  98. BDOS portions of CP/M.  The user I/O linkages (CBIOS), however, remain intact
  99. and are used by the package to perform disk and console functions.  The func-
  100. tions which must be provided by the system are a subset of those required by
  101. CP/M and should thus be readily available.  These functions are all accessed
  102. via a jump table within the interpreter and thus can be readily changed to
  103. accomodate different system requirements (see table 1).  Parameters must be
  104. passed to the drivers in register "C" (register pair "BC" for item six) and
  105. data, if any, is returned in the accumulator.
  106.  
  107.     ZX65 is referred to as a package since it includes three distinct
  108. function groups.  The first and largest is the interpreter/simulator itself.
  109. The second group is an elementary monitor providing the functions of memory
  110. examine and modify.  The third group consists of a self contained, elementary
  111. disk operating system (DOS). (Note: ZX65 files are not CP/M compatible.) The
  112. normal configuration assumes a two-drive system, with the system diskette on
  113. drive A, and all internal disk access routed to drive B.
  114.  
  115.  
  116.  
  117. ZX65: Simulating a Micro                    Page 3
  118.  
  119.  
  120. (Modification for a single drive system could easily be done, requiring the
  121. user to switch diskettes after the package is loaded.)  The package is writ-
  122. ten in standard Zilog/Mostek source code and is quite heavily commented.  Much
  123. use is made of the Z80's special instructions and index registers, and oper-
  124. ation on an 8080 is definitely not possible without extensive modification.
  125. Although the commented listing should guide you through the program's opera-
  126. tion without too much trouble, a brief description of the interpreter portion
  127. is in order. A study of the small but powerful instruction set of the 6502
  128. will reveal certain patterns in the op codes, as also occurs with most other
  129. processors. The eight "BRANCH ON CONDITION" codes, for example, all have zero
  130. as a low-order nybble, while the high-order portion is always an odd value.
  131. Another pattern, not so obvious, is that every instruction having an odd-
  132. valued op code uses multiple addressing modes.  These and other such patterns
  133. are exploited by the program.  Even so, much of the code is devoted solely to
  134. decoding the op code and transferring control to the proper instruction proc-
  135. essor.  The code beginning at "STEP" (line 241) performs the initial decoding,
  136. and fully decodes certain instructions such as "RTI", "JMP", and a few others.
  137. In most cases, decoding proceeds to the point where the instruction is known
  138. to be part of a group, such as the branch group described above.  In these
  139. cases, look-up tables are used, but not always in the same way.
  140.  
  141.  
  142.  
  143. ZX65: Simulating a Micro                    Page 4
  144.  
  145.  
  146. The branch group and the flag set/reset group, for example, derive mask
  147. patterns from the tables which are used for testing, setting, or resetting
  148. the condition flags.  In the case of multiple addressing mode instructions,
  149. however, the tables serve an entirely different purpose.  The table contents
  150. are, in these instances, decoded into addresses for indirect jumps; first to
  151. the addressing mode processors, and then to the actual instruction processors.
  152. Each processor performs its instruction as required.  The "ADC" instruction,
  153. as an example, causes a byte of data to be fetched from memory or from the
  154. object code, depending on the addressing mode.  After setting the Z80 carry
  155. flag to match the simulated 6502 carry flag, the data byte is added to the
  156. value currently in the simulated accumulator, and the result is stored there.
  157. The simulated carry flag is then updated to again match the Z80 carry, and the
  158. simulated sign, overflow, and zero flags are set or reset according to the re-
  159. sults in the accumulator.  (In this case, the overflow flag is set or reset
  160. according to a logical "OR" of bits six and seven.)  Considerable care has
  161. been given to treatment of the flags, since Z80 flags and their 6502 name-
  162. sakes do not always have the same meaning.  (Case in point:  the 6502 carry
  163. flag assumes a logical "NOT" borrow meaning during subtract and compare op-
  164. erations, while the Z80 and most other common processors invert the carry  
  165. flag internally during these operations so that it represents a "TRUE" bor-
  166. row. Other flag differences, for the most part, are more subtle.)
  167.  
  168.  
  169.  
  170. ZX65: Simulating a Micro                    Page 5
  171.  
  172.  
  173. Finally each individual processor is responsible for exiting with codes
  174. for the mnemonic, the addressing mode, and the number of bytes occupied by
  175. the instruction available for use by the "DISPLAY" routine (line 173) to in-
  176. dex into yet another set of tables and retrieve the ASCII messages for mnem-
  177. onic and addressing modes.  Upon exiting the instruction processors, the val-
  178. ue stored in "NEXT PROGRAM COUNTER" is updated, and control is passed back to
  179. the COMMAND section where the operating mode in effect determines whether to
  180. display the updated CPU contents, and whether or not to continue execution
  181. with the next instruction.  
  182.  
  183.  
  184.  
  185.     Several distinct operating modes are available, defined briefly as
  186. follows:
  187.  
  188. SINGLE-STEP MODE:  One instruction is decoded and executed. The console
  189.     then displays the address of the instruction just executed (Current
  190.     Program Counter), the decoded instruction (Mnemonic and Operand),  
  191.     the state of all CPU registers, and the address of the next instr-
  192.     uction to be executed (Next Program Counter).  Control is then
  193.     returned to the user.
  194.  
  195. MULTI-STEP TRACE MODE:  The user specifies up to 255 instructions to be
  196.     executed with the results displayed as above following each step.
  197.     This occurs at the rate of approximately two instructions per sec-
  198.     ond.  Control is returned to the user after the required number
  199.     of steps have been executed and displayed.
  200.  
  201. RUN-TO-BREAKPOINT MODE:  Instructions are executed without display up to
  202.     and including the user-specified breakpoint.  CPU registers are
  203.     then displayed as above, and control is returned to the user.
  204.  
  205.  
  206.  
  207. ZX65: Simulating a Micro                    Page 7
  208.  
  209.  
  210. FREE-RUN MODE:  Instructions are executed with no display and no break-
  211.     points.  The console keyboard, however, is monitored, and CPU con-
  212.     tents are displayed as above and control is returned to the user
  213.     at any point upon console input.
  214.  
  215.     The user may examine any or all CPU registers, including the Pro-
  216. gram Counter, at any time that he has control, without otherwise disturbing
  217. any operation on progress.
  218.  
  219.     The 6502 "BRK" instruction (software interrupt) is handled through
  220. a vector location, just as in a normal system.  Optionally, however, the BRK
  221. instruction may be used (and is initialized) to return control to the user
  222. in the same manner as the breakpoint mode described above.  The BRK instru-
  223. ction and breakpoint mode operate independently, and both may be used in the
  224. same program.  Additionally, up to five different "user" subroutines may be
  225. called for transfer of control to Z80 routines (such as console I/O).  These
  226. are invoked by executing either a "JMP" or "JSR" instruction to addresses
  227. 0000, 0001, 0002, 0003, and 0004 (HEX).  Control is passed via a jump table
  228. located within the interpreter, which the user may load with Z80 "JP" ins-
  229. tructions to the desired subroutines.  The subroutines must be terminated
  230. in the normal Z80 fashion by one of the "RET" instructions.  Note that the
  231. first two entries in the table (JMP or JSR 0000, 0001 HEX) are initialized
  232. as console input and output via the 6502 accumulator.  Three parameters may
  233. be passed to and from all user subroutines, as outlined in table 2.  Table
  234. 3 lists the locations of the BRK vector and the user subroutine jump table.
  235.  
  236.  
  237.  
  238. ZX65: Simulating a Micro                    Page 8
  239.  
  240.  
  241.     Although the interpreter is quite versatile and all 6502 instruc-
  242. tions are handled properly, there are some limitations to its use.  Perhaps
  243. the most important of these is that, even in the "free-run" mode, execution
  244. is quite slow compared to an actual 6502 running at normal clock speeds.  No
  245. attempt has been made to correlate execution times with normal 6502 clock
  246. periods.  (This may, in fact, be impossible due to the way in which the sys-
  247. tem handles multiple addressing modes.)  Therefore, programs incorporating 
  248. software timing loops will not execute properly.  Also, since the package was
  249. intended for software development, hardware interrupts are not supported, and
  250. only a limited amount of hardware interfacing can be performed through the
  251. "user" subroutine calls.
  252.  
  253.     Two program listings are included here.  The first, called "ZXLD",
  254. is a short program whose only function is to boot the main program from the
  255. CP/M Transient Program Area to high memory.  The second listing is the in-
  256. terpreter itself, assembled to reside from 6F00 to 7DFF (HEX) in a 32K sys-
  257. tem.  Note that this leaves 512 bytes, normally containing CBIOS, unaffected.
  258.  
  259.  
  260.  
  261. ZX65: Simulating a Micro                    Page 9
  262.  
  263.  
  264. The program is not relecatable, so that in order to run in a different mem-
  265. ory configuration, it will be necessary to reassemble the source with a new
  266. value in the "SIZE EQU XX" statement.  All other addresses are derived from 
  267. this value.  If the object code is to be manually loaded for the 32K system
  268. then "ZXLD" must be loaded first, starting at 0100 (HEX).  Then start loading
  269. ZX65 at 0110 (HEX), continuing until the end.  Finally, use the CP/M "SAVE"
  270. command (SAVE 15 ZX65.COM) to write the object code to disk.  The package can
  271. now be invoked by answering "ZX65" to the CP/M prompt.  If you are reassem-
  272. bling the package, then you should also reassemble the ZXLD routine (modified
  273. for your system) so that you have a .HEX file for each module.  Then load
  274. the package using DDT as follows:
  275.  
  276.     DDT ZXLD.HEX
  277.     IZX65.HEX
  278.     Rdisp
  279.  
  280. where "disp" is the load offset value required to load the object code from
  281. the .HEX file at a different address than that specified.  (DDT will calcu-
  282. late "disp" for you if you type "H110,ssss", where "ssss" is the actual
  283. starting address of your program.  DDT will respond with the sum and diff-
  284. erence of the two values, and the difference will be the required value
  285. "disp".)  Finally, save the object code as directed above for manual loading.
  286.  
  287.  
  288.  
  289. ZX65: Simulating a Micro                    Page 10
  290.  
  291.  
  292.     To run the program, place the disk with ZX65.COM on drive A (this
  293. disk should also have a copy of CP/M so that the system can be restarted, if
  294. necessary, without changing disks.)  Place the ZX65 data disk on drive B.
  295. Start CP/M and invoke ZX65 by answering "ZX65" to the CP/M input prompt.  
  296. The system will prompt you with a header and a ">" symbol.  You are now in
  297. the command mode, and typing one of the command codes (see table 4) will
  298. cause the appropriate action to occur.  Note that if you are using a disk
  299. not previously used for ZX65 on drive B, you will be unable to use the ZX65
  300. DOS functions until you have initialized the disk.  This is done simply by
  301. typing "I", at which point the system will ask you to verify this request
  302. with a "Y" or "N".  The reason for this (note this well) is that the "I"
  303. command clears and initializes the directory on disk B.  This is the equiv-
  304. alent of the CP/M command "ERA *.*" and must be used with caution.
  305.  
  306.     For those unwilling to type in a 4K byte program by hand, I will
  307. make the package available on a standard 8 inch IBM format, single side,
  308. single density diskette (Sorry, I can't handle any other format!) at a nom-
  309. inal charge of $15 to cover time and material.  Write to me at the address
  310. given at the head of this article, and specify your system memory size.  I
  311. will send a diskette containing both source and object files assembled to
  312. reside in high memory as described above, as well as a copy of ZXLD.
  313.  
  314.  
  315.  
  316. ZX65: Simulating a Micro                    Page 11
  317.  
  318.  
  319. A command summary, operating hints, and other general information will be in-
  320. cluded on the disk.
  321.  
  322.     Finally, although this program has been rather exhaustively tested
  323. with a variety of 6502 software (both simple and sophisticated) I cannot 
  324. guarantee it bug-free.  I have included no copyright notices of any kind,
  325. and I hope users will feel free to copy, add, delete, and improve at will.
  326. (I would like to hear of any major modifications...I may want to include them
  327. myself!)  As stated at the outset, the package was developed as a side benefit
  328. of another project, not as a money maker, and if anyone else finds it useful,
  329. so much the better.                -RMK
  330.  
  331.  
  332.  
  333. Acknowledgements:
  334.  
  335.     *CP/M is a registered trademark of Digital Research, Pacific
  336.     Grove, CA.
  337.  
  338.     While not specifically mentioned in the text, I have relied
  339.     heavily on the information contained in the book "6502 Assembly
  340.     Language Programming" by Lance A. Leventhal (Osborne/McGraw Hill
  341.     Inc., 1979)
  342.  
  343.  
  344.  
  345. *****    Notes on ZX65R v 2.1 and ZXLDR v 2.1    9/80    RMK
  346.  
  347.     The ZX65R program and source listings on this disk represent a
  348. substantial improvement over those published in DDJ #47.  The 'R' in the
  349. program names means 'relocatable', and that means that the same ZX65
  350. .COM file will now run on any size CP/M machine (except Heath/Zenith,
  351. TRS80, and any others using odd memory configurations).  This has been
  352. accomplished mainly through a new loader, ZXLDR.  This loader contains
  353. a complete relocation map for ZX65R.  It finds your CBIOS by examining
  354. the warm start vector at 0001H.  It then insinuates ZX65 just below CBIOS,
  355. after first calculating and inserting new values for all non-relocatable
  356. operands in the 'prototype' ZX65R code.  The loader and the main program
  357. appear as two separate source modules which have been concatenated using
  358. a linking loader, resulting in the run-able ZX65.COM file.  To run the
  359. program, transfer ZX65.COM onto a CP/M system disk using PIP.  Boot up
  360. this disk in drive A, and place a blank disk that you want to use for
  361. 6502 programs and data in drive B.  Type 'ZX65'.  Drive B will operate
  362. briefly and the ZX65 prompt will appear on the console.  You are now in
  363. ZX65's command mode.  Refer to the Dobb's article or file ZXTAB1.DOC for
  364. a command summary.
  365.  
  366.     If you compare the source code for ZX65R with that published
  367. in DDJ, you will notice what appear to be substantial differences in the
  368. listing.  The most obvious change is in the header comments and the 'eq-
  369. uates' which set up memory locations for the system. Even though this
  370. looks quite a bit different, it is for the benefit of relocatability and
  371. has no effect on the operation of the program once it is loaded.  If you
  372. will look a little further and compare the actual instructions, you will
  373. see that they are mostly unchanged.  There are two exceptions. The first
  374. involves the code from line 339 to line 428. These are the instruction
  375. processors for JMP, JSR, RTS, and RTI, and the new code corrects for im-
  376. proper stack handling in the original version. The second change is down
  377. near the end of the code in the console I/O handler. A patch there accom-
  378. odates a few BIOS console output routines which do not return with the
  379. output character still in the accumulator.
  380.  
  381.     Notice that the memory locations for the USER subroutine link-
  382. ages shown in Table 3 apply only after loading is complete.  To insert
  383. your own subroutine addresses, the best method is to load ZX65.COM under
  384. DDT. You will then find the USER jump table at the following locations:
  385.  
  386.     USR0        0FCCH *        * The first two locations are
  387.     USR1        0FCFH *        initialized to console I/O and
  388.     USR2        0FD2H         will be relocated during load-
  389.     USR3        0FD5H        ing. The last three will not
  390.     USR4        0FD8H        be relocated.
  391.  
  392. You may also wish to change the 16-bit 'BRK' vector:
  393.  
  394.     BRK VECTOR    0FDBH        Not relocated during loading.
  395.  
  396. Once you have inserted the desired changes under DDT, you may either ex-
  397. ecute the program directly by typing G100, or save it to disk following
  398. warm start with the command 'SAVE 20 ZX65.COM'.
  399.  
  400.  
  401.     CP/M COMPATABILITY: As of this writing, I have not yet succum-
  402. bed to Digital Research's efforts to get me to buy the new CP/M 2. From
  403. what I have been able to figure out, it offers very little to me in the
  404. way of advantages. Suffice it to say that ZX65 was written and debugged
  405. using V 1.4, and I cannot say whether or not it will run under any other
  406. version. (My guess is that it will work with V 1.3, but not v 2.X.) The
  407. main reason for any incompatibility will probably have to do with the
  408. fact that my self-contained mini DOS operates the disks and console dir-
  409. ectly through CBIOS rather than by using calls to BDOS which is the more
  410. conventional method. (There is a good reason for this madness which I
  411. will explain shortly.) In any event, since you have spent your hard-
  412. earned nickels for this copy, I suspect that you are resourceful enough
  413. to overcome such problems and implement any necessary patches. If you
  414. do come up with a running version patched for CP/M 2 or for some other
  415. disk format (i.e. North Star etc.), how about submitting it for possible
  416. publication in Dobb's? (No, I'm not on their payroll, but they are re-
  417. ceptive to this type of material and lots of 'hard core' dedicated
  418. computerists read their mag.)
  419.  
  420.     SOME NITTY-GRITTY: As promised, here is the explanation of why
  421. I have interfaced through CBIOS rather than using BDOS: If you have
  422. done any work at all with the 6502 processor, you will recall that page
  423. zero of memory (0000H to 00FFH) is sacred to it. There are short forms
  424. of many instructions for use on page zero, and the very powerful indirect
  425. indexing modes always use page zero. Now ZX65 by design uses no memory
  426. mapping at all...that is, if your 6502 program is ORG'd at 2000H, that
  427. is exactly where you will load it. (This is in contrast to at least one
  428. TRS80-based simulator that I know of.) Having gone this far, it is only
  429. reasonable to expect that page zero will be totally available to the
  430. 6502 program. As you have probably realized by now, the catch here is
  431. that BDOS also likes page zero, and uses large chunks of it during disk
  432. accesses. With one possible limitation (which I will discuss in a bit)
  433. ZX65 totally removes the host system from page zero...even the vectors
  434. at the bottom of memory need not be saved.  ZX65 is, in fact, confined
  435. to the top 1100H bytes of user memory (more if your CBIOS is longer than
  436. 512 bytes), and ALL space below that is available for 6502 programs and
  437. data. The one possible conflict that I mentioned is system-dependent,
  438. and may or may not apply in your case. CP/M V 1.4 has a reserved 'scr-
  439. atch' area of 16 bytes located from 0040H to 004FH. Some disk controllers
  440. use this area for temporary data storage during all disk transfers, whe-
  441. ther initiated by CP/M or not. If this is true of your controller, then
  442. you have very little choice but to accept the fact that this portion of
  443. page zero will be messed up whenever you do a disk access from ZX65.
  444. There is still one alternative (I know because I did it!): you may be
  445. able to move this scratch area out of page zero into high memory. Even
  446. if you have this conflict, 6502 programs that use page zero only for
  447. temporary data storage will probably run normally unless the 6502 pro-
  448. gram itself accesses the disk. (Yes, it is possible, using the 'system'
  449. subroutine calls.)
  450.  
  451.     ZXDOS COMMENTS: Having destroyed BDOS as described above, I was
  452. obliged to include an embedded disk operating system in ZX65. Now, ZXDOS
  453. will never win any awards for versatility, but it is, I think, adequate
  454. for the application. All internal disk access is confined to drive B (a
  455. two drive system is assumed). ZXDOS files are not CP/M compatible. A dir-
  456. ectory is maintained on track zero, and the remainder of the disk is
  457. available for program/data storage. Each directory entry is 16 bytes long,
  458. and contains the file name (format same as CP/M but file type has no spe-
  459. cial meaning), the load address, the disk location, the number of sectors,
  460. and an active/dead flag byte. During a directory display or search, the
  461. directory is paged through a buffer within ZX65 one sector at a time,
  462. continuing until an 'end of directory' mark is located. Files are stored
  463. sequentially and on sequential sectors (no interleaving). A new file will
  464. normally be appended at the tail end of existing files, unless the entire
  465. file will fit into the space allocated for a dead file. Thus a rudimentary
  466. form of dynamic disk space allocation is used, but a full disk will still
  467. contain quite a few empty slots. Killing a file does not actually erase
  468. anything, but simply resets the active status flag in the directory for
  469. that entry. The 'initialize' command writes a properly formatted empty
  470. directory to the disk.
  471.  
  472.     Finally, it is be possible to use ZX65 with only one drive. To
  473. implement this, load ZX65.COM using DDT, and change the value at address
  474. 484H from '01' to '00'.  Save the modified code back to a system disk
  475. following warm start using a 'SAVE 20 ZX65.COM' command. To operate in
  476. this mode, first start ZX65, then immediately remove the system disk
  477. and insert the ZX65 data disk.  From this point operation will be the
  478. same. This works because once loaded, ZX65 does not itself require any
  479. further disk access.
  480.  
  481.     CONCLUSION: Have fun with ZX65!        -RMK
  482.  
  483.  
  484. ZX65: Simulating a Micro                    Page T1
  485.  
  486.  
  487.                 *** TABLE 1 ***
  488.  
  489.     Functions which ZX65 requires of the host system, and their
  490.     locations within the interpreter.
  491.     -----------------------------------------------------------
  492.  
  493.     FUNCTION                    ADDRESS
  494.     --------                    -------
  495.  
  496. 1.    Test console input status --------------------- 7A2EH
  497.  
  498. 2.    Get single character from console ------------- 7A2BH
  499.  
  500. 3.    Send single character to console -------------- 7A28H
  501.  
  502. 4.    Select disk drive (A or B) -------------------- 7A34H
  503.  
  504. 5.    Home R/W head of selected drive --------------- 7A31H
  505.  
  506. 6.    Set disk transfer buffer address -------------- 7A3DH
  507.  
  508. 7.    Set sector number for next disk access -------- 7A37H
  509.  
  510. 8.    Set track number for next disk access --------- 7A3AH
  511.  
  512. 9.    Read one sector from selected drive ----------- 7A40H
  513.  
  514. 10.    Write one sector to selected drive ------------ 7A43H
  515.  
  516.  
  517.  
  518.  
  519.  
  520.  
  521.  
  522. ZX65: Simulating a Micro                    Page T2
  523.  
  524.  
  525.                 *** TABLE 2 ***
  526.  
  527.     6502/Z80 parameter passing to/from user subroutines.
  528.     ----------------------------------------------------
  529.  
  530.  
  531.         6502 Register    Passed as    Z80 Register
  532.         -------------            ------------
  533.  
  534.         Accumulator ------------------- Accumulator
  535.  
  536.         X Index ----------------------- B Register
  537.  
  538.         Y Index ----------------------- C Register
  539.  
  540.  
  541.  
  542.  
  543. ZX65: Simulating a Micro                    Page T3
  544.  
  545.                 *** TABLE 3 ***
  546.  
  547.  
  548.     Locations for "BRK" vector and user subroutine table.
  549.     -----------------------------------------------------
  550.  
  551.     Description        Address of vector/jump
  552.     -----------        ----------------------
  553.  
  554.     BRK Vector ------------ 7A55H
  555.  
  556.     User 0 ----------------    7A46H
  557.  
  558.     User 1 ---------------- 7A49H
  559.  
  560.     User 2 ---------------- 7A4CH
  561.  
  562.     User 3 ---------------- 7A4FH
  563.  
  564.     User 4 ---------------- 7A52H
  565.  
  566.  
  567.  
  568.  
  569. ZX65: Simulating a Micro                    Page T4
  570.  
  571.  
  572.                 *** TABLE 4 ***
  573.  
  574.  
  575.     A command summary for ZX65 (in alphabetical order)
  576.     --------------------------------------------------
  577.  
  578.  
  579.     COMMAND        FUNCTION
  580.     -------        --------
  581.  
  582.     C ------------- CPU register display & modify
  583.  
  584.     D ------------- Directory display of ZX65 files on drive B
  585.             Format: FILNAM.TYP    LOAD ADDR    # RECORDS
  586.  
  587.     E ------------- Examine block of memory. System will prompt
  588.             for starting address and number of bytes.
  589.  
  590.     G ------------- Go execute 6502 program per Current Program Counter.
  591.  
  592.     I ------------- Initialize a fresh disk on drive B. (Must be for-
  593.             matted.) System will prompt for verification.
  594.  
  595.     K ------------- Kill a ZX65 file on drive B. Similar to CP/M
  596.             ERA. System will prompt for file name.
  597.  
  598.     L ------------- Load a ZX65 file from drive B. System will prompt
  599.             for file name.
  600.  
  601.     M ------------- Memory substitution/modification. Use to view seq-
  602.             uential memory locations and update if desired.
  603.             System will prompt for address. Mode will then
  604.             continue in effect until a '.' is typed.
  605.  
  606.     R ------------- Load and run a ZX65 file from drive B, starting
  607.             at the address specified in the directory. (Must
  608.             be an executable 6502 program.)  System will
  609.             prompt for file name.
  610.  
  611.     S ------------- Save a ZX65 file on drive B. System will prompt
  612.             for file name, starting address, and number of
  613.             bytes.
  614.  
  615.     T ------------- Trace several 6502 instructions with display
  616.             following each step.  System will prompt for
  617.             desired number of steps.
  618.  
  619.     'SPACE' ------- Single-step command. System will execute one 6502
  620.             instruction, display the results, and stop.
  621.  
  622.  
  623.  
  624.  
  625.