home *** CD-ROM | disk | FTP | other *** search
/ messroms.de / 2007-01-13_www.messroms.de.zip / ASZMIC / IMAGES / ASZMIC10.ZIP / ASZMIC01.TXT < prev   
Text File  |  1997-06-28  |  136KB  |  3,231 lines

  1. --------
  2. Project 81 presents:
  3. Etext of the ZX-Aszmic manual (etext #2)
  4. converted to etext by Adam Bergstrom.
  5.  
  6. Project 81 is the official sister page of Project 64. Its goal is to
  7. is to preserve ZX81/80 documents like manuals and some other. By translating
  8. manuals into etexts, the documents will exist for a long time. Each manual
  9. is also a bit of computer history and should be preserved.
  10. The 'Project 81' needs your partizipation! If you have manuals
  11. or ZX81/80 related documets just send an e-mail to me what you want
  12. to convert. You can also send me an e-mail if you desperately need some
  13. information. 
  14.  
  15. The contributors of Project 81 do not take any responsibility for the accurrance
  16. in this etext. Please use the information given ihn this text at your own risk.
  17.  
  18. The Project 81 homepage is located at:
  19. http://www.hh.schule.de/hhs/mjaap/project.htm
  20. ----
  21. Comprocsys  limited
  22.  
  23. ZX.ASZMIC
  24. manual
  25. C FRAZER JOHNSON
  26.  
  27.  
  28.  
  29. Contents
  30.  
  31.  
  32. 1 Insertion & Overview
  33. 2 First Steps
  34. 3 First Steps continued
  35. 4 More Debug Operations
  36. 5 Text Operations
  37. 6 The Assembler
  38. 7 Program Execution & Test
  39. 8 Graphics
  40.  
  41. Appendices
  42.  
  43. 1 General Information
  44. 2 The Shift Keys
  45. 3 Debug Commands
  46. 4 System Addresses
  47. 5 Z80 Instructions
  48.  
  49.  
  50. Application Note *1
  51.  
  52.  
  53.  
  54.  
  55. *****  All rights reserved. Manual & ROM contents copyright  ***
  56.  
  57.     INSERTION & OVERVIEW        Chapter 1
  58.  
  59.  
  60.  
  61. Congratulations on your decision to buy ZX.ASZMIC. If you have had previous 
  62. experience of assembly and debug systems you may wish to proceed immediately 
  63. to the first 3 appendices, which summarise the ASZMIC features for you. 
  64. Otherwise the next 3 chapters contain a series of worked examples to help 
  65. give you a feel for ASZMIC usage. Chapters 5,6 & 7 are a more general 
  66. discussion of the features; chapter 8 introduces you briefly to the graphics 
  67. possibilities; and appendices 4 thru 6 contain useful reference information.
  68.  
  69. What exactly is ASZMIC? It was designed to be an ultra low cost program 
  70. development station for assembly language. As such it gives you all the 
  71. facilities you need to write and edit programs, assemble them and then run 
  72. and debug them in a controlled environment. Since the programs may also be 
  73. run on an '81 fitted with ASZMIC we tried to document some of the useful 
  74. routines in the monitor itself to help free you from that curse of assembly 
  75. language programming....Input/Output...., and we parametrised the display 
  76. routine to release the graphics possibilities which were latent in the 
  77. hardware. Unlike some of the other offerings on the market ASZMIC is almost 
  78. completely independent of Basic, and you should bear in mind that the 
  79. personality of the computer is completely transformed. ASZMIC tips its hat in
  80. the direction of Cambridge and then does its own thing. If you are experienced
  81. with microcomputer development systems then much of ASZMIC will be familiar
  82. to you; but if you are used only to Basic then ASZMIC will give you a power
  83. which you could never achieve when everything you did was filtered thru the 
  84. Basic interpreter. This is unfortunately a power for both good and evil; since
  85. ASZMIC does what you tell it to then a command which is, shall we say, less than
  86. wise can easily wipe out the system. Fortunately you will not do this very often.
  87.  
  88.  
  89. 1.1    INSTALLATION
  90.  
  91. ASZMIC is a direct replacement for the Basic Rom in the ZX81. To insert it
  92. in your computer you must first seperate the case by removing the 5 screws
  93. from the base of the ZX81; three of which are concealed under the peel-off
  94. rubber 'feet'. Then remove the three screws which hold the printed circuit
  95. board onto the lid and,taking care not to pull the 'tails' from the touch
  96. panel out of their holders, fold back the circuit board and rest it and the
  97. lid on a clean surface. If you do pull out the 'tails' they can be pushed
  98. back in without too much difficulty.
  99.  
  100. If you now look at the component side of the board; calling the edge with
  101. the edge connector 'top', that closest to the keyboard 'bottom' and the edge
  102. with the power, cassette & t.v. connections 'left', then the Rom lies at the
  103. bottom of the board. You can look at the diagram on p. 162 of the ZX8l manual
  104. to see the Rom identified (and beware1 in the picture it is inserted upside
  105. down). Although modern technology has made MOS circuits much more tolerant
  106. than they used to be you may feel more secure working on a large sheet of
  107. aluminium kitchen foil which is connected to a radiator or earth of
  108. some sort, or a metal draining board is excellent. Avoid wearing nylon
  109. clothing and try to earth yourself before touching any circuit not in its
  110. socket on the board. The Basic Rom will probably be in a 28-pin socket, even
  111. though it has only 24 pins, so there will be four empty 'holes' in the socket
  112. above the Rom. ASZMIC also has 24 pins so when it is inserted it also should
  113. be positioned at the bottom of the socket with four empty 'holes' above it.
  114. ASZMIC should be inserted so that the 1 on the label lies towards the left.
  115. Remove the Basic Rom by gently levering it up from top and bottom with a fine
  116. screwdriver until it lies loose in the socket, and then lifting it away. If you
  117. are too hasty you may bend the pins. Put it on a little bit of foil. ASZMIC's
  118. pins may now need to be bent slightly inwards so that you can press it into the
  119. socket, but not too much since the socket generally makes contact on the
  120. outside of the pins and you run the risk of a bad contact on one or more pins
  121. if you bend it too much. Push ASZMIC carefully into place.
  122. Before putting everything back together again you might like to connect up
  123. the power and t.v. lines and check that you have a blinking cursor.
  124. If not then you have a bad connection and you should try to remove and replace
  125. ASZMIC a couple of times
  126.  
  127. If you plan to use both ASZMIC and Basic alternately then you may wish to 
  128. invest in one of the boards available which will hold both Roms. Capital 
  129. Computers Ltd can give you details. When we were developing ASZMIC we cut a 
  130. hole in the lid of an '81 (from 4 to 6 back from the touch keyboard for
  131. about 5 cms and if you cut more than a mm into the keyboard you will kill it)
  132. and pic-a-backed a zero insertion force socket onto the ZX8l Rom socket.
  133. This worked surprisingly reliably, but a dual Rom board will give you the ability
  134. to preserve regions of memory when you transfer control.
  135.  
  136. 1.2    ZX80 INSTALLATION
  137.  
  138. The circuit board on the ZX80 is more accessible than on ZX8l; you just have to
  139. remove plastic pins to release the lid and the Rom lies on the right. ASZMIC
  140. should be inserted with the 1 closest to the UHF modulator (metal box). You
  141. will not be able to use the G command with a ZX80, and a steady display will
  142. not be maintained under Edit operations.
  143.  
  144. Some ZX80's suffer from excessive load on the Al2 address line which can lead 
  145. to difficulties in reading the key group 6 thru 0. This can be cured by soldering
  146. a 4.7K resistor between the left hand (keyboard) side of D7 to the earth plane
  147. below IC11 & IC17.
  148.  
  149.     FIRST STEPS WITH ZX.ASZMIC    Chapter 2
  150.  
  151.  
  152.  
  153.  
  154. 2.1    POWER UP
  155.  
  156. After connecting the power to your ZX80/81 you will have a clear screen,
  157. except for a funny little character towards the bottom left (End-of-Data)
  158. and a blinking cursor on the line just above it. The speed of blink identifies
  159. which mode ASZMIC is in..... Fast blink means EDIT, slow blink means DEBUG.
  160. With 16k of memory on the system you will be in DEBUG mode but if you are 
  161. using a "bare" machine then you will be in EDIT mode. Shifting between
  162. EDIT & DEBUG modes is achieved by use of the Shift 9 & Shift E keys. Experiment
  163. by pressing Shift 9 (DEBUG) and Shift E (EDIT) alternately, and watch what
  164. happens to the cursor blink rate. There is only one difference between EDIT
  165. and DEBUG modes, but that is an important one. When you hit newline (we shall
  166. write newline as /NL/ in future) in DEBUG mode the line you have just finished
  167. will be passed to the Command Interpreter. In EDIT mode you just start a new
  168. line.
  169.  
  170. 2.2    EDITING
  171.  
  172. Press Shift E to get yourself in EDIT mode. The cursor will be blinking quickly.
  173. Now type A. An "A" appears on the screen & the cursor is advanced to the right.
  174. Type A again, but this time leave your finger pressing on the key. After
  175. half a second ASZMIC will start writing A's at a rate of 8 per second. Take
  176. your finger off the key before the line is full. This illustrates the very
  177. useful key repeat feature built into ASZMIC. It works on all keys, including
  178. /NL/. Now type /NL/ & then press B for a second or two, type /NL/ and press C
  179. for a second or two, type /NL/ and repeat the process till you have 5 or 6
  180. lines on screen. Notice how the display is scrolled up with each /NL/. Now
  181. type a final line of, say, G's but do not press /NL/ at the end. Instead
  182. press Shift 5 (CURSOR LEFT) & keep your fingers on the keys. The cursor will
  183. move left along the line till it comes to line start. Press Shift 8 (CURSOR
  184. RIGHT) continuously & watch the cursor advance along the line to line end.
  185. Press Shift 5 (CURSOR LEFT) again until the cursor lies in the middle of
  186. the line.Type 12345. The figures are inserted in the middle of the line.
  187. What actually happens is that everything under and right of the cursor is
  188. shifted right, the character you have typed is placed under the cursor, and
  189. then the cursor is shifted one place to the right.
  190.  
  191. 2.2.1    RUBOUTS
  192.  
  193. Press Shift 0 (RUBOUT). The 5 you have just typed will disappear. This is
  194. the first type of rubout in ASZMIC, and is the typing error rubout. The
  195. character to the left of the cursor is deleted and everything past it moved
  196. left one place. Press Shift 5 twice to position the cursor over the 3.
  197. Press Shift Q (EDIT RUBOUT) and watch the 3 disappear. This is the second
  198. type of rubout; the editing rubout. The difference is that Shift 0 is more
  199. convenient when you are typing in a fresh line, and Shift C is better when
  200. editing a file. Experiment a bit with them if you like. Edit Rubouts do not work
  201. when there is only one character remaining on a line. You can rubout /NL/'s
  202. with Shift 0. Shift Q can also delete the "padding" blank ASZMIC inserts before
  203. a /NL/; which can give problems with assembly & merging.
  204.  
  205. 2.2.2    VERTCAL CURSOR OPERATIONS
  206.  
  207. Reset your ZX80/81 (turn off & on again). We ask you to do this quite often
  208. because if you have only 1K of memory these examples will soon fill up the
  209. text area. Enter DEBUG mode with Shift 9. Type D 0/NL/ .
  210. ASZMIC responds with  0000 F5
  211. Keep your finger on the /NL/ key until ASZMIC has printed 0030 3E and then
  212. type . (period) followed by /NL/ followed by E/NL/ to get back to
  213. EDIT mode. You have actually done a Dump & Modify of the first 49 monitor
  214. locations but we want it just to have some text to play with. Now press Shift
  215. 7 (CURSOR UP) and hold it down. Watch the cursor move up the screen until it
  216. reaches the top, and then watch the text scroll down until the cursor has moved
  217. onto a blank line. Now press Shift 6 (CURSOR DOWN) and watch the cursor move
  218. down until it is on the final line just above the End-of-Data character. It
  219. will not move down any further. Now press Shift 4 (PAGE UP) a couple of times
  220. and see how you flip up through the text. Press Shift 3 (PAGE DOWN) to reverse
  221. the process.
  222.  
  223. 2.2.3    DELETING A LINE
  224.  
  225. Move the cursor up to 0020 7E or thereabouts. Now press Shift 1 (DELETE LINE).
  226. The line will vanish. Repeat the process and sucessive lines will vanish
  227. until you are back down above the End-of-Data character. You cannot delete this
  228. final line with Shift 1; you have to rub it out character by character. This
  229. is to protect the vital End-of-Data character which is used as a "stop" for
  230. many ASZMIC operations. Now press Shift T (TOP). The cursor and display
  231. jump up to the very top. This is useful if you want to search down through
  232. large texts, but is most important because the top line has a special significance.
  233. It is the Shift Macro line, but more of that later. Now press Shift 9 (DEBUG)
  234. and notice how you have jumped down to the bottom line and entered DEBUG mode.
  235. Press Shift E (EDIT) and note that you have not only entered EDIT mode (fast
  236. blink) but also jumped back to the point where you were when you last pressed
  237. Shift 9. This enables you to toggle between EDIT and DEBUG modes without having
  238. to search for your place all the time.
  239.  
  240. 2.2.4    FILES & FILEMARKS
  241.  
  242. Unlike the BASIC rom, ASZMIC does not construct a special display file for
  243. you, but instead uses most of memory as one big text area over which you
  244. move the T.V. screen as a sort of window. A lot of operations are controlled
  245. by a special character, the  (sterling) sign, which acts as a delimiter. 
  246. Since blocks of text seperated by  signs are treated as files, we call the o
  247. a filemark. It is used by itself to indicate the end of a file, and is
  248. needed for print, assembly, cassette save, merge, and file deletion operations
  249. to tell ASZMIC that it is time to stop. You indicate the start of a file by a
  250. name which is particular to it & does not also occur in the body of the file.
  251. It is good practice to have a filemark as the first character of the name. Thus:-
  252.  
  253. oNURSERY.RHYME
  254. 1
  255. 2
  256. BUCKLE MY SHOE
  257. 3
  258. 4
  259. KNOCK ON THE DOOR
  260. o
  261.  
  262. is an example of a file, and can be printed, saved, edited etc. by
  263. referencing the name oNURSERY.RHYME  . A filename can be any combination of
  264. alphanumeric characters (0-9 A-Z) and . (period) and is terminated by any
  265. other character.
  266.  
  267. Home the cursor (Shift 9) & type /NL/  . Then press Shift E to get into EDIT
  268. mode & move the cursor till it blinks on the D of your original D 0 line at
  269. the top of the dump. Now press Shift 2 (delete file) . All the text from the
  270. cursor to the filemark will have been wiped away.
  271.  
  272. 2.2.5    RUNNING OUT OF SPACE
  273.  
  274. Reset the ZX80/81 and hit Shift 9 (DEBUG, as you probably know by now).
  275. Type D 0 5000/NL/   . The screen will go blank for several seconds because
  276. ASZMIC is generating 625 lines of formatted dump for you. Unfortunately
  277. it would take more than a 16k memory pack to contain so much text, even if
  278. ASZMIC had not divided up your memory into 3 parts for text and 1 for programs.
  279. When the display comes back try typing in a character. Nothing happens. You
  280. can move the cursor around (try it) but you cannot insert any fresh text. To
  281. use ASZMIC further you must delete some text. Move the cursor up 4 or 5 lines
  282. (Shift 7) and then hold Shift 1 continuously depressed. You will delete the
  283. last few lines. You can now insert characters (100 or more) until you run out
  284. of text space again.
  285.  
  286. 2.2.6    MACROS
  287.  
  288. We may as well use this mass of text for something. Press Shift T. This
  289. takes the cursor up to the top line. Now type E 40 but, since you are in
  290. DEBUG mode, do not press /NL/ to execute the command but instead press Shift 9
  291. (DEBUG) to home the cursor on the bottom line. Now press Shift R (Shift macro).
  292. The effect of this is to execute the top line as a DEBUG statement, irrespective
  293. of what mode you are in. E 40 is a DEBUG command to enter EDIT mode
  294. and position the cursor at the start of the first occurrence of the string "40"
  295. above its current position, so you will see the cursor blinking quickly on the
  296. "4" of a "40". Press Shift R several times and see how each "40" in the dump is
  297. successively searched out. You can have almost any DEBUG command or concatenation
  298. of commands on the top line and this is a way of doing a lot of work with a
  299. single keystroke. (there is another sort of macro, a Command Macro, built
  300. into ASZMIC and we will look at it when we discuss file merging)
  301. Now delete the dump by pressing Shift 9, typing /NL/ ( is not a valid DEBUG
  302. command and is ignored by the Command Interpreter), pressing Shift T, and
  303. then holding down Shift 6 to move the cursor down to the "D" of D 0 5000,and
  304. then pressing Shift 2 (delete file). You should have cleared out everything.
  305.  
  306. 2.2.7    MERGING
  307.  
  308. Reset the ZX80/81. Type Shift E (EDIT). Type the following:
  309.  
  310. >D 0 1/NL/
  311. D 0 2/NL/
  312. D 0 3/NL/
  313. D 0 4/NL/
  314. D 0 5/NL/
  315. o/NL/
  316.  
  317. Now press Shift G (merge) once. Everything between the > and  characters
  318. has been. duplicated. Try it again. Every time you press Shift G a further 5
  319. lines are copied down at the cursor position. Move the cursor up to the D of
  320. a D 0 3 and press Shift G. The 5 lines have been inserted before the D 0 3,
  321. because that is where the cursor was. Now type Shift 9 (DEBUG).
  322.  
  323. In EDIT mode the Shift G is a pure merge key. Now that you are in DEBUG mode
  324. the effect is rather different, because every time ASZMIC writes a /NL/ to
  325. the text area in DEBUG mode it passes control to the Command Interpreter.
  326. Press Shift G. Every "D" line has been copied, but since each line is a dump
  327. command, it is followed by the appropriate dump. Just by pressing 1 key we have
  328. executed 5 lines of DEBUG commands. This is called a Command Macro.
  329.  
  330. Normally in EDIT mode merging you will want to copy one piece of text into
  331. another. You do this by identifying the text to be moved by the > and  
  332. characters, putting the cursor at the point you want the text merged into,
  333. pressing Shift G, and then, if you want the original text deleted, positioning 
  334. the cursor on the > character and pressing Shift 2 (delete file). Simple,
  335. flexible, and, for the poor sweated labourer who wrote ASZMIC, easy to 
  336. implement. Check Appendix 4 for the symbols SHFTD & SHFTF. If they
  337. appear then you have 3 merge keys. Shift D is like Shift G but uses * as 
  338. merge start identifier, and Shift f uses <  .
  339.  
  340. 2.3    WHAT NEXT?
  341.  
  342. You have now covered all the Shift keys which control the EDIT functions. If
  343. you look at Appendix 2 you will see a formal summary of each Shift. Try
  344. setting up some text of your own and working with it. Then look at Appendix 3
  345. for a summary of the DEBUG commands. We are going to look a little more
  346. closely at them, although not in alphabetical order, since some of the
  347. commands are more complex in their implications than others.
  348.  
  349.     FIRST STEPS CONTINUED    Chapter 3
  350.  
  351.  
  352.  
  353.  
  354. 3 SIMPLER DEBUG COMMANDS
  355.  
  356. Everything that you can do in EDIT mode you can also do in DEBUG mode .
  357. The difference is that the Command Interpreter is called in DEBUG mode when
  358. you press /NL/. However if you do any editing in DEBUG mode then you cannot
  359. rely on Shift E (EDIT) to take you back to the point where you exited from EDIT
  360. mode. It will take you back to the location in memory where the cursor WAS, but
  361. you may have edited in something different there (such as a /NL/, in which case
  362. the cursor will not appear).
  363.  
  364. 3.1    D for DUMP
  365.  
  366. Reset your ZX8l. Hit Shift 9 to ensure you are in DEBUG mode. Type D :4300 12/NL/
  367. and you will get a display of the form:-
  368.  
  369. 4300 00 00 00 00 00 00 00 OC
  370. 4308 00 00 00 00
  371.  
  372. This is an example of a Dump Range command. It introduces an important new idea,
  373. that of a FIELD. The command itself is just a letter D, followed by a field which
  374. defines the starting address for the dump and then a field which defines the
  375. number of bytes which are to be dumped from successive locations. The : (colon)
  376. identifies the 4300 which follows as being a hexadecimal value. Lock at the
  377. definition of the field types in ASZMIC which you will find in Appendix 1.
  378. The use of fields defined there is common throughout ASZMIC with one exception
  379. which we shall discuss in a moment. Fields are seperated by one or more blanks
  380. or a comma, but not both. The first field can start immediately after the DEBUG
  381. command letter, but an intervening blank often looks better.
  382.  
  383. There is another form of dump which we call Dump & Modify. Type D :4300/NL/
  384. ASZMIC responds with:-
  385.  
  386. 4300 00
  387.  
  388. and the cursor is waiting on the line for input. Depress /NL/ 2 or 3 times.
  389. With each press the next location and its contents are printed out thus:-
  390.  
  391. 4301 00
  392. 4302 00
  393. 4303 00
  394.  
  395. How do you get out of this? Press . (period) followed by /NL/ and you are back
  396. in ordinary DEBUG mode again. So where does the Modify come in? Type
  397. D :4300/NL/ again. Now type 1 4 7 C 12/NL/ followed by . (period) and /NL/.
  398. Then do a dump range of the form D :4300 6/NL/  . The response is:-
  399.  
  400. 4300 01 04 07 0c 12 00
  401.  
  402. Compare this with the result of the first D :4300 12 that you did. Dump &
  403. Modify is the exception to the ASZMIC field rules that we mentioned earlier.
  404. Numbers are ASSUMED to be hexadecimal even without the : (colon) prefix. If
  405. you want to type in a decimal number use 0+decimalno. For a more dramatic (?)
  406. demonstration reset your ZX81,enter DEBUG mode, type 15 or 20 o signs, then look
  407. for the address of DSPBGN in appendix 4 and add 55 to it (e.g. :40B4+55). After
  408. terminating your oo's line with /NL/ type D :40B4+55/NL/  & then 1C/NL/ 1D/NL/
  409. etc. You can see the o signs being overwritten with the characters corresponding
  410. to the codes that you typed in.
  411.  
  412. 3.2    C for COPY
  413.  
  414. Reset the ZX8l (if you have 16K of memory you need not do this all the time).
  415. Enter DEBUG Mode (Shift 9). Type the following commands:-
  416.  
  417. D :4300 20/NL/
  418. D :4300/NL/
  419. 1 2 3 4 5 6 7 8 ./NL/
  420. D :4300 20/NL/
  421. C :4300 :4308 8/NL/
  422. D :4300 20/NL
  423.  
  424. Take a deep breath and look at what you did. First you dumped 20 locations which
  425. were all 0 (the machine zeroes memory on reset). Then you did a Dump and Modify
  426. of the first 8, and a Dump Range to verify that they had been modified. You
  427. then copied 8 bytes from the location :4300 to the location :4308 (the bytes
  428. are counted UP from the addresses you give) and finally you dumped the 20 locations
  429. again to verify that the copy had taken place.
  430.  
  431. The format for Copy is C from to count. It has logic in it to ensure
  432. that if you specify overlapping memory regions then the data moved to the 
  433. destination region is not corrupted. The copy goes from top to bottom or
  434. vice versa as required to ensure that the source region is not overwritten
  435. by the destination region before the source bytes have been copied.
  436.  
  437. 3.3    F for FILL
  438.  
  439. Reset the ZX81 & enter DEBUG mode. Type F :4300 :4310 :AA/NL/  .
  440. Then type D :4300 16/NL/ and note that you have filled the region with AA
  441. codes. The format is F from to fillerbyte . The command is most often used
  442. to initialise regions of memory (notably to zero them out; zero is the default
  443. fillerbyte if you do not specify a third field)
  444.  
  445. 3.4    E for EDIT
  446.  
  447. E by itself just shifts back to EDIT mode. If followed by a symbol
  448. then ASZMIC searches up for the symbol and positions the cursor at
  449. its start. Great for getting to a file when you have a lot of text. You have
  450. already used this command in 2.2.6 MACROS so we will not give any examples.
  451. Look at the description of the subroutine CMPSTR (used by E & many other
  452. ASZMIC commands) to see what constitutes a valid comparison.
  453.  
  454. 3.5    H for HORRIBLE JUMP
  455.  
  456. The format for this is H field  and the result is a jump to the address
  457. specified by the field whilst still in the context of the Command Interpreter
  458. You presumably have a program at the address which does something for you and
  459. then RET's to ASZMIC. Your routine can analyse further fields on the line using
  460. GETFLD, so this is a way of linking in your own personalised commands. If you
  461. want an example try looking up the address of INICON in Appendix 4
  462. and then doing an H to that address (remember the :). INICON is the start of
  463. the ASZMIC initialisation so the effect should be the same as resetting the
  464. ZX81.
  465.  
  466. 3.6    M for MACRO
  467.  
  468. This is an extension of the Shift G key. Reset the ZX8l and enter DEBUG mode.
  469. type: -
  470.  
  471. =D 0 8/NL/
  472. o/NL/
  473. +D 16 8/NL/
  474. o/NL/
  475.  
  476. Then type M=/NL/ a couple of times and M+/NL/ a couple of times. The dumps
  477. specified are generated. The character after the M specifies the start character
  478. for the command macro, unlike Shift G , which always uses > as a start
  479. character. You thus have a wide choice of macros.
  480.  
  481. 3.7    O for OLD REGISTERS
  482.  
  483. In DEBUG mode type O/NL/. You will get a pair of intimidating lines
  484. each with six 4-digit hexadecimal numbers on it. These are the registers which
  485. are saved in the register context area (REGIM). See the definition of O in
  486. Appendix 3 to tell you which is which. They do not mean too much until you 
  487. start executing programs and generating Breaks in them, which causes the 
  488. registers to be saved in the Image area. It is a very good idea to put an
  489. O in the Shift Macro line when you start a session with ASZMIC, since the
  490. Shift Macro line is executed for every break condition, and you normally
  491. are interested in register contents when a break has occurred.
  492.  
  493. If you are feeling dynamic try looking up the addres of REGIM in Appendix
  494. 4 and then modifying some locations between (REGIM) and (REGIM)+24 and
  495. noting the effect on the Old Register dump lines.
  496.  
  497. 3.8    P for PRINT
  498.  
  499. This command will do precisely nothing for you if you do not have a Sinclair
  500. printer attached. If you do then reset the ZX81 and enter EDIT mode. Type:-
  501.  
  502. oPRINT. FILE
  503. ANY
  504. SORT
  505. OF
  506. RUBBISH
  507. WILL DO
  508. o
  509.  
  510. and then hit Shift 9 to enter DEBUG mode.
  511. Type P oPRINT.FILE/NL/ and the file will be printed. If you want to terminate
  512. the printing prematurely (e.g. if you forgot the o sign which terminates the
  513. printing) you just have to hit the Break key.
  514.  
  515.  
  516. This concludes the simpler DEBUG commands. In the next chapter we shall be
  517. looking at some of the more complex, and interesting, ones.
  518.  
  519.     MORE DEBUG OPERATIONS    Chapter 4
  520.  
  521.  
  522.  
  523.  
  524.  
  525. 4 SAVING & LOADING
  526.  
  527. It is now time to look at the ASZMIC cassette interface. This uses the same
  528. recording format as the BASIC Rom, so that it is possible, using some tricks
  529. described in the chapter on text ops, to read in a program saved by BASIC,
  530. modify it with ASZMIC e.g. writing REM's full of machine code, and then write
  531. it back so that it can be loaded by BASIC again. The price you pay for this
  532. compatibility is the dreadful slowness of the interface, but of course you are
  533. used to that by now.
  534.  
  535. When ASZMIC writes out a file to cassette it first writes out a title line
  536. which identifies the program or file which follows, waits 5 seconds, and then
  537. writes out the file or memory region you specified. When you are loading from
  538. cassette ASZMIC detects the title line and writes it to screen, using the 5
  539. second pause before data to display it to you. You thus get a catalogue of
  540. everything on the tape built up for you, which is informative and soothing
  541. because you know that your system has not disappeared into one of those black
  542. holes which lurk around cassette reading.
  543.  
  544. 4.1    K for KASSETTE (sic)
  545.  
  546. Reset your ZX81, enter EDIT mode and type in a file, such as:-
  547.  
  548. oLIMERICK
  549. THERE WAS A YOUNG LADY FROM EXETER
  550. SO LOVELY THAT MEN CRANED THEIR NECKS AT HER
  551. AND ONE WENT SO FAR
  552. AS TO WAVE FROM HIS CAR
  553. THE DISTINGUISHING MARK OF HIS SEX AT HER
  554. o
  555.  
  556. Now enter DEBUG mode, connect your cassette recorder just as you do for
  557. BASIC, and type in :-
  558.  
  559. KoS "POETRY" oLIMERICK/NL/
  560.  
  561. The sequence K o S space   is very important. If you do not write it like
  562. that, with only 1 blank between S and ", then ASZMIC will not recognise it
  563. as a file title and you will never ever (unless you are very smart) be able
  564. to read the file back.
  565.  
  566. After you hit /NL/ you have S seconds to turn on your cassette recorder. It
  567. does no harm to turn it on early. The screen then blanks out for half a second
  568. and the title line is written out. The display returns for a further 5
  569. seconds and then the file itself is written out. The display comes back again 
  570. when the save is complete. You can abort a save at any time with the BREAK key.
  571. Stop the recorder .
  572.  
  573. Now type F :4300 :4320 :BB/NL/ to set a region of memory to "BB" codes.
  574. Do another save, but this time of a memory region:-
  575.  
  576. KoS "MEMSAVE" :4300 :4320/NL/
  577.  
  578. Cassette operating procedure is as above. Rewind the tape.
  579.  
  580. 4.2    L for LOAD
  581.  
  582. Reset the ZX81 and enter DEBUG mode. Type:
  583.  
  584. L "NOTHING"/NL/
  585.  
  586. and start the recorder in playback mode with the same volume setting that
  587. you use for BASIC. After a while the screen will light up with:-
  588.  
  589. KoS "POETRY" oLIMERICK
  590.  
  591.  
  592. for 5 seconds and then blank out again. A little later there comes another
  593. 5 second burst but this time the line:-
  594.  
  595. KoS "MEMSAVE" :4300 :432
  596.  
  597. has been added to the display.Since there is no file called "NOTHING" on
  598. the tape you may as well hit BREAK to come back in EDIT mode. Now rewind the
  599. tape, enter DEBUG mode and, using the same procedure as above but with:-
  600.  
  601. L "LIMERICK"/NL/
  602.  
  603. load the file you first saved. Check that it is O.K.
  604.  
  605. Reset the ZX8l, enter DEBUG mode and rewind the cassette. Check that :4300
  606. to :4320 contains zeroes (D :4300 32/NL/) and load the second file with:-
  607.  
  608. L "MEMSAVE"/NL/
  609.  
  610. Dump :4300 to :4320 to verify that it now contains "BB" bytes.
  611.  
  612. EASY?
  613.  
  614. 4.5    A for ASSEMBLE
  615.  
  616. The ASZMIC assembler was developed from a 1K assembler (yes, 1K) written for
  617. NASCOM 1 and normally called, with mixed emotion, the "Dirty Dog" assembler.
  618. It is a 2 pass assembler with full Zilog mnemonics. If you are not familiar
  619. with Zilog's assembly language then it might be a good idea, to put it mildly,
  620. if you bought a book on the subject. There are references in Chapter 26 of
  621. the ZX81 manual.
  622.  
  623. Reset the ZX81, enter EDIT mode and type the following sequence (we are going
  624. to assume that you know enough to terminate each line with a/NL/):-
  625.  
  626. oFILE
  627. ORG :4300
  628. START LD HL,0
  629. LD DE,0
  630. LD B,10
  631. LOOP INC DE
  632. ADD HL,DE
  633. LOOPEND DJNZ LOOP
  634. RST 0
  635. o
  636.  
  637. This is a program. Please always start every program with an ORG directive to
  638. tell the assembler where it should be located. It will probably start at 
  639. (TXTLIM) if you do not, but that default may not necessarily be in your version
  640. of ASZMIC. Now we are ready to do an assembly. Enter DEBUG mode and type:-
  641.  
  642. A oFILE 1
  643.  
  644. The "1" is an option to say that you want an assembly listing. Almost
  645. instantaneously ASZMIC comes back to you in EDIT mode (It can assemble at up
  646. to 300 statements a second) with a listing showing the code generated for
  647. each statement, plus the location in memory it has been assembled at. 
  648. Enter DEBUG mode and dump the program (D :4300 14) to see that it really has
  649. been assembled for you. We call this generated machine executable code "object
  650. code" .
  651. Now delete all the text in the text area, but do not reset the ZX81
  652. because we do not wish to lose the program.
  653.  
  654. 4.6    J for JUMP
  655.  
  656. We are now going to execute the program. It generates the sum of the numbers
  657. from 1 to 10 in the HL register. To help us see what is happening we are
  658. going to use a Shift Macro (which is automatically executed whenever a BREAK
  659. condition is encountered. BREAK means breakpoint,single step,RST 0 code or
  660. externally generated NMI interrupt). Hit Shift T, type O (not 0) without a
  661. newline and then Shift 9 to home back in DEBUG mode. Check Appendix
  662. 3 for the O command if you have forgotten it. Type:-
  663.  
  664. J :4300
  665.  
  666. You now have a dump of the registers at the end of the program. Look at HL.
  667. It should contain :0037, which is the hex equivalent of decimal 55. DE should
  668. contain :000A which is 10 of course.
  669.  
  670.     4.7    B for BREAKPOINT
  671.  
  672. Let us now try to execute the program again, but this time with a breakpoint
  673. inserted to stop execution "in midstream". Type B LOOPEND/NL/ (the DJNZ
  674. instruction) and then J START /NL/. Now take a look at the registers. Both
  675. DE and HL should contain :0001, and B should still contain :0A, since the
  676. breakpoint takes effect before the instruction at whose location it was
  677. inserted is executed.
  678.  
  679. Breakpoints work by saving the byte at the breakpoint location and substituting
  680. a RST 0 (:C7) code. When you hit a breakpoint in the course of normal execution
  681. the "normal" byte is put back there ( check with D LOOPEND 1).
  682. Now type B /NL/. Since you did not specify an address the breakpoint was reinserted
  683. at the previous breakpoint location ( check with D LOOPEND 1 again). Type B 0/NL/
  684. to clear the breakpoint.
  685.  
  686. 4.8    G for GO
  687.  
  688. Now type G/NL/. You have advanced one instruction. Type it a couple more times.
  689. This is called single stepping. You can see the Program Counter (PC) changing
  690.  as well as the registers you are working with. Since we did not specify an
  691. address with the G command it used the saved Program Counter address in the
  692. register image area (PCl in REGIM).
  693.  
  694. Now why not try executing 20 instructions before jumping back to the monitor?
  695. Type G START 20/NL/  .The "START" tells the G command where to go and the "20"
  696. tells it to execute 20 instructions before it comes back to you. You will
  697. see that the Program Counter,which points to the next instruction to be
  698. executed, is :4308, HL is :0015, DE is :0006 and B is :04. If you add it all
  699. up you will see that this is the sixth time through the loop and we have in fact
  700. executed 20 instructions. Then type J /NL/. This shows how J without an address
  701. will just continue the program to its end.
  702.  
  703. We sneaked in a little subtlety without mentioning it to you beforehand.
  704. You have used the symbolic names FROM YOUR PROGRAM in DEBUG instructions, and
  705. they worked. That sort of thing makes debugging a program very much simpler.
  706.  
  707. By the way, if you try single stepping through a breakpoint then you will single
  708. step into the breakpoint logic, which may not be exactly what you had in
  709. mind.
  710.  
  711. 4.9    I for Immediate
  712.  
  713. WE conclude this chapter by looking at the Immediate instruction facility in
  714. ASZMIC, which to the best of our knowledge is unique. It is a way of giving
  715. you the sort of interactive capacity you have in BASIC by allowing you to
  716. specify assembler statements which are immediately executed in your program
  717. context, and function as an extension of the program itself without
  718. the need to recompile.
  719.  
  720. Clean up the text area if you have a 1K system. Type I LD HL,1/NL/
  721. and look at the HL register in the "O" dump. It contains :0001. Type I EX DE,HL/NL/
  722. and note that the DE and HL registers have been exchanged. You can put any
  723. instruction in an Immediate command, and even define labels with the = (EQU)
  724. directive, but relative jumps and the other directives (ORG,DEFB,DEFW,DEFM)
  725. are meaningless and can crash the system when the I command tries to execute
  726. them.
  727.  
  728. Finally try I LD HL,1+2+3+4+5-15/NL/ and look at HL in the register dump. It
  729. should be zero, thus demonstrating how you can do simple arithmetic with
  730. fields.
  731.  
  732. We now recommend that you look at the formal definition of the DEBUG commands
  733. in Appendix 3 to see what you have been doing all the time. There is one
  734. more Debug command, the N command, which is used in conjunction with a
  735. special board which holds both Basic & ASZMIC roms to switch between roms
  736. whilst preserving memory. Its use is described in the board documentation.
  737.  
  738.     TEXT OPERATIONS    Chapter 5
  739.  
  740.  
  741.  
  742.  
  743. This and the next 2 chapters contain di scussi on around features of ASZMIC 
  744. to help 'flesh out' the bare bones of definition in the Appendices and the 
  745. exemplars of the previous chapters. They should not be taken as comprehensive 
  746. descriptions of everything which is available.
  747.  
  748. 5.0    INTRODUCTION
  749.  
  750. The second partition in ASZMIC memory, lying between DSPBGN & (TXTLIM), is 
  751. used for text preparation and editing. On a 16K system this means you have 
  752. around 12000 characters available; more if you move up the TXTLIM pointer 
  753. yourself. ASZMIC treats this as an allowed space in which you can insert 
  754. characters at will, and your T.V. screen becomes a window which is moved 
  755. over this enormous area under control of the Editor Shift keys. There is no 
  756. specific display file as with BASIC, but instead the whole text area is a 
  757. display file, and the BASIC notions of program, variable and display space 
  758. are no longer relevant. This is a- software utilisation of one of the 
  759. main strengths of ZX81 viz. that it allows most of memory to be mapped onto 
  760. a video display. We force a few conventions of our own onto this space to make 
  761. life a bit more meaningful for you.
  762.  
  763. 5.1    FILES
  764.  
  765. The first convention is to introduce a protocol which divides up the 
  766. text in the text area into identifiable sections. We call these sections files. 
  767. A file is identified by a symbol whose first character is a f (sterling) sign 
  768. left justified on the first line of the file. This symbol, plus its preceding 
  769. o sign, becomes the NAME of the file. The end of a file is signalled by a o 
  770. sign as the first character of a line. We call the o signs FILEMARKS in 
  771. consequence. The ASZMIC character string comparison routine CMPSTR is coded 
  772. to recognise a comparison of strings beginning with o only if the 
  773. destination string is the first on a line. This all sounds a bit complicated 
  774. but it works out very well in practice, because if you start every 
  775. file with an unique filename, and terminate it with a filemark, the ASZMIC 
  776. commands will unerringly pluck out the file you are interested in from the 
  777. text area and process it for you. The convention is fully integrated into 
  778. the Debug commands
  779.  
  780. This means that you can have as many files as you like, subject only to 
  781. space restrictions. We should point out that the Debug commands will often 
  782. work if you have specified an invalid filename for a file i.e. one not starting 
  783. with a filemark but there are no guarantees. Forgetting the terminating 
  784. filemark can be a nuisance for cassette ops and printing, and a total disaster 
  785. if you then try to assemble or merge the endless file.
  786.  
  787. 5.2    MERGING & DELETING
  788.  
  789. We implemented these functions as Edit Shift operations, rather than Debug 
  790. commands, to give extra flexibility and to tie up with the 'Show it 
  791. rather than tell it' philosophy of a full-screen Editor. The cursor 
  792. is used to identify the starting point for merge & delete operations; and a 
  793. filemark is used to terminate the operation. When a merge key is pressed 
  794. ASZMIC searches from a little past the shift macro line down to a little 
  795. beyond the current end of data pointer to find the merge start character 
  796. ( > for Shift G   < for Shift F  * for Shift D ) and then copies the source 
  797. text down (or up) to the cursor position until it finds a filemark in the 
  798. source text. Long merges can blank the screen for a moment.
  799.  
  800. At one extreme this is a conventional file merging operation, at the other it 
  801. becomes a text macro. You can, for example, copy in a file of subroutines 
  802. from tape and merge them into a program. You can also, if you are writing a 
  803. program with a lot of data in it, code something like   > DEFB o high up in 
  804. the text area and then whenever you hit Shift G the string     DEFB  will 
  805. be incorporated into your program. This can save quite a lot of typing.
  806.  
  807. When you want to delete the source file/string which you have merged you just 
  808. position the cursor onto the merge character and press Shift 2 
  809. and, Presto, it has been deleted. A filemark will always stop a delete or merge 
  810. operation. Failure to terminate a merge source string with a filemark will mean 
  811. that the poor computer will go trying to merge on forever. You can break 
  812. back to ASZMIC. Deletes just refuse to work if they cannot find 
  813. a terminating filemark.
  814.     
  815. 5.3 EDITING
  816.  
  817. You have covered the EDIT functions pretty comprehensively in Chapter 2, so 
  818. here we will just give a few hints & tips. Remember the use of the E string 
  819. command as a Shift Macro when you want to search out all occurrences of a name 
  820. in a file. Hitting /NL/ in the middle of a previously written line will convert 
  821. it to 2 lines, and Typing Rubout can be used to concatenate lines by deleteing 
  822. a /NL/. Please try not to edit in the top 20 lines of the text area unless you 
  823. are working with a shift macro. These lines are really padding to preserve a 
  824. clean display and deleting them could mean that you generate an illegal display. 
  825. In particular using type rubout to delete the /NL/ at the very beginning of 
  826. display can leave the vital (but invisible) start of data marker exposed with 
  827. later disastrous consequences. Editing out the blank which ASZMIC ensures 
  828. is before every /NL/ can also cause you to lose the cursor in some circumstances 
  829. and can cause cosmetic errors in assembly and merging. Writing more than a few 
  830. lines with more than 36 characters in them on any one display page can also 
  831. cause ASZMIC to position the cursor off the visible page, although this does no 
  832. harm.
  833.  
  834. When you want to insert lines in a text you should position the cursor 
  835. on the line above the desired insertion point, hit Shift W to get to the end of 
  836. the line and then hit /NL/ to create a new blank line. Shift 7 followed by Shift 
  837. 6 will take you back to the beginning of a line. Remember that Shift Q rubs out 
  838. under & forwards whilst Shift 0 rubs out backwards.
  839.  
  840. 5.4    PRINTING
  841.  
  842. The way the printer operates is determined by 2 bits in ASSFLG. This flag is 
  843. set automatically by the Assembler (it is in fact the options byte) and zeroed 
  844. at assembly termination (unless you used the Break key to escape from an assembly) 
  845. so if you want to control the printer you have to set these bits yourself. 
  846. Bit 1 set to 1 will route almost everything ASZMIC, as opposed to you, writes 
  847. to printer and Bit 5 will set the printer in fine pitch mode with 64 chars per 
  848. line.
  849.  
  850. You can fool the printer into writing double height characters if you want. If 
  851. you write a line of up to 32 characters and then pad it out with blanks (no 
  852. /NL/ ) to a total of 48 characters, and then type in the 32 characters again in 
  853. EXACTLY the same order you will get, not a long line with 2 messages, but 
  854. a single message with double height characters when the line is printed. 
  855. This can be effective for titling, and if you do it a lot you will learn to use 
  856. the merge facility as a convenient way of generating the double texts. If you 
  857. get the number of blanks wrong the effect is, well, interesting but hardly 
  858. legible. This technique will also work for fine pitch printing but double up 
  859. to 64 chars of message and 32 padding blanks.
  860.  
  861. Remeber the use of the Break key to get you out of print situations when you 
  862. have forgotten the terminating filemark. Finally, printing takes place indirectly, 
  863. that is ASZMIC jumps to the print routine via an address in RAM. If you alter 
  864. the contents of PRTJMP to the address of your own print routine then ASZMIC 
  865. will use yours instead of the Sinclair interface built in. Print is entered with 
  866. the stack containing the start of the line to be printed, and your routine must 
  867. clear this and exit with a RET with HL pointing at the first character after the 
  868. /NL/ which terminated the line.
  869.  
  870. 5.5    CASSETTE OPERATIONS
  871.  
  872. Your cassette recorder should function with ASZMIC at the same volume and tone 
  873. settings as with Basic. ASZMIC should in fact work rather more reliably since it 
  874. maintains a tone to the recorder until just before recording starts; so that the 
  875. automatic gain control on most low cost cassette recorders will not be so 
  876. obtrusive as it is for Basic. If you want to set up your recorder for a new tape 
  877. brand then try recording a sequence of blanks ( KoS "NULL" :7000 :7FFF ); 
  878. just after switch on when the program area is empty works very well. Try loading 
  879. it back in with your recorder volume control set to minimum and then watch the 
  880. effect as you slowly increase the volume. The screen will change from "white & 
  881. swimmy" to a series of well defined striated bands to a predominantly black 
  882. screen when the volume is too high. The volume control is best set in the middle 
  883. of the "band" region.
  884.  
  885. 5.5.1    HEADERS & FILES
  886.  
  887. Since there are 2 types of "file" we can manipulate with cassette; genuine 
  888. text files and defined regions of memory, we have to give each tape file a 
  889. seperate identification since memory regions do not have file names. When 
  890. you issue a save command to ASZMIC it writes out the command itself as a 
  891. header and then pauses before writing out the file proper. On playback the 
  892. syntax of the save command represents a virtually unique character sequence 
  893. which ASZMIC recognises, and causes it to be displayed for a few seconds 
  894. to identify what is on tape. If the identification in the header and the 
  895. Load command correspond then ASZMIC checks the rest of the header to find 
  896. out if it is loading text or memory and reacts accordingly. You always come 
  897. back from Load in Edit mode. There are a couple of extra features associated 
  898. with loading a memory region. The first is that the region into which the 
  899. saved program/data is loaded is offset by the contents of the OFFSET variable, 
  900. so you can do a relocated load from tape. The second is that if you analysed 
  901. the contents of LABSTK & LABEND and wrote out a Symbol Table to tape, then if 
  902. you followed the 'end of region' definition with a space and then the letter L 
  903. ASZMIC will recognise the load as a Symbol Table and set LABEND accordingly. 
  904. LABSTK is unchanged so you must have the same size memory and not have 
  905. relocated the Symbol Table before the save. A small feature but Symbol 
  906. Tables are sometimes worth saving for library or debug purposes.
  907. The physical seperation of header and file on tape gives you the chance to 
  908. do some very complex things by juggling and over-recording. This is for the 
  909. benefit of those hardy souls who are not content till they have abused a 
  910. system to a maximum, or the more practical who wish to recover a poor 
  911. recording.  The details you have to work out for yourself. Note that if 
  912. RDCASS is called before the tape has run onto the half-second silence 
  913. before a file or header it can pick up rubbish (depending on volume setting 
  914. and screen contents at record time). The silence will, however, synchronise 
  915. it onto a byte boundary so that the file may be displaced but will not be 
  916. corrupted.
  917.  
  918.  
  919. 5.5.2    CREATING BASIC PROGRAMS
  920.  
  921. There IS one creative abuse of the cassette recorder which we must mention. 
  922. For those of you who do not have a board which holds both ASZMIC 
  923. and BASIC Roms the cassette recorder is the most accessible form of 
  924. communication between the two. In the Application notes you will find a 
  925. listing for a general purpose program which simulates the context of a Basic 
  926. program with a single REM in it. By placing your own code at the indicated 
  927. point you can cause it to be incorporated into the REM. A cassette save of 
  928. the program will then be loadable by Basic, for the example given the 
  929. identifier "123456789" is used, and you can then add lines of genuine Basic 
  930. and reference the code in the REM by a USR (16514). Your code should not 
  931. affect the HL' register. You will need to use the OFFSET facility when 
  932. assembling the program. On a 16K system ORG .4000 and OFFSET = :3000 works 
  933. very well, but you must have a 9 byte header since the first 9 bytes 
  934. of the variables in Basic are not recorded.
  935.  
  936. If you want to go back in the other direction (it takes all sorts.....) then 
  937. you must start by initiating a save of a memory region large 
  938. enough to hold the Basic program. You can abort it with Break as soon as the 
  939. memory starts to be written out; all you want is the header. Then back the tape 
  940. so that you are just before the data which began to be recorded. If you then 
  941. perform your save of a basic program it can be loaded back by ASZMIC. You will 
  942. have to abort the load manually when the Basic program is complete. 
  943. Alternatively you can write a very small program which uses RDCASS to get bytes 
  944. from the tape and store them. This latter approach is probably quicker and more 
  945. controllable.
  946.  
  947. In the beginning ASZMIC had a super fast cassette interface with parity 
  948. checking and lots of goodies, plus an offset ASCII character set and an 
  949. RS232 style printer interface. We changed it all to give you Sinclair 
  950. compatibility on characters, printer & cassette so we hope that someone 
  951. does make use of this, otherwise it was all wasted.
  952.  
  953.     THE ASSEMBLER    chapter 6
  954.  
  955.  
  956.  
  957. Before discussing the Assemhler section of ASZMIC we should look at what an 
  958. assembler does for us. Unlike BASIC, assembler statements are closely 
  959. related to the actual operations of the Z80 cpu. The Z80 has a well defined 
  960. set of logical, arithmetic and data movement operations which it can 
  961. perform     operations which are relatively easy to understand even if it 
  962. takes a little time and practice to use them to perform 'useful' work. 
  963. Unfortunately the instructions which direct these operations when they are 
  964. read in from memory are more meaningful to the digital decoding logic in the 
  965. Z80 than they are to flesh and blood.
  966.  
  967. 6.1    MNEMONICS
  968.  
  969. The first thing an assembler can do for us is to allow us to write down the 
  970. instructions for the Z80 in a form which is more expressive for us, and then 
  971. translate them to the Z80 codes; for example CCF as an abbreviation for 
  972. Complement Carry Flag is easier to remember than hexadecimal 3F. This can 
  973. be extended further by allowing us express the Z80 instructions in terms 
  974. of operations on operands meaningful in terms of the Z80 internal architecture 
  975. (which is relatively comprehensible) and having the assembler decode the fields 
  976. down into valid instructions. The assembler thus enables us to write Z80 
  977. instructions in terms of our conceptual picture of the ZOO.
  978.  
  979. 6.2    SYMBOLS
  980.  
  981. The other thing that the assembler can do for us is to allow us to use symbols 
  982. instead of the binary codes that the ZOO enjoys to represent data and 
  983. addresses. Data items can be written in the decimal or character formats 
  984. which we are used too. The ZOO works with defined addresses in memory. Very 
  985. often we do not know as we code a program where its constituent routines 
  986. and entry points lie. We can give them symbolic names, called LABELS, and 
  987. let the assembler bear the burden of assigning precise addresses to them.
  988.  
  989. Some of the symbols the assembler uses are self-defining, things like numeric 
  990. constants, and the rest tend to be labels which can either be explicitly 
  991. defined with a directive to the assembler, or can appear as the first field 
  992. of a statement in which case they are assigned the address at which the code 
  993. generated by that statement will lie in memory. This address is called the 
  994. location of the code, the assembler keeps track of it by an internal variable 
  995. called the location counter, and there is a special symbol, the $ sign, which 
  996. the assembler interprets every time it encounters it as the value of the 
  997. location counter at the point of encounter. Thus the statements:-
  998.  
  999. LABLAB     JP LABLAB
  1000.     JP $
  1001.  
  1002. have the same effect when assembled.
  1003.  
  1004. 6.3    HOW DOES IT DO IT?
  1005.  
  1006. When the assembler reads through your program for the first time, and it 
  1007. encounters a label used as an argument in a statement, then if the label has 
  1008. been previously defined to the assembler the address or value associated with 
  1009. it can be incorporated in the instruction, but if the label is something like 
  1010. a jump address further down in the program then the poor old assembler is 
  1011. stuck for a value. The solution to this problem is that the assembler always 
  1012. assembles your program twice (makes what the refined refer to as a second pass 
  1013. over over the program). The first pass pretends to generate code, but really 
  1014. only generates a table (The Symbol Table) which at its conclusion contains 
  1015. a defined value for every label. The second pass can then reference the Symbol 
  1016. Table to substitute valid values for symbols and generate executable (object) 
  1017. code, fancy listings and error messages. Whilst we are talking about the Symbol 
  1018. Table let us slip in a few definitions. A label which is encountered as an 
  1019. argument before it is defined is called a forward reference, a label which 
  1020. is defined more than once in a program is called a duplicate definition, and a 
  1021. label which is referenced but never defined within the program is called 
  1022. an unsatisfied reference unless you have found some way to define it into 
  1023. the Symbol Table ( e.g. Immediate statements or use of force pass 2 
  1024. option) externally in which case it is called, surprisingly enough, an external 
  1025. reference.
  1026.  
  1027. 6.4    OPTIONS
  1028.  
  1029. When you use the A command to tell the Command Interpreter to invoke 
  1030. the Assembler you specify a file which is to be assembled, and also an OPTIONS 
  1031. field, which tells the Assembler how it is to work. Some of the options are 
  1032. pretty obvious. You can elect to generate an assembly listing...very important 
  1033. when debugging your program. You can elect to have the listing and any error 
  1034. messages directed to printer, with 64 characters per line if you want. 
  1035. You can suppress the generation of object code...............
  1036. ..useful in the first stages of checking a program and in other circumstances
  1037. too.
  1038. Then you can select some less obvious options. They are concerned with the 
  1039. linking together of seperate programs into a functioning whole. Normally 
  1040. when you initiate an assembly you zero out the Symbol Table, but you can elect 
  1041. to preserve it if you wish. Why? To allow your program to use external 
  1042. references defined in it. You can also elect that the assembler will proceed 
  1043. immediately to pass 2, which from our discussion earlier should be disasterous 
  1044. Why? Because when coupled with the Symbol Table preservation option this allows 
  1045. us to assemble together many seperate programs with cross-references into a 
  1046. functioning whole.
  1047. If you look in Appendix 3 at the A command it summarises the options available 
  1048. and the numbers which represent them. The options field is just the sum of the 
  1049. numbers for the options you want . So if a listing on printer, normal pitch, 
  1050. but with no object code is your desire the options field becomes 64+2+1  or, 
  1051. if your mental arithmetic is good and your patience weak, you can write 67 
  1052. directly
  1053.  
  1054. 6.5    OFFSETS
  1055.  
  1056. There is a variable called OFFSET, whose location you will find in 
  1057. Appendix 4, which has a special significance for both assembly and loading 
  1058. from cassette. The value of this variable is normally zero, and it is used 
  1059. as a relocation offset by the Assembler.
  1060. The way it works is this:-   Normally when you code a program you expect 
  1061. it to be assembled at the location you have specified with an ORG staement 
  1062. so that it will execute at that location. We say that in that case the 
  1063. EXECUTION LOCATION COUNTER and the LOAD LOCATION COUNTER are synchronous. 
  1064. But what happens if you are writing a program which will not be executed 
  1065. after assembly, but will instead be written out to an EPROM programmer to 
  1066. generate an EPROM which is supposed to execute starting at location zero. 
  1067. You have to write an ORG 0 statement at the start of the program so that the 
  1068. program is internally consistent, but if you just left it at that the assembler 
  1069. would try to generate the object code on top of the ASZMIC Rom. This would do 
  1070. no harm but your object code would be lost. You need some way to tell ASZMIC 
  1071. that it must place the object code somewhere else.
  1072. The OFFSET variable is the technique you use to achieve this. When ASZMIC is 
  1073. writing out object code it adds the contents of the OFFSET variable to the 
  1074. execution address to generate a load address at which each object byte is 
  1075. to be situated. If, before an assembly, you set OFFSET to :7000 then 
  1076. code which is supposed to execute starting at location 0 will in fact be loaded 
  1077. into memory starting at address :7000.
  1078. Remember to reset OFFSET to 0 when you are finished. ASZMIC 
  1079. will not do it automatically for you and you will have a fine old time 
  1080. wondering where your next assembly has vanished to.
  1081.  
  1082. 6.6    ASSEMBLING
  1083.  
  1084. You invoke the assembler by typing in A followed by the name of the file 
  1085. you wish to assemble and, unless you want to take the default of object code, 
  1086. no listing, error messages on screen, and new symbol table, an options 
  1087. field to control the assembly.
  1088.  
  1089. You must obviously have first written the program you wish to assemble, using 
  1090. the Editor or loading in a previously written file from cassette. Make sure 
  1091. that the file containing the program obeys ASZMIC conventions i.e. that it 
  1092. starts with a filename whose first character is a filemark, and that it is 
  1093. terminated by a filemark as the first character of the line after the final 
  1094. program line. Within the file the program lines, assembly statements, are 
  1095. written according to the conventions used by ZILOG and MOSTEK, the 
  1096. manufactures of Z80 chips (the only exception is the EQU directive). These 
  1097. conventions are, in brief, that the first character of the statement should 
  1098. be a blank unless you wish to specify a label at that point, and that any label 
  1099. be terminated by = or blank. There then follows an op-code or directive 
  1100. which must be terminated by at least one blank. If the op-code or directive 
  1101. needs it there then come one or two arguments. If there are two arguments 
  1102. they must be seperated by a comma without any preceding or following blanks. 
  1103. The final field (argument, op-code or directive) that you write may be 
  1104. terminated by a /NL/, a blank or a ; (semicolon). If a semicolon is found 
  1105. then any characters after it on the line are treated as comments.
  1106.  
  1107. If the first character of a statement is a semicolon then the whole statement 
  1108. is treated as a comment. If a label starting in column 1 of the statement is 
  1109. terminated by an = (equals) sign then the assembler assumes you are using 
  1110. an EQU directive to define the label, and searches for an argument after 
  1111. the = sign (you can have intervening blanks if you want) which is evaluated 
  1112. and assigned to the label.
  1113.  
  1114. Please note that the Assembler exits by using an RST 0 instruction instead 
  1115. of a RET, so that you can use the O command to see the end of the 
  1116. region for object code in the IX and IY registers.
  1117.  
  1118. 6.6.1    DIRECTIVES
  1119.  
  1120. The ASZMIC assembler has two genuine directives, ORG and =, which do not 
  1121. generate executable code, and three pseudo-directives, DEFB, DEFW, and DEFM 
  1122. which do not generate EXECUTABLE code but produce object code which is a 
  1123. representation of the data values expressed in the argument after the directive 
  1124. itself. We touched on = in the last paragraph; so we will look 
  1125. at ORG now. ORG causes the following argument to be evaluated and transferred 
  1126. to the execution location counter (the IX register). You can use it at program 
  1127. start to define where the program expects to be executing (and where object 
  1128. code will be located if you have left OFFSET at 0) and in the middle of a 
  1129. program to generate space. A cunning use of ORG in mid-program is a 
  1130. statement of the type:-
  1131.  
  1132.     ORG $+20
  1133.  
  1134. which will reserve 20 bytes of empty space in mid-program for use as a buffer 
  1135. or whatever. ZILOG use a DEFS directive for this purpose which we did not 
  1136. implement in ASZMIC because it was redundant. You cannot use forward references 
  1137. in ORG or = directives (there are ways round this but please phone your 
  1138. friendly local university computer department to find out about them 
  1139. rather than us).
  1140.  
  1141. DEFB will quite simply generate one byte of object code with the value, modulo 
  1142. 256, of the argument in it. DEFW will generate 2 bytes but with the least 
  1143. significant byte first in the way the Z80 expects so that:-
  1144.  
  1145.  DEFW :1234
  1146.  
  1147. will produce what looks like  :3412 in memory.
  1148. DEFM searches for a " (quote) sign and then transforms every character 
  1149. after it to a byte in memory according to the Sinclair values assigned to each 
  1150. character, until it finds another " which tells it to stop. This means that 
  1151. you cannot have " signs in a DEFM argument. Do not try coding two together 
  1152. to get round this, it just does not work.
  1153.  
  1154. 6.6.2    OP-CODES and ARGUMENTS
  1155.  
  1156. Op-codes are the mnemonic representation of Z80 operations. You can read about 
  1157. them in the Z80 assembly manual of your choice, and remind yourself 
  1158. about what they are and what they do by browsing thru appendix 5. Arguments 
  1159. are expressed in the standard ASZMIC form which you have been using already. 
  1160. They are defined for you in the "FIELDS" paragraph of Appendix 1.
  1161. The only argument you will encounter which you do not use generally 
  1162. throughout ASZMIC is the $ (dollar) symbol, which represents the value of 
  1163. the execution location counter at the start of the statement in which the $ 
  1164. occurs. This has been a short paragraph for a large topic because this is 
  1165. the information which you will hopefully have gleaned from your book on Z80 
  1166. Assembly Programming.
  1167.  
  1168.  
  1169. 6.6.3    COMMENTS
  1170.  
  1171. Comments are always said to be a VERY GOOD THING in a program of any sort, 
  1172. and are particularly desirable in assembler programs because the code tends 
  1173. to obscure function by detail ( the Devil's Data Dictionary claims that by 
  1174. the time the average professional programmer has reached the twelvth line 
  1175. of a program he has completely forgotten what the first six did). We follow ZILOG 
  1176. conventions by allowing you to terminate a statement with a semicolon 
  1177. and then fill up the rest of the line with commentary. Unfortunately the 
  1178. screen can only have 36 characters on a line (32 for the printer) so that by the 
  1179. time you have allowed 16 positions for location and code in an assembly listing 
  1180. you are liable to lose long arguments from the program statement, never mind 
  1181. comments tagged onto the end. They are still useful in the source code (sorry, 
  1182. source code is the name for the programs you input to the Assembler). Option 
  1183. bit 5 will remove the truncation effect, and also set the printer in fine 
  1184. pitch mode to give you up to 64 characters per line.
  1185.  
  1186. The assembly listing consists of four distinct fields. The first is the 
  1187. single byte error flag which is placed in  column 1. The second is the 
  1188. four hexadecimal digit location at which the code generated from each 
  1189. statement will lie (i.e. the value of the Execution Location Counter at the start of each statement); the third is a hexadecimal representation of the 
  1190. one to four bytes of code which each statement can generate (note that DEFM 
  1191. can generate up to 5 bytes before truncation); the fourth is as much of the original 
  1192. statement as the Assembler can fit into a 32 character line.
  1193.  
  1194. The listing, or error messages if a listing is not selected by the OPTIONS 
  1195. field, will be routed to printer instead of to screen if bit 1 of the 
  1196. OPTIONS byte is set.
  1197.  
  1198. 6.10 LIBRARIES
  1199.  
  1200. If you are just beginning with assembly programming you can ignore this 
  1201. section and the next one. They describe slightly exotic functions which you 
  1202. probably will not want to use for a while. A library is a piece of object 
  1203. code which contains frequently used routines accessible to many different 
  1204. and independent programs. If you write a program which needs such a routine 
  1205. you could always load in the source code from cassette (or microdrive when 
  1206. they become available), merge it into your program and then assemble the 
  1207. whole, but after a while you tend to find this a cumbersome and unecessary 
  1208. procedure. How much more pleasant to load in your collection of useful object 
  1209. code routines once (things like input and output routines, drivers for special 
  1210. peripherals, multiplication and division routines and the like) and have 
  1211. them available for all comers when required. Such a collection of routines 
  1212. is called a library (no prizes for guessing why) and is characterised by the 
  1213. fact that the routines within it are internally self sufficient1 and do not 
  1214. need to reference any external program. A library contains definitions, but 
  1215. no external references.
  1216.  
  1217. How would you use such a set of routines with ASZMIC? To begin with you would 
  1218. assemble the library modules (module=constituent program) and save both the object 
  1219. code (the library itself), AND THE SYMBOL TABLE WHICH ITS ASSEMBLY HAD 
  1220. GENERATED. When you needed to assemble a program which referenced (used) some 
  1221. routine in the library you would first load in the Symbol Table as 
  1222. described earlier, and then perform an assembly with bit 2 ("4") of the 
  1223. OPTIONS field set. This would mean that your program would start off 
  1224. with a Symbol Table which defined the addresses of all the names in the 
  1225. library programs, and references made to them would not be flagged as errors. 
  1226. Of course when you came to execute the program you would have to be sure 
  1227. that you had remembered to load the library into memory otherwise the result 
  1228. would be disaster.
  1229.  
  1230. 6.11 CROSS REFERENCING
  1231.  
  1232. The next stage in your development as a jejeune assembler prorammer is to 
  1233. write programmes so large that you do not have enough memory to assemble 
  1234. them as a single entity, or to cooperate with friends or colleagues 
  1235. to write separate sections of the same programme. In this case you are 
  1236. faced with a situation rather different from that we met with libraries, 
  1237. because each separately coded and assembled section contains not only 
  1238. definitions which other sections can use, but references to the other sections 
  1239. as well. How do you handle a situation like this? It is probably simplest 
  1240. to postulate an example with three separately coded but mutually (sic) 
  1241. dependent programmes; PROGA, PROGB and PROGC. PROGA is coded and as its 
  1242. final statement has    ENDA=$. PROGB starts with an  ORG ENDA
  1243. and terminates with an  ENDB=$. PROGC starts with an  ORG ENDB statement.
  1244.  
  1245. If you then assemble PROGA with an OPTIONS byte which includes bit 6 
  1246. (no object code) and then assemble both PROGB and PROGC with an OPTIONS byte 
  1247. which includes a setting of both bits 6 and 2 ( see Appendix 3) then you 
  1248. will have built up a symbol table which includes label definitions from all 
  1249. all three programs. You then assemble all three programs again, but this 
  1250. time using an options field which includes both bits 7 and 2, and you will 
  1251. have at the conclusion a single piece of object code which is internally 
  1252. self consistent, always assuming that you have not made any errors.
  1253. What you did was to suppress object code the first time you assembled the 
  1254. three programs in sequence so that at the end you were left with a Symbol 
  1255. Table which contained all the symbol definitions for all 3 programs, plus a 
  1256. bunch of error messages which, providing they refer only to unsatisfied cross 
  1257. references, are irrelevant. Because PROGB and PROGC were assembled 
  1258. selecting the symbol table preservation option the definitions ENDA and ENDB 
  1259. were available in the Symbol Table at the time the ORG statements were assembled 
  1260. so that the programs are automatically assembled to lie together in memory. The 
  1261. second time we assembled each program we used a preserve Symbol Table option 
  1262. so that all the definitions were available but, since the purpose of the 
  1263. first pass of any assembly is just to build up the Symbol Table and we had done 
  1264. that already, we also used a bit 7 (Force Pass 2) option to prevent the 
  1265. creation of a lot of duplicate definitions.
  1266.  
  1267. 6.12 VALETE
  1268.  
  1269. That pretty much covers all we wanted to say about the Assembler. The next 
  1270. chapter tells you how to debug your assembled object code. It is a very good 
  1271. idea to save your object code on cassette before you try to execute it for the 
  1272. first time, since mistakes can wipe out the system, and if you want to use 
  1273. program labels in your DEBUG commands you might also save the Symbol 
  1274. Table. Remember that ASZMIC comes back in EDIT mode after an assembly and, 
  1275. please, always start each program with an ORG directive.
  1276.  
  1277.     PROGRAM EXECUTION AND TEST    Chapter 7
  1278.  
  1279. When you have written and assembled a program you naturally want to execute 
  1280. it. ASZMIC gives you two major commands for program execution and one for single 
  1281. stepping thru a program (we are discounting possibilities such as referencing 
  1282. the program in an immediate statement using CALL or JP). We shall start 
  1283. by looking at the DEBUG statements available for program testing.
  1284.  
  1285. 7.1    THE J COMMAND
  1286.  
  1287. This is your primary command for program test. It can be specified with an 
  1288. address field, in which case the first instruction executed is at the address 
  1289. specified, or by itself, in which case the address stored
  1290. in PCl when last a Break condition occurred will be used as a transfer address. 
  1291. The J command is characterised by the fact that all the registers are loaded up 
  1292. from the register image area (REGIM) before execution, and that the I register 
  1293. is set to 1 to facilitate non-maskable interrupt (NMI) handling and Break 
  1294. conditions. If your program does not perform register initialisation then you 
  1295. can initialise the register image area using I or D commands.
  1296.  
  1297. This is all straightforward, but _if you J to your program and it contains a 
  1298. fault, then your chances of getting back to ASZMIC to find out what happened 
  1299. are slim unless you have an NMI interrupt button fitted to break you out of 
  1300. unforeseen loops. Your first line of defence against the self-immolating 
  1301. program is the breakpoint.
  1302.  
  1303. 7.2    BREAKPOINT
  1304.  
  1305. A breakpoint is an RST 0 code. It can be inserted via the B command, in 
  1306. which case ASZMIC will handle the restoration of the original byte and 
  1307. manipulate the saved Program pointer value so that you can continue with 
  1308. the instruction when you wish, or you can insert it yourself by the D 
  1309. command or by placing it in the original code in which case you must perform 
  1310. any skipping or replacement needed yourself. The conventional way to use a 
  1311. breakpoint is to divide your program into logical sections, and then use 
  1312. the B command to place a breakpoint at the end of the first section. When you 
  1313. execute the program and come to the breakpoint you can check using the DEBUG 
  1314. D and O commands that everything has gone as you wish, and then move the breakpoint 
  1315. to the end of the next section and use the J command to execute the second 
  1316. section. The process is repeated until you identify a section which fails. Very 
  1317. often the mere identification of the part of the program which is failing will 
  1318. concentrate your mind most wondreously and enable you to isolate and correct 
  1319. the mistake. Remember that the RST 0 code is removed, and the original byte 
  1320. replaced, when the breakpoint is encountered; so if you want to break again 
  1321. at that point use the 3 commands G  B  J to get you thru the breakpoint, 
  1322. restore it, and restart execution. If you have a breakpoint active
  1323.  and load in another program on top of the one in which you had the breakpoint 
  1324. then subsequent moving of the Breakpoint will restore the byte from the old 
  1325. program into the new. Remember that you cannot single step through
  1326. a breakpoint without single stepping into the breakpoint handler.
  1327.  
  1328. 7.3    THE G COMMAND
  1329.  
  1330. When you have isolated the section of a program which is failing you can then 
  1331. examine its functioning in detail using the G command. This is the ASZMIC 
  1332. single step feature. It has the effect of the J command but with an automatic 
  1333. Break condition occurring after each instruction. Break conditions always 
  1334. cause context saving in the REGIM area. If you want to step thru a number of 
  1335. instructions before coming back to ASZMIC you can specify a step count as a 
  1336. second field in the G command. In that case you have to specify the first 
  1337. field, the address to GO to, explicitly even if it is the stored Program 
  1338. Counter value.
  1339.  
  1340.  
  1341. The use of a step count with the G command can be extremely useful. Remember 
  1342. that although you do not return to ASZMIC until the step count is exhausted 
  1343. there is a break with context save and restoration after every instruction 
  1344. so that execution is very much slower than it would be normally. Since the 
  1345. single step feature works by using the ZX8l NMI coupled timer to simulate 
  1346. a breakpoint, the breakpoint and single step breaks are handled by the same 
  1347. code, and this gives you the facility to simulate a Rom breakpoint. If you 
  1348. have a home cooked Eprom with routines starting at :2000, and you want a 
  1349. breakpoint at :2122, then you use a B :2122-1 command and execute the Eprom 
  1350. routine with a G :2000 32767 command. ASZMIC will then single step through 
  1351. the Eprom code until it has executed the instruction before that at :2122, 
  1352. and then it will think that it has encountered a breakpoint and stop 
  1353. the single stepping.
  1354.  
  1355. The G command uses the ZX8l NMI interrupt timer in a special way, and is 
  1356. thus not fully compatible with routines which drive the display since they 
  1357. require an I register with 14 in it and an enabled maskable interrupt. 
  1358. A little ingenuity with breakpoints and single stepping over non critical 
  1359. sections will probably see you through problems like that.
  1360.  
  1361. 7.4    THE O COMMAND
  1362.  
  1363. This command, which displays the saved registers from the REGIM context 
  1364. save area, really comes into its own when you are program testing. The 
  1365. registers are displayed as 2 lines in the order:-
  1366.  
  1367. PC    HL    HL'    BC'    DE'    AF'
  1368. AF    BC    DE    IX    IY    SP
  1369.  
  1370. The ' (prime) registers are the Z80 alternate registers. PC is the 
  1371. Program Counter which tells you which instruction you are next due to execute. 
  1372. SP is the Stack Pointer and the rest are the standard register pairs. We 
  1373. are sorry that we could not print up headers above the dumped registers, but 
  1374. it takes as much ROM space as a printer interface to do that and it burns up 
  1375. the text area twice as quickly, so we felt that it was better to ask you to 
  1376. refer to the documentation.
  1377.  
  1378. The O command is usefully placed as a Shift Macro when you are debugging 
  1379. a program (i.e. hit Shift T and type O on the top line). Every Break 
  1380. condition, be it breakpoint or single step, then gives you an automatic 
  1381. register dump. If you have important variables in your program which you 
  1382. also want to dump out each breakpoint you can concatenate commands on 
  1383. the Shift Macro line, using ;/ (semicolon slash) as a delimiter between 
  1384. each command and starting the command immediately after the /. This facility 
  1385. is really meant for dump commands but most Debug commands WILL work there; 
  1386. but do not use an I command since it will then chase its own tail for 
  1387. eternity (purists call this a reiterative loop).
  1388.  
  1389. 7.5    THE I COMMAND
  1390.  
  1391. We are told that some CP/M debugs have the equivalent of the I command in 
  1392. them, which proves that it is such a good idea that many people will 
  1393. discover it independently, not that we ripped off the notion from CP/M. 
  1394. The I command enables you to write a line of assembler which is then 
  1395. immediately assembled and executed for you. Before execution the registers 
  1396. are loaded up using an internal form of the J command, and after the 
  1397. assembled instruction is executed a breakpoint is forced 
  1398. to save the context again, so that the I commands execute in the context 
  1399. of your program. Providing you still have the original assembly Symbol Table 
  1400. intact you can specify labels from your program in I commands, just as in 
  1401. other Debug commands. The only snag is that an I command will change the 
  1402. stored PC value, so remember to J or G to a specific address if you have 
  1403. used I before them or you will start executing the ASZMIC stack. Use of I 
  1404. is a good way to rectify some unimportant omissions in a program and continue 
  1405. with mainstream testing.
  1406.  
  1407. The I command is normally used for priming registers, but any executable 
  1408. command can be given. If you do not leave a space between the I and the start 
  1409. of the assembler statement then you will be presumed to have started the 
  1410. statement with a label which you are declaring via the = directive. The 
  1411. only snag is that the label declaration logic in ASZMIC uses /NL/ 
  1412. as a delimiter so that the I is taken to be part of the label. You can declare 
  1413. any label you like so long as it starts with I. Henry Ford would approve.
  1414.  
  1415. 7.6    THE D, F & C COMMANDS
  1416.  
  1417. These commands are fairly straightforward in their operation, and we really 
  1418. only mention them to preserve an illusion of completeness. Dump, and Modify, 
  1419. are the kernel commands of any debug system. Fill is valuable for initialising 
  1420. buffer or workspace areas to an initial value. C, whilst having its primary 
  1421. use in the relocation of code assembled or loaded using OFFSET, can often be 
  1422. useful to reinitialise complex data arrays from a 'spare' copy in memory when 
  1423. you want to return to an earlier stage in a program for re-testing without 
  1424. the trouble of reloading the program. F and C are excellent ways of wiping 
  1425. out the system, so check for typing errors before hitting /NL/.
  1426.  
  1427. 7.7    VALETE
  1428.  
  1429. Debugging a program, even more than writing one, is a black art in which luck, 
  1430. logic and intuition are inextricably blended. Logic and intuition you must 
  1431. supply for yourself, but we wish you all the luck in the world.
  1432.  
  1433.     GRAPHICS & SPECIAL OPS    Chapter 8
  1434.  
  1435.  
  1436. Aszmic offers high resolution graphics facilities. The display driver in 
  1437. the Basic Rom uses a fixed number of rasters (lines) for every character 
  1438. which it displays. This severely limits the graphics possibilities 
  1439. available with Basic unless you install special hardware. ASZMIC has a 
  1440. programmable driver which allows you to set the parameters which control 
  1441. display yourself, and has also substituted for the Sinclair graphics 
  1442. characters a special set which are independent of the hardware offsetting 
  1443. based on raster count. The effect is that from a machine language 
  1444. program you can plot on a 255 x 144 matrix, maintain a continuous display 
  1445. (ZX81 only), and still have time to do computation for movement effects. 
  1446. We suspect that although ASZMIC was really designed as a development 
  1447. station for assembly language programs, and to a lesser extent as a 
  1448. teaching tool, many people may use it just because it is the cheapest 
  1449. way to give yourself a convincing 'Dungeons & Dragons' scenario on 
  1450. the ZX computers.
  1451.  
  1452. 8.1    THE ASYNCHRONOUS DRIVER
  1453.  
  1454. In the Application notes this program is identified as the KERNEL routine. 
  1455. Its function is to create a blank display file, display it 50 times a second, 
  1456. handle syncs & keyboard read, and hand over control to the user program when 
  1457. it is not busy. From a user point of view all his program has to do is 
  1458. manipulate the display file contents; the KERNEL takes care of all the rest. 
  1459. If you are using a ZX80 you cannot use the KERNEL but must instead 
  1460. build up your display, send it out using OFRM1, and handle 
  1461. timing and frame sync yourself. If you have a ZX81 and use KERNEL then your 
  1462. program can act as if the mechanism of display was invisible to it. Do not 
  1463. take KERNEL as sacrosanct; we wrote it quickly (as did we all the graphics 
  1464. examples) just to show thw possibilities. You can probably do better yourself 
  1465. You might start by tuning NNN and IDLE (rasters at bottom of frame and sync 
  1466. pulse length tuning respectively) so that they suit your television.
  1467.  
  1468. 8.2    PLOT
  1469.  
  1470. The PLOT routine in the Application notes is fed by a subroutine CALL with 
  1471. the B register containing the X coordinate and the C register containing 
  1472. the V coordinate relative to screen bottom left. It computes the byte in the 
  1473. display that contains the point, decodes what is in the byte and inserts 
  1474. the new point, and then encodes the byte back again. UNPLOT does the same but 
  1475. deletes the relevant point instead. It does not check for point out of range; 
  1476. that you can put in yourself. It uses a shift and subtract algorithm to 
  1477. compute line address, and a little bit of fiddling with the high order bit 
  1478. in the desired byte to convert to and from the four points (pixels) which 
  1479. each byte can contain.
  1480.  
  1481. 8.3    LINE
  1482.  
  1483. There is another subroutine given which will use PLOT to generate a line 
  1484. beteen two specified points. If the line is between XY & X'Y' then D=y, E=X, 
  1485. B=Y' & C=X' when the subroutine is called. It uses a successive incrementing 
  1486. algorithm to calculate the points needed with the increment maximised to 
  1487. avoid redundent plotting. It works in theory, and in practice too, but other 
  1488. algorithms can give lines which are subjectively more pleasing; particularly 
  1489. when the line subtends only a small angle to one of the axes. A 'dotted line' 
  1490. algorithm in particular can often look much neater since one tends to join 
  1491. up the dots mentally with a much higher resolution than the screen can 
  1492. achieve; but we hesitated to provide any 'psychological' subroutines. They 
  1493. seemed to be straying too far from our path of self-imposed utilitarianism. 
  1494. ULINE deletes a line between the two specified points.
  1495.  
  1496. 8.4    UPROG's
  1497.  
  1498. This is the unlovely name we give to the application programs which create 
  1499. requests for points and lines which PLOT & LINE generate, and KERNEL 
  1500. displays. We offer two examples. STRUCTURES will generate diamond 
  1501. patterns using plot which can look like futuristic space cages. MOIRE will 
  1502. just write tightly packed lines to give a watered silk (who wears watered 
  1503. silk nowadays?) effect. We suggest that you get down and write your own UPROG 
  1504. to get the feel of the graphics. One useful technique that you can use is to 
  1505. achieve translation of images on the screen by use of LDIR instructions. A 
  1506. move of less than 37 bytes will translate on the X axis, and a multiple of 36 
  1507. will give V translation. This is a much easier way of moving composite 
  1508. images than painstakingly deleting and re-drawing them. You CAN also mix text 
  1509. and graphics by starting the text on a raster ('V') which is a multiple of 8 
  1510. from screen top and writing it 8 times on sucessive lines (V's). Remember 
  1511. that if you put a byte with bit 6 set to 1 in the display then the 
  1512. Sinclair hardware will try to execute it as an instruction, with results 
  1513. varying from minimal to a full blooded system crash
  1514.  
  1515. 8.6    OTHER RESOLUTIONS
  1516.  
  1517. You can alter the vertical resolution of each pixel by altering PIXSIZE in 
  1518. the KERNEL, and the total number of vertical pixels by changing RASTERS, and 
  1519. the number of blank lines at screen top by changing TOPS. If the product 
  1520. of PIXSIZE and RASTERS is summed with TOPS and NNN, and the result is around 
  1521. 300, then you will still probably have a synchronised display. Cheap portable 
  1522. T.V's seem most tolerant of liberties taken with display timing, and costly 
  1523. colour sets the least. We have to be a bit general about this since there 
  1524. are over ten billion display type alternatives. Choose one by muttering to 
  1525. yourself
  1526.  
  1527. "TOPS changes blank space at screen top"
  1528. "NNN controls my compute time per frame"
  1529. "RASTERS controls the number of active lines in the display"
  1530. "PIXSIZE sets the vertical size of each pixel"
  1531.  
  1532. and looking at your application. We do not frankly see anyone wanting to 
  1533. use a PIXSIZE larger than 2. Remember to change CLEAR and DISPEND if you 
  1534. change the display file size or position.
  1535.  
  1536. 8.7    SPECIAL OPERATIONS
  1537.  
  1538. When ASZMIC initialises at startup, it tests location :1000 at the end of 
  1539. initialisation to see if there is a JP instruction there, and if so does a 
  1540. CALL :1000. This means that you can add your own ROM onto a system with 
  1541. ASZMIC and cause it to integrate itself into ASZMIC. You have seen already 
  1542. how DADDR can be used to intercept coommand handling, PRTJMP to link in your 
  1543. own printer routine and INTJMP to take over break conditions after context 
  1544. save (that is what KERNEL does). There is one final reflection that we have 
  1545. not previously mentioned. KEYJMP normally contains the address KEYRET. If 
  1546. you put the address of your own handler there it can take over key 
  1547. interpretation (BC contains the undecoded result from KEYBRD) and then either 
  1548. jump back to keyret or RET to LIX if you have done all the work yourself.
  1549.  
  1550. The address SAVMEM can be used as a jump point if you ever want to reset ASZMIC whilst still retaining data in high memory, or to initialise it for a 
  1551. >16K memory. The HL register is loaded up with the address which is to be taken as the top of memory and then a JP made to SAVMEM. This 
  1552. roughly corresponds to a Basic "NEW" with RAMTOP altered
  1553.  
  1554. When you are debugging programmes it can be quite useful to have an external 
  1555. non-maskable interrupt button. The J command supports this by loading up the 
  1556. I register with 1 so that a single NMI pulse gives the effect of a breakpoint. 
  1557. You should, of course, use a Schmitt debounced monostable to provide this 
  1558. but we got pretty good mileage out of a 300 pF capacitor wielded on ZX80, 
  1559. where in the absence of a G command you really need NMI. Failure to debounce 
  1560. correctly may cause the screen to assume an "heiroglyphic" appearence but the 
  1561. first key pressed cures this. On ZX80 bad debouncing can also fool ASZMIC 
  1562. into thinking that it is living in a ZX8l; easily cured by providing a further 
  1563. 270 NMI pulses so perhaps you had better build a proper circuit instead.
  1564.  
  1565. 8.8    THE END
  1566.  
  1567. We would like to apologise for a slight flippancy which seems to have 
  1568. manifested itself in places in this documentation. We have felt increasingly 
  1569. frustrated by our inability to do any more than sketch out the bare bones 
  1570. of ASZMIC usage unless we issue a 3 volume set in a year or two: and 
  1571. this manifests itself as a seeming lack of seriousness. There is just so 
  1572. much which you can do with ASZMIC. We hope that you find it stimulating 
  1573. and useful. In the future there will probably be quite a lot of supporting 
  1574. hardware and software developed for it, and we are scheduled to work on a 
  1575. microdrive version, so with luck it will prove a long term extension to the 
  1576. capabilities of your ZX80/81.
  1577.  
  1578.             C FRAZER JOHNSON
  1579.             Nykoeping    Sept. 1982
  1580.  
  1581.     GENERAL INFORMATION    APPENDIX 1
  1582.  
  1583.  
  1584.  
  1585. INITIALISATION
  1586.  
  1587. After turning on a ZX80/81 equipped with ZX.ASZMIC memory has been divided 
  1588. into 3 partitions  The first consists of system variables, buffers, stack 
  1589. and register image area (REGIM). The second, which lies between DSPBGN and 
  1590. (TXTLIM), is the text area. The third is the program and data area which lies 
  1591. between (TXTLIM) and the top of memory. This area is sized to one quarter of 
  1592. the available memory on the system. The pointers LABEND and LABSTK both point 
  1593. to the top of memory. These pointers define the Symbol Table, and assembler 
  1594. operations will cause (LABEND) to be the address of the current bottom of the 
  1595. Symbol Table. (LABSTK) is always the top of available memory. The IY 
  1596. register is loaded with :4000, the I register with 14, and the interrupt mode 
  1597. set to 1.
  1598.  
  1599.  If any key is held depressed for more than half a second it will 
  1600. repeat at a rate of around 8 per second until released.
  1601.  
  1602. The screen contains 34 lines of up to 36 characters each. The ZX81 hardware 
  1603. automatically generates a new line for longer lines but since the EDIT display 
  1604. logic works by counting /NL/ characters this is a facility which should be 
  1605. used sparingly.
  1606.  
  1607. EDIT & DEBUG Modes
  1608.  
  1609. ASZMIC has 2 modes: EDIT mode, identified by a fast blinking cursor, and 
  1610. DEBUG mode, identified by a slower blink rate. The difference between them 
  1611. is that in DEBUG mode the typing of a /NL/ (newline) causes the line just 
  1612. terminated to be passed to the Command Interpreter. If the first letter of 
  1613. this line lies in the range A-P then some action will be taken, since the 
  1614. line is then assumed to be a command. It is otherwise ignored.
  1615.  
  1616. Keystrokes which do not pass control to the Command Interpreter use a 
  1617. vertical synchronisation clock which does its best to hold the screen steady 
  1618. whilst the keystroke is processed. The Command Interpreter disables the 
  1619. clock for the duration of its operations. The overall effect is that scrolling 
  1620. and cursor operations generate a slight flicker but still maintain a readable 
  1621. display. This feature is not available on ZX80.
  1622.  
  1623. FIELDS
  1624.  
  1625. The Assembler and Command Interpreter both use a subroutine called GETFLD, 
  1626. which is a general purpose field interpreter. The fields which are valid as 
  1627. arguments are:-
  1628.  
  1629. a) A decimal number containing the characters 0-9 (1 to 5 digits)
  1630.  
  1631. b) A hexadecimal number identified by a : (colon) prefix and containing the 
  1632.    characters 0-9 A-F (1 to 4 digits)
  1633.  
  1634. c) A $ sign, meaning the current contents of the IX register (used as a 
  1635.    location counter by the Assembler).
  1636.  
  1637. d) One or two characters enclosed in quotation marks (").
  1638.  
  1639.    Items a) thru d) are self defining fields
  1640.  
  1641. e) A Symbol. This is a character string consisting of 3 or more characters in 
  1642.    the range A-Z 0-9 . (period) and starting with a character in the range A-Z. 
  1643.    A symbol is only meaningful when it has been defined by appearance in the 
  1644.    label field of an assembled statement (via A or I commands). If a symbol 
  1645.    is preceded by a ? (question mark) WHEN REFERENCED AS AN ARGUMENT then the 
  1646.    rules for minimum number of characters and alphabetic start character are 
  1647.    relaxed. The ? is purely to identify the following string as a symbol, 
  1648.    and is not a part of the symbol itself.
  1649.  
  1650. f) Any combination of items a) thru f) seperated by + or - characters.
  1651.    + causes subfield addition, - causes subfield subtraction. Parentheses
  1652.    are not used. ( A left parenthesis will cause BFLAG to be set non 
  1653.    zero).
  1654.  
  1655. Fields are terminated by a blank or comma , but not both.
  1656.  
  1657. Examples:-
  1658.  
  1659. "A*"
  1660. 12345
  1661. :12345
  1662. FUDGE
  1663. ACCOUNTS.PAYABLE
  1664. $
  1665. 12345+"A*"+:12345-FUDGE+$-?HL+ACCOUNTS.PAYABLE
  1666.  
  1667.  
  1668. FILES
  1669.  
  1670. A file is a portion of the text area which is identified by a filename 
  1671. at its start and a filemark (o) as the first character of its terminating line. 
  1672. The filename should have a filemark (o) as its first character and can contain 
  1673. the characters A-Z 0-9 . (period).
  1674.  
  1675. Example
  1676.  
  1677. NOTHING
  1678. RUBBISH
  1679. FILEl
  1680. THIS IS AN
  1681. EXAMPLE OF
  1682. A FILE
  1683. 
  1684. MORE RUBBISH
  1685.  
  1686. The file FILE1 is defined as the 3 lines
  1687.  
  1688. THIS IS AN
  1689. EXAMPLE OF
  1690. A FILE
  1691.  
  1692. and may be used by commands such as A (not recommended in this case) P, K & E. 
  1693. The user can define as many files as he wishes, providing each filename is 
  1694. unique.
  1695.  
  1696. PARTITIONS
  1697.  
  1698. The user can create more file or program space for himself by manipulating 
  1699. the TXTLIM pointer which defines the boundary between text and program areas.
  1700.  Use Dump & Modify or Immediate statements. The symbol table may be relocated 
  1701. by altering LABEND (low memory bottom of Symbol Table) & LABSTK (high memory 
  1702. table top) pointers, and moving the content of memory between them if the table 
  1703. was not empty.
  1704.  
  1705. If a non standard memory unit is attached to the ZX80/8l then the ways in 
  1706. which memory can be divided up will depend on the decoding which the unit 
  1707. provides. Bear in mind that execution of a program over the 32K boundary can 
  1708. activate the ZX80/81 display logic hardware, which also relies on duplicate 
  1709. mapping of the 16-32K & 48-64K regions for its effect.
  1710.  
  1711. USE OF ASZMIC ROUTINES
  1712.  
  1713. Internal subroutines exist in ASZMIC to aid the user in handling I/O 
  1714. and various encoding and decoding functions. These must normally be used from 
  1715. an ASZMIC context (System variables internally consistent, IY=:4000, I=14, IM 1, 
  1716. 22 bytes of stack available). Routines include:-
  1717.  
  1718. GETFLD    decode a field
  1719. PUTDE    encode a hex number
  1720. WRITA    encode a single hex byte
  1721. WSTRNG    write contents of print buffer to screen
  1722. NRM2    write a character to screen
  1723. OUTFRM    write out a frame to screen
  1724. KEYBRD    do basic keyboard decode
  1725. KEYINT    translate decode to a character
  1726. RDCASS    read a character from cassette
  1727. WRCASS    write a character to cassette
  1728. PRNTER    write a line to printer
  1729.  
  1730. & many others. See the application notes for definitions ,calling sequences 
  1731. and examples.
  1732.  
  1733. ASSEMBLER
  1734.  
  1735. The Assembler is a small, very fast subprogram within ASZMIC which will accept 
  1736. all standard ZILOG mnemonics for assembler statements. The DEFM,DEFW,DEFB & ORG 
  1737. directives are supported. The EQU directive is supported in a nonstandard form 
  1738. Instead of LABEL EQU value    use LABEL=value   without imbedded blanks. 
  1739. The DEFS value directive is not supported: use ORG $+value instead, which has 
  1740. the same effect of reserving (value) bytes of free space. There are no 
  1741. conditional compilation, listing control or macro directives (hence the SET 
  1742. directive is not implemented).
  1743.  
  1744. A comments field may be appended after every assembler statement if preceded 
  1745. by a ; (semicolon). A ; in column 1 makes the whole line commentary.
  1746.  
  1747. Always start each file to be assembled with an ORG directive. ASZMIC will 
  1748. probably default you at (TXTLIM) but this is not a design feature and may be 
  1749. withdrawn.
  1750.  
  1751. ORG & EQU directives may not use forward references.
  1752.  
  1753. Assembler options (see A command in appendix 3) can be used to control object 
  1754. code generation and routing of listings.
  1755.  
  1756. Errors tested for include label errors (undefined and doubly defined), Op-Code & 
  1757. relative jump range errors. An error is indicated by a non blank column 1 
  1758. and error lines are listed even if no list option has been specified.
  1759.  
  1760. Use of the Symbol Table preservation option, combined with the "force pass 2" 
  1761. flag, enables many seperate programs with cross references to be assembled 
  1762. seperately to generate a single piece of internally consistent object code. 
  1763. The OFFSET variable can be used to generate an offset between load and 
  1764. execution counters which enables code to be loaded at one location for subsequent 
  1765. movement to and execution at another.
  1766.  
  1767.     THE SHIFT KEYS    APPENDIX 2
  1768.  
  1769.  
  1770.  
  1771.  
  1772. These are the keys which control the editing and macro functions of ZX.ASZMIC.
  1773.  
  1774.  
  1775. Shift 0 ..... TYPING RUBOUT
  1776.  
  1777.  The cursor is moved 1 position to the left, the character under it is deleted 
  1778.  and all subsequent characters to the right are shifted left 1 place. 
  1779. Positioning the cursor to the start of a line and then using
  1780.  Shift 0 will delete the preceding /NL/ to concatenate the two lines.
  1781.  
  1782. Shift 9 ..... HOME TO DEBUG MODE
  1783.  
  1784.  Set ASZMIC in DEBUG mode. Remember the current cursor position for use 
  1785.  by the Shift E keyin. Move the cursor to the bottom line of the bottom page 
  1786.  and move the display file pointers so that this line appears on screen. The 
  1787.  DEBUG mode flag automatically causes the cursor to assume a slow blink.
  1788.  
  1789. Shift 8 ..... CURSOR RIGHT
  1790.  
  1791.  Move the cursor I character to the right but never onto a /NL/ character.
  1792.  
  1793. Shift 7 ..... CURSOR UP
  1794.  
  1795.  Position the cursor at the left of the line above its current position. If 
  1796.  necessary scroll down the display so that the cursor remains on screen. 
  1797.  Do not move cursor onto or past an End-of-Data character.
  1798.  
  1799. Shift 6 ..... CURSOR DOWN
  1800.  
  1801.  Like CURSOR UP, but cursor moves down & scrolling is upwards.
  1802.  
  1803. Shift 5 ..... CURSOR LEFT
  1804.  
  1805.  Move cursor 1 character to left, but never onto a /NL/ character.
  1806.  
  1807. Shift 4 ..... PAGE FLIP UP
  1808.  
  1809.  Move the display start up 27 lines. Position the cursor at the left of the 
  1810.  third line down from the new top of screen. Do not move display onto or over 
  1811.  an End-of-Data character.
  1812.  
  1813. Shift 3 ..... PAGE FLIP DOWN
  1814.  
  1815.  As for PAGE FLIP UP, but the display is moved down 27 lines. If you move 
  1816.  to the final page then the cursor is positioned at the bottom line.
  1817.  
  1818. Shift 2 ..... DELETE FILE
  1819.  
  1820.  All text from the current cursor position right to the first filemark () 
  1821.  detected is deleted. No action if a terminating filemark not detected. If 
  1822.  the deletion moves the current cursor position onto the final display page 
  1823.  then the cursor is homed onto the bottom line.
  1824.  
  1825. Shift 1 ..... DELETE LINE
  1826.  
  1827.  Delete the line which currently contains the cursor. Position cursor at 
  1828.  start of next line. Do nothing if the cursor is currently on the bottom 
  1829.  line of the final page
  1830.  
  1831. Shift T ..... GO TO DISPLAY TOP
  1832.  
  1833.  Move the cursor to the Shift Macro definition line at the top of the display. 
  1834.  Display page is altered accordingly.
  1835.  
  1836. Shift R ..... SHIFT MACRO EXECUTION
  1837.  
  1838.  Independent of the current ASZMIC mode (EDIT/DEBUG) pass the contents of 
  1839.  the Shift Macro line to the Command Interpreter for execution. Cursor 
  1840.  and display page are unchanged unless as a result of the executed DEBUG 
  1841.  commands. If the line is empty no action results.
  1842.  
  1843. Shift E ..... EDIT RETURN
  1844.  
  1845.  Change the ASZMIC mode to EDIT. Position the cursor at the location it 
  1846.  had when HOME (shift 9) was last pressed. Alter display page if required to 
  1847.  keep cursor on screen. Effect unpredictable if editing has taken place whilst 
  1848.  in DEBUG mode. Fast blinking cursor identifies EDIT mode.
  1849.  
  1850. Shift W ..... RIGHT JUSTIFY CURSOR
  1851.  
  1852.  Move the cursor to the rightmost position of the current line.
  1853.         (note:- There is no corresponding left justification key. Use CURSOR 
  1854.         UP followed by CURSOR DOWN instead)
  1855.  
  1856. Shift Q ..... EDIT RUBOUT
  1857.  
  1858.  Like TYPING RUBOUT, but the cursor is not shifted left and it is the 
  1859.  character at the current cursor position which is deleted. It is not 
  1860.  possible to delete the last character on a line with a edit rubout i.e. one which 
  1861.  lies beteeen 2 /NL/ characters.
  1862.  
  1863. Shift G ..... MERGE
  1864.  
  1865.  Search down from beginning of display file to find a merge character (>). 
  1866.  Copy all text after it up to but not including a filemark (o) into the text 
  1867.  position identified by the current cursor position. Effect disastrous if 
  1868.  merge and filemark characters missing. In DEBUG mode if a /NL/ is copied then 
  1869.  the line it terminates is passed to the command interpreter, thus making the 
  1870.  copied text into a Command Macro. In DEBUG mode Shift G has the same effect 
  1871. as a M> command (see M in Appendix 3). 
  1872. UNSUPPORTED FEATURE:-  The Shift D & Shift F keys may be implemented on 
  1873. your system. They are like Shift G but with start character * and < 
  1874. respectively.
  1875.  
  1876.  
  1877.  
  1878.  
  1879.  Input of a normal character causes everything under & to the right of 
  1880.  the cursor to be shifted right one place and the character input is placed 
  1881.  under the cursor. The cursor is then moved one position to the right. The 
  1882.  EOD pointer is incremented.
  1883.  
  1884.  Input of a /NL/ character will cause a trailing blank to be appended 
  1885.  to the line if the previous character was non-blank. The cursor is advanced 
  1886.  past the /NL/ to the start of the next line. The display page is moved down 
  1887.  one line (i.e. text is scrolled up a line). The EOD pointer is incremented 
  1888.  as required.
  1889.  
  1890.  If input of a character would cause the EOD pointer to be incremented past 
  1891.  the (TXTLIM) text area upper partition then the character is ignored.
  1892.  
  1893.     DEBUG COMMANDS    APPENDIX 3
  1894.  
  1895.  
  1896.  
  1897.  
  1898.  
  1899. Whenever a /NL/ character is written to the text area by ASZMIC when in 
  1900. DEBUG mode the line just terminated is passed to the Command Interpreter, 
  1901. which identifies the command by the first letter on the line and calls the 
  1902. appropriate handler subroutine. A first character not in the range A-P is 
  1903. ignored.
  1904. Several DEBUG commands may be concatenated on a single line by using the 
  1905. seperator character sequence ;/ (semicolon slash) and commencing the next 
  1906. command immediately after the slash e.g.
  1907. D 0 3;/D 5 3;/D :7000 10 
  1908. The contents of the Shift Macro line are also passed to the Command Interpreter 
  1909. when a Shift R key is typed, and this line is also executed whenever a 
  1910. BREAK condition is encountered (Breakpoint,RST 0,Single Step,External NMI ).
  1911.  
  1912.  
  1913. A ..... ASSEMBLE
  1914.         A filename options
  1915.  
  1916. The named file is identified and assembled down to its terminating filemark 
  1917. () under the control of the option field. If no option field is specified 
  1918. the default is a 2 pass assembly with object code (executable machine code) 
  1919. generation but no assembly listing and no preservation of a previous symbol 
  1920. table.
  1921.  
  1922. The option field is converted to an 8-bit byte whose bits when set represent 
  1923. the following options :-
  1924.  
  1925.   BIT 7..(128).. force second pass
  1926.   BIT 6..( 64).. do not generate object code
  1927.   BIT 5..( 32).. Fine pitch mode on printer. No truncation of listing lines.
  1928.   BIT 2..(  4).. keep and add onto a previous Symbol Table
  1929.   BIT 1..(  2).. direct listing output to printer
  1930.   BIT 0..(  1).. generate assembly listing
  1931.  
  1932. Thus an option field to generate a listing on printer without object code 
  1933. would be :43 (decimal 67) or 64+2+1 (you can write it like that).
  1934.  
  1935. Assembler lines start with either a ; in column 1, in which case the line is 
  1936. treated as a comment; another non-blank character, in which case the 
  1937. character is assumed to be the first character of a symbol to be defined, 
  1938. or a blank. There then follows an Op-Code or assembly directive delimited by 
  1939. a blank, plus up to 2 argument fields seperated by a comma. A comment 
  1940. field can terminate the line if it is preceded by a ; (semicolon). The file 
  1941. is terminated by a line with a filemark (o) in column 1.
  1942.  
  1943. Example: -
  1944.  
  1945. EXAMPLE
  1946.  ORG :7000
  1947. NRM2=:492 ;CHECK VALUE FOR YOUR SYSTEM
  1948. START LD HL,$+120 ;ACTUALLY THE ADDRESS OF TABLE
  1949.  LD B,TABLEND-TABLE
  1950. LOOP LD A, (HL)
  1951.  PUSH HL
  1952.  PUSH BC
  1953.  CALL NRM2
  1954.  POP BC
  1955.  POP HL
  1956.  INC HL
  1957.  DJNZ LOOP
  1958. ; AND NOW EXIT TO ASZMIC
  1959.  RST 0
  1960. ;
  1961.  ORG :7000+120
  1962. TABLE DEFM "TEST"
  1963. TABLEND=$
  1964. 
  1965. A $EXAMPLE 
  1966.  
  1967. NOTE:- If the variable OFFSET is non-zero its value will be used to relocate 
  1968. the object code produced, although the code itself will be generated to 
  1969. execute at its ORG'd location.
  1970.  
  1971. B ..... BREAKPOINT
  1972.  
  1973.         B address
  1974.         B
  1975.  
  1976. If an address is specified then the current breakpoint is removed (saved 
  1977. byte substituted back at the current breakpoint address) and the address 
  1978. specified becomes the new breakpoint address. The byte at that address is 
  1979. saved and a RST 0 (:C7) code substituted. When the breakpoint is encountered 
  1980. in the course of program execution the saved byte is automatically restored 
  1981. ready for recommencement of execution. If the B command is given without an 
  1982. address then a RST 0 code is placed at the current breakpoint address.
  1983.  
  1984. C ..... COPY
  1985.  
  1986.         C from to bytecount
  1987.  
  1988. An intelligent copy operation of the specified number of bytes from the 
  1989. first address specified to the second. If the source and destination ranges 
  1990. overlap the copy will proceed so as not to corrupt the data in the destination 
  1991. range.
  1992.  
  1993. D ..... DUMP
  1994.  
  1995.         D address bytecount
  1996.         D address
  1997.  
  1998. In the first case a formatted dump of the specified number of bytes starting 
  1999. at the address specified is produced. There are 8 hexadecimal bytes to a line 
  2000. preceeded by a hexadecimal address. Long dumps may cause screen blanking for 
  2001. a few seconds whilst the dump is generated. Break key aborts a dump.
  2002.  
  2003. The second example is of a Dump & Modify mode. The contents of the address 
  2004. specified is displayed and ASZMIC waits for input. Successive bytes are placed 
  2005. in memory starting at the prompt address. Input is terminated by a . (period) 
  2006. after the prompt. This is the only case where hexadecimal fields do not have 
  2007. to be preceded by a : (colon). The colon is assumed, and decimal values must 
  2008. be input as 0+decimal field.
  2009. NOTE:- If bit 1 of ASSFLG has been set to route dump output to the printer 
  2010. then the user must precede input on each line by at least 7 blanks.
  2011.  
  2012. E .... EDIT
  2013.  
  2014.        E
  2015.        E symbol
  2016.  
  2017. If no argument is specified ASZMIC merely sets itself in EDIT mode (fast cursor 
  2018. blink). In addition, if a symbol is specified, the symbol is searched up for 
  2019. and the cursor placed at its start. The display page is altered if needed.
  2020. No action is taken if the string is not found. (Any character other than  . 
  2021. 0-9 A-Z will terminate the string comparison operation. o can be first char.)
  2022.  
  2023. F ..... FILL
  2024.         F from to fillerbyte
  2025.  
  2026. The specified range is filled with the filler byte.
  2027.  
  2028. G ..... GO      ***  ZX81 ONLY  ***
  2029.  
  2030.         G
  2031.         G address
  2032.         G address stepcount
  2033.  
  2034. This is ASZMIC's single step feature. If no arguments are specified 
  2035. then the context is restored from the register image area, and execution of 
  2036. the instruction at the saved Program Counter address (PC1) takes place. A 
  2037. single step break is generated at the end of the instruction, the new context 
  2038. is saved in the register image area, (if the INTJMP variable has been 
  2039. modified to contain an address other than INTRET a jump to (INTJMP) occurs 
  2040. at this point) and the Shift Macro line is executed before returning control 
  2041. to ASZMIC.
  2042.  
  2043. If an address is specified then it overwrites the saved Program Counter address 
  2044. (PC1) & becomes the address of the instruction to be executed.
  2045.  
  2046. If a stepcount is specified then the operation proceeds as above, but after 
  2047. context save and before Macro execution the saved step count is 
  2048. decremented &, if still positive, then context is restored & the next 
  2049. instruction executed. The rate of execution is typically a hundredth of 
  2050. normal, so a large stepcount may take some time to work thru. Maximum 
  2051. stepcount is :7FFF (decimal 32767). The G command will not work on ZX80.
  2052.  
  2053. NOTE:- The single step feature can be used to simulate a ROM breakpoint. Set 
  2054. the breakpoint for the desired address-I & use G address 32767. Break 
  2055. handling logic will then think it has reached a breakpoint; & terminate single 
  2056. stepping, when the stop address is reached.
  2057.  
  2058. H ..... HORRIBLE JUMP
  2059.         H address
  2060.  
  2061. This is not really so nasty. It is just a straightforward jump to the 
  2062. specified address in the context of the ASZMIC Command Interpreter. HL register 
  2063. points to the command line after the address, & the routine jumped to can do 
  2064. processing in the ASZMIC context, terminating with a simple RET. An easy way 
  2065. to link in your own commands.
  2066.  
  2067. I ..... IMMEDIATE
  2068.         I assembler line
  2069.  
  2070. An unusual feature which enables immediate assembly and execution of assembler 
  2071. statements. The assembler line follows immediately after the I (i.e. if a blank 
  2072. follows the I then no label has been specified). The line is assembled into 
  2073. object code in  low stack, followed by a break code, and then executed 
  2074. immediately using an internal form of the J command. It thus operates in the 
  2075. saved program context of the REGIM area. After execution the new context is 
  2076. saved just as for a normal BREAK.
  2077. Labels should only be defined via the Label=value statement form in immediate 
  2078. statements, & the directives ORG, DEFM, DEFB, DEFW & the JR and DJNZ 
  2079. instructions should be avoided.
  2080.  
  2081. J ..... JUMP
  2082.  
  2083.         J
  2084.         J address
  2085.  
  2086. This is just like the G command, except that there is no single step 
  2087. break in execution, which continues under the program logic unless the B 
  2088. command has been used to insert a breakpoint somewhere in the logic flow. 
  2089. The effect of a breakpoint, or an externally generated NMI interrupt, is 
  2090. similar to the single step interrupt.
  2091.  
  2092. K ..... CASSETTE SAVE
  2093.  
  2094.         KS "i.d." ofilename
  2095.         KS "i.d." from to 
  2096.         KS "i.d." from to  L
  2097.  
  2098. ASZMIC uses the same recording protocol as the standard ZX80/81, but the way 
  2099. in which it is used is rather different. ASZMIC can save either files or 
  2100. regions of memory (which presumably contain programs or data). When you type 
  2101. a K command there is a S second wait to allow you to turn on your recorder, 
  2102. then the command line itself is written out to tape to identify the file, a 
  2103. further S second pause ensues, and the file or memory region is written out.
  2104.  
  2105. The command must start with the 5 character sequence  K  FILEMARK  S  SPACE 
  2106. QUOTE as shown above since this is used to identify a title line to the 
  2107. cassette load routine.
  2108. The string enclosed in quotes identifies the file for the load routine, just 
  2109. like a standard ZX80/81. The filename or memory region to be saved is then 
  2110. indicated. If the memory range is followed by space L then the load command 
  2111. will alter LABEND to contain the "from" value when the region is loaded.
  2112.  
  2113. L ..... LOAD
  2114.  
  2115.         L "i.d."
  2116.  
  2117. In response to this command the cassette input is scanned continuously, and if 
  2118. a valid title line is found it is written to screen and the display activated
  2119. for 5 seconds, thus generating a running catalogue of the tape contents. If 
  2120. the "i.d."s of the Load Command and the saved title line match then the title 
  2121. line is analysed to determine if a file or memory load is required, and the 
  2122. following file is loaded. In the case of memory load the program/data is loaded 
  2123. in the region specified on the title line unless the variable OFFSET has 
  2124. been set to a non zero value, in which case this value is used as a 
  2125. relocation offset for the region. If the region range in the title line is 
  2126. followed by an L then the region will be presumed to be a Symbol Table, and 
  2127. LABEND will be modified to contain the "from" value. This presumes 
  2128. that save & load took place on the same size system.
  2129. Both K & L commands can be aborted by the Break key, which simulates a BREAK
  2130. condition.
  2131.  
  2132. M ..... MACRO
  2133.  
  2134.         M character
  2135.  
  2136. This is very like Shift G, but you can specify the start identifier yourself 
  2137. instead of using > as a default. Terminator is o as usual. Do not specify M 
  2138. by itself, always give a character after it and remember it is the 
  2139. first occurrence of the character (except for the Shift macro line) which 
  2140. defines macro start.
  2141.  
  2142. N ..... NEW
  2143.  
  2144.         N
  2145.  
  2146. Loads up BC with (TXTLIM). Sets HL to :3CA (Basic NEW command implementation) 
  2147. Jumps to (TXTLIM). Used for special board ops.
  2148.  
  2149. O ..... OLD REGISTERS
  2150.  
  2151.         O
  2152.  
  2153. The register image area is dumped as 2 lines of 6 four hexadecimal digit numbers 
  2154. The registers appear in the order:-
  2155.  
  2156. PC    HL    HL'    BC'    DE'    AF'
  2157. AF    BC    DE    IX    lY    SP
  2158.  
  2159. where PC is the Program Counter, SP the Stack Pointer, and the prime suffix (') 
  2160. indicates one of the alternate registers. We recommend that the user place an 
  2161. O command in the Shift Macro line as a useful default, since the registers will 
  2162. then be displayed whenever a BREAK condition occurs.
  2163.  
  2164. P ..... PRINT
  2165.  
  2166.         P filename
  2167.  
  2168. The named file is written out to printer until a terminating file mark is 
  2169. encountered as the first character of a line. The operation may be aborted 
  2170. at any time by pressing the Break key.
  2171. NOTE:- If PRTJMP variable is set to a value other than PRTRET then the 
  2172. address in it will be used as the address of the Print Line routine.
  2173.     SYMBOL ADDRESSES    APPENDIX 4
  2174.  
  2175.  
  2176. TO ENSURE THAT THE ASZMIC ROM CORRESPONDS TO THE VERSION DESCRIBED HERE; 
  2177. CHECK THE 2 BYTES AT MKDEF AGAINST THE DECLARED VARIABLE "VRSION" IN 
  2178. THE LIST. THEY SHOULD CORRESPOND; I.E VRSION E04 HAS MKDEF 04 0E .
  2179.  
  2180. ACOM2    0891    DCLPl    0881    EX3IR    0A3B    GHXVAL    0BDE
  2181. ACOMIN    08C4    DCOMM    057A    EX3IRX    0A42    GROUP0    095F
  2182. ACOMM    052D    DCOMX    057F    EXCFl    09A2    GROUPl    095F
  2183. AF1    40A6    DCONT    0895    EXCF2    09D0    GROUP2    097C
  2184. AF2    40A4    DEl    40AA    EXCF3    0A3l    GROUP3    0A49
  2185. ARG1    4001    DE2    40A2    EXTNAC    09CC    GROUP4    0A4D
  2186. ARG2    4003!    DECLOK    08A2    EXTNHL    0A27    GROUPS    0AAC
  2187. ASEXIT    086D    DEFMNT    0934    FCOMM    0602    GROUP6    0AB9
  2188. ASSFLG    4005    DELAYS    00DC    FILCHR    000C    GROUP7    0AD0
  2189. ASSMBL    0870    DFILE    4023    FLDFND    4076    GROUP8    0AE3
  2190. AUDUMP    0223    DFLIP    032E    FND2    0C83    GROUP9    0AF3
  2191. AXX    0547    DIGCON    0327    FNDLBL    0C72    GROUPA    0B03
  2192. BADDR    4007    DLLP1    00D6    FNDLCR    0028    GROUPB    0B30
  2193. BC1    40A8    DLLP5    00D4    FNDRCR    0030    GROUPC    0B3C
  2194. BC2    40A0    DLN1    03E0    FRAMES    4070    GROUPD    0B61
  2195. BCOMM    054C    DLOOP1    058E    FRMSND    00E5    GROUPE    0B68
  2196. BFLAG    4075    DLOOP2    0585    FRMSNX    00E8    GROUPF    0B71
  2197. BFLGST    0C2E    DLY05    00D2    GlCOMN    096E    HASH    08C7
  2198. BIGMEM    01A7    DMD2    05ED    G2IN2    0B88    HASHDN    08DC
  2199. BLONE    055E    DMDLP1    05DE    G2SBCN    0B76    HCOMM    0652
  2200. BOPSAV    4006    DMODIN    05CB    G2SUB    0008    HFLIP    0070
  2201. BRKCHK    030D    DMOUT    05B0    G34TAB    0AA2    HL1    409C
  2202. BRKOD    00C7    DMPMOD    05B3    G3G4    0A83    HL2    409E
  2203. CALLAS    0823    DMPREG    0733    G42ER    0A40    HLRIN    0CD0
  2204. CCC    0BC3    DOLLAR    0C1E    G4IN2    0A69    HLRTST    0CD7
  2205. CCOMM    0561    DONCHR    0C6E    G4IN3    0A76    HMCHK    03F9
  2206. CDLP1    0481    DONE    0CB9    G4IN4    0A79    HOME2    0434
  2207. CHRTAB    0D92    DOTTIM    0804    G4REG    0A57    HOME3    0448
  2208. CINCRT    0470    DPG1    03FE    G6INX    0ACE    HOMLP1    044A
  2209. CKINV    0C9F    DSPBGN    40B4    G6PA    0AC7    HRTIN1    0950
  2210. CLDIR    0577    DSPSET    019E    G8NIXY    0AFl    HRTLP    0953
  2211. CLNLP    0945    DSPTCH    0947    G92    0B00    HSHDN2    08FE
  2212. CLNUP    0941    ECOMM    05F0    GAHERE    0B18    HSHERR    0913
  2213. CLPRLD    0BE8    ECPOSN    401D    GANOBR    0B23    HSHLP1    08CB
  2214. CMDSUB    0295    EDCODE    0080    GARNDX    0B12    IAENT    061A
  2215. CMPSTR    02A3            GAUNC    0B1B    ICOMM    0655
  2216. CMPSTX    02B0    EDEXIT    05F7    GB01    0B3A    IGNBLK    0020
  2217. CMRTXi    0512    EDIN    0ACA    GBCOND    0B37    IMTAB    0AB6
  2218. CMSM1    02C3    EDINX    0AC9    GCENTX    022A    INHERE    0C9F
  2219. COMINC    0C23    EDLP1    0775    GCHERE    0B48    INICON    017E
  2220. COMINT    0507    EDLP2    0776    GCINX2    0978    INIT    017C
  2221. COMMND    052D    ELEM1    4072    GCNTSB    0250    INIT2    0189
  2222. COMRTX    0511    EOD    4021    GCOM2    0973    INIT3    0183
  2223. COMXTB    051D    EODCHR    0005    GCOMM    0615    INTJMP    4019
  2224. CONLIN    0023    EODOK    04B8    GCUNC    0B5D    INTRET    0lFC
  2225. CRCHAR    0076    EX102    09E1    GDLOOP    0B63    IX1    40AC
  2226.         EX103    0A11    GELOOP    0B69    IXIY    4074
  2227. CREN1    045B    EX104    09F6    GET2    0059    IYl    40AE
  2228. CRGEN1    0457    EX105    0A47    GETCHR    0226    JCOMM    0667
  2229. CRHNDL    0C24    EX107    0A81    GETFLD    0010    JGENT    0617
  2230. CSTR1    02B3    EX1213    09BB    GFCHAR    0C61    JMP2    063D
  2231. CTAB    0D04    EX1NN    09AC    GFDCLN    0BE1    JMPTYP    064D
  2232. CTAB2    0D4B    EX1NTA    09BE    GFDHEX    0ClA    JPTAB    0BCE
  2233. CUDRET    048D    EX2DBR    0A13    GFDLBL    0C89    KBD1    00F8
  2234. CUDRTX    0487    EX2IND    0A2A    GFDLBX    0C86    KBD2    00FA
  2235. CURSOR    401F    EX2NAF    09F9    GFDNUM    0C40    KCOMM    066B
  2236. DADDR    401B    EX2NAG    0A07    GFDREG    0CBD    KEYADD    027F
  2237. DBTLIM    0584    EX2NB    09E3    GFDTNM    0C38    KEYBRD    014
  2238. KEYINT    0277    NRMCHR    0491    RLOAD    0CE5    WRC1    0783
  2239. KEYINX    0275    NULIN2    04E6    RUBDNO    0380    WRC2    078B
  2240. KEYJMP    4017    NULINE    04D9    RUBOK    0378    WRCASS    0780
  2241. KEYRET    0254    NXTPLN    0818    SAVMEM    018D    WREG    073C
  2242. KYRDLP    014F    NXTSTP    087A    SAVSTR    001B    WREGL    0742
  2243. LABEND    4027    OCOMM    0733    SFILE    067E    WRITA    031E
  2244. LABSTK    4029    OFFSET    400B    SHFT0    0426    WSTR1    02F2
  2245. LBINX    08AC    OFRM1    016D    SHFT1    03BE    WSTRG2    02E2
  2246. LCOMM    0687    OFRM2    0171    SHFT2    03E2    WSTRLP    02DC
  2247. LDF2    0719    OUTFRM    0169    SHFT3    0408    WSTRNG    02D6
  2248. LDLP1    06C3    PARSE    0826    SHFT4    0412    Xl    0010
  2249. LDLP2    06D2    PC1    409A    SHFT5    0423
  2250. LDLP3    0703    PCHAR    07F8    SHFT6    0473    X2    0020
  2251. LDLPB    08A4    PCOMM    0752    SHFT7    04SF
  2252. LDN2    06BC    PDOT    0809    SHFT8    0456    X3    0030
  2253. LDN6    06BB    PDOTX    07F9    SHFT9    042D
  2254. LINEND    00C1    PRBUFF    402B    SHFTD    0339    ZXJPND    0507
  2255. LIX    022D            SHFTE    0398    ZXJPTB    04F5
  2256. LIX2    0236    PRCLR    0301    SHFTF    0330
  2257. LIXIMM    023B    PREADY    07D9    SHFTG    0341
  2258. LIXSUB    00AD    PRIGET    09245    SHFTQ    036C
  2259. LODFIL    0716    PRNTER    07CD    SHFTR    03B1
  2260. LOOPGF    0BF0    PROFF    081E    SHFTT    03B7
  2261.         PRTJMP    4015    SHFTW    0394
  2262. LSTEXP    406E    PRTRET    07D2    SHIFTS    0339
  2263. LX    4000    PSLP    0756    SHOME    03AE
  2264.         PTCON    00CB    SINGLE    0107
  2265. LY    4015    PUTA    0B9D    SINGLX    01F2
  2266.         PUTB    0B9C    SNLP1    0698
  2267. LZ    406E    PUTDE    0319    SNLP2    06A8
  2268.         PUTDEF    0316    SP1    4080
  2269. MCOMM    01724    PUTENT    0BAE    SRECUR    0679
  2270. MFLAG    4000    PUTNN    0B8E    SSCNT    4009
  2271. MIDWAY    0C70    PUTNNX    0B92    START    0000
  2272. MKDEF    0016    PUTOUT    0BBF    STENT    039F
  2273. MRGCHR    0017    QCOMM    0762    STKLOW    407A
  2274. MRGIN    0352    QUOTE    000B    STMEND    400F
  2275. MRGLP1    035B    RASCON    07E2    STRBOK    0773
  2276. MSKINT    004A    RASPRS    0043    STRCDB    0763
  2277. MSMTCH    02D0    RASTER    0705    STRSCH    0762
  2278. NCOMM    0728    RCOMM    0762    TABLE    0082
  2279. NEGEND    0CB0    RCOMP    0D99    TEMP    400D
  2280. NEGFLG    4077    RCOMPX    0DB0    TEMP2    406C
  2281. NEGNOT    OCAF    RDC1    07A2
  2282. NGENT    0CB4    RDC2    07A4    TIMING    0066
  2283. NGHNDL    0C33    RDC3    0782    TXTLIM    4025
  2284. NLBLF    0C45    RDC4    0784    UPDG1    0418
  2285. NLONP    0023    RDC5    07C5    UPDG2    0421
  2286. NOBRK1    0623    RDCASS    07A2    USAMOD    4011
  2287. NOBXRK    061E    RDCX    0780    V    0040
  2288. NOGCNT    061F    REG    4078
  2289. NOLIST    0859    REGCOD    4079
  2290. NORMSV    0690    REGIM    409A
  2291. NOTBRK    0215            VRSION    0E04
  2292. NOTHL    0CEA    REPEAT    406F    WCNORM    08F8
  2293. NOTIXY    096C    RESTOR    0628    WCRPT    08E1
  2294. NRM2    0492    RETNR    0C24    WCTAB    0DC7
  2295. NRM4    04A6    RLB    0B96    WCTABX    0DE4
  2296.  
  2297.     ASZMIC SUBROUTINES    Application Note  1
  2298.  
  2299.  
  2300. Appendix 4 contains a variable YRSION which de+ines the model 
  2301. number of ASZMIC which you are using. This is also stored as a DEFW at 
  2302. MKDEF in the Rom so you can check that the addresses given in App. 4 
  2303. are correct for the Rom you are using.
  2304.  
  2305.  
  2306. NAME ... BRKCHK
  2307.  
  2308. FUNCTION ... Check break key; simulate BREAK condition if pressed 
  2309.  
  2310. CALLING SEOUENCE ... CALL BRKCHK
  2311.  
  2312. EFFECT .... Also sets synch pulse level low
  2313.  
  2314. USES ... Abort routines
  2315.                 **********************
  2316.  
  2317.  
  2318. NAME ... CMPSTR
  2319.  
  2320. FUNCTION ... Compare two strings
  2321.  
  2322. CALLING SEOUENCE ... CALL CMPSTR  (HL) points to found string-1,(DE) to base string
  2323.  
  2324. EFFECT end comparison on encountering a /NL/ or any character < - (if the found 
  2325. string is not preceded by a character less than . (period) then the 
  2326. comparison is declared invalid. If the first character of the found (& base) 
  2327. strings is a filemark then a /NL/ must precede the o in the found string for 
  2328. the comparison to be accepted).
  2329. If strings are the same then carry reset, HL points at the beginning 
  2330. of the found string, DE points at the base string delimiter. If the strings are 
  2331. not identical carry is set and HL,DE unchanged.
  2332. REGISTERS USED ... A,HL,DE
  2333.  
  2334. USES ... String identification
  2335.                 **********************
  2336.  
  2337.  
  2338. NAME ... COMMANDS
  2339.  
  2340. FUNCTION ... 
  2341.  
  2342. CALLING SEOUENCE ... All commands have form *COMM, where * is DEBUG letter. 
  2343. HL points at first non-blank char after DEBUG letter. They exit by RET (to LIX).
  2344.  
  2345. EFFECT ... Performs actions appropriate to the Command.
  2346.  
  2347. USES ... 
  2348.                 **********************
  2349.  
  2350.  
  2351. NAME ... DFLIP
  2352.  
  2353. FUNCTION ... Set address jumped to for Command Interpretation
  2354.  
  2355. CALLING SEOUENCE . . . CALL DFLIP  HL contains new Command Int. address
  2356.  
  2357. EFFECT ... Loads HL into DADDR, takes old value and returns
  2358.            with it on stack. Uses HL.
  2359.  
  2360. USES ... User handling of newline character i.e. ASZMIC EDITOR used 
  2361.          as an input routine for user programs.
  2362.                 **********************
  2363.  
  2364.  
  2365. NAME ... DELAY5
  2366.  
  2367. FUNCTION ... Display for 5 seconds
  2368.  
  2369. CALLING SEQUENCE ... CALL DELAY5
  2370.  
  2371. EFFECT ... Send out a display for 5 seconds & return to caller. 
  2372.            FRAMES is loaded with 250 & FRMSND invoked. See FRMSND for details 
  2373.            of return. There is another delay called DLYO5 which sets sync 
  2374.            low and then loops for half a second before returning (uses A & DE).
  2375.  
  2376. USES ... 
  2377.                 **********************
  2378.  
  2379.  
  2380. NAME ... EDLP1
  2381.  
  2382. FUNCTION ... Entry point for STRSCH which expects DE to point
  2383.              to base string, HL to point to high end of search region 
  2384.              and BC to be search region size in bytes+1.
  2385.  
  2386. CALLING SEQUENCE ... CALL EDLP1   registers as above
  2387.  
  2388. EFFECT ... See STRSCH
  2389.  
  2390. USES ... Table search
  2391.                 **********************
  2392.  
  2393. NAME ... FNDLCR
  2394.  
  2395. FUNCTION ... find first newline char to left
  2396.  
  2397. CALLING SEQUENCE ... RST 40    HL points to text
  2398.  
  2399. EFFECT ... Positions HL to the left of the first newline found 
  2400.            left (below) its initial position. Uses A & HL.
  2401.  
  2402. USES ... Syntax analysis, text manipulation.
  2403.                 **********************
  2404.  
  2405.  
  2406. NAME ... FNDRCR
  2407.  
  2408. FUNCTION ... Find first newline char to right
  2409.  
  2410. CALLING SEQUENCE ... RST 48   HL points to current text position
  2411.  
  2412. EFFECT ... Positions KL to the right of the first newline char found 
  2413.            right (above) its initial position. Uses A & HL.
  2414.  
  2415. USES ... See FNDLCR
  2416.                 **********************
  2417.  
  2418.  
  2419. NAME ... FRMSND
  2420.  
  2421. FUNCTION ... Tramsmit a display file to screen until FRAMES
  2422.              (if positive) becomes zero or a key is pressed.
  2423.  
  2424. CALLING SEQUENCE ... CALL FRMSND     DFILE must contain address of a valid display file.
  2425.  
  2426. EFFECT ... Sends display file to screen; generates sync pulses;
  2427.            reads keyboard and performs debounce; blinks cursor; returns 
  2428.            with carry set if key pressed,reset if FRAMES timeout. 
  2429.            KEYBRD value lies in BC and STMEND, not HL.
  2430.  
  2431. USES ... Display
  2432.                 **********************
  2433.  
  2434.  
  2435. NAME ... GETFLD
  2436.  
  2437. FUNCTION ... Analyse a field down to a 16 bit value
  2438.  
  2439. CALLING SEQUENCE ... RST 16    HL points at or before field start
  2440.  
  2441. EFFECT ... HL advanced to field terminator; field converted to 2 bytes in 
  2442.            DE and ELEM1. Zero flag set on return if no field found. Any 
  2443.            argument recognisable to ASZMIC may be in the field. Uses all 
  2444.            registers except BC, IX, IY,I.
  2445.  
  2446. USES ... Myriad
  2447.                 **********************
  2448.  
  2449. NAME ... GET2
  2450.  
  2451. FUNCTION ... Analyse up to 2 fields
  2452.  
  2453. CALLING SEQUENCE ... CALL GET2   HL points at or before start of fields.
  2454.  
  2455. EFFECT ... Uses GETFLD. Loads ARG1 and BC with first field value, ARG2 
  2456.            and DE with second field value. Zero flag set on return if less than 
  2457.            2 fields found before ; or /NL/ terminator. HLpoints after last field 
  2458.            processed. I,IX,IY unaffected.
  2459.  
  2460. USES ... Syntax analysis
  2461.                 **********************
  2462.  
  2463.  
  2464. NAME ... IGNBLK
  2465.  
  2466. FUNCTION ... Advance HL register to point at a non-blank character
  2467.  
  2468. CALLING SEQUENCE ... RST 32   HL points at character string
  2469.  
  2470. EFFECT ... HL advanced until a non-zero byte pointed to. A contains (HL).
  2471.  
  2472. USES ... Syntax analysis
  2473.                 **********************
  2474.  
  2475.  
  2476. NAME ... KEYBRD
  2477.  
  2478. FUNCTION ... Scan keyboard matrix
  2479.  
  2480. CALLING SEQUENCE ... CALL KEYBRD
  2481.  
  2482. EFFECT ... Read the keyboard matrix into H (D5-D1 + shift as DO), 
  2483.            plus 8 address line bits in L. Both H & L = :FF if no key 
  2484.            pressed. Uses A,BC,DE,HL. HL also stored in STMEND. 
  2485.            See ZX81 construction leaflet for key-address/data line connection.
  2486.  
  2487. USES ... Read keyboard; Initiate vertical sync pulse.
  2488.                 **********************
  2489.  
  2490.  
  2491. NAME ... KEYINT
  2492.  
  2493. FUNCTION ... Decode a key stroke
  2494.  
  2495. CALLING SEQUENCE ... CALL KEYINT   BC contains HL pattern obtained from KEYBRD
  2496.  
  2497. EFFECT ... Both B & C must contain at least one zero bit if routine 
  2498.            is to return. Carry set on return if unallowed multiple key 
  2499.            depressions. Otherwise HL is absolute address of byte containing 
  2500.            the legal character and A is offset from TABLE start (HL=TABLE-1+(A)).
  2501.            Note that the shifted keys A-G,Q-t,1-0 do not return a valid char.
  2502.  
  2503. USES ... Keyboard read interpretation
  2504.                 ***********************
  2505.  
  2506.  
  2507. NAME ... LIX
  2508.  
  2509. FUNCTION ... Return point for all handlers in ASZMIC
  2510.  
  2511. CALLING SEQUENCE ... 
  2512.  
  2513. EFFECT ... 
  2514.  
  2515. USES ... 
  2516.                 **********************
  2517.  
  2518.  
  2519. NAME ... MSKINT
  2520.  
  2521. FUNCTION ... Setup some aspects of ASZMIC context
  2522.  
  2523. CALLING SEQUENCE ... CALL MSKINT
  2524.  
  2525. EFFECT ... Loads I=14,IY=:4OOO, resets bit 0 of MFLAG, sets interrupt 
  2526.           mode 1. Uses A register.
  2527.  
  2528. USES ... Programs entered by J command may need this if they use ASZMIC routines
  2529.                 **********************
  2530.  
  2531.  
  2532. NAME ... OUTFRM
  2533.  
  2534. FUNCTION ... Transmit a single frame to screen
  2535.  
  2536. CALLING SEQUENCE ... CALL OUTFRM    valid DFILE content required. B should 
  2537.                      contain the number of lines to be written and C should 
  2538.                      contain the number of blank rasters at screen top.
  2539.  
  2540. EFFECT ... Display a frame
  2541.  
  2542. USES ... Display
  2543.                 **********************
  2544.  
  2545. NAME ... OFRM1
  2546.  
  2547. FUNCTION ... Special purpose OUTFRM
  2548.  
  2549. CALLING SEQUENCE ... CALL OFRM1   like OUTFRM but in addition D 
  2550.                      register must be loaded with no of rasters per line.
  2551.  
  2552. EFFECT ... 
  2553.  
  2554. USES ... Graphics
  2555.                 **********************
  2556.  
  2557. NAME ... OFRM2
  2558.  
  2559. FUNCTION ... Specialised display
  2560.  
  2561. CALLING SEQUENCE ... CALL OFRM2    like OFRMI but in addition user is 
  2562.                      responsible for the OUT instruction to 
  2563.                      clear the vertical sync pulse and to load A with the 
  2564.                      number of Ml's before the first horizontal sync pulse 
  2565.                      is required.
  2566.  
  2567. EFFECT ... 
  2568.  
  2569. USES ... Sophisticated graphics
  2570.                 **********************
  2571.  
  2572. NAME ... PRCLR
  2573.  
  2574. FUNCTION ... Clear printer buffer to zeroes
  2575.  
  2576. CALLING SEQUENCE ... CALL PRCLR
  2577.  
  2578. EFFECT ... Blanks out PRBUFF. Uses HL,BC,DE.
  2579.  
  2580. USES ... User abuse of PRBUFF
  2581.                 **********************
  2582.  
  2583. NAME ... PRNTER
  2584.  
  2585. FUNCTION ... Print a line on Sinclair printer
  2586.  
  2587. CALLING SEQUENCE ... CALL PRNTER    HL points at start of line to be 
  2588.                      written. Line is written out to printer until a /NL/ 
  2589.                      is encountered. On return HL points to char after the 
  2590.                      terminating /NL/. Uses AF, BC,DE,HL.
  2591.  
  2592. EFFECT ... 
  2593.  
  2594. USES ... Printing
  2595.                 **********************
  2596.  
  2597. NAME ... PUTDE
  2598.  
  2599. FUNCTION ... Hexadecimal encode
  2600.  
  2601. CALLING SEQUENCE ... CALL PUTDE   HL points to output region, DE contains the 
  2602.                      number to be encoded into the region.
  2603.  
  2604. EFFECT ... Uses WRITA to encode the contents of the DE register 
  2605.            as four hexadecimal digits starting at (HL). HL is incremented
  2606.            past the last digit. PUTDEF is an entry point which presets HL to
  2607.            PRBUFF+1. Uses HL, A.
  2608.  
  2609. USES ... Output routines
  2610.                 **********************
  2611.  
  2612. NAME ... RDCASS
  2613.  
  2614. FUNCTION ... Read a byte from cassette recorder.
  2615.  
  2616. CALLING SEQUENCE ... CALL RDCASS
  2617.  
  2618. EFFECT ... Returns with a byte read from cassette in the A register. Can 
  2619.            be aborted by Break key. Uses A,HL,BC,DE.
  2620.            You have about 800 microseconds to process the byte before 
  2621.            RDCASS must be called again to catch the next byte.
  2622.  
  2623. USES ... Specialised tape analysis
  2624.                 **********************
  2625.  
  2626. NAME ... SHIFTS
  2627.  
  2628. FUNCTION ... 
  2629.  
  2630. CALLING SEQUENCE ... All Shift commands are c&lled by the sequence 
  2631.                      CALL SHFT* where * is the shifted character and must 
  2632.                      have HL=(CURSOR) on entry. They perform action approprate 
  2633.                      to the shift and then return to caller.
  2634.  
  2635. EFFECT ... 
  2636.  
  2637. USES ... 
  2638.                 **********************
  2639.  
  2640. NAME ... START
  2641.  
  2642. FUNCTION ... Breakpoint or , if 1=0, Restart
  2643.  
  2644. CALLING SEQUENCE ... RST 0
  2645.  
  2646. EFFECT ... Restart initialises ASZMIC. Breakpoint causes
  2647.            saving of context and return to ASZMIC
  2648.  
  2649. USES ... Monitor return
  2650.                 **********************
  2651.  
  2652. NAME ... STRSCH
  2653.  
  2654. FUNCTION ... String search
  2655.  
  2656. CALLING SEQUENCE ... CALL STRSCH    HL points at first char of base string
  2657.  
  2658. EFFECT ... If (HL)<DSPBGN+40 then HL first loaded from CURSOR (Shift 
  2659.            Macro use). Text area from (HL) to DSPBGN+50 searched to find 
  2660.            a destination string which matches the base string. Uses CMPSTR 
  2661.            so carry set if not found or set if found and HL & DE as for 
  2662.            CMPSTR except that if not found HL points at DSPGN+39. Uses
  2663.          AF,BC,DE,HL.  EDLPI is an entry point which expects DE to point to 
  2664.          base string, HL to point to high end of search region and BC to be 
  2665.          no of bytes to be searched+1.
  2666.  
  2667. USES ... Syntax analysis
  2668.                 *********************
  2669.  
  2670. NAME ... WRCASS
  2671.  
  2672. FUNCTION ... Write a byte to cassette recorder
  2673.  
  2674. CALLING SEQUENCE ... CALL WRCASS    HL points to byte to be written out.
  2675.  
  2676. EFFECT ... Byte written out using Sinclair BASIC standard. On return HL 
  2677.            has been incremented and A contains byte just written. Uses 
  2678.            AF, BC, DE, HL.
  2679.  
  2680. USES ... Special cassette operations
  2681.                 **********************
  2682.  
  2683. NAME ... WRITA
  2684.  
  2685. FUNCTION ... Encode a byte
  2686.  
  2687. CALLING SEQUENCE ... CALL WRITA    A contains number, HL points to encode region
  2688.  
  2689. EFFECT ... Number encoded as 2 hex digits. HL incremented past second
  2690.  
  2691. USES ... output
  2692.                 **********************
  2693.  
  2694. NAME ... WSTRNG
  2695.  
  2696. FUNCTION ... Write out PRBUFF to screen or printer
  2697.  
  2698. CALLING SEQUENCE ... Call WSTRNG    PRBUFF contains at least I non blank char.
  2699.  
  2700. EFFECT ... Presets B to length of PRBUFF. Fills PRBUFF backwards with
  2701.            /NL/'s until a non-blank char found. Drops thru to WSTRG2. Uses A,B,HL
  2702.  
  2703. USES ... Output
  2704.                 **********************
  2705.  
  2706. NAME ... WSTRG2
  2707.  
  2708. FUNCTION ... See WSTRNG
  2709.  
  2710. CALLING SEQUENCE ... CALL WSTRG2    B preset to max no chars to write
  2711.  
  2712. EFFECT ... If bit 1 of ASSFLG is set then PRNTER invoked followed by PRCLR 
  2713.            and return. Presets DE to PRBUFF. Drops thru to WSTR1.
  2714.  
  2715. USES ... 
  2716.                 **********************
  2717.  
  2718. NAME ... WSTR1
  2719.  
  2720. FUNCTION ... Write string to screen
  2721.  
  2722. CALLING SEQUENCE ... CALL WSTR1    DE points at string start. B preset to 
  2723.                      max no of chars to be written.
  2724.  
  2725. EFFECT ... Writes out from (DE) to screen, increments until B count
  2726.            exhausted or a /NL/ written. Drops thru to PRCLR. Uses all 
  2727.            registers except IX,IY,I.
  2728.  
  2729. USES ... Output
  2730.                 **********************
  2731.  
  2732.         EXAMPLES
  2733.  
  2734.  
  2735. Invoke by H command. Use = directives to declare the addresses of the
  2736. undefined symbols as defined in Appendix 4. USE AN ORG DIRECTIVE APPROPRIATE
  2737. TO YOUR SYSTEM MEMORY SIZE.
  2738.  
  2739. 1 Write a char to screen
  2740.  
  2741. START LD A,'X'
  2742.  CALL NRM2
  2743.  RET
  2744.  
  2745.  
  2746. 2 WRITE OUT A STRING TO SCREEN
  2747.  
  2748. START LD DE,STRING
  2749.  LD B,7
  2750.  CALL WSTRl
  2751.  RET
  2752. STRING DEFM "ABCDEFG"
  2753.  
  2754.  
  2755. 3 ADD 2 NUMBERS AND DISPLAY RESULT. CALL BY H START NOl NO2
  2756.  
  2757. START RST 16 ;GETFLD
  2758.  PUSH DE
  2759.  RST 16 ;GET 2ND NO
  2760.  POP HL
  2761.  ADD KL,DE
  2762.  EX DE,HL
  2763.  CALL PUTDEF
  2764.  LD (HL),:76
  2765.  CALL WSTRNG
  2766.  RET
  2767.  
  2768.  
  2769. 4 PALINDROME. INVOKE WITH H START. IMPORTANT BECAUSE IT SHOWS YOU HOW 
  2770.   TO LINK IN YOUR OWN PROGRAM AS A COMMAND INTERPRETER, AND HOW TO 
  2771.   RESTORE ASZMIC AT END. AFTER THE H START YOU TYPE IN THE LINE
  2772. TO BE INVERTED.
  2773.  
  2774. START LD HL,HANDLE; ADDRESS OF USER C.I.
  2775.  CALL DFLIP; SWAP CI ADDRESSES
  2776.  JP LIX ;JUMP TO ASZMIC  CONTEXT STILL ON STACK
  2777. ;
  2778. HANDLE RST 48; FNDRCR
  2779.  RST 40; FNDLCR
  2780.  SET 7, (IY) ; SET EDIT MODE
  2781.  LOOP LD A, (HL)
  2782.  PUSH HL
  2783.  PUSH AF
  2784.  CALL NRM2
  2785.  POP AF
  2786.  POP HL; CHAR WRITTEN
  2787.  DEC HL
  2788.  CP :76 ;DID WE WRITE A /NL/?
  2789.  JR NZ,LOOP; LOOP IF NOT
  2790.  POP AF ;CLEAR LIX RETURN ON STACK
  2791.  POP HL ;ASZMIC CI ADDRESS STORED BY DFLIP
  2792.  LD (DADDR),HL; RESTORE ASZMIC CI ADDRESS
  2793.  RES 7,(IY) ;ONLY IF YOU WANT TO RETURN IN DEBUG MODE
  2794.  RET
  2795.  
  2796.  
  2797. 5 PRINT NUMBERS FROM 0 TO 6.  USE H START
  2798.  
  2799. START XOR A
  2800.  LD HL,PRBUFF
  2801. LOOP LD B,A; SAVE A
  2802.  CALL WRITA
  2803.  LD A,B; RESTORE
  2804.  INC HL; SPACE
  2805.  INC A
  2806.  CP 7
  2807.  JR NZ,LOOP
  2808.  CALL WSTRNG
  2809.  RET
  2810.  
  2811.  
  2812. 6 PRINT A LINE
  2813.  
  2814. START LD HL,TEXT
  2815.  CALL PRNTER
  2816.  RET
  2817. TEXT DEFM "SAMPLE TEXT"
  2818.  DEFB :76; /NL/
  2819.  
  2820.  
  2821.  
  2822.  
  2823. 7 CREATE A BASIC PROGRAM WITH A SINGLE REM STATEMENT WHICH CONTAINS 
  2824.   MACHINE CODE WHICH YOU CAN WRITE YOURSELF .  SEE THE FINAL SECTION 
  2825.   IN CHAPTER 5 .
  2826.  
  2827.  
  2828.  ORG :4000
  2829.  DEFM "l2345678"
  2830.  DEFB "9"+128 ;FINAL TITLE CHAR INVERTED A LA ZX8l
  2831.  DEFB 0
  2832.  DEFW 1
  2833.  DEFW DFILE
  2834.  DEFW DFILE+1
  2835.  DEFW VARS
  2836.  DEFW 0
  2837.  DEFW VARS+1
  2838.  ORG $+9
  2839.  DEFW MEMBOT
  2840.  DEFW 512
  2841.  DEFW 0
  2842.  DEFW :FDBF
  2843.  DEFW :37FF
  2844.  DEFW DFILE
  2845.  ORG $+9
  2846.  DEFW -l
  2847.  DEFW 0
  2848.  DEFW :2l8C
  2849.  DEFW :4018
  2850.  ORG $+32
  2851.  DEFB :76
  2852. MEMBOT ORG $+32
  2853.  DEFW 256
  2854.  DEFW DFILE-PROG
  2855. PROG DEFB :EA ;REM
  2856. ;
  2857. ;
  2858. ;  PUT HERE THE CODE WHICH YOU WANT TO BE INCLUDED IN THE REM
  2859. ;
  2860. ;
  2861. DFILE=$+1
  2862.  DEFW :7676
  2863.  DEFW :7676
  2864.  DEFW :7676
  2865.  DEFW :7676
  2866.  DEFW :7676
  2867.  DEFW :7676
  2868.  DEFW :7676
  2869.  DEFW :7676
  2870.  DEFW :7676
  2871.  DEFW :7676
  2872.  DEFW :7676
  2873.  DEFW :7676
  2874.  DEFW :7676
  2875. VARS DEFB 128
  2876.  
  2877.  
  2878. 8  GRAPHICS PROGRAMS . .. ... SEE DESCRIPTION IN CHAPTER 8
  2879.   ENTER BY H :7000
  2880.  
  2881.  
  2882. ;DEFINITIONS FOR E04 ASZMIC     CHECK FOR YOUR VRSION
  2883.  ORG :7000
  2884. INTJMP=:4019
  2885. DFILE=:4023
  2886. PCONE=:409A
  2887. TXTLIM=:4025
  2888. FRAMES=:4070
  2889. OFRM1=:16D
  2890. MFLAG=:4000
  2891. RESTOR=:628
  2892. KEYBRD=:145
  2893. STMEND=:400F
  2894. SAVMEM=:18D
  2895. NNN=46
  2896. TOPS=1
  2897. PIXSI ZE=1
  2898. IDLE=30        1
  2899. RASTERS=255
  2900. DISPEND=:    6501
  2901. DSTART=:    4100
  2902. ;
  2903. ; KERNEL ROUTINE
  2904. ;
  2905. KERNEL LD HL,ONEP
  2906.   LD (INTJMP),HL ;INTERCEPT BREAK PROCESSING BY OWN HANDLER
  2907.   CALL CLEAR ;SETUP DISPLAY
  2908.   LD HL,UPROG
  2909.   LD (PCONE),HL ;PRIME CONTEXT SAVE TO RETURN TO UPROG
  2910. ;
  2911. ONEP CALL KEYBRD ;READ KEYBOARD (RAW)
  2912.   LD HL, (FRAMES)
  2913.   INC HL
  2914.   LD (FRAMES),HL ;BUMP FRAME COUNT
  2915.   LD B, IDLE
  2916.   DJNZ $ ;YOU JUST KEEP ME HANGIN' ON
  2917.   LD D,PIXSIZE
  2918.   LD B,RASTERS
  2919.   LD C, TOPS
  2920.   CALL OFRKl ;WRITE OUT A PART FRAME
  2921.   LD A,1
  2922.   LD (MFLAG),A ;LET NMI INTERRUPT HANDLER KNOW IT MUST BREAK ON 0 COUNT
  2923.   LD C,NNN+NNN+1 ;SETUP C FOR B COMMAND
  2924.   EXX
  2925.   JP RESTOR ;GO INTO MIDDLE OF B HANDLING
  2926. ;
  2927. ;SETUP DISPLAY FILE,,,,COULD BE IMPROVED
  2928. ;
  2929. CLEAR LD HL,DSTART
  2930.   LD DE,DSTART+2
  2931.   LD BC,:2400
  2932.   LD (HL),:76 ;/NL/
  2933.   LD (DFILE),HL
  2934.   INC HL
  2935.   LD (HL),0
  2936.   LDIR
  2937.   RET
  2938. ;
  2939. ; PLOT & UNPLOT SUBROUTINES     Y->B    X->C
  2940. ;
  2941. PLOT LD D,15
  2942.   JR $+4
  2943. UNPLOT LD D,0
  2944.   LD A,3 ;MASK FOR PIXEL NO IN BYTE
  2945.   AND C
  2946.   SRL C
  2947.   SRL C
  2948.   INC A ;C IS NOW X BYTE, NOT PIXEL
  2949.   LD E,l6 ;BIT MASK
  2950. LOOP1 SRL E
  2951.   DEC A
  2952.   JR NZ,LOOP1 ;LOOP UNTIL 0-3 CONVERTED TO 8,4,2,1 IN E
  2953.   CP D ;UNPLOT
  2954.   JR NZ,ENT2 ;J IF NOT
  2955.   LD A,E
  2956.   CPL
  2957.   LD D,A ;MASK OUT BYTE
  2958. ENT2 PUSH DE
  2959.   LD HL,DISPEND ;PREPARE TO COMPUTE Y ADDRESS
  2960.   LD DE,:l200
  2961.   LD A,B
  2962.   LD B,8
  2963. LOOP2 RLCA
  2964.   JR NC,NOSUBT
  2965.   OR A
  2966.   SBC HL,DE ;SUBTRACT ONLY IF BINARY POWER PRESENT IN Y VALUE
  2967. NOSUBT SRL D
  2968.   RR E ;SHIFT SUBTRACTOR
  2969.   DJNZ LOOP2
  2970.   ADD HL,BC ;ADD ON X TO GET TARGET BYTE
  2971. ; NOW PROCESS THE BYTE TO PUT IN THE PIXEL
  2972.   POP DE
  2973.   LD A, (HL)
  2974.   BIT 7,A ;GET ROUND INVERSE TRICKERY
  2975.   JR Z,$+3
  2976.   CPL ;CONVERT 7,2,l,0 TO 3,2,1,0
  2977.   AND 15
  2978. ;
  2979.   OR E
  2980.   AND D ;PIXEL NOW IN
  2981. ; REENCODE
  2982.   CP 8
  2983.   JR C,NOTINV ;DO NOT NEED INVERSION
  2984.   CPL
  2985.   AND :87
  2986. NOTINV LD (HL),A
  2987. ;
  2988. ;FOLLOWING CODE JUST CAUSES SUBROUTINE TO LOOP AROUND UNTIL
  2989. ;A FRAME HAS BEEN SENT. IT IS NOT ESSENTIAL BUT SLOWS PLOTTING
  2990. ;DOWN A BIT
  2991. ;
  2992. NLINE LD DE,FRAMES
  2993.  LD A, (DE)
  2994.   LD B,A
  2995. LOOPX LD A, (DE)
  2996.   CP B
  2997.   JR Z,LOOPX
  2998. ;END OF DELAY CODE
  2999.   RET
  3000. ;
  3001. ;LINE OR UNLINE FROM XY TO X'Y'
  3002. ;
  3003. ; X->E  Y->D  X'->C  Y'->B
  3004. ;
  3005. LINE LD A,15
  3006.   JR $+3
  3007. UNLINE XOR A
  3008.   LD (DORDEL),A ;MEMORY TO DETERMINE PLOT OR UNPLOT
  3009.  LD HL,XMID
  3010. ;INIT CELLS
  3011.   XOR A
  3012.   LD (HL),A
  3013.   INC HL
  3014.   LD (HL),E
  3015.   INC HL
  3016.   LD (HL),A
  3017.   INC HL
  3018.   LD (HL),D
  3019.   INC HL
  3020.   LD (HL),C
  3021.   INC HL
  3022.   LD (HL),B
  3023. ;
  3024. ;NOW CALCULATETHE INCREMENTS
  3025. ;
  3026.   LD L,C
  3027.   LD D,A
  3028.   LD H,A
  3029.   SBC HL,DE
  3030.   PUSH HL ;X'-X
  3031.   LD L,B
  3032.   LD H,A
  3033.   LD A, (YMID+l)
  3034.   LD E,A
  3035.   SBC HL,DE ;HL NOW Y'-Y
  3036.   POP DE
  3037. ;LEFT JUSTIFY INCREMENTS TILL ONE >= 128/256
  3038. JUSTIFY LD C,L
  3039.   LD A,H
  3040.   RLCA
  3041.   RL L
  3042.   ADC A,0
  3043.   EX AF,AF'
  3044.   LD B,E
  3045.   LD A,D
  3046.   RLCA
  3047.   RL E
  3048.   ADC A,0
  3049.   JR NZ,JSTDUN
  3050.   EX AF,AF'
  3051.   JR Z,JUSTIFY
  3052. JSTDUN LD E,B
  3053.   LD B,H
  3054. ;
  3055. ; DE IS XINC   BC IS YINC
  3056. ;
  3057. LLOOP LD HL, (XMID)
  3058.   ADD HL,DE ;INCREMENT
  3059.   LD (XMID),HL
  3060.   LD HL, (YMID)
  3061.   ADD HL,BC
  3062.   LD (YMID),HL
  3063.   EXX ;PRESERVE INCREMENTS
  3064. LPLOT LD A, (XKID+l)
  3065.   LD C,A ;X
  3066.   LD A, (YMID+1)
  3067.   LD B,A ;Y
  3068.   LD A, (DORDEL)
  3069.   LD D,A
  3070.   CALL UNPLOT+2  ;PLOT OR UNPLOT THE NEW POINT
  3071.   LD HL,XPRIM
  3072.   LD A,(XMID+l)
  3073.   CP (HL)
  3074.   INC HL
  3075.   EX AF,AF'
  3076.   LD A,(YMID+1)
  3077.   CP (HL)
  3078.   EXX
  3079.   JR NZ,NYLIM ;HAVE NOT REACHED Y LIMIT
  3080.   LD BC,0 ;ZERO YINC IF AT Y LIMIT
  3081. NYLIM EX AF,AF'
  3082.   JR NZ,NXLIM
  3083.   LD DE,0 ;ZERO XINC IF A X LIMIT
  3084. NXLIM  LD A,D ;USE XINC + YINC BOTH 0 AS END OF LINE TEST
  3085.   OR E
  3086.   OR B
  3087.   OR C
  3088.   JR NZ,LLOOP
  3089.   RET
  3090. ;
  3091. ;DATA REGION
  3092. ;
  3093. XMID DEFW 0 ;ORDER IS IMPORTANT
  3094. YMID DEFW 0
  3095. XPRIM DEFB 0
  3096. YPRIM DEFB 0
  3097. DORDEL DEFB 0
  3098. ;
  3099.  
  3100. **********************************************************
  3101.  
  3102. MOIRE
  3103.  
  3104. **********************************************************
  3105.  
  3106. UPROG LD SP,:7F00
  3107. MAINLOOP LD DE,:4078
  3108.  LD BC,:101
  3109. MLOOP PUSH DE
  3110.  PUSH BC
  3111.  CALL LINE
  3112.  POP BC
  3113.  POP DE
  3114.  INC D
  3115.  INC D
  3116.  INC B
  3117.  INC B
  3118.  INC B
  3119.  INC B
  3120.  LD A, 250
  3121.  CP B
  3122.  JR C,OUTCOD
  3123.  LD A, (STMEND)
  3124.  AND 1
  3125.  JR NZ,MLOOP
  3126. ; ZXCV PRESSED HERE
  3127.  LD HL,:8000 ;FIRST LOC OF UNAVAILABLE MEMORY
  3128.  JP SAVMEM
  3129. OUTCOD CALL CLEAR
  3130.  JP MAINLOOP
  3131.  
  3132.  
  3133.  
  3134. **********************************************************
  3135.  
  3136. STRUCTURES
  3137.  
  3138. ***********************************************************
  3139.  
  3140. UPROG LD SP,:7F00
  3141.  JR OUTCOD
  3142. MAINLOOP LD IX,XVAR
  3143.  CALL PROSUB
  3144.  LD IX,YVAR
  3145.  CALL PROSUB
  3146.  LD B,(IX+VAR)
  3147.  LD A, (XVAR)
  3148.  LD C,A
  3149.  CALL PLOT
  3150.  LD A, (STMEND)
  3151.  AND 1
  3152.  JR Z,OUTCOD
  3153.  JR MAINLOOP
  3154. ;
  3155. OUTCOD LD HL,DUMMY
  3156.  LD DE,XVAR
  3157.  LD BC, 12
  3158.  LDIR ;INIT VARIABLE REGION
  3159.  CALL CLEAR
  3160.  LD HL, (FRAMES)
  3161.  LD A, (HL)
  3162.  AND 15
  3163.  INC A
  3164.  LD (XVAR+1),A
  3165.  INC HL
  3166.  LD A, (HL)
  3167.  AND 7
  3168.  INC A
  3169.  LD (YVAR+1),A
  3170.  JR MAINLOOP
  3171. ;
  3172. PROSUB LD A,(IX+VAR)
  3173.  ADD A, (IX+DIR)
  3174.  LD (IX+VAR),A
  3175.  CP (IX+MAX)
  3176.  JR NC,OUTCOD
  3177.  CP (IX+LOW)
  3178.  JR NC,POSCHEK
  3179.  LD A,(IX+INC)
  3180.  CPL
  3181.  ADD A, (IX+LOW)
  3182.  LD (IX+LOW),A
  3183.  CALL DIDLIM
  3184. POSCHEK LD A, (IX+VAR)
  3185.  CP (IX+HIGH)
  3186.  RET C
  3187.  LD A, (IX+INC)
  3188.  ADD A, (IX+HIGH)
  3189.  LD (IX+HIGH),A
  3190. ;
  3191. DIDLIM LD A, (IX+DIR)
  3192.  NEG
  3193.  LD (IX+DIR),A
  3194.  LD A, (IX+INC)
  3195. ;
  3196.  DEC A
  3197.  JR NZ,$+3
  3198.  INC A
  3199. ;
  3200.  LD (IX+INC),A
  3201.  RET
  3202. ;
  3203. ; DATA
  3204. ;
  3205. VAR=0
  3206. INC=1
  3207. DIR=2
  3208. LOW=3
  3209. HIGH=4
  3210. MAX=5
  3211.  
  3212. XVAR ORG $+6
  3213. YVAR ORG $+6
  3214. DUMMY  DEFB 75
  3215.  DEFB B
  3216.  DEFB -1
  3217.  DEFB 70
  3218.  DEFB 90
  3219.  DEFB 135
  3220.  DEFB 110
  3221.  DEFB 12
  3222.  DEFB 1
  3223.  DEFB 90
  3224.  DEFB 130
  3225.  DEFB 240
  3226.  DEFB 0
  3227.  
  3228.  
  3229.  
  3230.  
  3231.