home *** CD-ROM | disk | FTP | other *** search
/ ftp.barnyard.co.uk / 2015.02.ftp.barnyard.co.uk.tar / ftp.barnyard.co.uk / cpm / walnut-creek-CDROM / ENTERPRS / C128 / TEXT / A-DOC.ARC / PA2.TXT < prev    next >
Text File  |  1993-01-07  |  54KB  |  1,345 lines

  1.      80  PRINT'X'ROUTINE  LDA  CHARACTER
  2.      90  JMP  $FFD2
  3.  
  4. If you use POWER ASSEMBLER to assemble this, then DLOAD "SIMPLE" and RUN it, 
  5. you would see an X printed on your screen (be still my heart). 
  6.  
  7. Basic may even use the symbol table names in expressions.  Anywhere the actual 
  8. value is needed the quoted symbol may be used.  Lines like; 
  9.  
  10.      100  FOR N=0 TO PEEK("TABLE'LENGTH")
  11.      110  POKE"TABLE"+N,PEEK("DATA"+N)
  12.      120  NEXT:REM MOVE DATA TO TABLE
  13.  
  14. ... could be used.  If any of the symbol names referenced were not defined in 
  15. the assembler source an UNDEFINED SYMBOL error would ensue. 
  16.  
  17. .LINK  "0:NEXTSOURCEFILE"
  18.  
  19. This is one way of chaining a number of source files together.  The .LINK 
  20. command will appear at the end of each but the last source file in the chain.  
  21. It causes POWER ASSEMBLER to LOAD the source file specified into memory before 
  22. continuing the assembly.  The last program in your chain will end with a .LOOP  
  23. "0:FIRSTSOURCEFILE" line.  The names used will be of course be the names you 
  24. have DSAVE'd your files to disk under. 
  25.  
  26. If you make use of the "+" forward referencing temporary label then the 
  27. largest source file should be the first in the chain.  The address stack for 
  28. these labels builds up from the end of the program in memory when assembly 
  29. begins.  If a longer source file is .LINKed in it will overwrite these 
  30. addresses spoiling everything. 
  31.  
  32. .LOOP  "0:FIRST-FILE"
  33.  
  34. This tells POWER ASSEMBLER that there are no more files in the LINKed chain.  
  35. The file name specified by .LOOP will be the first file in the chain.  On pass 
  36. one this file will be loaded into memory and pass two begun.  On pass two the 
  37. .LOOP command signals the end.  Any output files are closed and control is 
  38. returned to Basic.  The source program ending with the .LOOP instruction will 
  39. be sitting in Basic's program buffer. 
  40.  
  41. For the Commodore 64 only,  .LINK....LOOP memory chaining allows you to take 
  42. full advantage of FASTDISK utilities which intercept Basic's LOAD vector.  
  43. Again though, make sure that the largest source file comes first if you are 
  44. using the forward "+" temporary symbols. 
  45.  
  46. .FILE  "0:SAVED-SOURCEFILE"
  47.  
  48. This is a very convenient way of chaining source files together.  The .FILE 
  49. command tells POWER ASSEMBLER to assemble the specified source file directly 
  50. from disk then to return to the next line of the in memory source and 
  51. continue.  A very short program containing nothing but .FILE statements can be 
  52. used  to assemble multiple giant source programs as one.  It might look like 
  53. this: 
  54.  
  55.  
  56.  
  57.  
  58.  
  59.                         - Page 25 -
  60.  
  61.      SYS 999  (SYS 4000 for C-128)           ;call POWER ASSEMBLER
  62.      10  .FILE  "0:INITIALIZE"
  63.      20  .FILE  "0:PROCESS"
  64.      30  .FILE  "0:THESEROUTINES"
  65.      40  .FILE "0:THOSEROUTINES"
  66.      50  .FILE "0:MOREROUTINES"
  67.      60  .FILE  "0:MESSAGES"
  68.  
  69. With this type of setup the assembly process and file chain can be very  
  70. easily modified.  To add a source file called "PROTECTION" to the chain would 
  71. be as simple as adding a line 70  .FILE  "0:PROTECTION" to the rest before 
  72. running (assembling).  Changing the order in which the files are assembled 
  73. would involve merely switching a few line numbers.  To save the symbol table 
  74. part way through would entail only inserting the line 15  .SST  "0:INIT-SYMS" 
  75. for example.  Alternating display options, I/O device numbers and assembly 
  76. modes (e.g. .FAS or .MEM) would also not involve loading, modifying and 
  77. resaving large source files. 
  78.  
  79. It is not even necessary to save the changes made to the memory-based file 
  80. chaining program before assembly; it will still be there afterwards. 
  81.  
  82. The relative sizes of .FILEd source programs are unimportant because they are 
  83. read directly from disk.  The temporary label address stack will always be 
  84. completely safe.  The amount of memory available for .MEM output and symbol 
  85. tables is also maximized by this method of source file chaining. 
  86.  
  87. Large source files and even .LINKed source files may contain .FILE statements.  
  88. Control will always return to the next line after the specified source has 
  89. been assembled in from disk.  .FILE assembled source, however, may not contain 
  90. its own .FILE or .LINK commands.  This type of nesting would lead to great 
  91. unhappiness were POWER ASSEMBLER to attempt it.  The .LINK and .LOOP commands 
  92. are ignored in .FILE assembled source. 
  93.  
  94. .SEQ  "0:ASCIISRCFILE"
  95.  
  96. This works exactly like .FILE except that the source is expected in ASCII 
  97. format, not Basic.  This makes POWER ASSEMBLER highly compatible with almost 
  98. any editor or word processor. 
  99.  
  100. With POWER ASSEMBLER you can combine types to produce a single, ML object 
  101. program using (1) in-memory Basic type source created on the C-64 or C-128 
  102. Basic editor, (2) .FILE'ing in SAVE'd source programs and (3) .SEQ'ing in 
  103. source created on the ASCII editor of your choice. 
  104.  
  105. Source files specified in the .SEQ instruction must have the following 
  106. attributes: 
  107.  
  108.    1.  They will be in pure ASCII form.  No screen code or 
  109.      tokenization.
  110.  
  111.    2.  Lines will not be numbered.  POWER ASSEMBLER will 
  112.      attach a sequence number to each line in a file for 
  113.      display purposes.
  114.  
  115.    3.  A carriage return, i.e. CHR$(13), will be the last 
  116.      character of each line, and at least two of these will 
  117.      be at the end of each source file.
  118.  
  119.  
  120.  
  121.  
  122.  
  123.                         - Page 26 -
  124.      
  125.   4.  Colons may still be used to link statements on a 
  126.      line, but no line should be longer than 255 characters
  127.  
  128. A large source program in this format might possibly assemble slightly faster 
  129. than if it were in Basic source format.  It would not be necessary for POWER 
  130. ASSEMBLER to un-crunch tokens or to read in the four bytes of overhead 
  131. associated with link and line number. 
  132.  
  133. .TOP
  134.  
  135. In some situations it may be desirable to save only a portion of the symbols 
  136. defined or used in a program.  The .TOP command lowers the symbol table top in 
  137. so far as any future .SST is concerned, permitting the saving of intermittent 
  138. symbols only.  Symbols defined prior to .TOP, although accessible to the 
  139. program in every other way, will not be saved.  Unless one has a penchant for 
  140. empty files one should not attempt to .SST immediately following .TOP.  Here 
  141. is probably the more practical application of .TOP: 
  142.  
  143.      100  .LST  "0:HUGE-SYMTAB"
  144.      120  .TOP                     ;will not effect coding
  145.      130                           ;now a whole bunch
  146.              .                          ;of neat stuff using the
  147.              .                          ;loaded symbol table
  148.      500  .SST  "0:NEW-SYMS"            ;saves only the newly defined symbols
  149.  
  150. Numerous, completely exclusive symbol tables can be saved from within one 
  151. assembly list just as numerous separate object files can be created. 
  152.  
  153. With .TOP it is possible for two programs to access each other's symbol tables 
  154. without re-definition problems or phase errors caused by late zero page 
  155. assignments.  If .TOP is not used then every symbol defined prior to the .SST 
  156. command will be saved. 
  157.  
  158. .SST  "0:SYMBOL-TABLE-NAME"; save symbol table
  159.  
  160. This can be used to save all or portions of a symbol table.  If the above were 
  161. the last line of your source program all of its symbols might be saved to a 
  162. file under the name you used. 
  163.  
  164. Use .SST to create a file of Kernal routines, important register addresses and 
  165. memory locations for use in all your programs.  There are clear advantages to 
  166. this. 
  167.  
  168.    1.  You don't have to type them all in every time you 
  169.      start something new.
  170.  
  171.    2.  Your source files will be shorter without the 
  172.      numerous assignment statements.
  173.  
  174.    3.  Certain consistency and uniformity will be lent to 
  175.      your source programs.  The names of key symbols will 
  176.      not change from one project to the next.
  177.  
  178. .SST and .LST provide an excellent way of modifying large ML programs without 
  179. having to re-assemble the entire system each time changes are to be tested. 
  180.  
  181.  
  182.  
  183.  
  184.  
  185.  
  186.                         - Page 27 -
  187.  
  188. Imagine that you have developed a sophisticated word processor or game or 
  189. assembler or something and you now wish to add to it a fancy new feature.  You 
  190. know perfectly well you're not going to get it right the first, second, third 
  191. or maybe even the twentieth time.  We're talking tricky here.  The thought of 
  192. re-assembling the fifteen of so chained files involved with each new try is 
  193. not the most fun thing that you could possibly ever imagine.  you'd probably 
  194. spend more time waiting than working.  Try this: 
  195.  
  196.    1.  Put a call to the new routine in the main source and 
  197.      also assign therein an address to it.  This will not be 
  198.      the final destination, just a free, safe place to work 
  199.      on it.  So somewhere in the main source will be a line 
  200.      like 500  JSR  NEW'FEATURE, and a line like 50  
  201.      NEW'FEATURE =  50000.
  202.  
  203.    2.  Now assemble the whole thing.  Be sure to create an 
  204.      object file via an .OBJ "GREAT-BIG-ML-PGM" and to save 
  205.      its symbol table at the end via .SST "ITS-SYMBOLS".
  206.  
  207.    3.  You should have then a BLOAD'able version of your 
  208.      program and a copy of its symbol table, i.e.  the 
  209.      addresses and values of all of the routines, and 
  210.      variables contained in or used by it.
  211.  
  212.    4.  Write the new routine.  You don't have to get it 
  213.      perfect right off.  It should .ORG originate at the 
  214.      address you told the main program it would.  The first 
  215.      thing this source will do is load in the symbol table 
  216.      of the main program with .LST "ITS-SYMBOLS" line.
  217.  
  218. .LST  "0:ITS-SYMBOLS"
  219.  
  220. This will load in the specified symbol table for use by your program.  ... 
  221. carrying on with our example: 
  222.  
  223.    5.  BLOAD the main program in then assemble the new 
  224.      module (routine) right into memory using .MEM.  This 
  225.      new module will have complete access to the main one as 
  226.      if they had been assembled together.  Any routine in 
  227.      the large one will be made call-able by name from the 
  228.      new one.  Any flags, registers or variables in the main 
  229.      one are also at the disposal of the new part.
  230.  
  231.    6.  So try the whole thing out.  Run it.  Crash-boom, or 
  232.      yuk, or whatever.  It didn't work but that's okay 
  233.      because you planned it that way.  At worst you'll have 
  234.      to re-boot POWER ASSEMBLER, LOAD you ML code and the 
  235.      source for your test program before you can try it 
  236.      again.  At best you won't have to do any of that before 
  237.      you begin making corrections.
  238.  
  239.    7.  Sooner or later you'll get it perfect.  Believe.  Now 
  240.      remove the line from the main source which assigned the 
  241.      test address to the routine and either .FILE or .LINK 
  242.      assemble them together the way you would have like to do 
  243.      in the first place if life wasn't so full of mistakes.
  244.  
  245. If you .LST symbols in before you define any of your own (i.e. first), re-
  246. definitions will trigger error messages when they occur.  Duplicates will not 
  247. be loaded in.  In the case of labels this is usually convenient since it is 
  248. the last occurrence of a label that you are probably interested in anyway. 
  249.  
  250.  
  251.  
  252.  
  253.  
  254.  
  255.  
  256.  
  257.  
  258.  
  259.  
  260.                         - Page 28 -
  261. 
  262. .BYTE [onebytevalues,...,...]
  263.  
  264. This is used to place one byte value(s) into your code.  Here are a few 
  265. examples of .BYTE: 
  266.  
  267.      10  .BYTE 0,2,4,8,16,32,64,128               ;powers of  2
  268.      20  .BYTE  <1000,2000,3000              ;low bytes only
  269.      30  .BYTE  >SUB1,SUB2,SUB3              ;high bytes only
  270.      40  .BYTE  "a","b","c"+128              ;ASCII values
  271.  
  272. Notice that commas separate the operands and that no spaces are included.  
  273. Also notice how the <  and  >  work:  they affect the entire string of values 
  274. and should not be repeated.  This will make setting up high and low byte 
  275. address tables more convenient. 
  276.  
  277. .WORD [twobytevalues,...,...]
  278.  
  279. Use .WORD to set up address tables.  All values following will be treated as 
  280. two byte values.  This means that 10  .WORD  $FF,$FF would have the same 
  281. effect as 10  .BYTE 0,$FF,0,$FF. 
  282.  
  283. Here are some examples of .WORD:
  284.  
  285.      10  .WORD  DESTINATION-1           ;setup rts jmp
  286.      20  .WORD 12*4096,$c000+OFFSET          ;expressions
  287.  
  288. It would be pointless to use >  or  < in conjunction with word data since the 
  289. resulting values would never exceed one byte. 
  290.  
  291. .ASC  "***ASCII TEXT***"
  292.  
  293. Use the .ASC command followed by any quote-mode-typeable string of ASCII 
  294. characters you wish to be placed in your code. 
  295.  
  296. The opening quote is not optional.  Omitting it will result in a "QUOTE 
  297. EXPECTED" error message. 
  298.  
  299. A closing quote is optional unless of course you wish to include some banks at 
  300. the end of your text entry. 
  301.  
  302. For the Commodore 64, the following is a staple routine for printing messages 
  303. in ML.  It is almost always used in conjunction with the .ASC pseudo-op. 
  304.  
  305.      50   SYS 999                  ;again
  306.      70   .ORG 820                 ;sys 820 after
  307.      80   .MEM
  308.      90   PTR =251
  309.      95   PRINT =$FFD2             ;Kernal ROM
  310.      100  JSR  WRITE               ;print message routine
  311.      110  .ASC  "***HI MOM***":.BYTE 13,0
  312.      120  RTS
  313.      130  WRITE  =*
  314.      140  LDY  #0
  315.      150  PLA:STA  PTR+1           ;message address-1 on stack
  316.      160  PLA:STA  PTR
  317.      170  -  INC  PTR
  318.  
  319.                         - Page 29 -
  320.  
  321.      180  BNE  +                   ;to line 200
  322.      190  INC  PTR+1
  323.      200  +  LDA  (PTR),Y
  324.      210  BEQ  +                   ;to line 240
  325.      220  JSR  PRINT
  326.      230  BNE  -                   ;jmp to line 170
  327.      240  +  LDA  PTR+1:PHA        ;restore the rts address past zero
  328.      250  LDA  PTR:PHA
  329.      260  RTS
  330.  
  331. The preceding WRITE routine works much the way Basic's PRINT command does in 
  332. that the following text is printed.  A zero marks the end of WRITE text.  If 
  333. you examine this routine you will see how the 6510 stack works during JSR and 
  334. RTS executions. 
  335.  
  336. The C-128 only, has a new Kernal routine to print out strings of text.  This 
  337. text cannot be longer that 255 characters and must be terminated by a null 
  338. (zero). 
  339.  
  340. Here is as example of this routine used in conjunction with the .ASC pseudo-
  341. op: 
  342.  
  343.      50   SYS 4000                      ;again
  344.      70   .ORG  $B00                         ;sys 2816 after
  345.      80   .MEM
  346.      90   FOREVER  =*
  347.      100  JSR  $FF7D                         ;kernal primm routine
  348.      120  .ASC  "HI MOM":.BYTE 13,0
  349.      130  -  JSR  $FFE4                 ;kernal get keystroke]
  350.      140  BEQ  -                        ;loop if no key
  351.      150  JSR  $FF7D                         ;primm routine again
  352.      160  .ASC  "HI MOM":.BYTE 13,0
  353.      170  JMP  FOREVER
  354.  
  355. NOTE:  don't try  JMPing to $FF7D
  356.  
  357. .SCR  "***SCREEN CODE VALUES***"
  358.  
  359. .SCReen works the same as .ASC except the following text is converted to its 
  360. screen code equivalent.  That is the value you would use to poke the character 
  361. directly to the screen. 
  362.  
  363. The line   100  .SCR  "A" would code the value 1 whereas the line  100  .ASC  
  364. "A" would code the value 65.  This should make like a little easier for 
  365. programmers who maintain menu lines and display by "poking" character values 
  366. directly to the screen. 
  367.  
  368. .FAS
  369.  
  370. For the Commodore 64, .FASt switches off the screen.  This should increase in-
  371. memory assembly speed approximately by about 20 percent. 
  372.  
  373. For the Commodore 128, .FASt switches the micro processor into the 2mhz mode 
  374. and turns off the video.  This should at least double in-memory assembly 
  375. speed. 
  376.  
  377.  
  378.  
  379.                         - Page 30 -
  380.  
  381. There is no danger of missing any important messages by doing this.  If any 
  382. errors are encountered the screen is turned back on for you.  It would be 
  383. pointless, a waste of time to use .FASt and .DISplay together. 
  384.  
  385. .BURST  (C-128 only)
  386.  
  387. the .BURST command is for disk based (i.e. .SEQ and .FILE) assembly using the 
  388. 1571.  When .BURST is used source files, instead of being read via kernal 
  389. routines a line at a time from disk, will be burst loaded into memory at the 
  390. bottom of bank 1.  From here they will be accessed RAM DISK fashion by the 
  391. assembler.  This more than doubles the speed of disk based operation making 
  392. this almost as fast as .LINK/>LOOP load chaining which is always burst driven. 
  393.  
  394. If you are using the .FILE or .SEQ commands have a 1571 and can spare low 
  395. memory in bank 1 during assembly then .BURST is highly recommended.  It need 
  396. only be used once at the beginning of your source.  If you are using more than 
  397. one drive and only one is a 1571 the others will not be affected. 
  398.  
  399. .PSU
  400.  
  401. .PSeUdo allows for the use of mnemonics like LAX, DCM, INS, SKB, AXS, .etc. to 
  402. code non-standard opcode.  The reliability of some of these are somewhat moot.  
  403. I would suggest you execute them with interrupts disabled.  Some very widely 
  404. distributed commercial programs make extensive use of non-standard opcode both 
  405. to conserve space and to confuse disassembly. 
  406.  
  407. Like most inherent (operand-less) pseudos it is a toggle command.  Using it 
  408. for a second time will turn the feature off.  You will probably want it on 
  409. only for those portions of code which make use of non-standard opcode.  as 
  410. with standard mnemonics like LDA and INX you will have to avoid giving symbols 
  411. in your program the same names as non-standard mnemonics when .PSU is enabled. 
  412.  
  413. See the table appended to this manual for a full listing and brief 
  414. descriptions of the pseudo mnemonics which POWER ASSEMBLER recognizes. 
  415.  
  416. .IF  [operand];  conditional assembly
  417.  
  418. When the expression following an .IF is not equal to zero then assembly will 
  419. proceed until an .ELSE is encountered, then skip to an .IFE line marking the 
  420. end of conditional assembly or another .ELSE. 
  421.  
  422. When the value following .IF equals zero then POWER ASSEMBLER will ignore 
  423. everything until an .ELSE or an .IFE is found.  Assembly will resume there. 
  424.  
  425.  
  426.  
  427.  
  428.  
  429.  
  430.  
  431.  
  432.  
  433.  
  434.  
  435.  
  436.  
  437.  
  438.  
  439.                         - Page 31 -
  440.  
  441. .ELSE
  442.  
  443. This is where assembly will pick up when the value following the previous .IF 
  444. was zero.  If a second (third, fourth...) .ELSE follows, assembly will 
  445. alternate between them. 
  446.  
  447.      20  .IF  FLAG
  448.      30  :      LDA  "A":JSR $FFD2           ;Kernal print
  449.      40  .ELSE
  450.      50  :       LDA  "1":JSR $FFD2
  451.      60  .ELSE
  452.      70  :        LDA  "B":JSR $FFD2
  453.      80  .ELSE
  454.      90  :         LDA  "2":JSR $FFD2
  455.      100  .ELSE
  456.      110  :         LDA  "C":JSR $FFD2
  457.      120  .ELSE
  458.      130  :         LDA  "3":JSR $FFD2
  459.      140  .IFE                     ;end of conditional assembly
  460.      110  :         LDA  "!":JMP $FFD2
  461.  
  462. If flag  =  0 in the above then the assembled code would print "123", 
  463. otherwise the code would print "ABC!" 
  464.  
  465. Another more useful application of .IFE .ELSE conditional assembly would be to 
  466. protect you indirect jumps from accidentally falling on page boundaries. 
  467.  
  468.      10  JMP  (INDIRECT)                ;to destination
  469.             .
  470.             .
  471.      500  .IF  <*=1                     ;check page boundary
  472.      510  INDIRECT =*                   ;not page boundary
  473.      520  .WORD  DESTINATION
  474.      530  .ELSE
  475.      540  NOP                      ;pass page boundary
  476.      550  INDIRECT  =*
  477.      560  .WORD  DESTINATION
  478.      570  .IFE                     ;end of conditional assembly
  479.  
  480. No re-definition of a symbol error would occur during the above assembly.  
  481. Only the .IFE  or  .ELSE portion of the actual source would be assembled.  
  482. This would depend on whether or not  <*+1 (the low byte of the program counter 
  483. was  +1)  was zero. 
  484.  
  485. If you are using a number of .ELSEs you might want to take advantage of  the 
  486. fact that pseudo-ops can be extended and tack some alternating character on 
  487. telling you which condition belongs to, i.e. 
  488.  
  489.      .ELSE1,...ELSE0,...ELSE1,...Else0,  etc.
  490.  
  491. Note:  Don't try JMPing to $FF7D.  Never stick a label in front of an  .ELSE  
  492. or an  .IFE.  POWER ASSEMBLER will look no further and miss the switch. 
  493.  
  494.  
  495.  
  496.                         - Page 32 -
  497.  
  498. .IFE
  499.  
  500. This ends conditional assembly.  Everything following is assembled. 
  501.  
  502. MACRO-OPS
  503.  
  504. Three of the most common activities in machine language involve (1) comparing 
  505. pointers, (2) filling, i.e. erasing, ranges of memory, and (3) moving ranges 
  506. of memory.  POWER ASSEMBLER has provided macro-ops to make short work of these 
  507. traditionals while enhancing the readability and reducing the size of your 
  508. source. 
  509.  
  510. All require operands which are expected to be in the form of zero page 
  511. pointers.  While this may seem a trifle inconvenient at first glance it makes 
  512. the resultant code much more flexible. 
  513.  
  514. For instance, you do not want to have to use the .MOVE macro every time you 
  515. want to relocate some range of memory.  It would be much more efficient to use 
  516. it once as a subroutine (i.e. preceded by a label and followed by a RTS) and a 
  517. JSR to it whit its three pointers set to your specific needs on each 
  518. particular occasion.  This would not of course be possible if this macro-op 
  519. took constraints as operands. 
  520.  
  521. Another advantage to taking pointers is that you can choose precisely what 
  522. addresses will be used by the generated code.  Only the pointers you specify 
  523. and the processor's registers are manipulated.  Back in the joyous awareness 
  524. that your data and variables will always be safe when macro coding; trip on to 
  525. the absolute power you exercise over memory usage when employing POWER 
  526. ASSEMBLER's macros. 
  527.  
  528. I have come into contact with a number of very proficient and talented, 
  529. professional assembly language programmers over the last several years and not 
  530. one has confessed to having ever used macros.  I believe this is because by 
  531. their very nature ML programmers enjoy the exquisite control they have over 
  532. their machines and do not wish to relinquish this to something "standard".  
  533. Perfection is in order.  Custom subroutines seem to hold more appeal than 
  534. built-in, space-wasting, other-people's macros. 
  535.  
  536. However, the few that have been selected for POWER ASSEMBLER are universally 
  537. applicable.  To overcome your apprehensions about using them I would suggest 
  538. that you UNASM to disassemble the code generated by each.  You will find it 
  539. totally re-locatable and non-self-modifying as well as fast, efficient and 
  540. correct. 
  541.  
  542. .TEST  ZEROPTR1,ZEROPTR2
  543.  
  544. In situations where you wish to compare two addresses designated indirectly by 
  545. zero page pointers you could use the .TEST macro-op.  The carry returns clear 
  546. if the first was pointing to a lower address, otherwise it will be set.  The Z 
  547. flag is set if they both point to the same address. 
  548.  
  549.  
  550.  
  551.  
  552.  
  553.  
  554.  
  555.  
  556.  
  557.  
  558.  
  559.  
  560.                         - Page 33 -
  561.  
  562. .DUMP  BEGINPTR,ENDPTR
  563.  
  564. This dumps the contents of the accumulator to a range of memory.  It might be 
  565. used quite effectively to clear buffers or hi-res screen areas.  The first 
  566. pointer must designate the first address to be filled and the second pointer 
  567. the last.  Make sure that they are properly set and that the A register has 
  568. been loaded with the desired value before you use (or call the subroutine 
  569. using) the .DUMP command.  In the following exciting demonstration of it the 
  570. 40 column screen is filled with "B"s 
  571.  
  572.      10   SYS  999 (C-64)               SYS 4000  (C-128)
  573.      20   .ORG  820:.MEM
  574.      30  SCREEN  =1024             ;in 40 column mode for C-128
  575.      40   LDA  <SCREEN:STA  TOPPTR
  576.      50   LDA  >SCREEN:STA  TOPPTR+1
  577.      60  LDA  <SCREEN+999:STA  BOTPTR
  578.      70   LDA  >SCREEN+999:STA  BOTPTR+1
  579.      80   LDA  "B"                 ;screen code for "B"
  580.      90   .DUMP  TOPPTR+BOTPTR
  581.      100  RTS
  582.  
  583. .MOVE  BEGINPTR,ENDPTR,DESTINATIONPTR
  584.  
  585. This will generate the code to move the range of memory specified by the first 
  586. two pointers to begin at the address pointed to by the third pointer.  The 
  587. range can be moved in either direction any distance without overwriting 
  588. itself.  In other words, it does not matter whether the destination is above 
  589. or below the beginning range to be moved or if the distance is very small.  
  590. Memory will still be intact.  This macro is used in EDITOR.64 or LABELGUN (C-
  591. 128 only) to shift ranges of source up or down when inserting or deleting text 
  592. and replacing strings with others that are longer or shorter.  Of course the 
  593. memory being mover (your source) cannot be corrupted in any way. 
  594.  
  595. Write the following short program to locate in the cassette buffer. 
  596.  
  597.      10  SYS  820                  SYS4000 for C-128
  598.      20  .ORG  820:.MEM FOR C-64        .ORG  $B00:.MEM for C-128
  599.      30  FROMPTR  =251             ;safe Basic zero page
  600.      40  TOPTR  =253
  601.      50  DESTPTR  =65
  602.      60  .MOVE FROMPTR,TOPTR,DESTPTR
  603.  
  604. Now use UNASMbler to disassemble and examine it.  Notice that only the 
  605. pointers you defined and the micro processor's registers are used.  Try  
  606. moving some memory around.  Convince yourself that .MOVE works and is safe.  
  607. Almost every ML program ever written uses memory moves.  Getting comfortable 
  608. with this POWER ASSEMBLER macro can save you time and trouble. 
  609.  
  610. WRITING YOUR OWN COMMANDS
  611.  
  612. There is space in POWER ASSEMBLER's pseudo-op stack for up to five new 
  613. commands.  Each one takes up five bytes of memory.  The first three, which are 
  614. currently spaces will be replaced by your own 
  615.  
  616.  
  617.  
  618.  
  619.  
  620.                         - Page 34 -
  621.  
  622. three-letter command which you will make up all by yourself; the next two will 
  623. be the address-1 of the routine you want to execute when the assembler comes 
  624. across this command. 
  625.  
  626. A symbol table for each version of your assembler is on the system disk.  To 
  627. display one use the following technique: 
  628.  
  629.      10   SYS  999 (C-64)               SYS 4000  (C-128)
  630.      20  .DIS                      ;to display to screen
  631.      30  .LST BUDDYSYMS
  632.  
  633. The symbol you will use to get your commands into the code is called 
  634. "PUT'YOUR'CMDS'HERE"; and nothing could be easier that putting your command 
  635. there.  Let us create a new feature for POWER ASSEMBLER  called "fun"; every 
  636. time the pseudo-op .FUN is encountered in your source POWER ASSEMBLER will 
  637. inform you that fun is being had; what could be nicer? 
  638.  
  639.      10   SYS  999 (C-64)               SYS 4000  (C-128)
  640.      20  .LST BUDDYSYMS            ;so you can use them
  641.      30  .ORG  PUT'YOUR'CMDS'HERE
  642.      40  .MEM                 ;now we put fun on the stack
  643.      50  .ASC  "FUN"                    ;no period here
  644.      60  .WOR FUNROUTINE-1         ;address of new useful routine less one
  645.      70  .ORG  832  ($B00 on C-128)          ;we'll put it in the cassette 
  646.                                               buffer
  647.      80  FUNROUTINE =*             ;powerful new command
  648.      90  JSR  MESSAGE              ;POWER ASSEMBLER's print message subroutine
  649.      100  .ASC "WHEEEE!  THIS IS FUN."
  650.      110  BYTE 13,0                ;must end with zero
  651.      120  JMP NEWLINE              ;POWER ASSEMBLER takes over
  652.  
  653. after running this, run the following:
  654.  
  655.      10 SYS  999 (C-64)                 SYS  4000 (C-128)
  656.      20  .FUN
  657.  
  658. Your "fun" message should have been printed twice: once on each pass.  If it 
  659. wasn't then it's your fault.  Fix whatever you did wrong, try again, and be 
  660. more careful this time (GRIN). 
  661.  
  662. IMPORTANT ROUTINES AND LOCATIONS
  663.  
  664. Every source line is de-tokenized into memory at the address of the BUFFER 
  665. symbol.  A zero byte marks the end of that line. 
  666.  
  667. If you generate output you should call POWER ASSEMBLER's NEWPC routine.  First 
  668. set BYTES to the appropriate value, not greater than three.  Put code 
  669. generated at OUTPUT, OUTPUT+1,  and OUTPUT+2 as necessary.  You may call NEWPC 
  670. more than once (i.e. in a loop)  When you are done, a JMP NEWLINE; passes 
  671. control back to POWER ASSEMBLER. 
  672.  
  673. If your command takes and operand you can immediately JSR the EVALOPERAND 
  674. routine.  Any valid POWER ASSEMBLER expression will be evaluated and the value 
  675. returned in SUM and SUM+1. 
  676.  
  677.  
  678.  
  679.                         - Page 35 -
  680.  
  681. PASSNUM will be 0 on pass 1 and  255 on pass 2.
  682.  
  683. Try changing the previous .FUN command so you can use .FUN 100 to print the 
  684. "fun" message 100 times, but only on pass 1. 
  685.  
  686. Of course there are many, many more routines and flags and variables that you 
  687. will want to become familiar with if you plan to really get intimate with the 
  688. inner workings of your assembler.  You have symbol tables.  You have a 
  689. powerful unassembler.  You have fun. 
  690.  
  691. TEMPORARY SYMBOLS
  692.  
  693.    TEMPORARY LABELS: - / +
  694.  
  695.    The multiplication, division, addition and subtraction 
  696.    characters each have two  possible uses.  In expressions, if 
  697.    "*"  is an arithmetic operator then values on either side 
  698.    are multiplied (e.g.  12*4096); whereas, if it is used as a 
  699.    symbol it will represent the program counter (e.g.  LABEL =*  
  700.    or *=*+4).  This is standard use of "*" and is mentioned 
  701.    only to illustrate dual functioning of one special 
  702.    character.
  703.  
  704.    In POWER ASSEMBLER source the "+", the "-" and the "/" also 
  705.    serve two purposes.  In addition to their standard 
  706.    application in arithmetic, they may be used as temporary 
  707.    labels.  Many ML programmers don't like having to think up 
  708.    symbol names for numerous, routine, short branches.  This is 
  709.    especially so in very long programs after all variations of 
  710.    the labels SKIP and LOOP and BACK and AHEAD and OVER and so 
  711.    on....  and so on....  have been exhausted.  Objections to 
  712.    using these often random symbols are based on the following:
  713.  
  714.    1.  Time and effort are wasted in deciding on their names 
  715.      and typing them in, each at least twice.
  716.  
  717.    2.  They have a tendency to camouflage more meaningful 
  718.      symbols, making it harder to visualize what is happening.
  719.  
  720.    3.  Symbol tables become unnecessarily large, wasting memory 
  721.      and slowing things down.
  722.  
  723.    Judicious use of POWER ASSEMBLER's three temporary flags 
  724.    smartly overcome all of these difficulties.
  725.  
  726.    TEMPORARY BACKWARD REFERENCING
  727.  
  728.    When the "-" is used as a symbolic operand, the last 
  729.    occurrence of it as a label is referred to.  The command BNE  
  730.    -  will code a conditional branch back to the last line 
  731.    flagged with a "-" character.  Here is how it might be used 
  732.    in a simple time delay routine:
  733.  
  734.    100  WAIT  =*                     ;name of subroutine
  735.    110  LDX   #0                     ;initialize x and y
  736.    120  LDY   #0
  737.  
  738.  
  739.  
  740.  
  741.  
  742.  
  743.  
  744.                        - Page 36 -
  745.    
  746.    130  - DEX
  747.    140  BNE -                             ;loop back until x=0
  748.    150  DEY
  749.    160  BNE -                             ;same for y
  750.    170  RTS
  751.  
  752. Up to three minus signs may be used together as a symbol (e.g. BCC - - -) to 
  753. refer back as far as the third last "-" flagged line; only the last three are 
  754. remembered.  The minus sign may be used as a label again and again in your 
  755. source without re-definition errors.  You must be careful that when you use "-
  756. " characters symbolically that the line on which the referenced one has 
  757. occurred as a label is the one you will want to access (e.g. branch to).  Any 
  758. "-" markers prior to the third one are inaccessible. 
  759.  
  760. TEMPORARY FORWARD REFERENCING
  761.  
  762. The plus sign, as you may have guessed already, works in just the opposite 
  763. way.  That is, BNE + would code a conditional branch to the very next 
  764. occurrence of the "+" flag.  Here is how one might use it to increment a 
  765. pointer. 
  766.  
  767.    10  INC  PTR                      ;the low byte
  768.    20  BNE  +
  769.    30  INC  PTR+1                         ;the high byte
  770.    40  +  RTS
  771.  
  772. A symbol could have been used instead of "+", but what a bother, a mess and a 
  773. waste of space. 
  774.  
  775. There is no limit to how far forward the next "+" flag may be or how far back 
  776. to the last "-" flagged lines may be.  JMP - - or JMP ++ are valid too.  
  777. Within there scope of three, these temporary flags may be dealt with just like 
  778. any other symbol.  Still, all subroutines and data should be given meaningful 
  779. labels even if you could get away with a "+" or "-" temp. 
  780.  
  781. The next three "+" flagged lines may be referenced at any point by using 1 to 
  782. 3 "+"'s (e.g. BEQ +, BEQ ++, or BEQ +++) as a symbol just as any of the last 
  783. three "-" flagged lines may be accessed by using 1 to 3      "-"'s. 
  784.  
  785. Don't let temporary labels permit you to become un-imaginative.  Restrict 
  786. their use to short, redundant branches. 
  787.  
  788. FORWARD OR BACKWARD
  789.  
  790. When the "/" character is used as a label it serves as both "+" and "-", 
  791. either of which can be used to reference it.  In effect it is as though the 
  792. "/" flagged line had both "+" and "-" as a label on it.  The JMP - statement 
  793. would actually code a jump back to either the very last "-" or "/" flagged 
  794. line.  A JMP + would code a jump forward to the very next "/" or "+" label 
  795. position.  In the next example both conditional branches target the RTS in the 
  796. middle. 
  797.  
  798.  
  799.  
  800.  
  801.  
  802.  
  803.  
  804.  
  805.                         - Page 37 -
  806.  
  807.    10  BEQ  +
  808.    20  LDA  #0                       ;or whatever
  809.    30  /  RTS                             ;destination of both 
  810.    branches
  811.    40  DEX                           ;or whatever
  812.    50  BEQ  -
  813.  
  814. TEMPORARY SYMBOL MANAGEMENT
  815.  
  816. The backward referenced "-" label is handled only on pass two.  Only three 
  817. addresses need ever be "remembered" by the assembler with regard to it.  The 
  818. forward referenced "+" can not be dealt with so easily.  A table of all of its 
  819. occurrences as a flag is created on pass one which is then accessed on pass 
  820. two.  This table is separate from the normal symbol table and  contains only 
  821. addresses.  It builds up from the end of your source. 
  822.  
  823. If you are using the memory based 
  824.  
  825.      .LINK "NEXTFILE".  .  .  .
  826.      .LOOP  "FIRSTFILE"
  827.  
  828. system to chain source files together and you have made use of any temporary, 
  829. forward "+" references you should make sure that the largest file in the chain 
  830. comes first; otherwise, a larger file when loaded into memory will clash with 
  831. the "+" address table.  Consider disk based .FILE "ANYFILE" chaining as an 
  832. excellent alternative to memory based chaining in this situation. 
  833.  
  834. LABELGUN (for C=128 only)
  835.  
  836. The C=128 screen editor is an excellent one.  With it you can redefine keys, 
  837. freeze scrolling, delete ranges, renumber, auto line number and much more. 
  838.  
  839. About the only thing missing when it comes to developing a large program is 
  840. sophisticated string handling.  To be able to seek our occurrences of and 
  841. possibly modify a given symbol (e.g. string of characters) instantly 
  842. throughout an entire source program is so useful as to be almost essential. 
  843.  
  844. With Bud installed you have this ability.  So never strain your eyes scrolling 
  845. through screen after screen of source looking for that elusive BUG subroutine.  
  846. Just enter the following command: 
  847.  
  848.      L,BUG
  849.  
  850. Every line in your program with the word BUG on it will be listed for you.  
  851. Change every occurrence of BUG to CRITTER like this: 
  852.  
  853.      C,BUG,CRITTER
  854.  
  855. In the above case words like DEBUG, BUGEYES and BUGGY would also be changed.  
  856. This may not be what you had in mind. 
  857.  
  858.  
  859.  
  860.  
  861.  
  862.  
  863.  
  864.                         - Page 38 -
  865.  
  866. To have only whole words considered you would have to use a period in place of 
  867. the first comma. 
  868.  
  869.      C.X,EXITROUTINE
  870.  
  871. This would not ruin all your words containing X's.  Only if X occurred as a 
  872. whole symbol would it be changed to EXITROUTINE.  All those LDX, INX, STX and 
  873. TXA commands would go unmolested. 
  874.  
  875. Sometimes the string you seek will contain a Basic keyword but not have been 
  876. tokenized by the Basic editor.  This may be due to its following a DATA or REM 
  877. string on a line or because it exists between quotes.  In this situation it is 
  878. possible that the string you target, even though it looks the same as in your 
  879. program, will not be found by Labelgun. 
  880.  
  881. If you have doubts or if you are after a string you know is in quotes, do 
  882. this: 
  883.  
  884.      L,"ENDING
  885. or
  886.      C"STOPTHIS,STOPTHAT
  887.  
  888. You may put a period at the end of any Labelgun command to add extra spaces to 
  889. the end of a string; 
  890.  
  891.      L,MODULE .
  892.  
  893. ... would find any subroutines whose names ended in MODULE, but probably not 
  894. calls to them. 
  895.  
  896. You will find these string handling commands virtually indispensable.  Use 
  897. them to update label names that have changed their meaning.  Quickly locate 
  898. routines by name.  If you have source for the C=64 around that you would like 
  899. to convert to the C=128, Labelgun can help. 
  900.  
  901. Source written on the C=64 editor can be assembled by BUD, but source written 
  902. on the C=128 might not work with a C=64 basic environment assembler because of 
  903. the much larger set of tokens used on the C=128. 
  904.  
  905. TWO ENVIRONMENT EDITOR
  906.  
  907. Buddy-System 64 actually encompasses two machine language development 
  908. environments.  It is the POWER ASSEMBLER half which has been discussed so far.  
  909. Although POWER ASSEMBLER is able to assemble ASCII files from disk such as can 
  910. be written on EDITOR.64 (or EDITOR.128) or on most word processors, its memory 
  911. based source must be in Basic format.  Basic source, unlike pure ASCII text is 
  912. actually a linked list:  each line starts with a two byte pointer to the next.  
  913. Following this pointer are two more bytes representing the line number.  Next 
  914. comes the actual text with all Basic keywords tokenized (i.e. crunched).  At 
  915. the end of each line is a zero byte. 
  916.  
  917. While this format does very well for Basic it may not be the most efficient 
  918. for assembly language.  However, many programmers are comfortable with the 
  919. Basic editor and source format, have acquired 
  920.  
  921.  
  922.  
  923.  
  924.  
  925.  
  926.  
  927.  
  928.                         - Page 39 -
  929.  
  930. utilities such as POWER-64 which greatly extend its capabilities, and have no 
  931. desire to switch to a different system.  If you are one of these people then 
  932. stay with POWER ASSEMBLER; it was made for you. 
  933.  
  934. LOADING EBUD
  935.  
  936. On the disk is another version of the assembler which can be invoked by 
  937. entering LOAD "EBUD",8  <RETURN>   and then RUN.  This will result in the 
  938. editor compatible version of your assembler.          ED-BUDDY.64 or ED-
  939. BUDDY.128 and the ASCII editor itself.  EDITOR.64 or EDITOR.128, being loaded 
  940. into memory.  You will not return immediately to Basic as in the case when 
  941. booting with POWER ASSEMBLER. 
  942.  
  943. EDITOR.64 (or EDITOR.128)
  944.  
  945. Printed at the top of your screen will be  COLUMN:1    LINE:1; a solid cursor 
  946. will be in the upper left corner of the now clear text area.  Welcome to our 
  947. editor! 
  948.  
  949. MEMORY USAGE
  950.  
  951. EDITOR.64 commandeers the highest 2k of Basic RAM and sets the top of Basic to 
  952. a point below itself.  Thus it is safe from Basic activities and any utilities 
  953. (such as UNASM) which are sensitive to Basic's pointers.  Although 2k is quite 
  954. small by some standards the editor, as you will soon see, is no weakling. 
  955.  
  956. REPLACES BASIC EDITOR (C=128 only)
  957.  
  958. EDITOR.128 effectively replaces the Basic editor insofar as the EBUD version 
  959. of your assembler is concerned.  Basic is still completely at your disposal, 
  960. but you will not be using its line number oriented editor to write your source 
  961. on or assemble your source from.  EDITOR.128 is short, as editors go, and easy 
  962. to learn to use.  Nonetheless, a number of very useful features have been 
  963. built into it. 
  964.  
  965. 4-WAY SCROLLING and PAGING
  966.  
  967. Begin typing.  When you come to the right of the screen instead of wrapping to 
  968. the next line as you would in Basic the screen window scrolls with you to the 
  969. right.  Lines may be up to 250 characters long.  With text in memory you can 
  970. scroll up, down, left and right by using the cursor keys.  You may also page 
  971. up and down with the f3/f4 key and page left and right with the f5/f6 key.  
  972. This allows you to fillip through your source very quickly.  The CLR HOME key 
  973. can be used to position you immediately to the top or bottom of your source. 
  974.  
  975.  
  976.  
  977.  
  978.  
  979.  
  980.  
  981.  
  982.  
  983.  
  984.  
  985.  
  986.  
  987.  
  988.  
  989.                         - Page 40 -
  990.  
  991. SIMPLE INSERT and DELETE
  992. The INST DEL key works pretty much the way it does in Basic to add or remove 
  993. text one character at a time.  The f1/f2 key can be used to delete the 
  994. remainder of a line or to insert a new line.  This key can also be used to 
  995. split and join lines. 
  996.  
  997. CUT and PASTE
  998.  
  999. To delete an entire range of text position the cursor at one end of the text 
  1000. you wish to remove, then press <LOGO> S to set range.  You will see [RNG] 
  1001. appear at the left of your status line next to COLUMN:  Now move to the other 
  1002. end of the range of text to cut.  It does not matter how far or near this is.  
  1003. Press   <LOGO> D and this text will all disappear.  Pressing <LOGO> S twice in 
  1004. a row takes you out of the Set Range mode. 
  1005.  
  1006. Once you've cut a range of text you may paste (insert) it back anywhere, as 
  1007. often as you like and even move blocks of source between files.  To insert the 
  1008. range simply position the cursor to where you would like it to begin and press 
  1009. <LOGO> T for Text and presto -- there it is again. 
  1010.  
  1011. You may go back and forth from Basic, clear (new) source and load files 
  1012. without disturbing cut text so that routines can easily be moved from one file 
  1013. to another. 
  1014.  
  1015. FIND and REPLACE
  1016.  
  1017. To find occurrences of any word or words in your source, press <LOGO> F for 
  1018. Find.  This will temporarily position you on the status line.  Following the 
  1019. "OLD:" prompt, enter the string of characters you would like to find.  When 
  1020. you are done press <RETURN> to get back to where you where in your text.  Move 
  1021. to where you would like the search to begin (to search all your source press 
  1022. <SHFT> CLR HOME to go to the top) and then the f7 key.  Every time you press 
  1023. the f7 your cursor will move to the next occurrence of the target string you 
  1024. entered until you reach the bottom of your source. 
  1025.  
  1026. If you would like this target string replaced in your source with something 
  1027. else, press <LOGO> R for  Replace.  Again you will move to the status line 
  1028. where following the "NEW:" you will type in whatever you would like to change 
  1029. the "OLD:" stuff to. 
  1030.  
  1031. You may proceed in two ways: (1) If you press f7 only the next occurrence of 
  1032. the old will be replaced with the new.  (2) If you press f8 then all 
  1033. occurrences following will be changed and you will finish at the end of your 
  1034. source. 
  1035.  
  1036. LOADING and SAVING TEXT
  1037.  
  1038. Text may be kept as either sequential or program files.  ASCII Sequential 
  1039. files can be disk assembled by either version of your assembler via  SEQ 
  1040. FILENAME.  Program files can be .LINK/.LOOP load chain assembled (i.e. 
  1041. assembled directly from memory) by EBUD only.  The C=64 can also take 
  1042. advantage of FAST LOAD/SAVE cartridges for the 1541. 
  1043.  
  1044.  
  1045.  
  1046.  
  1047.  
  1048.  
  1049.  
  1050.  
  1051.                         - Page 41 -
  1052.  
  1053. PROGRAM FILES
  1054.  
  1055. To save your source as a program file simply press RUN STOP to return to 
  1056. Basic, then enter SAVE "MY-STUFF",8 (C=64) or DSAVE "MYSTUFF" (C=128) just the 
  1057. way you would any Basic program.  To load this file back in tomorrow you would 
  1058. enter LOAD "MY-STUFF",8 (C=64) or DLOAD "MYSTUFF",8 (C=128). 
  1059.  
  1060. TO & FROM BASIC
  1061.  
  1062. To return to the editor from Basic use the ED command.  If you loaded 
  1063. something new it will be there; otherwise whatever you were working on will 
  1064. still be waiting, unless of course you gave the NEW command to Basic in which 
  1065. case your source will have been cleared. 
  1066.  
  1067. SEQUENTIAL FILES
  1068.  
  1069. To save and load sequential files it is not necessary to leave the editor.  To 
  1070. save a file as a SEQ file begin by pressing <LOGO> P.  Then, following the 
  1071. "PUT:" prompt enter the name you would like to give your source on disk. 
  1072.  
  1073. To load a SEQ file press <LOGO> G and following the "GET:" prompt type in the 
  1074. file-name and press RETURN.  The file will be loaded in, beginning at the 
  1075. position of the cursor.  This can be used to join two files. 
  1076.  
  1077. ASSEMBLING
  1078.  
  1079. To assemble editor source, first press RUN STOP to return to Basic.  Then 
  1080. enter the AS command.  The source in the editor will be assembled directly 
  1081. from memory.  It is not necessary to save it first (unless you plan to kill 
  1082. the machine).  You may then issue the appropriate SYS command to test the code 
  1083. (hopefully) return to your still intact source via the ED command afterwards.  
  1084. Complete memory based operation is supported.  Either EBUD and EDITOR.64 and 
  1085. EDITOR.128 you can also disk assemble, file chain, load and save symbol 
  1086. tables, create object files, and indeed do all of the things POWER ASSEMBLER 
  1087. does with the Basic editor. 
  1088.  
  1089. SOMETHING TO TRY (C=64 only)
  1090.  
  1091. The source for the BUDDY-UNASMBLER is on disk in sequential format.  Either 
  1092. version of Buddy will assemble it from disk to memory at 50000.  To create a 
  1093. program file of ML code from this source you will have to use EBUD.  After 
  1094. loading and running EBUD use <LOGO> G to get UNASM-SOURCE into memory. 
  1095.  
  1096. Change the .MEM on line 2 to .OBJ UNASM.OBJ then RUN STOP to Basic.  Enter the 
  1097. AS command to assemble UNASM-SOURCE creating UNASM.OBJ which can now be 
  1098. LOADed...,8,1.  If you would like a version to load somewhere else in memory 
  1099. change the .ORG 50000 line. 
  1100.  
  1101. Now you've got a really powerful and fast memory based unassembler that will 
  1102. convert code to true POWER ASSEMBLER source. 
  1103.  
  1104.  
  1105.  
  1106.  
  1107.  
  1108.  
  1109.                         - Page 42 -
  1110.  
  1111. CONVERTING SOURCE TO ASCII
  1112.  
  1113. On the disk is a program called MAKE-ASCII that will create an ASCII file 
  1114. completely compatible with  the EBUD system from any Basic format source file 
  1115. such as created by UNASM and used by POWER ASSEMBLER. 
  1116.  
  1117. LOAD and RUN MAKE-ASCII
  1118.  
  1119. Enter the name of the Basic file followed by the name of the ASCII file you 
  1120. would like to create.  It will be done.  You can get this file into EDITOR.64 
  1121. or EDITOR.128 using the <LOGO> G command to load a sequential file.  You will 
  1122. probably see that this new ASCII file consumes less space on disk than the 
  1123. original Basic one did. 
  1124.  
  1125. EDITOR COMMAND SUMMARY
  1126.  
  1127. f1                              delete rest of line
  1128. f2                              insert new line
  1129. f3                              page up
  1130. f4                              page down
  1131. f5                              page right
  1132. f6                              page left
  1133. f7                              find/replace next occurrence
  1134. f8                              replace all occurrences
  1135. CLR                             top of text
  1136. HOME                            bottom of text
  1137. <LOGO> S                        start set range
  1138. <LOGO> D                        delete range
  1139. <LOGO> T                        insert range
  1140. <LOGO> F                        set string to find
  1141. <LOGO> R                        set string to replace
  1142. <LOGO> P                        save (put) seq file
  1143. <LOGO> G                        get (load) seq file
  1144. RUN STOP                        go to Basic
  1145. ED                              go to editor
  1146. AS                              assemble source in editor
  1147.  
  1148. ZBUDDY (for Commodore 128 only)
  1149.  
  1150. The following is intended to assist the more advanced ML programmer in making 
  1151. use of the C=128's Z/80 micro processor via the very powerful cross assembler, 
  1152. ZBUDDY.  ZBUDDY lets you use standard Z/80 mnemonics (see "TEST.ZMNE" program 
  1153. on disk) and BUDDY's expression syntax and rich body of pseudo-ops (see those 
  1154. sections of this manual) to create ML code for the 128's "other" micro 
  1155. processor.  Symbol tables for these assemblers are fully compatible (i.e. 
  1156. symbols can be .SST saved on one and .LST loaded by another) so that complex 
  1157. programs involving both the Z/80 and the 8500 can be written. 
  1158.  
  1159.  
  1160.  
  1161.  
  1162.  
  1163.  
  1164.  
  1165.  
  1166.                         - Page 43 -
  1167.  
  1168. PROGRAMMING THE Z/80  (C=128 only)
  1169.  
  1170. The C=128 is a two processor system.  Inside are the 8500 and a Z/80.  The 
  1171. Z/80 is one of the most advanced 8 bit processors alive.  It, unlike the 8500 
  1172. which is memory based, is a register based micro processor.  It has two sets 
  1173. of general purpose registers.  Each of these sets contains an accumulator, a 
  1174. status register and a six, 8 bit, general purpose registers.  The second set 
  1175. can be used for the interrupt flip-flop (IFF) or by the exchange (EXX) command 
  1176. to remember and restore register contents.  Data registers can also be paired 
  1177. for 16 bit addressing and arithmetic.  In addition to these there are four 
  1178. other 16 bit registers:  the PC (program counter), the SP (stack pointer) and 
  1179. the (IX) and (IY) (index) registers. 
  1180.  
  1181. 8 BIT INTERNAL REGISTERS  (C=128 only)
  1182.  
  1183. A         A'  accumulator
  1184. B         B'  general purpose
  1185. C         C'
  1186. D         D'
  1187. E         E'
  1188. H         H'
  1189. L         L'
  1190. F         F'  flag status
  1191.  
  1192. 16 BIT REGISTER PAIRS  (C=128 only)
  1193.  
  1194. BC        B=hi byte C=lo byte
  1195. DE        D=hi byte E=lo byte
  1196. HL        H=hi byte L=lo byte
  1197.  
  1198. TRUE 16 BIT REGISTERS  (C=128 only)
  1199.  
  1200. IX        index
  1201. IY        index
  1202. SP        stack pointer
  1203. PC        program counter
  1204.  
  1205. COMMANDS  (C=128 only)
  1206.  
  1207. The Z/80 recognizes several times as many instructions as the 8500; some 
  1208. therefore require more than one byte of opcode.  These commands can be 
  1209. functionally divided into 13 groups. 
  1210.  
  1211. 1.  THE EIGHT BIT LOAD GROUP  (C=128 ONLY)
  1212.  
  1213. The Z/80 assembler load instruction, LD, might more aptly be named MOVE.  
  1214. There is no store instruction.  Every LD will be followed by two operands 
  1215. delimited by commas.  The first operand represents the destination and the 
  1216. second the source, so that the instruction LD  ($C000),A means store the 
  1217. contents of A at $C000 whereas LD A,($C000) would mean load A from $C000.  In 
  1218. Z/80 mnemonics, parenthesis define memory location; otherwise an immediate 
  1219. value is assumed. 
  1220.  
  1221.  
  1222.  
  1223.  
  1224.  
  1225.  
  1226.                         - Page 44 -
  1227.  
  1228. 2.  THE SIXTEEN BIT LOAD GROUP  (C=128 ONLY)
  1229.  
  1230. This includes all the commands which move two byte values either between 
  1231. registers or between registers and addresses.  Included here are the PUSH and 
  1232. POP instructions which is handy since addresses are what stacks are mainly 
  1233. for. 
  1234.  
  1235. 3.  THE EXCHANGE GROUP (C=128 only)
  1236.  
  1237. Register contents can be swapped with the secondary set or within the primary 
  1238. set.  There's nothing like this on the 8500 although we often wish there was. 
  1239.  
  1240. 4.  THE BLOCK TRANSFER GROUP  (C=128 only)
  1241.  
  1242. Set a few register pairs and use one of these to move or fill memory a byte at 
  1243. a time or in a Z/80 controlled loop.  The short Z/80 routine which we will 
  1244. later call from Basic to copy its ROM into 8500 visible RAM uses an LDIR loop. 
  1245.  
  1246. 5.  THE BLOCK SEARCH GROUP  (C=128 only)
  1247.  
  1248. As above, the Z/80 can automatically control looping by counting down the 
  1249. value contained in the BC pair and incrementing the address pointed to by DE.  
  1250. Ranges of memory are compared with the A register until a match is found or 
  1251. the BC pair decrements to zero. 
  1252.  
  1253. 6.  THE 8 BIT ARITHMETIC AND LOGICAL GROUP  (C=128 only)
  1254.  
  1255. These allow for manipulation of one byte values in pretty much the same way 
  1256. 6510 programmers are used to.  Addition and subtraction are possible with or 
  1257. without a carry. 
  1258.  
  1259. 7.  THE 16 BIT ARITHMETIC AND LOGICAL GROUP  (C=128 only)
  1260.  
  1261. Same as above but with two byte values being manipulated.  The logical AND, OR 
  1262. and XOR are not found in this group. 
  1263.  
  1264. 8.  THE CPU CONTROL GROUP  (C=128 only)
  1265.  
  1266. Processor and interrupt modes and status flags are handled. 
  1267.  
  1268. 9.  THE ROTATE AND SHIFT GROUP  (C=128 only)
  1269.  
  1270. Many different types of shifts accessing both one and two byte values via a 
  1271. variety of addressing modes are available. 
  1272.  
  1273.  
  1274.  
  1275.  
  1276.  
  1277.  
  1278.  
  1279.  
  1280.  
  1281.  
  1282.  
  1283.                         - Page 45 -
  1284.  
  1285. 10.  THE BIT SET RESET AND TEST GROUP  (C=128 only)
  1286.  
  1287. These commands provide for complete bit addressing.  Each takes two 
  1288. parameters.  The first will specify which bit (0-7) is to be set, reset, or 
  1289. tested; the second will designate the register or memory location to be 
  1290. manipulated.  For example SET 3,(IX+0) would set bit 3 in the address pointed 
  1291. to by the ISX register     (i.e. OR it with the number 8). 
  1292.  
  1293. 11.  THE JUMP GROUP  (C=128 only)
  1294.  
  1295. Conditional and unconditional, jumps (direct) and branches (relative) are 
  1296. supported.  Anyone who had ever had to fake a conditional jump in the 6510 via 
  1297. BNE *+5:JMP FAR or an unconditional branch via SEC:BCS  NEAR will appreciate 
  1298. the versatility of this Z/80 group. 
  1299.  
  1300. 12.  THE CALL AND RETURN GROUP  (C=128 only)
  1301.  
  1302. Subroutines may also be called and returned from conditionally or 
  1303. unconditionally. 
  1304.  
  1305. 13.  INPUT OUTPUT GROUP  (C=128 only)
  1306.  
  1307. These are specialized load and store instructions.  In the C=128, when 
  1308. accessing I/O memory (D000-DFFF), IN and OUT commands should be used instead 
  1309. of LD. 
  1310.  
  1311. PROGRAMMING THE Z/80 IN 128 MODE  (C=128 ONLY)
  1312.  
  1313. The Z/80 brings a convenience and conciseness to ML programming that is sure 
  1314. to please and impress 6510 assembly language programmers.  I hope the above 
  1315. has wetted your appetite for doing a little exploring.  It will inspire you to 
  1316. know that this micro processor can be used in conjunction with (not at the 
  1317. same time as) the 8500 in the C=128, even from Basic; switching between them 
  1318. is not much more difficult than switching between memory banks once you know 
  1319. how. 
  1320.  
  1321. SWITCHING PROCESSORS  (C=128 only)
  1322.  
  1323. Bit 0 at $D505 (54533) controls the micro processor mode.  If it is turned on 
  1324. then the 8500 becomes active; if it is not then the Z/80 takes over. 
  1325.  
  1326. You can't just poke it off.  A little housekeeping is first in order: 
  1327.  
  1328. Disable the 8500 interrupts via SEI because you are going to switch to a 
  1329. memory configuration in which Kernal ROM is not visible. 
  1330.  
  1331. To do this, store a $3E (62) at $FF00 (the configuration register).  This 
  1332. leaves I/O RAM intact but switches everything else to RAM 0. 
  1333.  
  1334.  
  1335.  
  1336.  
  1337.  
  1338.  
  1339.  
  1340.  
  1341.  
  1342.  
  1343.                         - Page 46 -
  1344.  
  1345.