home *** CD-ROM | disk | FTP | other *** search
/ A.C.E. 1 / ACE CD 1.iso / files / docs / devpac2d.lha / DevpacV2Part1.doc next >
Encoding:
Text File  |  1994-11-27  |  112.5 KB  |  2,765 lines

  1.                           DEVPAC 2 PART 1
  2.  
  3. Originaly typed in for DEVPAC ST by THE ANIMAL HOUSE. Converted to
  4. DEVPAC AMIGA by PARASITE of LSD. Over 12 continueous hours of typing
  5. to convert these so I hope you appreciate them!
  6.  
  7.  
  8. CHAPTER 1: INTRODUCTION
  9.  
  10. ALWAYS MAKE A BACK-UP
  11.         Before using Devpac AMIGA you should make a back-up copy of
  12. the original disk and put the original away in a safe place. It is not
  13. copy-protected to allow easy back-up and to avoid inconvenience. This
  14. disk may be backed up using the Workbench or any back-up utility.
  15.  
  16.         NOTE: The original DEVPAC master disk had a technical support
  17. serial registration number, but you wont get this!.
  18.  
  19. REGISTRATION CARD
  20.         Enclosed with the manual is a registration card (but not for
  21. you, and you also get a free 68000 Pocket Guide (£2.95 from any
  22. good bookshop.)
  23.  
  24. THE README FILE
  25.         As with all Hisoft products Devpac AMIGA is continually being
  26. improved and the latest details cannot be included in this manual
  27. may be found in the README.S file on the disk. If you are not already
  28. in th CLI you should wait for any disk activity to stop. Press CTRL
  29. and both AMIGA keys (A software reset), insert your DEVPAC disk. Once
  30. in the CLI this file should be read by entering the command:
  31.  
  32. type readme (RETURN)
  33.  
  34. This display can be paused by holding down the menu button on the
  35. mouse.
  36.  
  37. INTRODUCTION TO THE CLI
  38.         Like most other programming developement tools, DeVPAC AMIGA
  39. is designed to be run from the CLI (Command Line Interface). If you
  40. examine the disk from the Workbench icon interface you won't see many
  41. icons on the disk because of this.
  42.         The CLI is deliberatly hidden from the average user, but as a
  43. programmer you will need to use it, although most of your developement
  44. time will be spent in th DEVPAC programs rather than the CLI.
  45.         DEVPAC disk one is a modified Workbench disk and to start with
  46. you should boot your machine as normal, with a kickstart disk if
  47. required, but when asked for workbench, insert DEVPAC disk one. If you
  48. have already booted from another disk, you should wait for all disk
  49. activity to stop, insert DEVPAC and preform a software reset.
  50.         The CLI is similar in concept to other non-iconic computers,
  51. such as those running MS-DOS or CP/m. It works by you entering
  52. commands such as:
  53.  
  54. dir (RETURN)
  55.  
  56. to get a directory of the disk. There is a full description on how to
  57. use the CLI and tutorial in the AMIGA user manuel.
  58.  
  59.         NOTE: If you have a non-UK keyboard, you may need to modify
  60. your s/startup-sequence file on your DEVPAC back-up disk, although
  61. this may have been done for you! See the readme for more details.
  62.  
  63. BACKUP DETAILS
  64.         Before making your security backups please ensure your master
  65. disks are write protected. It is recommended the backups made are
  66. regually virus checked with a reliable virus killer, or life could
  67. become very nasty!.
  68.  
  69. ONE-DRIVE SYSTEMS
  70.         Once you have booted the DEVPAC disk one enter the command
  71.  
  72. diskcopy df0: to df0: (RETURN)
  73.  
  74. Then follow the prompts given. The disk to copy from is our write-
  75. protected master disk one the disk to copy to should be a write-
  76. enabled blank disk. Then repeat the procedure with disk two.
  77.  
  78. TWO-DRIVE SYSTEMS
  79.         Enter the command:
  80.  
  81. diskcopy df0: to df1: (RETURN)
  82.  
  83. inset a write-enabled blank disk in the internal drive, and the write-
  84. protected DEVPAC disk one in the external drive and follow the prompts
  85. given. Repeat the procedure with disk two.
  86.  
  87. MAKING A WORK DISK
  88.         Although you now have a back-up, the disk as supplied dosen't
  89. have room on it for large programs, and it is best to make one or more
  90. work disks when you want to start serious programming. Exactly how you
  91. do this depends on your hardware confuguration.
  92.  
  93. ONE-DRIVE SYSTEMS
  94.         For single drive users it is best to get rid of as much as you
  95. can fron the DEVPAC disk. Prime candidates are all .info files
  96. together with the printer drivers and keymap files not required.
  97. Deleting Preferances will save space, but this may be useful.
  98.         If you follow these reccomendations the commands required (on
  99. another backup) would be:
  100.  
  101. cd df0: (RETURN)
  102. delete #?.info (RETURN)
  103. cd devs/printers (RETURN)
  104. dir (RETURN)
  105.  
  106. This will produce a list of printer drivers. Use the delete command to
  107. erase those you do not need.
  108.  
  109. cd devs/keymaps (RETURN)
  110. dir (RETURN)
  111.  
  112. This will produce a list of keymap files. Continue as above.
  113.  
  114. If space still bets tight you could start deleting the examples
  115. directory, seldom used include files and some commands in the c
  116. directory.
  117.  
  118. TWO-DRIVE SYSTEMS
  119.         Two drive owners are reccomended to keep the workbench disk
  120. free of all source code, and put such files together with the include
  121. files on the disk in th external drive. The commands to do this (using
  122. another back-up) would be:
  123.         (NOTE: The first command formats a blank disk in the  external
  124. drive losing all data. If you are using a pre-formatted disk you don't
  125. need to do this)
  126.  
  127. format drive df1: name "source" (RETURN)
  128.  
  129. Insert a blank disk in the external drive, then press (RETURN) to
  130. format it.
  131.  
  132. cd df0: (RETURN)
  133. makedir df1:include (RETURN)
  134. makedir df1:examples (RETURN)
  135. copy include to df1:include all (RETURN)
  136. copy examples to df1:examples all (RETURN)
  137. delete include all (RETURN)
  138. delete examples all (RETURN)
  139.  
  140.         The commands create directories on the external drive for the
  141. example programs and the include files, then delete them from the disk
  142. in the internal drive (which must, of course, be a back-up).
  143.  
  144.         You will now probably want to copy the program files from
  145. DEVPAC disk two to your workbench disk. To do this insert your back-up
  146. disk two of DEVPAC master disk in df1: and type:
  147.  
  148. copy df1:c to df0:c all (RETURN)
  149. cd df1: (RETURN)
  150.  
  151.         This final command changes the default directory to the
  152. external drive so you can edit source files there more easily. It is
  153. often worthwile to build such a command into your startup-sequence.
  154.  
  155. HARD DISK USERS
  156.         Hard disk users should firstly boot from the hard disk, and
  157. not the DEVPAC workbench disk. Having done this, the DEVPAC disk one
  158. should be placed in the internal drive and the following commands
  159. executed, to copy the programs onto the hard disk:
  160.  
  161. copy df0:c/genam2 to c: (RETURN)
  162. copy df0:c/monam2 to c: (RETURN)
  163. copy df0:c/genim2 to c: (RETURN)
  164.  
  165.         Next the two subdirectories should be copied, and this depends
  166. on your requiremants - for example, you may wish to make a seperate
  167. DEVPAC directory on your herd disk. Whatever you choose you will need
  168. to copy the whole of directories "include" and "examples". If you
  169. choose to have a seperate DEVPAC sub-directory the commands would be
  170. (assuming dh0: is the name of your hard disk):
  171.  
  172. makedir dh0:devpac (RETURN)
  173. copy df0:include to dh0:devpac all (RETURN)
  174. copy df0:examples to dh0:devpac all (RETURN)
  175.  
  176.         Note that if you put the example directory within another
  177. directory you will have to change the INCDIR directives at the
  178. beginning of them for correct assembly.
  179.  
  180.         You will also want to copy the following file from your DEVPAC
  181. disk two backup.
  182.  
  183. copy df0:c/blink to dh0:c
  184.  
  185.         It probably isn't worth copying the other files until you need
  186. them.
  187.  
  188. THE DEVELOPMENT CYCLE
  189.         The purpose of DEVPAC is to allow you to enter assembly
  190. language programs, assemble  them to machine-code and debug them if
  191. (or should that be 'when') they don't work. Depending on your
  192. application, you may also be using a linker to join together seperate
  193. modules, possibly with the output from a high level language compiler.
  194. Of course the faster the development cycle, the faster you can get
  195. your programs up and running and DEVPAC was designed to be as fast and
  196. powerful as possible. The link stage is optional, as is the Compile
  197. stage.
  198.  
  199. DEVPAC DISK CONTENTS
  200.         DEVPAC is supplied on two 3.5" disks, the first a standard
  201. Workbench 1.2 disk, configured to enter the CLI on boot, and the other
  202. contains additional files.
  203.  
  204. DISK 1
  205. Programs in c directory:
  206. GENAM2 - Screen editor and control program
  207. GENIM2 - Assembler
  208. MONAM2 - Debugger
  209.  
  210. Other files:
  211. LIBS/LIBFILE.MONAM - Binary file used by debugger
  212. LIBS/ARP.LIBRARY   - Additional library
  213. README             - Latest details about DEVPAC
  214.  
  215. Additional subdirectories:
  216. INCLUDE  - Contains files for accessing the operating system.
  217. EXAMPLES - The source code to various example programs.
  218.  
  219. DISK 2
  220. Programs in the c directory:
  221. BLINK     - PD linker
  222. CONVERTFD - FD file conversion utility
  223. CONVERTI  - Include file conversion utility
  224.  
  225. + some Workbench files for which there is insufficient room on disk
  226. one.
  227.  
  228. Text files:
  229. BLINK.DOC - Instructions for linker
  230.  
  231. Additional subdirectories:
  232. INCLUDE.CBM   - The original Commodore include files with comments
  233. INCLUDE.STRIP - The original Commodore include files without comments
  234. FD.FILES      - The original Commodore fd files. Includes which
  235.                 registers are used when calling libraries.
  236. LIBRARY       - Contains amiga.lib, debug.lib
  237. ARP           - Contains parts of Charlie Heaths AmigaDOS replacement
  238.                 project (ARP)
  239.  
  240. HOW TO USE THE MANUAL
  241.      This manual makes no attempt to teach 68000 assembly language
  242. programming or to detail the instruction set.  For the former, the
  243. bibliography  lists  suitable  books,  while for  the  latter  the
  244. supplied  Pocket  Guide is very useful.  The  Appendices  give  an
  245. overview of the technical aspects of the AMIGA but they are not
  246. intended as a complete technical description of the machine.
  247.      This manual is set out in five chapters, this introduction, a
  248. chapter on the screen editor,  a chapter on the macro assembler, a
  249. chapter on the debugger, then a chapter on the linker. In addition
  250. there  are  eight  Appendices  which  detail  various   additional
  251. information.  We suggest you use the manual in a way that  depends
  252. on what type of user you are:
  253.  
  254. DEVPAC VERSION 1 USERS
  255. Turn  to  Appendix  F and read the  section  describing  the  new
  256. features,  then  read the Reference section of Chapter 4  if  you
  257. intend  using MonAM, as it has changed considerably. You will then
  258. probably want to dip into the manual to read about the new features
  259. that interest you.
  260.  
  261. BEGINNERS
  262.      If you are a newcomer to assembly language then we  recommend
  263. that you read one of the books in the Bibliography alongside  this
  264. manual.
  265.      At  the end of this chapter there is a simple tutorial  which
  266. you should follow to familiarise yourself with the use of the main
  267. parts of the program suite.
  268.      Chapter  2  details  the editor and is  well  worth  reading,
  269. though much of Chapter 3,  detailing the assembler,  is liable  to
  270. mean  nothing  until you become  more  experienced.  The  Overview
  271. section  of  Chapter 4,  the debugger,  is  strongly  recommended,
  272. though Appendices can be left  for  a  while.
  273. Looking  at the supplied source code may be helpful.
  274.  
  275. EXPERIENCED USER
  276.      If you are experienced in the use of 68000 assembly  language
  277. but have not used DEVPAC before then here is a very quick way of
  278. assembling a source file:
  279.      Load GENAM2, Press Amiga-L and select your file which will
  280. load into the editor. Press Amiga-A and select the options which you
  281. require  - if generating executable code then click on the  Memory
  282. button  for  additional  speed.  Pressing RETURN  will  start  the
  283. assembler, which may be paused by pressing any key, RETURN resumes.
  284. Any assembly errors will be remembered and on return to the editor
  285. you  will  be placed on the first one.  Subsequent errors  may  be
  286. found by pressing Amiga-J.
  287.      To run your successfully-assembled program (if assembled  to
  288. memory ) press Amiga-X. If assembled to disk, leave the editor and
  289. run it from CLI.
  290.      As  a  quick  introduction  to  the  debugger  the  following
  291. tutorial is recommended.  If you have any problems please read the
  292. relevant section of the manual before contacting us for  technical
  293. support.
  294.  
  295. A VERY QUICK TUTORIAL
  296.      This  is a quick tutorial intended to let you see  how  quick
  297. and easy it is to edit, assemble and debug programs with DEVPAC.
  298.      In  this tutorial we are going to assemble and run  a  simple
  299. program,  which  contains two errors,  and debug it.  The  program
  300. itself  is  intended to print a message.
  301.      To  run this tutorial you must be in the CLI. If you are not you
  302. should wait for any disk activity to stip, eject all disks, press
  303. (CTRL) and both Amiga keys, and insert the backup of DEVPAC disk one.
  304. It is convenient if we make the current directory the one where our
  305. source program is, with the command:
  306.  
  307. cd examples (RETURN)
  308.  
  309. Next load the editor/assembler, by typing:
  310.  
  311. genam2 (RETURN)
  312.  
  313.         After a short delay the screen will show an empty window: to
  314. load  the  file you should move the mouse over the PROJECT menu and
  315. hold the right mouse button, and release it on LOAD. A file selector
  316. will then appear and the file we want is called DEMO.S. You should
  317. click on the name to load followed by OK.
  318.      When  the file has loaded the window will show the top  lines
  319. of the file.  If you want to have a quick look at the program  you
  320. may press (SHIFT)-(DOWNCURSOR) or (CTRL)-C to move to the next page.
  321.      With  most  shorter  programs  it is best  to  have  a  trial
  322. assembly  that doesn't produce a listing or binary file  to  check
  323. the syntax of the source and show up any typing errors and so  on.
  324. Move the mouse to the  Program menu and click on Assemble.
  325.      A dialogue box will appear, which should be left alone except
  326. the button near the bottom,  labelled NONE,  should be clicked on.
  327. Click on the Assemble button or press RETURN and the assembly will
  328. begin.
  329.      The   assembler  will  report  an  error,   instruction   not
  330. recognised, and pressing any key will return you to the editor. The
  331. cursor will be placed on the incorrect line and the error  message
  332. displayed in the status line.
  333.      The program line should be changed from MOV.L to MOVE.L so do
  334. this,  then  click on Assemble form the Program menu  again.  This
  335. time  click on the Memory button,  this means the program will  be
  336. assembled  into memory,  instead of onto disk.  This is very  much
  337. faster  and  allows you to try things out  immediately,  which  is
  338. exactly what we want.  Clicking on the Assemble button will  again
  339. assemble  it,  and after you press a key to return to  the  editor
  340. it's ready to run.
  341.      The  assembly  worked this time, but don't run it yet - you will
  342. probably get a software error task held message from the system and
  343. have to reboot the machine.
  344.      The  tool for finding bugs and checking programs is a debugger,
  345. so click on  Debug from the Program menu.  The debugger is described
  346. more fully later, but for now we just want to run the program from the
  347. debugger to 'catch' any problems and find out what causes them, so
  348. press (CTRL)-R.
  349.      After a brief delay the message Address Error will appear at the
  350. bottom  of the display, with the disassembly window showing the
  351. current instruction:
  352.  
  353. start        MOVE.L    dosname,a1
  354.  
  355.      This will cause an address error because location dosname is at
  356. an odd address which cannot be accessed with the MOVE.L instruction.
  357. There should be a hash sign before the dosname to put the address of
  358. dosname into the register a1. To return to the editor press (CTRL)-Q,
  359. to ensure that the program will be killed and press Y to terminate the
  360. program and the debugger. We can fix this bug in the source code.
  361.      Press (AMIGA)-T, to go to the top of the file, then click on Find
  362. from the Search menu.  We are going to find the errant instruction
  363. so enter:
  364.  
  365.              MOVE.L
  366.  
  367.      Then press Return to start the search. The first occurrence is
  368. the one we are looking for:
  369.  
  370. start        MOVE.L    dosname,a1
  371.  
  372.      Ahah! - this is the one, so add a hash to change it to
  373.  
  374. start        MOVE.L    #dosname,a1
  375.  
  376.      then assemble it again.  If you click on RUN from the Program
  377. menu you should see the message,  and pressing any key will return
  378. you to the editor.
  379.      Although  the  program  now works we  shall  use  MONAM2,  the
  380. debugger,  to trace through the program,  step by step. To do this
  381. click on Debug from the Program menu, and the debugger will appear
  382. with the message Breakpoint, showing your program.
  383.      There are various windows, the top one displaying the machine
  384. registers, the second a disassembly of the program, the third some
  385. other memory.
  386.      If you look at window 2, the disassembly window, you will see
  387. the current instruction, which in our case is:
  388.  
  389. start        MOVE.L    #dosname,a1
  390.  
  391.      As  the  debug was specified in the source code  any  symbols
  392. will appear in the debugger.
  393.      Let's check the area around dosname. Press (AMIGA)-3 and you
  394. should see the window 3's title inverted. Next press (AMIGA)-A and a
  395. dialogue box will appear, asking WINDOW START ADDRESS? - to this
  396. enter:
  397.  
  398. string
  399.  
  400.      (it  must  be  in lower-case) and  press  (RETURN).  This  will
  401. re-display  window 3 at the address,  showing the message in  both
  402. hex and ASCII.
  403.      To  execute  this MOVE instruction press  Ctrl-Z.  This  will
  404. execute the instruction then the screen will be updated to reflect
  405. the  new  values of the program counter and register  A1.  If  you
  406. press Ctrl-Z again the MOVEQ instruction will be executed and d0 will
  407. be modified. The next two instructions are the expansion of the
  408. CALLEXECOpenLibrary macro call. Use (CTRL)-z to single step the move
  409. to a6 instruction.
  410.  
  411.         Next we have:
  412.  
  413.         jsr     _LVOOpenLiberary(a6)
  414.  
  415.         This is the call to the exec liberary. All calls to the AMIGAs
  416. operating system have the same form. We don't want to single step this
  417. - we know that amigaDOS works. To treat this system call as one
  418. instruction use (CTRL)-T
  419.         Now single step the next (TST.L d0). D0 should be non-zero; so
  420. the Z flag won't be present in MONAM's register display area.
  421.         Now you can continue to press (CTRL)-z until you get to:
  422.  
  423.         jsr _LVOOutput(a6)
  424.  
  425.         This is the call to the DOS.liberary to find our output
  426. handle. Use (CTRL)-T to skip over this. Use (CTRL)-Z to continue
  427. single stepping until we get to:
  428.  
  429.         jsr     _LVOWrite(a6)
  430.  
  431.         This is the call that will actually write our string on the
  432. screen - lets make sure that the registers are set up correctly. d1
  433. should have the output handle that came back from the output call in
  434. d0. d2 should have the address of the message. If you look from d2 in
  435. the register display you will see the ASCII bytes of the string. Now
  436. use (CTRL)-T to skip over the Write call. To check that it worked
  437. press the V key, then press any other key to return to monam (being
  438. careful not ot activate any other windows meantime).
  439.         Now all that is left is our de-initialisation. You can use the
  440. (CTRL)-Z and (CTRL)-T commands to step through it as before.
  441.         The last instruction in the program is an RTS. Single stepping
  442. this will terminate Monam, for now, and return to the editor.
  443.  
  444. CHAPTER 2: SCREEN EDITOR
  445.  
  446. INTRODUCTION
  447.      To  enter  and assemble your programs you need an  editor  of
  448. some sort and an assembler. GenAM is our editor which loads and runs
  449. the assembler. Genim as required giving the appearance of a full
  450. screen editor and a fast, full specification assembler as one program.
  451. It  also allows  you  to run your assembled programs directly  from
  452. memory without  having  to quit the program or do a disk  access  and
  453. to access a debugger at the press of a key.  The fact that all  these
  454. features  are  combined in one program means that correcting
  455. errors and making changes is as fast as possible without the  need
  456. for slow disk accesses and other programs.
  457.      This chapter details the use of the editor and how to
  458. assemble program  - it does not detail the assembler or the
  459. debugger themselves, they are covered in the following chapters.
  460.      To  run GenAM, enter the command GENAM2 from the CLI. When it has
  461. loaded it will open an empty window, ready for you to enter and
  462. assemble your programs.
  463.  
  464. THE EDITOR
  465.      A  text  editor is a program which allows you  to  enter  and
  466. alter lines of text, store them on disk, and load them back again.
  467. There  are two types of text editors:  line editors,  which  treat
  468. each  line separately and can be very tricky to  use,  and  screen
  469. editors,  which display your text a screen at a time.  The  latter
  470. tend to be much easier to use.
  471.      The GENAM is a screen editor which allows you to enter and edit
  472. text and save and load from disk, as you would expect. It also lets
  473. you print all or some of your text, search and replace text patterns.
  474. It is intuition based, which means it uses all the user friendly
  475. features of amiga programs that you have become familiar
  476. with on your computer such as windows, menus and mice. However, if
  477. you're a die-hard,  used to the hostile world of computers  before
  478. the  advent of WIMP's,  you'll be pleased to know that you can  do
  479. practically everything you'll want to do from the keyboard without
  480. having to touch a mouse.
  481.      The editor is 'RAM-based',  which means that the file you are
  482. editing stays in memory for the whole time,  so you don't have  to
  483. wait while your disk grinds away loading different sections of the
  484. file  as you edit.  As the amiga can have so much memory, the  size
  485. limitations often found in older computer editors don't exist with
  486. GenAM;  if you have enough memory you can edit files of over  300k
  487. (though make sure your disk is large enough to cope with saving it
  488. if  you do !).
  489.         As all editing operations, including things like searching,
  490. are RAM based they act blindingly quickly. When you have typed in your
  491. program it is not much use if you are unable to save it to disk,  so
  492. the editor has a comprehensive range of save and load options,
  493. allowing you to save all or part of the text and to load other files
  494. into the middle of the current one, for example.
  495.      To  get  things to happen in the editor,  there  are  various
  496. methods available to you.  Features may be accessed in one or more
  497. of the following ways;
  498.  
  499.      Using a single key, such as a Function or cursor key:
  500.  
  501.      Clicking on a menu item, such as SAVE:
  502.  
  503.      Using  a  menu  shortcut,   by  pressing  the right amiga key
  504.      (subsequently  referred  to  as  (amiga))  in  conjunction   with
  505.      another such as (AMIGA)-F for Find:
  506.  
  507.      Using  the control key (subsequently referred to as Ctrl)  in
  508.      conjunction  with  another,  such as Ctrl-A for  cursor  word
  509.      left:
  510.  
  511.      Clicking on the screen, such as in the window itself.
  512.  
  513.      The  menu short cuts have been chosen to be easy and  obvious
  514. to  remember, the cursor key functions are based on those in the
  515. amigaBASIC editor check, while the Ctrl commands are based on those
  516. used  in Wordstar, and many other compatible editors since.
  517.      If  at  any time you get stuck,  pressing the HELP  key  will
  518. bring  up  a comprehensive display of the keys for  functions  not
  519. visible in menus.
  520.  
  521. A FEW WORDS ABOUT REQUESTERS
  522.         The editor makes extensive use of requesters,  so it  is
  523. worth recapping how to use them,  particularly for entering  text.
  524. The  editor's requesters contains string gadgets and buttons.
  525.         String gadgets enables to enter and edit text, and are
  526. depicted by a box containing the text, and with a block indicating the
  527. cursor position. Characters may be typed in and corrected using the
  528. (BACKSPACE), (DEL), and cursor keys. You can clear the whole edit
  529. field by pressing (AMIGA)-X. Ypu can move the cursor to the beginning
  530. by pressing (SHIFT) and left cursor key, or to the end by (SHIFT) and
  531. right cursor key. If there is more than one editable text field in a
  532. dialog box, you can move between them by clicking near them with the
  533. mouse.
  534.         Buttons  may  be  clicked on with the  mouse  and  cause  the
  535. requester to go away.  Usually there is a default button, shown
  536. by having a double border. Pressing (RETURN) on  the keyboard is
  537. equivalent to clicking on the default button, so long as a string
  538. gadget is active.
  539.         Some requesters allow only a limited range of  characters
  540. to  be  typed into them - for example the Goto Line requester.
  541.  
  542. THE FILE REQUESTER
  543.         The file requester is used to select file names for the disk
  544. input and output facilities of the editor. In it's simplest form all
  545. you need is to click on the file on the cancel button. At the top of
  546. Requester is the drawer specification, this determines which disk and
  547. sub-directory is displayed and can include wildcards, for example the
  548. specification:
  549.  
  550. df1:examples/#?.s
  551.  
  552. will display all files ending in .s. If you edit this specification,
  553. pressing the (RETURN) key will cause the directory to be read and
  554. displayed in the main part of the requester. Files may be selected by
  555. clicking on them and pressing (RETURN) or clicking on OK. The file
  556. list shows sub-directories with the (dir) prefix and the scroll bar
  557. may be used to navigate the file list. Files mey be selected or the
  558. requester cancelled while the directory is still being read! When
  559. initially invoked, only the first fiew files will be displayed. To
  560. update the file listm, click on the slider on the right of the
  561. filename list.
  562.         NOTE: Teh file requester uses the ARP libarary by Charlie
  563. Heath. If this library is not found then a simple string gadget will
  564. be used in it's place, in the same way as GenAm version 1. More
  565. details of the ARP library can be found in the ARP sub-directory on
  566. disk two.
  567.  
  568. ENTERING TEXT AND MOVING THE CURSOR
  569.      Having loaded GenAM, you will be presented with an empty
  570. window  with a status line at the top and an orange block, which is
  571. the cursor, in the top left-hand corner.
  572.      The  status  line  contains  information  about  the   cursor
  573. position in the form of Line Column offsets as well as the  number
  574. of  bytes of memory which are free to store your  text.  Initially
  575. this  is  displayed as 59980,  as the default text size  is  60000
  576. bytes.  You  may change this default if you  wish,  together  with
  577. various other options,  by selecting Preferences, described later.
  578. The  missing  20  bytes  are  used  by  the  editor  for  internal
  579. information.  The  rest of the status line area is used for  error
  580. messages, which will usually be accompanied with a 'display flash'
  581. to alert you. Any message that get  printed wil  be removed
  582. subsequently when you press a key.
  583.      To enter text,  you type on the keyboard.  As you press a key
  584. it  will  be shown on the screen and the cursor will  be  advanced
  585. along the line.  If you are a good typist you may be able to  type
  586. faster  than  the editor can re-display the  line;  if  so,  don't
  587. worry,  as the program will not lose the keystrokes and will catch
  588. up  when you pause.
  589.         At the end of each line you press the (RETURN) key (or the
  590. Enter key on the numeric pad) to start the next  line. You can correct
  591. your mistakes by pressing the Backspace key, which deletes the
  592. character to the left of the cursor, or the Delete key, which removes
  593. the character the cursor is over.
  594.      The  main  advantage  of a computer editor as  opposed  to  a
  595. normal typewriter,  is its ability to edit things you typed a long
  596. time  ago.  The  editor's large range of  options  allow  complete
  597. freedom to move around your text at will.
  598.  
  599. CURSOR KEYS
  600.      To move the cursor around the text to correct errors or enter
  601. new characters, you use the cursor keys, (the arrows). If you move
  602. the  cursor  past the right-hand end of the line  this  won't  add
  603. anything to your text,  but it you type some text at the point the
  604. editor  will  automatically add the text to the real  end  of  the
  605. line.  If  you type in long lines the window display  will  scroll
  606. sideways if necessary.
  607.      If  you cursor up at the top of the window the  display  will
  608. either  scroll  down if there is a previous  line,  or  print  the
  609. message  Top of file in the status line.  Similarly if you  cursor
  610. down  off the bottom of the window the display will either  scroll
  611. up if there is a following line, or print the message End of file.
  612.      For those of you used to Wordstar,  the keys Ctrl-S,  Ctrl-D,
  613. Ctrl-E and Ctrl-X work in the same way as the cursor keys.
  614.      To move immediately to the start of the current  line,  press
  615. Ctrl  (left arrow),  to move to the end of the current line  press
  616. Ctrl (right arrow).
  617.      To  move  the cursor a word to the left,  press  Shift  (left
  618. arrow) and to the right press Shift (right arrow). You cannot move
  619. a  cursor past the end of a line with this.  A word is defined  as
  620. anything surrounded by a space,  a tab or a start or end of  line.
  621. The keys Ctrl-A and Ctrl-F also move the cursor left and sight  on
  622. a word basis.
  623.      To move the cursor a page up, you can click on the upper grey
  624. part  of  the vertical scroll bar,  or press Ctrl-R or  Shift  (up
  625. arrow). To move the cursor a page down, you can click on the lower
  626. grey  part  of  the scroll bar,  or press Ctrl-C  or  Shift  (down
  627. arrow).
  628.      If you want to move the cursor to a specific position on  the
  629. screen you move the mouse pointer to the required place and  click
  630. (There is no Wordstar equivalent for this feature!)
  631.  
  632. TAB KEY
  633.         The Tab key inserts a special character (ASCII code 9) into
  634. your text, which on the screen looks like a number of spaces, but is
  635. rather  different.  Pressing Tab aligns the cursor onto  the  next
  636. 'multiple of 8' column,  so if you press it at the start of a line
  637. (column 1) the cursor moves to the next multiple of 8 +  1,  which
  638. is column 9.  Tabs are very useful indeed for making items line up
  639. vertically  and its main use in GenAM is for  making  instructions
  640. line up.  When you delete a tab the line closes up as if a  number
  641. of  spaces had been removed.  The advantage of tabs is  that  they
  642. only  take  up 1 byte of memory,  bat can show on screen  as  many
  643. more, allowing you to tabulate your program neatly. You can change
  644. the  tab size before or after loading GenAM using the  Preferences
  645. command described shortly.
  646.  
  647. BACKSPACE KEY
  648.      The  Backspace key removes the character to the left  of  the
  649. cursor.  If you backspace at the very beginning of a line it  will
  650. remove  the 'invisible' carriage return and join the line  to  the
  651. end of the previous line.  Backspacing when the cursor is past the
  652. end of the line will delete the last character on the line, unless
  653. the line is empty in which case it will re-position the cursor  on
  654. the left of the screen.
  655.  
  656. DEL KEY
  657.      The Delete key removes the character under the cursor and has
  658. no effect if the cursor is past the end of the current line.
  659.  
  660. GOTO A PARTICULAR LINE
  661.      To move the cursor to a particular line in the text, click on
  662. Goto line..  from the Options menu, or press (AMIGA)-G. A requester
  663. will appear allowing you to enter the required line number.  Press
  664. (RETURN) or click on OK button to go to the line or click on  Cancel
  665. to abort the operation.  After clicking on OK the cursor will move
  666. to the specific line,  re-displaying if necessary,  or give  error
  667. End of file if the line does't' exist.
  668.  
  669. GOTO TO TOP OF FILE
  670.         To  move to the top of the text, click on Goto Top from the
  671. Options  menu,  or  press (AMIGA)-T. The screen will be  re-drawn if
  672. requested.
  673.         NOTE: (AMIGA)-upcurser goes to the previous page not to the
  674. top of file - this has been changed from DEVPAC 1 because some users
  675. found this sequence too easy to hit by mistake.
  676.  
  677. GOTO END OF FILE
  678.      To  move  the cursor to the start of the very  last  line  of
  679. text, click on Goto Bottom, or press (AMIGA)-B
  680.         NOTE: (AMIGA)-downcursor goes to the next page not to the
  681. bottom of file - this has been changed from DEVPAC 1 because some
  682. users found this sequence too easy to hit by mistake.
  683.  
  684. QUITTING GENAM
  685.           To leave GenAM, and remove it from memory, click on Quit
  686. from the Project menu, or press (AMIGA)-Q. If changes have been made
  687. to the text which have not  been saved to disk,  an alert box will
  688. appear asking for confirmation. Clicking on Cancel will return you to
  689. the editor, while clicking on OK will discard the changes and return
  690. you to the CLI.
  691.  
  692. DELETING TEXT
  693.  
  694. DELETE LINE.
  695.      The  current  line can be deleted from the text  by  pressing
  696. Ctrl-Y.
  697.  
  698. DELETE TO END OF LINE.
  699.         The text from the cursor position to the end of the current
  700. line can be deleted by pressing Ctrl-Q. (This is equivalent to the
  701. Wordstar sequence Ctrl-Q Y).
  702.  
  703. UNDELETE LINE
  704.      When a line is deleted using either of the above commands  it
  705. is  preserved in an internal buffer,  and can be re-inserted  into
  706. the text by pressing Ctrl-U,  or the Undo key. This can be done as
  707. many times as required,  particularly useful for repeating similar
  708. lines or swapping over individual lines.
  709.  
  710. DELETE ALL TEXT
  711.      To clear out the current text, click on Clear from the Project
  712. menu, or press (AMIGA)-C. If you have made any changes to the text
  713. that have not been saved onto the disk, a confirmation is required
  714. and  the  requisite alert box will appear.  Clicking  on  OK  will
  715. delete the text, or Cancel will abort the operation.
  716.  
  717. DISK OPERATIONS
  718.         It is no use being able to type in text if you are unable to
  719. save it anywhere perminently, or load it back subsequently, so the
  720. editor has a comprehensive set of features to read from and write to
  721. disk.
  722.  
  723. SAVING TEXT
  724.      To save the text you are currently editing,  click on Save As
  725. from the Project Menu, or press (AMIGA)-S. The File requester
  726. will appear,  allowing you to select a suitable disk and filename.
  727. Clicking  OK or pressing Return will then save the file  onto  the
  728. disk.  If an error occurs a requester will appear showing a sutable
  729. error message, or an AmigaDOS error number, the exact meaning of which
  730. can be found in Appendix A.
  731.      If you click on Cancel the text will not be  saved.  Normally
  732. if  a  file  exists  with the same name it  will  be  deleted  and
  733. replaced  with the new version,  but if Backups are selected  from
  734. the  Preferences  options then any existing file will  be  renamed
  735. with  extension .BAK (deleting any existing .BAK file) before  the
  736. new version is saved.
  737.  
  738. SAVE
  739.         If you have already done a save as (or a load), GenAm will
  740. remember the name of the file and display it in the title bar of the
  741. window. If you want to save it without having to bother with the file
  742. requester. You can click on save on the Project menu, or press Shift-
  743. (AMIGA)-S, and it will use the old name and save it as above. If you
  744. try to sve without having previously specified a filename you will be
  745. presented with a file requester, as in save as.
  746.  
  747. LOADING TEXT
  748.      To  load a new file, click on Load from the Project menu, or
  749. press (AMIGA)-L. If you have made any changes that have not been
  750. saved, a confirmation will be required. The file requester will
  751. appear, allowing you to specify the disk and filename. Assuming you do
  752. not cancel, the editor will attempt to load the file. If  it will fit,
  753. the file is loaded into memory and the window is re-drawn. If it will
  754. not fit an alert box will appear warning you, and you should use
  755. preferances to make the edit buffer size larger, then try to load it
  756. again.
  757.  
  758. INSERTING TEXT
  759.      If  you  want to read a file from disk and insert it  at  the
  760. current  position in your text click on Insert File from the  File
  761. menu or press (AMIGA)-I. The file requester will appear and assuming
  762. that you do not cancel, the file will be read from the disk and
  763. inserted, memory permitting.
  764.  
  765. CHANGE DIRECTORY
  766.       This command lets you change the current directory that you are
  767. using. Simply uses the file requester to change the directory you
  768. wish.
  769.  
  770. SEARCHING AND REPLACING TEXT
  771.      To  find a particular section of text click on Find from  the
  772. Search menu,  or press (AMIGA)-F. A dialogue box will appear, allowing
  773. you to enter the Find and Replace strings. If you click on Cancel,
  774. no action will be taken;  if you click Next (or press Return)  the
  775. search will start forwards,  while clicking on Previous will start
  776. the  search backwards.
  777.         If you do not wish to replace, leave the Replace string empty.
  778. If the search was successful, the screen will be re-drawn at that
  779. point with the cursor positioned at the start of the string. If the
  780. search string could not be found, the message Not Found will appear in
  781. the status area and the cursor will remain unmoved. By default the
  782. search is always case-independant, so for example if you enter the
  783. search string as test you could find the words TEST,  Test or test.
  784. If you click on the Upper & Lower case Different button the search
  785. will be case dependant.
  786.      To find the next occurrence of the string click on Find  Next
  787. from  the Search menu,  or press (AMIGA)-N.  The search starts at the
  788. position just before the cursor.
  789.      To search for the previous occurrence of the string click  on
  790. Find Previous from the Search menu, or press (AMIGA)-P.
  791.      Having  found an occurrence of the required text,  it can  be
  792. replaced  with the Replace string by clicking on Replace from  the
  793. Search menu,  or pressing (AMIGA)-R.  Having replaced it,  the  editor
  794. will then search for the next occurrence.
  795.      If  you wish to replace every occurrence of the  find  string
  796. with the replace string from the cursor position onwards, click on
  797. Replace  All from the Search menu.  During the global replace  the
  798. ESC  key  can be used to abort and the status area will  show  how
  799. many  replacements were made.  There is deliberately  no  keyboard
  800. equivalent for this to prevent it being chosen accidentally.
  801.         To search and replace tab characters just press (TAB) when
  802. typing in the dialog box. Other control characters may be searched for
  803. by typing them in directly ((CTRL)-G for example). However do not use
  804. this for CR((CTRL)-M) and LF((CTRL)-J) characters.
  805.  
  806. BLOCK COMMANDS
  807.      A  Block is a marked section of text which may be  copied  to
  808. another section, deleted, printed or saved onto disk. The function
  809. keys are used to control blocks.
  810.      Block markers remain during all editing commands, moving where
  811. necessary. and are only reset by the commands New, Delete Block, and
  812. Load.
  813.  
  814. MARKING A BLOCK
  815.      The  start of a block is marked by moving the cursor  to  the
  816. required place and pressing key F1.  The end of a block is  marked
  817. by moving the cursor and pressing key F2. The start and end of the
  818. block do not have to be marked in a specific order - if it is more
  819. convenient you may mark the end of the block first.
  820.      A marked block is highlighted by showing the text in reverse.
  821. While  you  are  editing  a  line that  is  within  a  block  this
  822. highlighting  will not be shown but will be re-displayed when  you
  823. leave that line or choose a command.
  824.  
  825. SAVING A BLOCK
  826.      Once a block has been marked, it can be saved by pressing key
  827. F3.  If no block is marked,  the message What blocks! will appear.
  828. If  the start of the block is textually after its end the  message
  829. Invalid  block!  will  appear.  Both  errors  abort  the  command.
  830. Assuming  a  valid block has been marked,  the file requester
  831. will appear,  allowing you to select a suitable disk  and
  832. filename.  If  you save the block with a name that already  exists
  833. the  old  version will be overwritten - no backups are  made  with
  834. this command.
  835.  
  836. COPYING A BLOCK
  837.      A marked block may be copied,  memory permitting,  to another
  838. part of the text by moving the cursor to where you want the  block
  839. copied and pressing key F4. If you try to copy a block into a part
  840. of itself, the message Invalid block will appear and the copy will
  841. be aborted.
  842.  
  843. DELETING A BLOCK
  844.      A  marked  block  may be deleted from the  text  by  pressing
  845. Shift-F5.  The  shift key is deliberately required to  prevent  it
  846. being  used accidentally.  A deleted block is  remembered,  memory
  847. permitting, in the block buffer, for later use.
  848.         There are two key sequences with this command for
  849. compatibility with both DEVPAC version 2 and DEVPAC version 1.
  850.  
  851. COPY BLOCK TO BLOCK BUFFER
  852.      The  current marked block may be copied to the block  buffer,
  853. memory permitting,  by pressing Shift-F4.  This can be very useful
  854. for  moving blocks of text between different files by loading  the
  855. first,  marking  the block,  copying it to the block  buffer  then
  856. loading the other file and pasting the block buffer into it.
  857.  
  858. PASTING A BLOCK
  859.      A  block  in the block buffer may be pasted  at  the  current
  860. cursor position by pressing F5.
  861.     The  block  buffer will be lost if the edit  buffer  size  is
  862. changed or an assembly occurs.
  863.  
  864. PRINTING A BLOCK
  865.      A  marked  block may be sent to the printer  by  printing  on
  866. Print Block from the File menu, or by pressing (AMIGA)-W. A requester
  867. will appear asking for the name of the printer, which defaults to
  868. PRT:, and clickingon ok will print the block. Of course the name can
  869. be any valid AmigaDOS device, so you could "print" the block to disk
  870. if required. It is differant to Save Block in that tabs are expanded
  871. to spaces.
  872.      If you try to print when there is no block marked,  the whole
  873. file will be printed.
  874.  
  875. MISCELLANEOUS COMMANDS
  876.  
  877. HELP SCREEN
  878.         The key equivalents for the commands not found in menus can
  879. be seen by pressing the HELP key, or (AMIGA)-H. A dialogue box will
  880. appear showing the function key uses, the version of GenAm that is
  881. running and the total free memory in the system.
  882.  
  883. PREFERENCES
  884.      Selecting Preferences..  from the Options menu will produce a
  885. dialogue box allowing you to change several editor settings.
  886.  
  887. TABS
  888.      By default,  the tab setting is 8, but this may be changed to
  889. any value from 2 to 16.
  890.  
  891. TEXT BUFFER SIZE
  892.      By default the text buffer size is 60000 bytes,  but this can
  893. be changed from 4000 to 999000 bytes.  This determines the largest
  894. file size that can be loaded and edited,  Care should be taken  to
  895. leave  sufficient room in memory for assembly or running  MonAm.
  896. Changing  the editor work-space size will cause any text  you  are
  897. currently editing to be lost,  so a confirmation is required if it
  898. has not been saved.
  899.  
  900. BACKUPS
  901.      By  default the editor doesn't make backups of programs  when
  902. you  save them,  but this can be turned on by clicking on the  Yes
  903. radio button.
  904.  
  905. AUTO INDENTING
  906.      It can be particularly useful when editing programs to indent
  907. subsequent  lines from the left,  so the editor supports an  auto-
  908. indent mode.  When active, an indent is added to the start of each
  909. new line created when you press RETURN. The contents of the indent
  910. of  the new line is taken from the white space (i.e.  tabs  and/or
  911. spaces) at the start of the previous line.
  912.  
  913. END OF LINE
  914.      By default (i.e. when Stop is selected) when you press cursor
  915. left at the beginning of a line or cursor right at the end of line the
  916. cursor does not move. Changing this item to wrap causes the cursor to
  917. move to the previous line if you press cursor left at the beginning
  918. and to the next line if you press curser left at the beginning and the
  919. next line if you presscursor right at the end. The best way to find
  920. out which you prefer is to try using both settings.
  921.  
  922. LOAD MONAM
  923.      By  default  a  copy of MonAM is  loaded  during  the  editor
  924. initialisation,  allowing it to be accessed at the press of a key.
  925. Should  this not be required it can be disabled with this  option.
  926. This will save around 24k of memory.  The new value of this option
  927. will  only  have  an effect if you save the  preferences  and  re-
  928. execute the editor.
  929.  
  930. AUTOSIZE WINDOW
  931.      By default, Genam will not use the entire screen display, but if
  932. this is selected then it will make it's initial window as large as
  933. possible.
  934.  
  935. SAVING PREFERENCES
  936.      If  you click on the Cancel button any changes you make  will
  937. be ignored.  If you click on the OK button the  changes  specific
  938. will remain in force until you quit the editor.  If you would like
  939. the  configuration made permanent then click on the  Save  button,
  940. which will create the file GENST2.INF on your disk.  Next time you
  941. run GenST the configuration will be read from that file in the current
  942. directory. In  addition to saving the editor configuration  the
  943. current setting from the Assembly Options dialogue box are also saved.
  944. If the .INF file is not found in the current directory when the editor
  945. is loaded, the c: directory is also searched. This allows a global
  946. settings as well as specific local ones.
  947.  
  948. ASSEMBLING & RUNNING PROGRAMS
  949.      All assembly and run options can be found on the Program menu
  950.  
  951. ASSEMBLY
  952.      To  assemble the program you are currently editing  click  on
  953. Assemble from the Program menu, or press (AMIGA)-A. The meaning of the
  954. various  options,  together  with the assembly process  itself  is
  955. detailed in the next chapter.  The only option covered here is the
  956. Output option.
  957.      GenAM  can  assemble  to  disk,   to  memory,  or  nowhere  -
  958. assembling to nowhere is ideal for syntax checking while  assembly
  959. to  memory is much faster than to disk and good for trying  things
  960. out quickly.
  961.      If you assemble to disk and you haven't saved your program source
  962. code yet the file will be based on the name NONAME.
  963.      After  you  click on Assembly or press  RETURN  the  assembly
  964. process will start,  describe more fully in the next  chapter.  At
  965. the  end  of the assembly the program will wait for a  key  press,
  966. allowing you to read any messages produced,  before returning  you
  967. to the editor.  If there were any errors the editor will go to the
  968. first  erroneous line and display the error message in the  status
  969. bar.  Subsequent  errors  (and warnings) may  be  investigated  by
  970. pressing (AMIGA)-J.
  971.  
  972. RUNNING PROGRAMS
  973.      If you click on Run or press (AMIGA)-X (eXecute) you can then run
  974. a  program  previously assembled into memory.  When  your  program
  975. finishes it will return you to the editor.  If the assembly didn't
  976. complete  normally for any reason then it is not possible  to  run
  977. the program.
  978.      If  your  program crashes badly you may never return  to  the
  979. editor, so if in doubt save your source code before using this, or
  980. the following command.
  981.      If  only non-fatal errors occurred  during  assembly  (e.g.
  982. undefined  symbols)  you  will  still be  permitted  to  run  your
  983. program, at your own risk.
  984.  
  985. DEBUG
  986.      If you wish to debug a program previously assembled to memory
  987. click  on Debug form the Program menu, or press (AMIGA)-D. This will
  988. invoke  MonAM to  debug your  program,  including  any  debugging
  989. information specified.  Pressing Ctrl-C from MonAM will  terminate
  990. the debugger.
  991.      If  the  Load  MonAM option is disabled this  option  is  not
  992. available and the menu is disabled.
  993.  
  994. MONAM
  995.      Clicking on MonAM from the Program menu, or pressing (AMIGA)-M,
  996. will invoke MonAM in a similar way to if it was invoked by typing it's
  997. name in CLI, but instantly, as it  is  already  in  memory.  You will
  998. return  to  the  editor  on termination of the debugger.
  999.      If  the  Load  MonAM option is disabled this  option  is  not
  1000. available and the menu is disabled.
  1001.  
  1002. JUMP TO ERROR
  1003.      During  an  assembly any warnings or errors  that  occur  are
  1004. remembered,  and can be recalled from the editor. Clicking on Jump
  1005. to  Error from the Program menu,  or pressing (AMIGA)-J will move  the
  1006. cursor  to the next line in your program which has an  error,  and
  1007. display  the  message in the status line of the  window.  You  can
  1008. step to the next one by pressing (AMIGA)-J again,  and so on,  letting
  1009. you  correct errors quickly and easily.  If there are  no  further
  1010. errors when you select this option the message No more errors will
  1011. appear,  or if there are no errors at all the message What errors!
  1012. will appear.
  1013.  
  1014. THE EDITOR WINDOW
  1015.         The window used by the editor works like the most other Amiga
  1016. windows, so you can move it around by using the drag gadget on the top
  1017. of it, you can change it's size by dragging on the size gadget and
  1018. control it's position relative to the other windows by using the front
  1019. and back gadgets. Clicking on the close gadget is equivelant to
  1020. choosing Quit fron the project menu. Like all intuition windows, it
  1021. has to be active for you to be able get at it's menu items. If you
  1022. have a larger than normal screen size (eg. a european PAL system which
  1023. has 256 vertical lines) you can re-size the window to be the full size
  1024. of your screen.
  1025.         When GenAm is busy doing a disk access or assembly the cursor
  1026. changes to an hourglass and all menu items are made grey.
  1027.         NOTE: When using GenAm (And MonAm) on PAL machines with
  1028. external RAM, you may sometimes get two mouse pointers; one will be
  1029. the normal intuition pointer, the other will be the custom pointer
  1030. allocated with the program you are using. Do not be alarmed - this
  1031. seems to be a harmless bug in intuition.
  1032.  
  1033. SYSTEM REQUESTERS
  1034.         When a system requester appears from the editor (eg. File not
  1035. found), pressing any key is equivelant to clicking on cancel.
  1036.  
  1037. CHAPTER 3: MACRO ASSEMBLER
  1038.  
  1039. INTRODUCTION
  1040.      GenAM is a powerful,  fast,  full  specification  assembler,
  1041. available  instantly  from within the editor or as a  stand  alone
  1042. program.  It  converts the text typed or loaded into  the  editor,
  1043. optionally  together  with the files read from the  disk,  into  a
  1044. binary file suitable for immediate execution or linking, or into a
  1045. memory image for immediate execution from the editor.
  1046.  
  1047. INVOKING THE ASSEMBLER
  1048.  
  1049. FROM THE EDITOR
  1050.      The  assembler  is  invoked from the editor  by  clicking  on
  1051. Assemble from the Program menu,  or by pressing (AMIGA)-A.  A dialogue
  1052. box will appear which looks like this (almost);
  1053.  
  1054. |------------------------------------------------|
  1055. | Program type   Executable    Linkable          |
  1056. | Symbols case   Dependant     Independant       |
  1057. | Debug info     None    Normal   Exports        |
  1058. | List           None  Screen  Printer  Disk     |
  1059. | Assembly       Fast          Slower            |
  1060. | Output to      None          Memory            |
  1061. |       ______________________________________   |
  1062. | Disk |______________________________________|  |
  1063. |                Assembly options                |
  1064. | Cancel                        Assemble         |
  1065. | _______________________________________________|
  1066.  
  1067.      PROGRAM  TYPE This lets you select between executable or
  1068. linkable format  output.  The differences between these  are  detailed
  1069. later.
  1070.  
  1071.      SYMBOLS  CASE  This lets you select whether labels  are  case
  1072. dependant or not. If case Dependant is selected then Test and test
  1073. would  be different labels,  if the case Independant  is  selected
  1074. then they would be the same.
  1075.  
  1076.      DEBUG  INFO  If  you wish to debug your  program  using  your
  1077. original  symbols you can select Normal or Extended  debug  modes.
  1078.  
  1079.      LIST  selecting Printer will divert the assembly listing to the
  1080. PRT: device, or selecting Disk will send the listing to a
  1081. file based on the source filename, but with the extension .LST.
  1082.  
  1083.      ASSEMBLER  Normally this option should be left as fast selected,
  1084. but if the assembler runs out of memory select slower. Selecting
  1085. Slower forces the assembler to use little memory as possible thus
  1086. slowing down things like reading include files.
  1087.  
  1088.      OUTPUT TO This lets you select where the output file is to be
  1089. created. None means it is 'thrown away', ideal for syntax checking
  1090. a program;  Memory means it is assemble into a buffer allowing  it
  1091. to be run or debugged instantly form the editor without having  to
  1092. create  a  disk  file:  Disk means a file  will  be  created.  The
  1093. selection  of the name of this file can be left to the  assembler,
  1094. using rules described shortly.
  1095.      The  first  two options may be specified in the  source  file
  1096. using the OPT directive.
  1097.      Having selected your required options you should click on the
  1098. Assemble  button (or press Return) to start the assembly.  At  the
  1099. end of assembly you should press any key to return to the  editor.
  1100. If any errors occurred the cursor will be positioned on the  first
  1101. offending line.
  1102.  
  1103. STAND ALONE ASSEMBLER
  1104.  
  1105. COMMAND LINE FORMAT
  1106.      The assembler, Genim2, may by invoked directly from the CLI.
  1107. The command line should be the form:
  1108.  
  1109. GenIm2   mainfile    <-options>  [-options]
  1110.  
  1111.      The  mainfile  should  be  the name  of  the  file  requiring
  1112. assembly and if no extension is specified defaults to ,S.  Options
  1113. should  follow  this  donated by a -  sign  then  an  alphabetical
  1114. character.   Allowed   options  are  shown  below  together   with
  1115. equivalent OPT directives :
  1116.  
  1117.      B    no binary file should be created
  1118.  
  1119.      C    case insensitive labels (OPT C-)
  1120.  
  1121.      D    debug (OPT D+)
  1122.  
  1123.      I    specify include directory (follow immediatly with path)
  1124.  
  1125.      L    linkable code (OPT L+)
  1126.  
  1127.      M    use slow(low memory) assembly mode. See above. Not the
  1128.           same as OPT m+
  1129.  
  1130.      O    specify output filename (follows immediately after O)
  1131.  
  1132.      P    specify  listing  filename  (should  follow  immediately
  1133.           after P) defaults to source filename with extension .LST
  1134.  
  1135.      Q    pause for key press after assembly
  1136.  
  1137.      T    specifies the tab setting for listing. For example -T10
  1138.           uses a tab setting of 10.
  1139.  
  1140.      X    used when generating linkable code to export only the
  1141.           exported (XDEFed) symbols (OPT X+)
  1142.  
  1143.      NOTE: The options used by GenIm2 are rather differant to those
  1144. used in DEVPAC version 1 but the same as DEVPAC version 2.
  1145.  
  1146.         The default is to create an executable binary file with  the
  1147. name based on the source file and output file type,  no  listing,
  1148. with no case sensitive labels. For example,
  1149.  
  1150. genim2    test  -b
  1151.  
  1152. assembles test.s with no binary output file
  1153.  
  1154. genim2    test  -oram:test -p -iminc/
  1155.  
  1156. assembles test.s into a binary file ram:test.prg and a listing  file
  1157. to test.lst, with an include directory of myinc.
  1158.  
  1159. genim2    test  -ldppprt:
  1160.  
  1161. assembles  test.s into linkable code with debug and a  listing
  1162. to  the printer as set using the Amiga Preferances tool.
  1163.  
  1164. OUTPUT FILENAME
  1165.      GenAM  has  certain rules regarding the  calculation  of  the
  1166. output filename, using a combination of that specified at assembly
  1167. time  (either in the Disk: string gadget in the requester) or
  1168. using the -O option on the command line) and the Output directive:
  1169.      If an output filename is explicitly given at assembly time then:
  1170.      name = explicit filename
  1171.  
  1172. else:
  1173.      if the Output directive has not been used then
  1174.           name = source filename without an extension or .O
  1175.      else if the Output directive specifies an extension then
  1176.           name = source filename + extension in Output
  1177.      else
  1178.           name = name in Output
  1179.  
  1180. ASSEMBLY PROCESS
  1181.      GenAM is a two-pass assembler; during the first pass it scans
  1182. all  the text in memory and from disk if required,  building up  a
  1183. symbol  table.  If  syntax  errors are found  on  the  first  pass
  1184. assembly these will be reported and assembly will stop at the  end
  1185. of  the  first  pass,   otherwise,  during  the  second  pass  the
  1186. instructions are converted into bytes,  a listing may be  produced
  1187. if required and a binary file can be created on the  disk.  During
  1188. the  second  pass any further errors and warnings will  be  shown,
  1189. together with a full listing and symbol table if required.
  1190.      During assembly, any screen output can be paused by holding down
  1191. the right mouse button or, when using the stand alone assembler, by
  1192. pressing  any key (pressing (RETURN) will  resume it).  Assembly  may
  1193. be  aborted  by pressing Ctrl-C, although doing so will make any
  1194. binary file being created  invalid  as  it  will be incomplete  and
  1195. should  not  be executed.
  1196.  
  1197. ASSEMBLY TO MEMORY
  1198.         To reduce development time GenAM can assemble  programs  to
  1199. memory, allowing immediate execution or debugging from the editor.
  1200.         A  program running from memory is just like any other  normal
  1201. AmigaDOS  program and should terminate using an RTS instruction with
  1202. the stack as the program was entered.
  1203.        Programs should be careful if they self-modify as a re-executed
  1204. program will be in its original state. The state is left as when the
  1205. program was previously executed.
  1206.        The current assembly options can be made the default on re-
  1207. loading the editor if Save Preferences is used.
  1208.  
  1209. BINARY FILE TYPES
  1210.      There are two types of binary files which may be produced  by
  1211. GenAM, for different types of applications. They are distinguished
  1212. by the extension on the filename:
  1213.      If there is no extension then this is a directly executable file,
  1214. or if the extension is .o or .obj then this is an AmigaDOS linkable
  1215. file.
  1216.      Actually there are two sorts of executable files; those that are
  1217. designed to be run from the CLI and those that are designed to be run
  1218. from workbench. The differance is in the code that is part of the
  1219. program; the assembler cannot tell the differance. This is described
  1220. later.
  1221.      .o files cannot be run immediatly, but have to be read into a
  1222. linker, usually with other sections, and are known as linkable object
  1223. modules.
  1224.  
  1225. TYPES OF CODE
  1226.     Unlike  most 8-bit operating systems,  but like  most  16-bit
  1227. systems,  an executable program under AmigaDOS will not be loaded at
  1228. a  particular  address  but,  instead,  be loaded  at  an  address
  1229. depending on the exact free memory configuration at that time.
  1230.      To get around the problem of absolute addressing the ST  file
  1231. format includes relocation information allowing GEMDOS to relocate
  1232. the  program  after it has loaded it but before  running  it.  For
  1233. example the following program segment:
  1234.  
  1235.                move.l #string, a0
  1236.                .
  1237.                .
  1238.                .
  1239.      string    dc.b   'Press any key',0
  1240.  
  1241. places the absolute address of string into a register, even though
  1242. at  assembly  time the real address of string cannot  possibly  be
  1243. known.  Generally  the programmer may treat addresses as  absolute
  1244. even though the real addresses will not be known to him, while the
  1245. assembler  (or  linker) will look after the  necessary  relocation
  1246. information.
  1247.     NOTE: For certain programs, normally games or cross machine
  1248. development an absolute address may be required,  for this  reason
  1249. the ORG directive is supported.
  1250.  
  1251. The syntax of the assembler will now be described.
  1252.  
  1253. ASSEMBLER STATEMENT FORMAT
  1254.      Each  line  that is to be processed by the  assembler  should
  1255. have the following format;
  1256.  
  1257.      Label     Mnemonic       Operand(s)          Comment
  1258.      Start     move.l         d0,(a0)+            store the result
  1259.  
  1260.      Exceptions  to  this  are  comment  lines,  which  are  lines
  1261. starting with an asterisk or semi-colon,  and blank  lines,  which
  1262. are  ignored.  Each field has to be separated from the  others  by
  1263. white space - any number or mixture of space and tab characters.
  1264.  
  1265. LABEL FIELD
  1266.      The label should normally start at line 1,  but if a label is
  1267. required  to start at another position then it should be  followed
  1268. immediately   by  a  colon  (:).   Labels  are  allowed   on   all
  1269. instructions, but are prohibited on some assembler directives, and
  1270. absolutely  required  on  others.  A  label  may  start  with  the
  1271. characters A-Z,  a-z,  or underline (_),  and may continue with  a
  1272. similar  set together with the addition of the digits 0-9 and  the
  1273. period (.).
  1274.      Labels  starting with a period are  local  labels,  described
  1275. later. Sequances of digits terminated by a $ are also labels. Macro
  1276. names and register equate symbols may not have periods in them,
  1277. though macro names may start with a period. By default the first 127
  1278. characters of labels are significant, though this can be reduced if
  1279. required.  Labels should not be the same as register names, or the
  1280. reserved words SR, CCR or USP.
  1281.      By default labels are case-sensitive though this may be changed.
  1282.  
  1283.      Some example legal labels are ;
  1284.  
  1285. test, Test, TEST, _test, _test.end, test5, _5test
  1286.  
  1287.      Some illegal labels are;
  1288.  
  1289.      5test, _&e, test>,
  1290.  
  1291.      There  are  certain reserved symbols  in  GenST,  denoted  by
  1292. starting with two underline characters.  These are __LK,  __RS and
  1293. __G2.
  1294.  
  1295. MNEMONIC FIELDS
  1296.      The  mnemonic  field  comes after the  label  field  and  can
  1297. consist  of 68000 assembler instructions,  assembly directives  or
  1298. macro  calls.  Some  instructions  and  directives  allow  a  size
  1299. specifier,  separated from the mnemonic by a period. Allowed sizes
  1300. are .B for byte,  .W for word, .L for long and .S for short. Which
  1301. size specifiers are allowed in each case depends on the particular
  1302. instruction or directive.  GenAM is case-sensitive to mnemonic and
  1303. directive names, so Move is the same as move and the same as mOvE,
  1304. for example.
  1305.  
  1306. OPERAND FIELD
  1307.      For those instructions or directives which require  operands,
  1308. this field contains one or more parameters,  separated by  commas.
  1309. GenST is case-sensitive regarding register names so they may be in
  1310. either or mixed case.
  1311.  
  1312. COMMENT FIELD
  1313.      Any  white space not within quotes found after  the  expected
  1314. operand(s)  is  treated  as a delimiter before the  start  of  the
  1315. comment, which will be ignored by the assembler.
  1316.  
  1317. EXAMPLES OF VALID LINES
  1318.  
  1319.                move.l  d0,(a0)+         comment is here
  1320.  
  1321.      loop      TST.W       d0
  1322.  
  1323.      lonely.label
  1324.  
  1325.         rts
  1326.  
  1327. * this is a complete line of comment
  1328.  
  1329. ; and so is this
  1330.  
  1331.      indented: link A6,#-10 make room
  1332.  
  1333. a_string: dc.b 'spaces allowed in quotes' a string
  1334.  
  1335. EXPRESSIONS
  1336.      GenAm allows complex expressions and supports full  operator
  1337. precedence, parenthesis and logical operators.
  1338.      Expressions are in two types -absolute and relative - and the
  1339. distinction is important. Absolute expressions are constant values
  1340. which are known at assembly time. Relative expressions are program
  1341. addresses  which  are  not known at assembly-time  as the AmigaDOS
  1342. loader  can  put  the  program where  it  likes  in  memory.  Some
  1343. instructions and directives place restrictions on which types  are
  1344. allowed  and  some  operators cannot be used  with  certain  type-
  1345. combinations.
  1346.  
  1347. OPERATORS
  1348.      The operators available, in decreasing order of precedence, are:
  1349.      monadic minus (-) and plus (+)
  1350.      bitwise not (~)
  1351.      shift left (<<) and shift right (>>)
  1352.      bitwise And (&), Or (!), and Xor (^)
  1353.      multiply (*) and divide (/)
  1354.      addition (+) and subtraction (-)
  1355.      equality (=), less than (<), greater than (>)
  1356.  
  1357.      The comparison operators are signed and return 0 if false  or
  1358. -1  ($FFFFFFFF) if true.  The shift operators take the  left  hand
  1359. operand and shift it the number of bits in the right hand  operand
  1360. and vacated bits are filled with zeros.
  1361.  
  1362.      This precedence can be overridden by the parentheses ( and ).
  1363. With operators of equal precedence, expressions are evaluated from
  1364. left-to-right.  Spaces  in  expressions (other than  those  within
  1365. quotes  as ASCII constants) are not allowed as they are  taken  as
  1366. the separator to the comment.
  1367.  
  1368.      All expression evaluation is done using 32-bit signed-integer
  1369. arithmetic, with no checking of overflow.
  1370.  
  1371. NUMBERS
  1372.      Absolute numbers may be in various forms;
  1373.  
  1374.           decimal constants, e.g. 1029
  1375.           hexadecimal constants, e.g. $12f
  1376.           octal constants, e.g. @730
  1377.           binary constants, e.g. %1100010
  1378.           character constants, e.g. 'X'
  1379.  
  1380.      $ is used to denote hex numbers,  % for binary,  @ for  octal
  1381. and single ' or double quotes " for character constants.
  1382.  
  1383. CHARACTER CONSTANTS
  1384.      Whichever  quote is used to mark the start of a  string  must
  1385. also  be used to denote its end and quotes themselves may be  used
  1386. in  strings delimited with the same quote character by  having  it
  1387. occur  twice.  Character  constants can be upto  4  characters  in
  1388. length and evaluate to right-justified longs with null-padding  if
  1389. required.  For example, her are some character constants and their
  1390. ASCII and hex values:
  1391.  
  1392.      "Q"       Q              $00000051
  1393.      "hi"      hi             $00006869
  1394.      "Test"    test           $54657374
  1395.      "it's"    it's           $6974277C
  1396.      'it''s'   it's           $6974277C
  1397.  
  1398.      Strings  used  in DC.B statements follow  slightly  different
  1399. justification rules, detailed with the directive later.
  1400.  
  1401.      Symbols  used  in  expressions will  be  either  relative  or
  1402. absolute,  depending on how they were defined.  Labels within  the
  1403. source  will  be  relative,  while those  defined  using  the  EQU
  1404. directive  will be the same type as the expression to  which  they
  1405. are equated.
  1406.      The  use of an asterisk (*) denotes the value of the  program
  1407. counter at the start of the instruction or directive and is always
  1408. a relative quantity.
  1409.  
  1410. ALLOWED TYPE COMBINATIONS
  1411.      The  table below summarises for each operator the results  of
  1412. the various type combinations of parameter an d which combinations
  1413. are  not allowed.  An R denotes a Relative result,  an  A  denotes
  1414. absolute  and a * denotes that the combination is not allowed  and
  1415. will produce an error message if attempted.
  1416.  
  1417.                     A op A   A op R   R op A   R op R
  1418. Shift operators       A        *        *         *
  1419. Bitwise operators     A        *        *         *
  1420. Multiply              A        *        *         *
  1421. Divide                A        *        *         *
  1422. Add                   A        R        R         *
  1423. Subtract              A        *        R         A
  1424. Comparisons           A        *        *         A
  1425.  
  1426. ADDRESSING MODES
  1427.      The available addressing modes are shown in the table  below.
  1428. Please   note  that  GenST  is  case-insensitive   when   scanning
  1429. addressing modes, so D0 and a3 are both valid registers.
  1430.  
  1431. FORM      MEANING                                 EXAMPLE
  1432. Dn        data register direct                    D3
  1433. An        address register direct                 A5
  1434. (An)      address register indirect               (A1)
  1435. (An)+     address reg indirect + post-increment.  (A5)+
  1436. -(An)     address reg indirect + pre-increment.   -(A0)
  1437. d(An)     address reg indirect with displacement  20(A7)
  1438. d(An,Rn.s)address register indirect with index    4(A6,D4.L)
  1439. d.W       absolute short address                  $0410.W
  1440. d.L       absolute long address                   $12000.L
  1441. d(PC)     program counter relative with offset    NEXT(PC)
  1442. d(PC,Rn.s)program counter relative with index     NEXT(PC,A2.W)
  1443. #d        immediate data                          #26
  1444.  
  1445. n         denotes register number from 0 to 7
  1446. d         denotes a number
  1447. R         denotes index register, either A or D
  1448. s         denotes size, either W or L, when omitted defaults to W
  1449.  
  1450. When  using address register indirect with index the  displacement
  1451. may be omitted, for example
  1452.  
  1453. move.l    (a3,d2.l),d0
  1454.  
  1455. will assemble to the same as
  1456.  
  1457. move.l    0(a3,d2.l),d0
  1458.  
  1459. SPECIAL ADDRESSING MODES
  1460.  
  1461. CCR       condition code register
  1462. SR        status register
  1463. USP       user stack pointer
  1464.  
  1465. In  addition to the above,  SP can be used in place of A7  in  any
  1466. addressing mode, e.g. 4(SP,D3.W)
  1467.      The data and address registers can also be denoted by use  of
  1468. the reserved symbols R0 through R15. R0 to R7 are equivalent to D0
  1469. to D7,  R8 to R15 are equivalent to A0 to A7. This is included for
  1470. compatibility with other assemblers.
  1471.  
  1472. LOCAL LABELS
  1473.      GenAm supports local labels,  that is labels which are  local
  1474. to  a  particular area of the source code.  These are  denoted  by
  1475. starting  with  a period and are attached to  the  last  non-local
  1476. label, for example;
  1477.  
  1478. lenl      move.l    4(sp),a0
  1479. .loop     tst.b     (a0)+
  1480.           bne.s     .loop
  1481.           rts
  1482. len2      move.l    4(sp),a0
  1483. .loop     tst.b     -(a0)
  1484.           bne.s     .loop
  1485.           rts
  1486.  
  1487.     There  are  two labels called .loop in this code segment but the
  1488. first is attached to lenl, the second to len2.
  1489.     If you wish to use global labels starting with a dot you may use
  1490. OPT U+ to allow this and make the underline character introduce local
  1491. labels.
  1492.     The local labels .W and .L are not allowed to avoid confusion with
  1493. the absolute addressing syntax.
  1494.  
  1495. AMIGA MACRO ASSEMBLER LOCAL LABELS
  1496.     You may also use strings of decimal digits terminated by the $
  1497. sign as local labels. This facility has been provided for
  1498. compatability with other assemblers; we reccomend the use of form
  1499. shown above as this makes programs much more readable.
  1500.  
  1501. SYMBOLS AND PERIODS
  1502.      Symbols which include the period character can cause problems
  1503. with GenAm due to absolute short addressing.
  1504.      The Motorola standard way of denoting absolute short addresses
  1505. causes  problems as periods are considered to be part of a  label,
  1506. best illustrated by an example:
  1507.  
  1508.           move.l    vector.w,d0
  1509.  
  1510. where vector is an absolute value, such as a system variable. This
  1511. would  generate an undefined label error,  as the label  would  be
  1512. scanned as vector.w.  To get around this,  the expression, in this
  1513. case a symbol, may be enclosed in brackets, e.g.
  1514.  
  1515.           move.l    (vector).w,d0
  1516.  
  1517. though the period mat still be used after numeric expressions, e.g.
  1518.  
  1519.           move.l    $4.w,d0
  1520.  
  1521.     NOTE: GenAm version 1 also supported the use of \  instead  of  a
  1522. period to denote short word addressing and this is still supported
  1523. in this version,  but this is not recommended due to the potential
  1524. for \W and \L to be mistaken for macro parameters.
  1525.  
  1526. INSTRUCTION SET
  1527.  
  1528. WORD ALIGNMENT
  1529.      All  instructions  with the exception of DC.B  and  DS.B  are
  1530. always  assembled on a word boundary.  Should you require  a  DC.B
  1531. explicitly on a word boundary,  the EVEN directive should be  used
  1532. before  it.  Although all instructions that require it  are  word-
  1533. aligned,  labels with nothing following them are not word  aligned
  1534. and can have odd values. This is best illustrated by an example;
  1535.  
  1536.           nop                 this is always word aligned
  1537.           dc.b      'odd'
  1538. start
  1539.           tst.l     (a0)+
  1540.           bne.s     start
  1541.  
  1542. The  above  code would not produce the required  result  as  start
  1543. would have an odd value.  To help in finding such an  instructions
  1544. the assembler will produce an error if it finds an odd destination
  1545. in a BSR or BRA operand. Note that such checks are not made on any
  1546. other  instructions,  so it is recommended that you  precede  such
  1547. labels  with  EVEN  directives if you require  them  to  be  word-
  1548. aligned.  A  common error is deliberately not to do this,  as  you
  1549. know  the preceding string is an even number of  bytes  long.  All
  1550. will be well until the day you change the string...
  1551.  
  1552. INSTRUCTION SET EXTENSIONS
  1553.      The  complete 68000 instruction set is supported and  certain
  1554. shorthands are automatically accepted,  detailed below. A complete
  1555. description of the instruction set including syntax and addressing
  1556. modes can be found in any 68000 reference guide or in the supplied
  1557. pocket guide.
  1558.  
  1559. CONDITION CODE
  1560. The altenate condition codes HS and LO are supported in Bcc, DBcc
  1561. and Scc instructions, equivalent to CC and CS, respectively.
  1562.  
  1563. BRANCH INSTRUCTIONS
  1564.      To force a short branch use Bcc.B or Bcc.S,  to force a  word
  1565. branch  use  Bcc.W or to leave the optimiser  use  Bcc.  Bcc.L  is
  1566. supported for compatibility with GenAm 1 with a warning as it  is,
  1567. strictly  speaking,   a  68020  instruction.   A  BRA.S  to   the
  1568. immediately following instruction is not allowed and is converted,
  1569. with  a warning,  to a NOP.  A BSR.S to the immediately  following
  1570. instruction is not allowed and will produce an error.
  1571.  
  1572. BTST INSTRUCTION
  1573.      BTST is unique among bit-test instructions in supporting  PC-
  1574. relative addressing modes.
  1575.  
  1576. CLR INSTRUCTION
  1577.      CLR An is not allowed,  use SUB.L An,An instead (though  note
  1578. that the flags are not affected).
  1579.  
  1580. CMP INSTRUCTION
  1581.      If  the source is immediate then CMPI is used,  else  if  the
  1582. destination is an address register then CMPA is used, else if both
  1583. addressing modes are post-incremented then CMPM is used.
  1584.  
  1585. DBcc INSTRUCTION
  1586.      DBRA is accepted as an equivalent to DBF.
  1587.  
  1588. ILLEGAL INSTRUCTION
  1589.      This generates the op-cope word $4AFC.
  1590.  
  1591. LINK INSTRUCTION
  1592.      If the displacement is positive or not even a warning is given.
  1593.  
  1594. MOVE FROM CCR INSTRUCTION
  1595.      This  is a 68010 and upwards instruction,  converted  with  a
  1596. warning to MOVE from SR.
  1597.  
  1598. MOVEQ INSTRUCTION
  1599.      If the data is in the range 128-255 inclusive a warning  will
  1600. be  given.  It  may be disabled by specifying a long size  on  the
  1601. instruction.
  1602.  
  1603. ASSEMBLER DIRECTIVES
  1604.      Certain  pseudo-mnemonics  are  recognised  by  GenIm.  These
  1605. assembler  directives,  as  they are called,  are  not  (normally)
  1606. decoded into opcodes, but instead direct the assembler time. These
  1607. actions have the effect of changing the object code  produced,  or
  1608. the  format of the listing.  Directives are scanned  exactly  like
  1609. executable  instructions and some may be preceded by a label  (for
  1610. some  it is obligatory) and may be followed by a comment.  If  you
  1611. put  a  label on a directive for which it  is  not  relevant,  the
  1612. result  will  be undefined but will usually result  in  the  label
  1613. being ignored.
  1614.      Each  directive will now be described in  turn.  Please  note
  1615. that  the case of a directive name is not important,  though  they
  1616. generally are shown in upper case. The use of angled brackets ( <> )
  1617. in descriptions denote optional  items,  ellipses  (  ...  )
  1618. denote repeated items.
  1619.  
  1620. ASSEMBLY CONTROL
  1621.  
  1622. END
  1623.      This directive signals that no more text is to be examined on
  1624. the current pass of the assembler. It is not obligatory.
  1625.  
  1626. INCLUDE filename
  1627.      This directive will cause source code to be taken from a file
  1628. on  disk  and assembled exactly as though it were present  in  the
  1629. text.  The  directive  must be followed by a  filename  in  normal
  1630. AmigaDOS format.
  1631.      If the filename has a space in it the name should be enclosed
  1632. in  single  or double quotes.  A drive  specifier,  directory  and
  1633. extension may be included as required, e.g.
  1634.  
  1635.      include b:constants/header.s
  1636.  
  1637.      Include  directives may be nested as deeply as memory  allows
  1638. and  if any error occurs when trying to open the file or read  it,
  1639. assembly will be aborted with a fatal error.
  1640.      If  no  drive or path name is specified,  that  of  the  main
  1641. source file will be used when trying to open the file.
  1642.  
  1643.      NOTE: The more memory the better, GenAm will read the whole of the
  1644. file in one go if it can and not bother to re-read the file during
  1645. pass 2.
  1646.  
  1647. INCDIR "directory"<,"directory" etc.>
  1648.      This directive specifies a list of directories that the include
  1649. directive should search in order to find each file. GenIm will append
  1650. each string onto the front of that given in the include directive. This
  1651. directive must appear before any include directives.
  1652.  
  1653. INCBIN    filename
  1654.      This  takes a given binary file and  includes  it,  verbatim,
  1655. into the output file.  Suggested uses include screen data,  sprite
  1656. date and ASCII files.
  1657.      The included data is forced to an even boundary and a single null
  1658. character is appended if the file is an odd number of bytes in length.
  1659.  
  1660. OPT       option <,option>...
  1661.      This  allows  control over various options within  GenAm  and
  1662. each one is denoted by a single character normally followed by a +
  1663. or - sign. Multiple options may be specified, separated by commas.
  1664. The allowed options are:
  1665.  
  1666. OPTION A - AUTOMATIC PC MODE ADDRESSING
  1667.      If OPT A+ is specified then GenAm will use PC mode addressing
  1668. where possible. For example:
  1669.  
  1670.           move.l    int_in,d0
  1671.  
  1672. will automatically be transformed into
  1673.  
  1674.           move.l    int_in(pc),d0
  1675.  
  1676. when assembled.
  1677.  
  1678.      Use of this option can significally reduce program size and
  1679. running time without a lot of extra typing. Please note however thit
  1680. it does not guarentee that the code generated will be position
  1681. independant.
  1682.      If you need to over-ride the automatic use of PC mode then use
  1683. the form (expression).l in a similar manner to that of short word
  1684. addressing as described above under labels and periods.
  1685.      So the example above could be forced to use absolutre addressing
  1686. by using the following:
  1687.  
  1688. move.l     (int_in).l,d0
  1689.  
  1690.     The default is A- when no such transformations are performed.
  1691.  
  1692. OPTION C - CASE SENSITIVITY AND SIGNIFICANCE.
  1693.      By default,  GenAm is sensitive to label case and labels  are
  1694. significant to 127 characters.  This can be overridden , using  C-
  1695. for case-sensitivity or C+ for case-insensitivity. The significan
  1696. ce  may be specified by specifying a decimal number between the  C
  1697. and  the sign,  for example C16+ denotes case  insensitive  labels
  1698. with  16 character significance.  This option may be used  at  any
  1699. time  in  a  program but normally only makes  sense  at  the  very
  1700. beginning of a source file.
  1701.  
  1702. OPTION D - DEBUGGING INFORMATION
  1703.      The  AmigaDOS  binary file format supports the inclusion of a
  1704. symbol hunk, which may be read by debuggers such  as
  1705. MONAm and  can be extremely useful when  debugging  programs.  By
  1706. default  this is switched off but it may be activated with D+  and
  1707. de-activated with D-. Normally all the relative symbols are included
  1708. in the file, but if OPT X+ is used in linkable mode then only the
  1709. exported (XDEF) symbols will be included.
  1710.  
  1711. OPTION L - LINKER MODE.
  1712.      The  default for GenAM is to produce executable code  but  L+
  1713. will  make it produce AmigaDOS linkable code, or L- will make it
  1714. revert to executable. This directive must be the very first line, in
  1715. the first text file.
  1716.  
  1717. OPTION M - MACRO EXPANSIONS.
  1718.      When an assembly listing is produced,  macro calls are  shown
  1719. in  the same form as in the source.  If you wish the  instructions
  1720. within  macros to be listed,  use M+,  while M- will  disable  the
  1721. option. You can use this directive as often as required. M- is the
  1722. default.
  1723.  
  1724. OPTION O - OPTIMISING.
  1725.      GenAM is capable of optimising certain statements to  faster
  1726. and  smaller versions.  By default all optimising is off but  each
  1727. type  can  be  abled and disabled as  required.  This  option  has
  1728. several forms:
  1729.  
  1730. OPT  O1+       will optimise backward branches to short if  within
  1731.                range, can be disabled with O1-.
  1732.  
  1733. OPT  O2+       will   optimise  address  register  indirect   with
  1734.                displacement addressing modes to addresss  register
  1735.                indirect,  if the displacemant evalues to zero, and
  1736.                can be disabled with O2-. For example,
  1737.  
  1738.           move.l   next(a0),d3
  1739.  
  1740. will be optimised to
  1741.  
  1742.           move.l   (a0),d3
  1743.  
  1744. If the value of next is zero.
  1745.  
  1746. OPT O+         will turn all optimising on.
  1747.  
  1748. OPT O-         will turn all optimising off.
  1749.  
  1750. OPT O1-, OPT O2-    will disable the relevant optimisation.
  1751.  
  1752. OPT OW-        will disable the warning messages generated by each
  1753.                optimisation, OW+ will enable them.
  1754.  
  1755.      If any optimising has been done during an assembly the number
  1756. of optimisations made and bytes saved will be shown at the end  of
  1757. assembly.
  1758.  
  1759. OPTION P - POSITION INDEPENDANT CHECKS.
  1760.      With  this  enabled with P+ GenAM will check  that  all  code
  1761. generated is position-independant,  generating errors on any lines
  1762. which require relocation.  It can be disabled with P- and defaults
  1763. to off.
  1764.  
  1765. OPTION S - SYMBOL TABLE
  1766.      When  a listing is turned on a symbol table will be  produced
  1767. at the end.  If you wish to change this S- will disable it,  while
  1768. S+ will re-enable it.  If you use this directive ore than once  the
  1769. last one will be taken into account.
  1770.  
  1771. OPTION T - TYPE CHECKING.
  1772.      GenST  can  often spot programming errors as  it  checks  the
  1773. types of certain expressions.  For some applications or styles  of
  1774. programming  this can be more of a hindrance than a  help.  So  T-
  1775. will  turn checks off.  T+ turning them back on.  For example  the
  1776. program segment
  1777.  
  1778.      main      bsr            initialise
  1779.                lea            main(a6),a0
  1780.                move.l         (main).w,a0
  1781.  
  1782.      will  normally  produce  an  error  as  main  is  a  relative
  1783. expression  where as the assembler expects an absolute  expression
  1784. in both cases.  However if this code is designed to run on another
  1785. 68000  machine this may be perfectly valid,  so the type  checking
  1786. should be disabled.
  1787.  
  1788. OPTION U - UNDERLINES FOR LOCAL LABELS
  1789.      Option U+ changes the character that introduces local tables to
  1790. be underline (_) rather than dat (.). Usa this if you need to use
  1791. labels beginning with dot for non-local labels.
  1792.  
  1793. OPTION W - WARNINGS
  1794.      If  you wish to disable the warnings that GenST can  produce,
  1795. you can do so with W-.  To re-enable them use W+.  This  directive
  1796. can be used as often as required.
  1797.  
  1798. OPTION X - EXPORTDEBUG
  1799.      This is a special version of option D which only outputs the
  1800. exported (XDEFed) symbols when producing linkable code. See the D
  1801. option above.
  1802.  
  1803. OPTION SUMMARY
  1804.      The  defaults  are  shown  in  brackets  after  each  options
  1805. description;
  1806.  
  1807. A    automatic PC mode addressing
  1808. C    case-sensitivity and significance (C127+)
  1809. D    include debugging info, (D-)
  1810. L-   produce executable code (default)
  1811. L+   produce GST linkable code
  1812. M    expand macros enlisting (M+)
  1813. O    optimising control (O-)
  1814. P    position independant code checks (P-)
  1815. S    symbol table listing
  1816. T    type checking (T+)
  1817. W    warning control (W+)
  1818. X    export debug (X-)
  1819.  
  1820. For example -   opt  m+,s+,w-
  1821.  
  1822. will  turn macro expansion on,  enable the symbol table  list  and
  1823. turn warnings off.
  1824.  
  1825. <label> EVEN
  1826.      This  directive  will force the program counter to  be  even,
  1827. i.e.   word  aligned.   As  GenAM automatically  word-aligns  all
  1828. instructions (except DC.Bs and DS.Bs).  It should not be  required
  1829. very often but can be useful for ensuring buffers and strings  are
  1830. word-aligned when required
  1831.  
  1832. CNOP      offset,alignment
  1833. This  directive  will align the program counter  using  the  given
  1834. offset  and alignment.  An alignment of 2 means  word-aligned,  an
  1835. alignment of 4 means long-word-aligned and so on. The alignment is
  1836. relative to the start of the current section. For example,
  1837.  
  1838.           cnop   1,4
  1839.  
  1840. aligns  the  program  counter  a  byte  past  the  next  long-word
  1841. boundary.
  1842.  
  1843.      Some parts of the Amiga operating system require certain items to
  1844. be longword aligned and this can be achieved with:
  1845.  
  1846.           cnop   0,4
  1847.  
  1848.      The start of a program and of each section is always guaranteed
  1849. to be longword aligned.
  1850.  
  1851. <label>   DC.B      expression<,expression> ...
  1852. <label>   DC.W      expression<,expression> ...
  1853. <label>   DC.L      expression<,expression> ...
  1854.  
  1855.      These  directives define constants in memory.  They may  have
  1856. one or more operands,  separated by commas.  The constants will be
  1857. aligned  on  word boundaries for DC.W and DC.L no  more  than  128
  1858. bytes can be generated by a single DC directive.
  1859.      DC.B  treats  strings slightly different to those  in  normal
  1860. expressions.  While the rules described previously about quotation
  1861. marks still applies.  No padding of the bytes will occur,  and the
  1862. length of any string can be upto 128 bytes.
  1863.      Be very careful of spaces in any DC directives, as a space is
  1864. the delimiter before a comment. For example, the line
  1865.  
  1866.           dc.b      1,2,3 ,4
  1867.  
  1868. will only generate 3 bytes - the ,4 will be taken as a comment.
  1869.  
  1870. <label>   DS.B      expression
  1871. <label>   DS.W      expression
  1872. <label)   DS.L      expression
  1873.  
  1874.      These  directives  will  reserve  memory  locations  and  the
  1875. contents will be initialised to zeros. If there is a label then it
  1876. will be set to the start of the area defined,  which will be on  a
  1877. word  boundary  for  DS.W  and  DS.L  directives.   There  is   no
  1878. restriction  on the size though the larger the area the longer  it
  1879. will take to save to disk.
  1880.  
  1881.       For example, all of these lines will reserve 8 bytes of space,
  1882. in different ways :
  1883.  
  1884.           ds.b 8
  1885.           ds.w 4
  1886.           ds.l 2
  1887.  
  1888. <label>   DCB.B     number,value
  1889. <label>   DCB.W     number,value
  1890. <label>   DCB.L     number,value
  1891.  
  1892.      This directive allows constant blocks of data to be generated
  1893. of the size specified,  number specifies how many times the  value
  1894. should be repeated.
  1895.  
  1896. FAIL
  1897.      This directive will produce the error user error.  It can  be
  1898. used  for  such things as warning the programmer if  an  incorrect
  1899. number of parameters have been passed to a macro.
  1900.  
  1901. OUTPUT    filename
  1902.      This directive sets the normal output filename though can  be
  1903. overridden by specifying a filename at the start of  assembly.  If
  1904. filename starts with a period then it is used as an extension  and
  1905. the output name is built up as described previously.
  1906.  
  1907. __G2      (reserved symbol)
  1908.      This is a reserved symbol that can be used to detect  whether
  1909. GenST is being used to assemble a file using the IFD  conditional.
  1910. The  value of this symbol depends on the version of the  assembler
  1911. and is always absolute.
  1912.  
  1913. REPEAT LOOPS
  1914.      It  is  often  useful  to  be able  to  repeat  one  or  more
  1915. instructions  a  particular number of times and  the  repeat  loop
  1916. construct allows this.
  1917.  
  1918. <label>   REPT      expression
  1919.           ENDR
  1920.  
  1921.      Lines to be repeated should be enclosed within REPT and  ENDR
  1922. directives  and will be repeated the number of times specified  in
  1923. the expression. If the expression is zero or negative then no code
  1924. will be generated.  It is not possible to nest repeat  loops.  For
  1925. example
  1926.  
  1927.           REPT      512/4             copy a sector quickly
  1928.           move.l    (a0)+,(a1)+
  1929.           ENDR
  1930.  
  1931.      NOTE: Program  labels should not be define within repeat  loops
  1932. to prevent label defined twice errors.
  1933.  
  1934. LISTING CONTROL
  1935.  
  1936. LIST
  1937.      This  will  turn the assembly listing on during  pass  2,  to
  1938. whatever  device was selected at the start of the assembly (or  to
  1939. the  screen of None was initially chosen).  All  subsequent  lines
  1940. will be listed until an END directive is reached,  the end of  the
  1941. text is reached, or a Nolist directive is encountered.
  1942.      Greater  control  over  listing sections of  program  can  be
  1943. achieved using LIST+ or LIST- directives. A counter is maintained,
  1944. the state of which dictates whether listing is on or off.  A LIST+
  1945. directive  adds one to the counter and a LIST- subtracts  one.  If
  1946. the  counter  is zero or positive then listing is  on,  if  it  is
  1947. negative  then listing is off.  The default starting value  is  -1
  1948. (i.e.  listing  off)  unless  a  listing  is  specified  when  the
  1949. assembler was invoked,  when it is set to zero. This system allows
  1950. a  considerable  degree of control over listing  particularly  for
  1951. include  files.  The normal LIST directive sets the counter to  0,
  1952. NOLIST sets it to -1.
  1953.  
  1954. NOLIST
  1955.      This will turn off any listing during pass 2.
  1956.  
  1957.      When  a listing is requested onto a printer or to  disk,  the
  1958. output is formatted into pages,  with a header at the top of every
  1959. page.  The header itself consists of a line containing the program
  1960. title, date, time and page number, then a line showing the program
  1961. title,  then a line showing the sub-title,  then a blank line. The
  1962. date  format  will be printed in the  form  DD/MM/YY,  unless  the
  1963. assembler  is  running  on a US Atari ST,  then  it  is  MM/DD/YY.
  1964. Between  pages  a  form-feed character (ASCII  FF,  value  12)  is
  1965. issued.
  1966.  
  1967. PLEN      expression
  1968.      This  will  set the page length of the assembly  listing  and
  1969. defaults to 60. The expression must be between 12 and 255.
  1970.  
  1971. LLEN      expression
  1972.      This  will  set the line width of the  assembly  listing  and
  1973. defaults  to 132.  The value of the expression must be between  38
  1974. and 255.
  1975.  
  1976. TTL       string
  1977.      This  will set the title printed at the top of each  page  to
  1978. the  given string,  which may be enclosed in  single  quotes.  The
  1979. first TTL directive will set the title of the first printed  page.
  1980. If  no  title is specified the current include file name  will  be
  1981. used.
  1982.  
  1983. SUBTTL    string
  1984.      Sets  the  subtitle printed at the top of each  page  to  the
  1985. given string,  which may be enclosed in single quotes.  The  first
  1986. such directive will set the sub-title of the first printed page.
  1987.  
  1988. SPC       expression
  1989.      This  will  output  the number of blank lines  given  in  the
  1990. expression in the assembly listing, if active.
  1991.  
  1992. PAGE
  1993.      Causes a new page in the listing to be started.
  1994.  
  1995. LISTCHAR  expression<,expression> ...
  1996.      This will send the characters specified to the listing device
  1997. (except  the  screen)  and is intended for doing  things  such  as
  1998. setting  condensed mode on printers.  For example,  on Epsons  and
  1999. compatibles the line
  2000.  
  2001.           listchar  15
  2002.  
  2003. will set the printer to 132-column mode.
  2004.  
  2005. FORMAT    parameter<,parameter> ...
  2006.      This allows exact control over the listed format of a line of
  2007. source  code.  Each parameter controls a field in the listing  and
  2008. must consist of a digit from 0 to 2 inclusive followed by a +  (to
  2009. enable the field) or a - (to disable it):
  2010.  
  2011. 0    line number, in decimal
  2012. 1    section name/number and program counter
  2013. 2    hex data words, up to 10 words unless printer is less than 80
  2014.      characters wide, when up to three words are listed.
  2015.  
  2016. LABEL DIRECTIVES
  2017.  
  2018. label     EQU       expression
  2019.  
  2020.      This directive will set the value and type of the given label
  2021. to  the  results of the expression.  It may  not  include  forward
  2022. references,  or  external  labels.  If there is any error  in  the
  2023. expression,  the  assignment  will  not  be  made.  The  label  is
  2024. compulsory and must not be a local label.
  2025.  
  2026. label     =         expression
  2027.  
  2028. Alternate form of EQU statement
  2029.  
  2030. label     EQUR      register
  2031.  
  2032.      This  directive  allows  a data or  address  register  to  be
  2033. referred  to  by  a  user-name,  supplied as  the  label  to  this
  2034. directive.  This is known as a register equate.  A register equate
  2035. must be defined before it is used.
  2036.  
  2037. label     SET       expression
  2038.  
  2039.      This is similar to EQU,  but the assignment is only temporary
  2040. and  can  be  changed with a  subsequent  SET  directive.  Forward
  2041. references  cannot  be used in the expression.  It  is  especially
  2042. useful for counters within macros, for example, using a line
  2043.  
  2044. zcount    set       zcount+1
  2045.  
  2046. (assuming zcount is set to 0 at the start of the source).  At  the
  2047. start of pass 2 all SET labels are made undefined, so their values
  2048. will always be the same on both passes
  2049.  
  2050. label     REG       register-list
  2051.  
  2052.      This  allows  a symbol to be used to denote a  register  list
  2053. within MOVEM instructions,  reducing the likelihood of having  the
  2054. list at the start of a routine different from the list at the  end
  2055. of the routine. A label defined with REG can only be used in MOVEM
  2056. instructions.
  2057.  
  2058. <label>   RS.B      expression
  2059. <label>   RS.W      expression
  2060. <label>   RS.L      expression
  2061.  
  2062.      These  directives  let you set up lists of  constant  labels,
  2063. which is very useful for data structures and global variables  and
  2064. is best illustrated by a couple of examples
  2065.      Let's  assume you have a data structure which consists  of  a
  2066. long word,  a byte and another long word,  in that order.  To make
  2067. your code more readable and easier to update should the  structure
  2068. change, you could use lines such as:
  2069.  
  2070.           rsreset
  2071. d_next    rs.l      1
  2072. d_flag    rs.b      1
  2073. d_where   rs.l      1
  2074.  
  2075. and then you could access them with lines like
  2076.  
  2077.           move.l    d_next(a0),a1
  2078.           move.l    d_where(a0),a2
  2079.           tst.b     d_flag(a0)
  2080.  
  2081. As  another  example  let's assume you are  referencing  all  your
  2082. variables  off register A6 (as done in GenAM and MonAM) you  could
  2083. define them with lines such as
  2084.  
  2085. onstate   rs.b      1
  2086. start     rs.l      1
  2087. end       rs.l      1
  2088.  
  2089. you then could reference them with lines such as
  2090.  
  2091.           move.b    onstate(a6),d1
  2092.           move.l    start(a6),d0
  2093.           cmp.l     end(a6),d0
  2094.  
  2095.      Each such directive uses its own internal counter, which is reset
  2096. to 0 at the beginning of each pass. Every time the assembler comes
  2097. across  the directive it sets the label according to  the  current
  2098. value  (with word alignment if it is .W or .L) then increments  it
  2099. according to the size and magnitude of the directive. If the above
  2100. definitions  were  the first RS directives,  onstate would  be  0,
  2101. start would be 2 and end would be 6.
  2102.  
  2103. RSRESET
  2104.      This directive will reset the internal counter as used by the RS
  2105. directive.
  2106.  
  2107. RSSET     expression
  2108.      This allows the RS counter to be set to a particular value.
  2109.  
  2110. __RS      (reserved symbol)
  2111.      This is a reserved symbol having the current value of the RS
  2112. counter.
  2113.  
  2114. CONDITIONAL ASSEMBLY
  2115.      Conditional  assembly  allows  the  programmer  to  write   a
  2116. comprehensive  source  program  that can  cover  many  conditions.
  2117. Assembly  conditionals  may  be  specified  through  the  use   of
  2118. arguments,  in the case of macros,  and through the definition  of
  2119. symbols  in EQU or SET directives.  Variations in these  can  then
  2120. cause  assembly  of only those parts necessary for  the  specified
  2121. conditions.
  2122.      There   are  a  wide  range  of  directives  concerned   with
  2123. conditional assembly. At the start of the conditional blocks there
  2124. must  be  one of many IF directives and at the end of  each  block
  2125. there must be an ENDC directive.  Conditional blocks may be nested
  2126. up to 65535 levels.
  2127.      Labels  should not be placed on IF or ENDC directives as  the
  2128. directives will be ignored by the assembler.
  2129.  
  2130.           IFEQ      expression
  2131.           IFNE      expression
  2132.           IFGT      expression
  2133.           IFGE      expression
  2134.           IFLT      expression
  2135.           IFLE      expression
  2136.  
  2137.      These directives will evaluate the expression, compare it with
  2138. zero and then turn the conditional assembly on or off depending on
  2139. the  result.  The  conditions  correspond  exactly  to  the  68000
  2140. condition codes.  For example, if the label DEBUG had the value 1,
  2141. then with the following code,
  2142.  
  2143.           IFEQ DEBUG
  2144. logon     dc.b      'enter a command:'.0
  2145.           ENDC
  2146.           IFNE DEBUG
  2147.           opt       d+        labels please
  2148. logon     dc.b      'Yeah, gimme man:',0
  2149.           ENDC
  2150.  
  2151. the first conditional would turn assembly off as 1 is not EQ to 0,
  2152. while the second conditional would turn it on as 1 is NE to 0.
  2153.  
  2154.      NOTE: IFNE corresponds to IF in assemblers with only one
  2155. conditional directive.
  2156.      The  expressions  used in these conditional  statements  must
  2157. evaluate correctly.
  2158.  
  2159. IFD       label
  2160. IFND      label
  2161.      These  directives  allow  conditional  control  depending  on
  2162. whether a label is defined or not.  With IFD, assembly is switched
  2163. on if the label is defined, whereas with IFND assembly is switched
  2164. on  if the label is not defined.  These directives should be  used
  2165. with  care otherwise different object codes could be generated  on
  2166. pass  1 and pass 2 which will produce incorrect code and  generate
  2167. phasing errors. Both directives also work on reserved symbols.
  2168.  
  2169. IFC       'string1','string2'
  2170.      This  directive will compare two strings,  each of which  must
  2171. be surrounded  by single quotes.  If they are identical  assembly  is
  2172. switched  on,  else  it i switched off.  The  comparison  is  case
  2173. sensitive.
  2174.  
  2175. IFNC      'string1','string2'
  2176.      This directive is similar to the above, but only switches
  2177. assembly on  if  the strings are not identical.  This may at  first
  2178. appear somewhat useless, but when one or both of the parameters are
  2179. macro parameters it can b every useful, as shown in the next section.
  2180.  
  2181. ELSEIF
  2182.      This  directive toggles conditional assembly from on  to  off,
  2183. or vice versa.
  2184.  
  2185. ENDC
  2186.      This  directive  will terminate the current level  of
  2187. conditional assembly.  If  there  are more IF's then ENDC's an error
  2188. will be reported at the end of assembly.
  2189.  
  2190. IIF       expression   instruction
  2191. This  is  a  short form of the IFNE directive  allowing  a  single
  2192. instruction  or directive to be assembled conditionally.  No  ENDC
  2193. should be used with IIF directives.
  2194.  
  2195. MACRO OPERATIONS
  2196.      GenAM fully supports Motorola-style macros, which together with
  2197. conditional  assembly  allows you greatly  to  simplify  assembly-
  2198. language programming and the readability of your code.
  2199.      A macro is a way for a programmer to specify a whole sequence
  2200. of  instructions  or  directives  that  are  used  together   very
  2201. frequently. A macro is first defined, then its name can be used in
  2202. a macro call like a directive with up to 36 parameters.
  2203.  
  2204. label     MACRO
  2205.      This starts a macro definition and causes GenAM to copy all
  2206. following  lines  to  a macro buffer until an  ENDM  directive  is
  2207. encountered. Macro definitions may not be nested.
  2208.  
  2209. ENDM
  2210.      This terminates the storing of a macro definition, after a  MACRO
  2211. directive.
  2212.  
  2213. MEXIT
  2214.      This stops prematurely the current macro expansion and is best
  2215. illustrated by the INC example given later.
  2216.  
  2217. NARG      (reserved label)
  2218.      This is not a directive but a reserved symbol, Its value is  the
  2219. number  of parameters passed to the current macro,  or 0  if  used
  2220. when not within any macro.  If GenAM is in the case sensitive mode
  2221. then the name should be all upper-case.
  2222.  
  2223. MACRO PARIMETERS
  2224.      Once a macro has been defined with the Macro directive it can
  2225. be invoked by using its name as a directive,  followed by upto  36
  2226. parameters.  In the macro itself the parameters may be referred to
  2227. by  using a backslash character (\) followed by  an  alpha-numeric
  2228. (1-9,  A-Z  or  a-z)  which will be  replaced  with  the  relevant
  2229. parameter when expanded or with nothing if no parameter was given.
  2230. There  is  also the special macro parameter \0 which is  the  size
  2231. appended to the macro call and defaults to W if none is given.  If
  2232. a  macro  parameter  is  to include  spaces  or  commas  then  the
  2233. parameter should be enclosed in between < and > symbols;  in  this
  2234. case  a  >  symbol  may  be  included  within  the  parameters  by
  2235. specifying >>.
  2236.      A special form of macro expansion allows the conversion of  a
  2237. symbol to a decimal or hexadecimal sequence of digits,  using  the
  2238. syntax \<symbol> or \$<symbol>, the latter denoting hex expansion.
  2239. The symbol mast be defined and absolute at the time of expansion.
  2240.      The  parameter \@ can be useful for generating unique  labels
  2241. with each macro call and is replaced when the macro is expanded by
  2242. the  sequence  _nnn where nnn is a number which increases  by  one
  2243. with  every  macro call.  It may be expanded up to  5  digits  for
  2244. very large assemblies.
  2245.      A true \ may be included in a macro definition by specifying \\.
  2246.  
  2247.      A  macro  call  may  be  spread  over  more  than  one  line,
  2248. particularly  useful for macros with large numbers of  parameters.
  2249. This  can  be  done  by ending a macro  call  with  a  comma  then
  2250. starting  the next line with an & followed by tabs or spaces  then
  2251. the continuation of the parameters.
  2252.      In the assembly listing the default is to show just the macro
  2253. call and not the code produced by it. However, macro expansion
  2254. listings can  be  switched on and off using the OPT M  directive
  2255. described previously.
  2256.      Macro  calls may be nested as deeply as memory  permits,
  2257. allowing recursion if required.
  2258.      Macro  names are stored in a separate symbol table to normal
  2259. symbols so will not clash with similarly named routines,  and  may
  2260. start with a period.
  2261.  
  2262. MACRO EXAMPLES
  2263.  
  2264. EXAMPLE 1 - CALLING A LIBRARY
  2265.      As the first example, a common way of calling an Amiga library
  2266. routine is:
  2267.  
  2268.         save register a6
  2269.         load a6 from a library pointer
  2270.         do a jsr with offset
  2271.         restore a6
  2272.  
  2273.      A macro to follow the above specifications could be:
  2274.  
  2275. call_lib MACRO
  2276.          move.l   a6,-(sp)
  2277.          move.l   \2,a6       get lib pointer
  2278.          jsr      _LVO\l(a6)  call it
  2279.          move.l   (sp)+,a6    restore
  2280.          ENDM
  2281.  
  2282.      The directives are in capitals only to make them stand  out:  they
  2283. don't have to be.  If you wanted to call this macro to use the DOS
  2284. function Output the code would be:
  2285.  
  2286. call_lib Output,_DOSbase
  2287.  
  2288.      When this macro call is expanded, \1 is replaced with Output and
  2289. \2 is replaced with _DOSbase. \0, if it occurred in the macro, would
  2290. be W as no size  is given on the call.  So the above call would be
  2291. assembled as:
  2292.  
  2293.         move.l  a6,-(sp)
  2294.         move.l  _DOSbase,a6     get lib pointer
  2295.         jsr     _LVOOutput(a6)  call it
  2296.         move.l  (sp)+,a6        restore a6
  2297.  
  2298. EXAMPLE 2 - AN INC INSTRUCTION
  2299.      The 68000 does not have the INC instruction like other
  2300. processors but the same effect can be achieved using an ADDQ #1
  2301. instruction. A macro may be used to do this, like so:
  2302.  
  2303. inc       MACRO
  2304.           IFC       '','\1'
  2305.           fail      missing parameter!
  2306.           MEXIT
  2307.           ENDC
  2308.           addq.\0   #1,\1
  2309.           ENDM
  2310.  
  2311. An example call would be
  2312.  
  2313.           inc.1     a0
  2314.  
  2315. which would expand to
  2316.  
  2317.           addq.1    #1,a0
  2318.  
  2319.      The macro starts by comparing the first parameter with an empty
  2320. string and causing an error message to be issued using FAIL if  it
  2321. is equal.  The MEXIT directive is used to leave the macro  without
  2322. expanding the rest of it.  Assuming there is a non-null parameter,
  2323. the next line does the ADDQ instruction, using the \0 parameter to
  2324. get the correct size.
  2325.  
  2326. EXAMPLE 3 - A FACTORIAL MACRO
  2327.      Although  unlikely actually to be used as it stands, this macro
  2328. defines  a  label to be the factorial of a number.  It  shows  how
  2329. recursion  can work in macros.  Before showing the  macro,  it  is
  2330. useful to examine how the same thing would be done in a high level
  2331. language such as Pascal.
  2332.  
  2333. function  factor(n:integer):integer;
  2334. begin
  2335.           if n>0 then
  2336.                     factor:=n*factor(n-1)
  2337.           else
  2338.                     factor:=1
  2339. end;
  2340.  
  2341.      The macro definition for this uses the SET directive to do the
  2342. multiplication n*(n-1)*(n-2) etc. in this way
  2343.  
  2344. *    parameter 1= label,   parameter 2= 'n'
  2345. factor    MACRO
  2346.           IFND      \1
  2347. \1        set       1         set if not yet defined
  2348.           ENDC
  2349.           IFGT      \2
  2350.           factor    \1,\2-1   work out next level down
  2351. \1        set       \1*(\2)   n = n * factor(n-1)
  2352.           ENDC
  2353.           ENDM
  2354. *    a sample call
  2355.           factor test,3
  2356.  
  2357.      The net result of the previous code is to set test to 3! (3
  2358. factorial). The reason the second set  has (\2) instead of just \2
  2359. is  that  the  parameter  will  not  normally  be  just  a  simple
  2360. expression,  but a list of numbers separated by minus signs, so it
  2361. could assemble to:
  2362.  
  2363. test      set       test*5-1-1-1
  2364.  
  2365. (i.e. test*5-3) instead of the correct
  2366.  
  2367. test      set       test*(5-1-1-1)
  2368.  
  2369. (i.e. test *2)
  2370.  
  2371. EXAMPLE 4 - CONDITIONAL RETURN INSTRUCTION
  2372.      The 68000 lacks the conditional return instruction found on other
  2373. processors,  but macros can be defined to implement them using the
  2374. \@ parameter. For example, a return if EQ macro could look like:
  2375.  
  2376. rtseq     MACRO
  2377.           bne.s     \@
  2378.           rts
  2379. \@
  2380.           ENDM
  2381.  
  2382.       The \@ parameter has been used to generate a unique label every
  2383. time  the macro is called,  so will generate in this  case  labels
  2384. such as _002 and _017.
  2385.  
  2386. EXAMPLE 5 - NUMERIC SUBSTITUTION
  2387.      Suppose you have a constant containing the version number of
  2388. your program and wish it to appear as ASCII in a message:
  2389.  
  2390. showname  MACRO
  2391.           dc.b      \1,'\<version>',0
  2392.           ENDM
  2393.           .
  2394.           .
  2395. version   equ       42
  2396.           showname  <'Real Ale Search Program v'>
  2397.  
  2398. will expand to the line
  2399.  
  2400.           dc.b      'Real Ale Search Program v','42',0
  2401.  
  2402. Note  the  way  the string parameter is enclosed in  <  >s  as  it
  2403. contains spaces.
  2404.  
  2405. EXAMPLE 6 - COMPLEX MACRO CALL
  2406.      Suppose your program needs a complicated table structure which
  2407. can have a varying number of fields.  A macro can only be written  to
  2408. using those parameters that are specified,  for example:
  2409.  
  2410. table_entry         macro
  2411.           dc.b      .end\0-*            length byte
  2412.           dc.b      \1                  always
  2413.           IFNC      '\2',''
  2414.           dc,w      \2,\3               2nd and 3rd together
  2415.           ENDC
  2416.           dc.l      \4,\5,\6,\7
  2417.           IFNC      '\8',''
  2418.           dc.b      '\8'                text
  2419.           ENDC
  2420.           dc.b      \9
  2421. .end\@    dc.b      0
  2422.           ENDM
  2423.  
  2424. * a sample call
  2425.           table_entry                   &42,,,t1,t2,t3,t4,
  2426. &                                       <Enter Name:>,%0110
  2427.  
  2428. NOTE: THE NEXT 2 PAGES ARE MISSING FROM MY PHOTOCOPY (THANX REB!) SO
  2429. I'LL HAVE TO IMPROVISE.. I'LL MARK WHERE IT'S BACK FROM THE MANUAL.
  2430.  
  2431.      This is a non-trivial example of how macros can make a
  2432. programmer's  life so much easier when dealing with  complex  data
  2433. structures.  In  this  case the table consists of a  length  byte,
  2434. calculated in the macro using \@,  two optional words, four longs,
  2435. an optional string, a byte, then a zero byte. The code produced in
  2436. this example would be :
  2437.  
  2438.           dc.b      .end_001
  2439.           dc.b      $42
  2440.           dc.l      t1,t2,t3,t4
  2441.           dc,b      'Enter Name:'
  2442.           dc,b      %0110
  2443. .end_001  dc.b      0
  2444.  
  2445. OUTPUT FILE FORMATS
  2446.      GenAM is very flexible in terms of output file formats. These
  2447. are detailed in this section together with notes on the advantages
  2448. and  disadvantages  of each.  Certain  directives  take  different
  2449. actions, depending on what output file format is specified.
  2450.  
  2451.      The exact details of using each format will now be described.
  2452.  
  2453. EXECUTABLE FILES
  2454.      These  are  directly  executable,   for  example,  by  double
  2455. clicking  from the workbench, or from the CLI. The file may include
  2456. relocation information  and/or symbolic information.
  2457.  
  2458. ADVANTAGES
  2459.      true BSS sections, reduced development time.
  2460.  
  2461. DISADVANTAGES
  2462.      messy if more than one programmer.
  2463.  
  2464. GST LINKABLE FILES
  2465.      When  writing  larger programs,  or  when  writing  assembly
  2466. language  modules  for  use  from  the  high  level  language,   a
  2467. programmer needs to generate a linkable file.  The GST link format
  2468. is  supported  by  most of the high level  languages  produced  in
  2469. Britain as well as others,  for example HiSoft Basic,  Lattice  C,
  2470. Prospero  Fortran and Prospero Pascal.  GST format files  normally
  2471. have the extension .BIN.
  2472.  
  2473. ADVANTAGES
  2474.      Great  degree of freedom - imported labels  can  be
  2475. used  practically anywhere including within arbitrary  expressions,
  2476. libraries can be created from the assembler,  import methods means
  2477. the assembler can detect type conflicts.
  2478.  
  2479. DISADVANTAGES
  2480.      Library format means selective library linking  can
  2481. be  slow,  true AmigaDOS sections not supported as standard.
  2482.  
  2483. CHOOSING THE RIGHT FILE FORMAT
  2484.      If  you wish to link with a high level language  there  isn't
  2485. usually  much  choice  -  you have  to  use  whichever  format  is
  2486. supported by the language.
  2487.      If  you  are writing entirely in assembly language  then  the
  2488. normal  choice has to be executable - it is fast to  assemble,  no
  2489. linking  required,  and  allows assembly to memory  for  decreased
  2490. development time.
  2491.      If  you  are writing a larger program,  say bigger  than  32k
  2492. object,  or writing a program as a team,  then linkable code often
  2493. makes  most sense.  We recommend GST-linkable over DRI because  of
  2494. the much greater flexibility of the format.
  2495.  
  2496. OUTPUT FILE DIRECTIVES
  2497.      This section details those directives whose actions depend on
  2498. the  output  file format chosen.  The file format  itself  can  be
  2499. chosen by one of the following methods; command line options using
  2500. GENST2.TTP;  clicking on the radio buttons in the Assembly Options
  2501. dialogue box from the editor,  or with the OPT L directive at  the
  2502. beginning of the source file.
  2503.  
  2504. Icons are used to denote those sections specific to a file format,
  2505. viz
  2506.  
  2507. *EXEC*    Executable-code, also assembled to memory code.
  2508.  
  2509. *GST*     GST-linkable code
  2510.  
  2511. *DRI*     DRI-linkable code.
  2512.  
  2513. BACK TO THE MANUAL, HOPE I GOT IT RIGHT, shit! THE NEXT BIT IS VERY
  2514. DIFFERANT SO THE ABOVE IS PROBABLY WRONG!           PARASITE 4.26am
  2515.  
  2516. SECTIONS
  2517.  
  2518. SECTION string<,type>
  2519.      This  defines a switch to the named section and optionally
  2520. defines it's type. A program may consist of several sections which
  2521. will be concentrated together with other sections of the same name in
  2522. the final executable file. This will use the supplied string and type
  2523. as the section name and type of this section (of hunk) respectivly.
  2524. Each can be up to 32 characters long and should not include tabs or
  2525. spaces or be enclosed in quotes. The casing of the name is
  2526. significant. You may have many SECTION directives in your program.
  2527.      The type can be one of the following (in upper or lower case):
  2528.  
  2529. CODE    code section, public memory
  2530. CODE_F  code section, Fast memory
  2531. CODE_C  code section, chip memory
  2532. DATA    data section, public memory
  2533. DATA_F  data section, fast memory
  2534. DATA_C  data section, chip memory
  2535. BSS     BSS section, public memory
  2536. BSS_F   BSS section, fast memory
  2537. BSS_C   BSS section, chip memory
  2538.  
  2539.      CODE sections are used for executable instructions, DATA sections
  2540. for initialised data (constants), and BSS for un-initialised data. BSS
  2541. sections  have the advantage that they take no disk space - only the
  2542. length of the BSS section is stored. If you define a section to be BSS
  2543. you can only use the directive to produce code - any other code
  2544. generating instructions will cause a binary file i/o error.
  2545.      NOTE: Do not use types requesting chip or fast memory, with
  2546. versions prior to version 2.3 of the Alink linker - these versions
  2547. will crash!
  2548.  
  2549. CODE/DATA/BSS
  2550.      These directives are supported for compatability with the Amiga
  2551. macro assembler. They are the same as specifying the directive as the
  2552. section name and type.
  2553.  
  2554. IDNT string
  2555.      This will use the supplied name as the hunk unit name for this
  2556. section, It can be up to 32 characters long and should not include
  2557. tabs or spaces or be enclosed in quotes.
  2558.  
  2559. IMPORTS AND EXPORTS
  2560.      With both linkable types of program it is crucial to be  able
  2561. to import and export symbols,  both relative symbols (i.e. program
  2562. references) and absolute symbols (i.e.  constants). The AmigaDOS
  2563. linker format does not distinguish between these types; however by
  2564. specifying the type when importing, the assembler can type check,
  2565. often  finding programming errors that would otherwise be missed.
  2566.  
  2567. XDEF      export<,export>...
  2568.      This  defines  labels  for  export  to  other  programs   (or
  2569. modules).  If any of the labels specified are not defined an error
  2570. will occur. It is not possible to export local labels.
  2571.  
  2572. EXEC
  2573.      This directive is ignored
  2574.  
  2575. XREF      import<,import>...
  2576. XREF.L    import<,import>...
  2577.      This  defines  labels to be imported from other  programs  or
  2578. modules.  If any of the labels specified are defined an error will
  2579. occur.  The  normal  XREF  statement should be used  to  import  a
  2580. relative label (i.e.  program reference),  while XREF.L should  be
  2581. used to import absolute labels (i.e. constants). If you do not type
  2582. your imports you should turn type-checking off using OPT T-
  2583.      Importing a label more than once will not produce an error.
  2584.  
  2585. EXEC
  2586.      This directive is ignored
  2587.  
  2588. USING IMPORTS IN EXPRESSIONS
  2589.  
  2590. EXEC
  2591.      There are no imports! However referances to labels in other
  2592. sections are subject to the limitations described below.
  2593.  
  2594. LINK
  2595.      Imports  may be used in expressions but only one  import
  2596. per  expression is allowed.  The results of an expression with  an
  2597. import  in must be of the form import+number  or  import-number.
  2598. Imports can be combined with arbitrarily complex  expressions,  so
  2599. long as the complex expression lexically precedes it, for example
  2600.  
  2601.           move.l    3+(1<<count+5)+import
  2602.  
  2603. EXPRESSION     GST            DRI       EXAMPLE
  2604. byte           Y              N         move.b #test,do
  2605. word           Y              Y         move.w test(a3),d0
  2606. long           Y              Y         move.l test,d0
  2607.  
  2608. COMMENT   comment string
  2609.  
  2610. This directive is ignored at present
  2611.  
  2612. ORG       expression
  2613.      This will make the assembler generate position dependant code
  2614. and  set  the program counter to the given  value.  Normal AmigaDOS
  2615. program,s do not need an ORG statement even if position dependant.
  2616. It  is included to allow code to be generated for the ROM port  or
  2617. for other 68000 machines.  More than one ORG statement is  allowed
  2618. in a source file but no padding of the file is done.
  2619.  
  2620. EXEC
  2621.      It  should  be used with great care as the  binary  file
  2622. generated will probably not execute correctly when double clicked.
  2623. as  no  relocation information is written  out.  The  binary  file
  2624. produced  has  the standard AmigaDOS header at  the  front,  but  no
  2625. relocation information.
  2626.  
  2627. LINK
  2628.      This directive is not allowed.
  2629.  
  2630. OFFSET    <expression>
  2631.      This  switches  code  generation  to  a  special  section  to
  2632. generate absolute labels. The optional expression sets the program
  2633. counter for the start of this section. No bytes are written to the
  2634. disk and the only code generating directive allowed is DS.  Labels
  2635. defined in this section will be absolute.  For example,  to define
  2636. some of the system variables of the ST. (This is in the AMIGA
  2637. manual!);
  2638.  
  2639.           offset    $400
  2640. etv_timer           ds.l      1         will be $400
  2641. etv_critic          ds.l      1         404
  2642. etv_term            ds.l      1         408
  2643. ext_extra           ds.l      5         40C
  2644. memvalid            ds.l      1         420
  2645. memcntlr            ds.w      1         424
  2646.  
  2647. __LK      (reserved symbol)
  2648.      This  is a reserved symbol that can be used to  detect  which
  2649. output  mode  is specified.  The value of this symbol  is  alwayus
  2650. absolute and one of the following:
  2651.  
  2652. 3 linkable
  2653. 4 executable
  2654.  
  2655.       Values 0-2 are reserved for the production of ST code; other
  2656. values and the high word are reserved for future expansion.
  2657.  
  2658. RETURN CODES
  2659.      When using the stand alone assembler from within batch files or
  2660. make files, it's return code can be used to determine  the success of
  2661. the assembly. Values returned are:
  2662.  
  2663. 100+ initialisation failure
  2664.  20  fatal error
  2665.   5  warnings
  2666.   0  OK
  2667.  
  2668. DIRECTIVE SUMMARY
  2669.  
  2670. ASSEMBLY CONTROL
  2671. END       terminate source code
  2672. INCLUDE   read source file from disk
  2673. INCBIN    read binary file from disk
  2674. OPT       option control
  2675. EVEN      ensure PC even
  2676. CNOP      align PC arbitrarily
  2677. DC        define constant
  2678. DS        define space
  2679. DCB       define constant block
  2680. FAIL      force assembly error
  2681.  
  2682. REPEAT LOOPS
  2683. REPT      start repeat block
  2684. ENDR      end repeat block
  2685.  
  2686. LISTING CONTROL
  2687. LIST      enable list
  2688. NOLIST    disable list
  2689. PLEN      set page length
  2690. LLEN      set line length
  2691. TTL       set title
  2692. SUBTTL    set sub-title
  2693. PAGE      start new page
  2694. LISTCHAR  send control character
  2695. FORMAT    define listing format
  2696.  
  2697. LABEL DIRECTIVES
  2698. EQU       define label value
  2699. EQUR      define register equate
  2700. SET       define label value temporarily
  2701. REG       define register list
  2702. RS        reserve space
  2703. RSRESET   reset RS counter
  2704. RSSET     set RS counter
  2705.  
  2706. CONDITIONAL ASSEMBLY
  2707. IFEQ      assemble if zero
  2708. IFNE      assemble in non-zero
  2709. IFGT      assemble if greater than
  2710. IFGE      assemble if greater than or equal to
  2711. IFLT      assemble if less than
  2712. IFLE      assemble if less than or equal to
  2713. IFD       assemble if label defined
  2714. IFND      assemble if label not defined
  2715. IFC       assemble if strings same
  2716. IFNC      assemble if strings different
  2717. ELSEIF    switch assembly state
  2718. IIFC      immediate IF
  2719.  
  2720. MACROS
  2721. MACRO     define macro
  2722. ENDM      end macro definition
  2723.  
  2724. OUTPUT FILE DIRECTIVES
  2725. MODULE    start new module
  2726. SECTION   switch section
  2727. XDEF      define label for export
  2728. XREF      define label for import
  2729. COMMENT   send linker comment
  2730. ORG       set absolute code generation
  2731. OFFSET    define offset table
  2732.  
  2733. RESERVED SYMBOLS
  2734. NARG      number of macro parameters
  2735. __G2      internal version number
  2736. __RS      RS counter
  2737. __LK      output file type
  2738.  
  2739. BLINK LINKER
  2740.      This version of BLINK is a public domain limker designed as a
  2741. replacement for the standard AmigaDOS linker, Alink. The program has
  2742. many powerful features, but in the simplest case the command line is
  2743.  
  2744. blink (from) <infile.o> [<infile2.o>...] [ TO <outfile>]
  2745.  
  2746. which specifies one or more input files and an output file. Normally
  2747. all sections will be placed in seperate hunks, but they can be forced
  2748. into one hunk by specifying SMALLCODE or SMALLDATA on the command
  2749. line. For example;
  2750.  
  2751. blink test.o
  2752.  
  2753. will link test.o into the file test
  2754.  
  2755. blink FROM start.o middle.o end.o TO total
  2756.  
  2757. will link the specified three files into total
  2758.  
  2759. blink FROM start.o middle.o end.o TO total SMALLCODE
  2760.  
  2761. as above but coalescing for BLink are contained in a  file on disk 2,
  2762. which can be read on screen or printed out in the usual manor.
  2763.  
  2764. NOW LOAD PART 2...
  2765.