Subversion Repositories pentevo

Rev

Blame | Last modification | View Log | Download | RSS feed | ?url?

  1. %% Hi Folks,
  2. %%
  3. %% this is a release of the English AS manual.  I haven't
  4. %% done the entire translation myself, large parts of it are the work of some
  5. %% other people around the net who deserve my deep appreciation for this job.
  6. %% My parts of the translation are the results of a brute-force attempt,
  7. %% so there are surely tons of spelling errors and passages that will
  8. %% make people with English as their mother tongue either laugh or cry...
  9.  
  10. %% Alfred Arnold
  11.  
  12. %%         translation by: Oliver Sellke (OSIP, D-65199 Wiesbaden)
  13. %%                           (proof-read in parts by Stefan Hilse, Wiesbaden)
  14. %%                         Alfred Arnold
  15. %%                         Stephan Kanthak
  16. %%                         Vittorio De Tomasi
  17. %%
  18. %%         thanks to the authors of:
  19. %%                         FB-translator
  20. %%                         GNU-ispell
  21. %%
  22. %% ------------------------------------------------------------------------------
  23.  
  24. %%TITLE User's Manual for Macro Assembler AS
  25. \documentclass[12pt,twoside]{report}
  26. \usepackage{makeidx}
  27. \usepackage{hyperref}
  28. \usepackage{longtable}
  29. \pagestyle{headings}
  30. \sloppy
  31. %%\textwidth 15cm
  32. %%\evensidemargin 0.5cm
  33. %%\oddsidemargin 0.5cm
  34. \topsep 1mm
  35. \parskip 0.3cm plus0.25cm minus0.25cm
  36. \parindent 0cm
  37.  
  38. \newcommand{\ii}[1]{{\it #1}}
  39. \newcommand{\bb}[1]{{\bf #1}}
  40. \newcommand{\tty}[1]{{\tt #1}}
  41. \newcommand{\tin}[1]{{\scriptsize #1}}
  42. \newcommand{\ttindex}[1]{\index{#1@{\tt #1}}}
  43. \newcommand{\asname}{{AS}}
  44.  
  45. \font\mengft=cmss9 scaled \magstep1
  46. \def \rz{\hbox{\mengft{I \hskip -1.7mm R}}}
  47.  
  48. \makeindex
  49.  
  50. %%===========================================================================
  51.  
  52. \begin{document}
  53.  
  54. \thispagestyle{empty}
  55.  
  56. \
  57. \vspace{7cm}\par
  58.  
  59. \begin{raggedright}
  60. {\large Alfred Arnold, Stefan Hilse, Stephan Kanthak, Oliver
  61. Sellke, Vittorio De Tomasi}
  62. \vspace{1cm}\par
  63. {\huge Macro Assembler \asname{} V1.42}\\
  64. \rule{9.5cm}{0.3mm}\\
  65. \vspace{2mm}\par
  66. {\huge User's Manual}
  67.  
  68. \vspace{1cm}\par
  69.  
  70. {\large Edition March 2024}
  71. \end{raggedright}
  72.  
  73. \clearpage
  74. \thispagestyle{empty}
  75.  
  76. \ \vspace{5cm}
  77.  
  78. {\em IBM, PPC403Gx, OS/2, and PowerPC} are registered trademarks of IBM
  79. Corporation.
  80.  
  81. {\em Intel, MCS-48, MCS-51, MCS-251, MCS-96, MCS-196 und MCS-296} are
  82. registered trademarks of Intel Corp. .
  83.  
  84. {\em Motorola and ColdFire} are registered trademarks of Motorola Inc. .
  85.  
  86. {\em MagniV} is a registered trademark of Freescale Semiconductor.
  87.  
  88. {\em PicoBlaze} is a registered trademark of Xilinx Inc.
  89.  
  90. {\em UNIX} is a registered trademark of the The Open Group.
  91.  
  92. {\em Linux} is a registered trademark of Linus Thorvalds.
  93.  
  94. {\em Microsoft, Windows, and MS-DOS} are registered trademarks of
  95. Microsoft Corporation.
  96.  
  97. All other trademarks not explicitly mentioned in this section and used in
  98. this manual are properties of their respective owners.
  99.  
  100. \vspace{5cm}
  101.  
  102. This document has been processed with the LaTeX typesetting system, using
  103. the Linux operating system.
  104.  
  105. \clearpage
  106.  
  107. %%===========================================================================
  108.  
  109. {\parskip 0cm plus0.1cm \tableofcontents}
  110.  
  111. %%===========================================================================
  112.  
  113. \cleardoublepage
  114. \chapter{Introduction}
  115.  
  116. This instruction is meant for programmers who are already very familiar
  117. with Assembler and who like to know how to work with \asname{}.  It is rather a
  118. reference than a user's manual and so it neither tries to explain the
  119. ''language assembler'' nor the processors.  I have listed further
  120. literature in the bibliography which was substantial in the implementation
  121. of the different code generators.  There is no book I know where you can
  122. learn Assembler from the start, so I generally learned this by ''trial and
  123. error''.
  124.  
  125. %%After a small discussion on the mailing list, I decided to make an own proposal
  126. %%for a better name: ''ACASM''.  It is good tradition in the open source scene
  127. %%that acronyms may have multiple meanings.  Just some ideas:
  128. %%\begin{itemize}
  129. %%\item{,,AC'' may just refer to my hometown Aachen, since that is what cars
  130. %%      over here have on their license plates;}
  131. %%\item{,,Another CPU'', every time yet another new target was added;}
  132. %%\item{,,All Crap'', if you got frustrated over it...}
  133. %%\item{...or ,,Alfreds Cute Assembler'', if you really want to reference my
  134. %%      name...}
  135. %%\end{itemize}
  136.  
  137. %%---------------------------------------------------------------------------
  138.  
  139. \section{License Agreement}
  140. \label{SectLicense}
  141.  
  142. Before we can go ''in medias res'', first of all the inevitable prologue:
  143.  
  144. As in the present version is licensed according to the Gnu General Public
  145. License (GPL); the details of the GPL may be read in the file COPYING
  146. bundled with this distribution.  If you did not get it with \asname{}, complain
  147. to the one you got \asname{} from!
  148.  
  149. Shortly said, the GPL covers the following points:
  150. \begin{itemize}
  151. \item{Programs based upon \asname{} must also be licensed according to the GPL;}
  152. \item{distribution is explicitly allowed;}
  153. \item{explicit disclaiming of all warranties for damages resulting from
  154.      usage of this program.}
  155. \end{itemize}
  156. ...however, I really urge you to read the file COPYING for the details!
  157.  
  158. To accelerate the error diagnose and correction, please add the
  159. following details to the bug report:
  160. \begin{itemize}
  161. \item{Operating system (DOS, Windows, Linux) and its version}
  162. \item{Version of \asname{} used, resp. dates of the \tty{EXE}-files}
  163. \item{If you compiled the assembler yourself, the compiler used and its version}
  164. \item{If possible, the source file that triggered the bug}
  165. \end{itemize}
  166. You can contact me as follows:
  167. \begin{itemize}
  168. \item{by Surface Mail: \begin{description}
  169.               \item{Alfred Arnold}
  170.               \item{Hirschgraben 29}
  171.               \item{D-52062 Aachen}
  172.               \item{Germany}
  173.               \end{description}}
  174. \item{by E-Mail: \tty{alfred@ccac.rwth-aachen.de}}
  175. \end{itemize}
  176. If someone likes to meet me personally to ask questions and lives
  177. near Aachen (= Aix-la-Chapelle), you will be able to meet me there.
  178. You can do this most probably on thursdays from 8pm to 9pm at the
  179. RWTH Aachen Computer Club (Elisabethstrasse 16, first floor, corridor
  180. on the right).
  181.  
  182. Please don't call me by phone.  First, complex relations are
  183. extremely hard to discuss at phone.  Secondly, the telephone
  184. companies are already rich enough...
  185.  
  186. The latest version of \asname{} (DPMI, Win32, C) is available from
  187. the following Server:
  188. \begin{verbatim}
  189. http://john.ccac.rwth-aachen.de:8000/as
  190. \end{verbatim}
  191. or shortly
  192. \begin{verbatim}
  193. http://www.alfsembler.de
  194. \end{verbatim}
  195.  
  196. Whoever has no access to an FTP-Server can ask me to send the assembler
  197. by mail.  Only requests containing a blank CD-R and a self-addressed,
  198. (correctly) stamped envelope will be answered.  Don't send any money!
  199.  
  200. Now, after this inevitable introduction we can turn to the actual
  201. documentation:
  202.  
  203. %%---------------------------------------------------------------------------
  204.  
  205. \section{General Capabilities of the Assembler}
  206.  
  207. In contrast to ordinary assemblers, \asname{} offers the possibility to
  208. generate code for totally different processors.  At the moment, the
  209. following processor families have been implemented:
  210. \begin{itemize}
  211. \item{Motorola 68000..68040,, 683xx, and Coldfire incl. coprocessor and MMU}
  212. \item{Motorola ColdFire}
  213. \item{Motorola DSP5600x,DSP56300}\item{Motorola M-Core}
  214. \item{Motorola/IBM MPC601/MPC505/PPC403/MPC821}
  215. \item{IBM PALM}
  216. \item{Motorola 6800, 6801, 68(HC)11(K4) and Hitachi 6301}
  217. \item{Motorola/Freescale 6805, 68HC(S)08}
  218. \item{Motorola 6809 / Hitachi 6309}
  219. \item{Motorola/Freescale 68HC12(X) including XGATE}
  220. \item{Freescale/NXP S12Z (''MagniV'')}
  221. \item{Motorola 68HC16}
  222. \item{Freescale 68RS08}
  223. \item{Konami 052001}
  224. \item{Hitachi H8/300(H)}
  225. \item{Hitachi H8/500}
  226. \item{Hitachi SH7000/7600/7700}
  227. \item{Hitachi HMCS400}
  228. \item{Hitachi H16}
  229. \item{Rockwell 6502, 65(S)C02, Commodore 65CE02, WDC W65C02S, Rockwell 65C19, and
  230.      Hudson HuC6280}
  231. \item{Rockwell PPS-4}
  232. \item{CMD 65816}
  233. \item{Mitsubishi MELPS-740}
  234. \item{Mitsubishi MELPS-7700}
  235. \item{Mitsubishi MELPS-4500}
  236. \item{Mitsubishi M16}
  237. \item{Mitsubishi M16C}
  238. \item{DEC PDP-11}
  239. \item{Western Digital WD16}
  240. \item{Intel 4004/4040}
  241. \item{Intel MCS-48/41, including Siemens SAB80C382, and the OKI
  242.      variants}
  243. \item{Intel MCS-51/251, Dallas DS80C390}
  244. \item{Intel MCS-96/196(Nx)/296}
  245. \item{Intel 8080/8085}
  246. \item{Intel i960}
  247. \item{Signetics 8X30x}
  248. \item{Signetics 2650}
  249. \item{Philips XA}
  250. \item{Atmel (Mega-)AVR}
  251. \item{AMD 29K}
  252. \item{Siemens 80C166/167}
  253. \item{Zilog Z80 (including undocumented instructions), Z180, Z380}
  254. \item{Sharp LR35902 (,,Gameboy Z80'')}
  255. \item{Sharp SC61860}
  256. \item{Sharp SC62015}
  257. \item{Zilog Z8, Super8, Z8 Encore}
  258. \item{Zilog Z8000}
  259. \item{Xilinx KCPSM/KCPSM3 ('PicoBlaze')}
  260. \item{LatticeMico8}
  261. \item{Toshiba TLCS-900(L)}
  262. \item{Toshiba TLCS-90}
  263. \item{Toshiba TLCS-870(/C)}
  264. \item{Toshiba TLCS-47}
  265. \item{Toshiba TLCS-9000}
  266. \item{Toshiba TC9331}
  267. \item{Microchip PIC16C54..16C57}
  268. \item{Microchip PIC16C84/PIC16C64}
  269. \item{Microchip PIC17C42}
  270. \item{Parallax SX20/28}
  271. \item{SGS M380/GI LP8000}
  272. \item{SGS-Thomson ST6}
  273. \item{SGS-Thomson ST7/STM8}
  274. \item{SGS-Thomson ST9}
  275. \item{SGS-Thomson 6804}
  276. \item{Texas Instruments TMS32010/32015}
  277. \item{Texas Instruments TMS3202x}
  278. \item{Texas Instruments TMS320C3x/TMS320C4x}
  279. \item{Texas Instruments TMS320C20x/TMS320C5x}
  280. \item{Texas Instruments TMS320C54x}
  281. \item{Texas Instruments TMS320C6x}
  282. \item{Texas Instruments TMS99xx/99xxx}
  283. \item{Texas Instruments TMS7000}
  284. \item{Texas Instruments TMS1000}
  285. \item{Texas Instruments TMS370xxx}
  286. \item{Texas Instruments MSP430(X)}
  287. \item{National Semiconductor IMP-16}
  288. \item{National Semiconductor IPC-16 ('PACE'), INS8900}
  289. \item{National Semiconductor SC/MP}
  290. \item{National Semiconductor INS807x}
  291. \item{National Semiconductor COP4}
  292. \item{National Semiconductor COP8}
  293. \item{National Semiconductor SC144xx}
  294. \item{National Semiconductor NS32xxx}
  295. \item{Olympia CP-3F (resp. SGS M380, GI LP8000)}
  296. \item{Fairchild ACE}
  297. \item{Fairchild F8}
  298. \item{NEC $\mu$PD78(C)0x/$\mu$PD 78(C)1x}
  299. \item{NEC $\mu$PD75xx}
  300. \item{NEC $\mu$PD 75xxx (alias 75K0)}
  301. \item{NEC 78K0}
  302. \item{NEC 78K2}
  303. \item{NEC 78K3}
  304. \item{NEC 78K4}
  305. \item{NEC $\mu$PD7720/7725}
  306. \item{NEC $\mu$PD77230}
  307. \item{NEC V60}
  308. \item{Fujitsu F$^2$MC8L}
  309. \item{Fujitsu F$^2$MC16L}
  310. \item{OKI OLMS-40}
  311. \item{OKI OLMS-50}
  312. \item{Panafacom MN1610/MN1613}
  313. \item{Renesas RX}
  314. \item{Padauk PMS/PMC/PFSxxx}
  315. \item{Symbios Logic SYM53C8xx (yes, they are programmable!)}
  316. \item{Intersil CDP1802/1804/1805(A)}
  317. \item{Intersil IM6100/6120}
  318. \item{XMOS XS1}
  319. \item{MIL STD 1750}
  320. \item{KENBAK-1}
  321. \item{GI CP-1600}
  322. \item{HP Nano Processor}
  323. \end{itemize}
  324. under work / planned / in consideration :
  325. \begin{itemize}
  326. \item{ARM}
  327. \item{Analog Devices ADSP21xx}
  328. \item{SGS-Thomson ST20}
  329. \item{Texas Instruments TMS320C8x}
  330. \end{itemize}
  331. Unloved, but now, however, present :
  332. \begin{itemize}
  333. \item{Intel 80x86, 80186, Nec V20..V55 incl. coprocessor 8087}
  334. \end{itemize}
  335. The switch to a different code generator is allowed even within one
  336. file, and as often as one wants!
  337.  
  338. The reason for this flexibility is that \asname{} has a history, which may also
  339. be recognized by looking at the version number. \asname{} was created as an
  340. extension of a macro assembler for the 68000 family. On special request, I
  341. extended the original assembler so that it was able to translate 8051
  342. mnemonics.  On this way (decline ?!) from the 68000 to 8051, some other
  343. processors were created as by-products.  All others were added over time
  344. due to user requests.  So At least for the processor-independent core of
  345. \asname{}, one may assume that it is well-tested and free of obvious bugs.
  346. However, I often do not have the chance to test a new code generator in
  347. practice (due to lack of appropriate hardware), so surprises are not
  348. impossible when working with new features.  You see, the things stated in
  349. section \ref{SectLicense} have a reason...
  350.  
  351. This flexibility implies a somewhat exotic code format, therefore I
  352. added some tools to work with it. Their description can be found in
  353. chapter \ref{ChapTools}.
  354.  
  355. \asname{} is a macro assembler, which means that the programmer has the
  356. possibility to define new ''commands'' by means of macros.
  357. Additionally it masters conditional assembling.  Labels inside macros
  358. are automatically processed as being local.
  359.  
  360. For the assembler, symbols may have either integer, string or floating
  361. point values.  These will be stored - like interim values in formulas -
  362. with a width of 32 bits for integer values, 80 or 64 bits for floating
  363. point values, and 255 characters for strings.  For a couple of micro
  364. controllers, there is the possibility to classify symbols by segmentation.
  365. So the assembler has a (limited) possibility to recognize accesses to
  366. wrong address spaces.
  367.  
  368. The assembler does not know explicit limits in the nesting depth of
  369. include files or macros; a limit is only given by the program stack
  370. restricting the recursion depth.  Nor is there a limit for the
  371. symbol length, which is only restricted by the maximum line length.
  372.  
  373. From version 1.38 on, \asname{} is a multipass-assembler.  This pompous term
  374. means no more than the fact that the number of passes through the
  375. source code need not be exactly two. If the source code does not
  376. contain any forward references, \asname{} needs only one pass.  In case \asname{}
  377. recognizes in the second pass that it must use a shorter or longer
  378. instruction coding, it needs a third (fourth, fifth...) pass to
  379. process all symbol references correctly. There is nothing more behind
  380. the term ''multipass'', so it will not be used further more in this
  381. documentation.
  382.  
  383. After so much praise a bitter pill: \asname{} cannot generate linkable code.
  384. An extension with a linker needs considerable effort and is not planned
  385. at the moment.
  386.  
  387. Those who want to take a look at the sources of \asname{} can simply get the
  388. Unix version of \asname{}, which comes as source for self-compiling.  The sources
  389. are definitely not in a format that is targeted at easy understanding -
  390. the original Pascal version still raises its head at a couple of places,
  391. and I do not share a couple of common opinions about 'good' C coding.
  392.  
  393. %%---------------------------------------------------------------------------
  394.  
  395. \section{Supported Platforms}
  396.  
  397. Though \asname{} started as a pure DOS \marginpar{{\em DOS}} program, there are a
  398. couple of versions available that are able to exploit a bit more than the
  399. Real Mode of an Intel CPU.  Their usage is kept as compatible to the DOS
  400. version as possible, but there are of course differences concerning
  401. installation and embedding into the operating system in question.
  402. Sections in this manual that are only valid for a specific version of \asname{}
  403. are marked with a corresponding sidemark (at this paragraph for the DOS
  404. version) aheaded to the paragraph.  In detail, the following further
  405. versions exist (distributed as separate packages):
  406.  
  407. In case you run \marginpar{{\em DPMI}}into memory problems when assembling
  408. large and complex programs under DOS, there is a DOS version that runs in
  409. protected mode via a DOS extender and can therefore make use of the whole
  410. extended memory of an AT.  The assembly becomes significantly slower by
  411. the extender, but at least it works...
  412.  
  413. There is a native OS/2 \marginpar{{\em OS/2}} version of \asname{} for friends of
  414. IBM's OS/2 operating system.  Since version 1.41r8, this is a full 32-bit
  415. OS/2 application, which of course means that OS/2 2.x and at least an
  416. 80386 CPU are mandatory.
  417.  
  418. You can leave \marginpar{{\em UNIX}} the area of PCs-only with the C
  419. version of \asname{} that was designed to be compilable on a large number of UNIX
  420. systems (this includes OS/2 with the emx compiler) without too much of
  421. tweaking.  In contrast to the previously mentioned versions, the C version
  422. is delivered in source code, i.e. one has to create the binaries by
  423. oneself using a C compiler.  This is by far the simpler way (for me) than
  424. providing a dozen of precompiled binaries for machines I sometimes only
  425. have limited access to...
  426.  
  427. %%===========================================================================
  428.  
  429. \cleardoublepage
  430. \chapter{Assembler Usage}
  431.  
  432. \begin{quote}\begin{raggedright}{\it
  433. Scotty: Captain, we din\verb!'! can reference it! \\
  434. Kirk:   Analysis, Mr. Spock? \\
  435. Spock:  Captain, it doesn\verb!'!t appear in the symbol table. \\
  436. Kirk:   Then it\verb!'!s of external origin? \\
  437. Spock:  Affirmative. \\
  438. Kirk:   Mr. Sulu, go to pass two. \\
  439. Sulu:   Aye aye, sir, going to pass two. \\
  440. }\end{raggedright}\end{quote}
  441.  
  442. %%---------------------------------------------------------------------------
  443.  
  444. \section{Hardware Requirements}
  445.  
  446. The hardware requirements of \asname{} vary substantially from version to
  447. version:
  448.  
  449. The DOS version \marginpar{{\em DOS}} will principally run on any
  450. IBM-compatible PC, ranging from a PC/XT with 4-dot-little megahertz up to
  451. a Pentium.  However, similar to other programs, the fun using \asname{} increases
  452. the better your hardware is.  An XT user without a hard drive will
  453. probably have significant trouble placing the overlay file on a floppy
  454. because it is larger than 500 Kbytes...the PC should therefore have at
  455. least a hard drive, allowing acceptable loading times.  \asname{} is not very
  456. advanced in its main memory needs: the program itself allocates less than
  457. 300 Kbytes main memory, \asname{} should therefore work on machines with at least
  458. 512 Kbytes of memory.
  459.  
  460. The version of \asname{} \marginpar{{\em DPMI}} compiled for the DOS Protected
  461. Mode Interface (DPMI) requires at least 1 Mbyte of free extended memory.
  462. A total memory capacity of at least 2 Mbytes is therefore the absolute
  463. minimum given one does not have other tools in the XMS (like disk caches,
  464. RAM disks, or a hi-loaded DOS); the needs will rise then appropriately.
  465. If one uses the DPMI version in a DOS box of OS/2, one has to assure that
  466. DPMI has been enabled via the box's DOS settings (set to \tty{on} or
  467. \tty{auto}) and that a sufficient amount of XMS memory has been assigned
  468. to the box.  The virtual memory management of OS/2 will free you
  469. from thinking about the amount of free real memory.
  470.  
  471. The C version of \asname{} \marginpar{{\em UNIX}} is delivered as source code and
  472. therefore requires a UNIX or OS/2 system equipped with a C compiler.  The
  473. compiler has to fulfill the ANSI standard (GNU-C for example is
  474. ANSI-compliant).  You can look up in the \tty{README} file whether your
  475. UNIX system has already been tested so that the necessary definitions have
  476. been made.  You should reserve about 15 Mbytes of free hard disk space for
  477. compilation; this value (and the amount needed after compilation to store
  478. the compiled programs) strongly differs from system to system, so you
  479. should take this value only as a rough approximation.
  480.  
  481. %%---------------------------------------------------------------------------
  482.  
  483. \section{Delivery}
  484.  
  485. Principally, you can obtain \asname{} in one of two forms: as a {\em binary} or a
  486. {\em source} distribution.  In case of a binary distribution, one gets \asname{},
  487. the accomanying tools and auxiliary files readily compiled, so you can
  488. immediately start to use it after unpacking the archive to the desired
  489. destination on your hard drive.
  490. Binary distibutions are made for widespread platforms, where either the
  491. majority of users does not have a compiler or the compilation is tricky
  492. (currently, this includes DOS and OS/2).  A source distribution in
  493. contrast contains the complete set of C sources to generate \asname{}; it is
  494. ultimately a snapshot of the source tree I use for development on \asname{}.  The
  495. generation of \asname{} from the sources and their structure is described in
  496. detail in appendix \ref{ChapSource}, which is why at this place, only the
  497. contents and installation of a binary distribution will be described:
  498.  
  499. The contents of the archive is separated into several subdirectories,
  500. therefore you get a directory subtree immediately after unpacking without
  501. having to sort out things manually.  The individual directories contain
  502. the following groups of files:
  503. \begin{itemize}
  504. \item{{\tt BIN}: executable programs, text resources;}
  505. \item{{\tt INCLUDE}: include files for assembler programs, e.g. register
  506.      definitions or standard macros;}
  507. \item{{\tt MAN}: quick references for the individual programs in Unix
  508.      'man' format.}
  509. \end{itemize}
  510. A list of the files found in every binary distribution is given in table
  511. \ref{TabCommonPackageList}.  In case a file listed in one of these (or the
  512. following) tables is missing, someone took a nap during copying (probably
  513. me)...
  514.  
  515. \begin{center}\begin{longtable}{|l|l|}
  516. \hline
  517. File              & Function \\
  518. \hline
  519. \hline
  520. \endhead
  521. {\bf Directory BIN} & \\
  522. \hline
  523. AS.EXE            & executable of assembler \\
  524. PLIST.EXE         & lists contents of code files \\
  525. PBIND.EXE         & merges code files \\
  526. P2HEX.EXE         & converts code files to hex files \\
  527. P2BIN.EXE         & converts code files to binary files \\
  528. AS.MSG            & text resources for \asname{} (DOS only) \\
  529. PLIST.MSG         & text resources for PLIST *) \\
  530. PBIND.MSG         & text resources for PBIND *) \\
  531. P2HEX.MSG         & text resources for P2HEX *) \\
  532. P2BIN.MSG         & text resources for P2BIN *) \\
  533. TOOLS.MSG         & common text resources for all tools *) \\
  534. CMDARG.MSG        & common text resources for all programs *) \\
  535. IOERRS.MSG        & \\
  536. \hline
  537. \multicolumn{2}{|l|}{*) DOS only} \\
  538. \hline
  539. {\bf Directory DOC} & \\
  540. \hline
  541. AS\_DE.DOC        & german documentation, ASCII format \\
  542. AS\_DE.HTML       & german documentation, HTML format \\
  543. AS\_DE.TEX        & german documentation, LaTeX format \\
  544. AS\_EN.DOC        & english documentation, ASCII format \\
  545. AS\_EN.HTML       & english documentation, HTML format \\
  546. AS\_EN.TEX        & english documentation, LaTeX format \\
  547. \hline
  548. {\bf Directory INCLUDE} & \\
  549. \hline
  550. BCDIC.INC         & definition of BCDIC/code page 359 \\
  551. BITFUNCS.INC      & functions for bit manipulation \\
  552. CTYPE.INC         & functions for classification of \\
  553.                  & characters \\
  554. EBCDIC.INC        & includes all EBCDIC variants \\
  555. CP037.INC         & definition EBCDIC (code page 037) \\
  556. CP5100.INC        & definition character set IBM 5100 \\
  557. CP5110.INC        & definition EBCDIC (IBM 5110) \\
  558. 80C50X.INC        & register addresses SAB C50x \\
  559. 80C552.INC        & register addresses 80C552 \\
  560. H8\_3048.INC      & register addresses H8/3048 \\
  561. KENBAK.INC        & register addressed Kenbak-1 \\
  562. RADIX50.INC       & definition of RADIX 50 character set \\
  563. REG166.INC        & addresses and instruction macros 80C166/167 \\
  564. REG251.INC        & addresses and bits 80C251 \\
  565. REG29K.INC        & peripheral addresses AMD 2924x \\
  566. REG53X.INC        & register addresses H8/53x \\
  567. REG6303.INC       & register addresses 6303 \\
  568. REG683XX.INC      & register addresses 68332/68340/68360 \\
  569. REG7000.INC       & register addresses TMS70Cxx \\
  570. REG78310.INC      & register addresses \& vectors 78K3 \\
  571. REG78K0.INC       & register addresses 78K0 \\
  572. REG96.INC         & register addresses MCS-96 \\
  573. REGACE.INC        & register addresses ACE \\
  574. REGF8.INC         & register and memory addresses F8 \\
  575. REGAVROLD.INC     & register and bit addresses AVR family (old)\\
  576. REGAVR.INC        & register and bit addresses AVR family \\
  577. REGCOLD.INC       & register and bit addresses Coldfire family \\
  578. REGCOP8.INC       & register addresses COP8 \\
  579. REGGP32.INC       & register addresses 68HC908GP32 \\
  580. REGH16.INC        & register addresses H16\\
  581. REGHC12.INC       & register addresses 68HC12 \\
  582. REGM16C.INC       & register addresses Mitsubishi M16C \\
  583. REGMSP.INC        & register addresses TI MSP430 \\
  584. REGPDK.INC        & register and bit addresses PMC/PMS/PFSxxx \\
  585. REGS12Z.INC       & register and bit addresses S12Z family \\
  586. REGST6.INC        & register and macro definitions ST6 \\
  587. REGST7.INC        & register and macro definitions ST7 \\
  588. REGSTM8.INC       & register and macro definitions STM8 \\
  589. REGST9.INC        & register and macro definitions ST9 \\
  590. REGV60.INC        & register addresses NEC V60 \\
  591. REGZ380.INC       & register addresses Z380 \\
  592. STDDEF04.INC      & register addresses 6804 \\
  593. STDDEF16.INC      & instruction macros and register addresses \\
  594.                  & PIC16C5x \\
  595. STDDEF17.INC      & register addresses PIC17C4x \\
  596. STDDEF18.INC      & register addresses PIC16C8x \\
  597. STDDEF2X.INC      & register addresses TMS3202x \\
  598. STDDEF37.INC      & register and bit addresses TMS370xxx \\
  599. STDDEF3X.INC      & peripheral addresses TMS320C3x \\
  600. STDDEF4X.INC      & peripheral addresses TMS320C4x \\
  601. STDDEF47.INC      & instruction macros TLCS-47 \\
  602. STDDEF51.INC      & definition of SFRs and bits for \\
  603.                  & 8051/8052/80515 \\
  604. STDDEF56K.INC     & register addresses DSP56000 \\
  605. STDDEF5X.INC      & peripheral addresses TMS320C5x \\
  606. STDDEF60.INC      & instruction macros and register addresses \\
  607.                  & PowerPC \\
  608. REGSX20.INC       & register and bit addresses Parallax SX20/28 \\
  609. AVR/\*.INC        & register and bit addresses AVR family \\
  610.                  & (do not include directly, use REGAVR.INC) \\
  611. COLDFIRE/\*.INC   & register and bit addresses ColdFire family \\
  612.                  & (do not include directly, use REGCOLD.INC) \\
  613. PDK/\*.INC        & register and bit addresses PMC/PMS/PFSxxx \\
  614.                  & (do not include directly, use REGPDK.INC) \\
  615. S12Z/\*.INC       & register and bit addresses S12Z family \\
  616.                  & (do not include directly, use REGS12Z.INC) \\
  617. ST6/\*.INC        & register and bit addresses ST6 family \\
  618.                  & (do not include directly, use REGST6.INC) \\
  619. ST7/\*.INC        & register and bit addresses ST7 family \\
  620.                  & (do not include directly, use REGST7.INC) \\
  621. STM8/\*.INC       & register and bit addresses STM8 family \\
  622.                  & (do not include directly, use REGSTM8.INC) \\
  623. STDDEF62.INC      & register addresses and macros ST6 (old)\\
  624. STDDEF75.INC      & register addresses 75K0 \\
  625. STDDEF87.INC      & register and memory addresses TLCS-870 \\
  626. STDDEF90.INC      & register and memory addresses TLCS-90 \\
  627. STDDEF96.INC      & register and memory addresses TLCS-900 \\
  628. STDDEFXA.INC      & SFR and bit addresses Philips XA \\
  629. STDDEFZ8.INC      & register addresses Z8 family (old) \\
  630. REGZ8.INC         & register addresses Z8 family (new) \\
  631. Z8/\*.INC         & register and bit addresses Z8 family \\
  632.                  & (do not include directly, use REGZ8.INC) \\
  633. \hline
  634. {\bf Directory LIB} & \\
  635. \hline
  636. {\bf Directory MAN} & \\
  637. \hline
  638. ASL.1             & Short Reference for \asname{} \\
  639. PLIST.1           & Short Reference for PLIST \\
  640. PBIND.1           & Short Reference for PBIND \\
  641. P2HEX.1           & Short Reference for P2HEX \\
  642. P2BIN.1           & Short Reference for P2BIN \\
  643. \hline
  644. \caption{Standard Contents of a Binary Distribution
  645.         \label{TabCommonPackageList}}
  646. \end{longtable}\end{center}
  647.  
  648.  
  649. Depending on the platform, a binary distribution however may contain more
  650. files to allow operation, like files necessary for DOS extenders. In case
  651. of the DOS DPMI version \marginpar{{\em DPMI}}, the extensions listed in
  652. table \ref{TabDPMIPackageList} result.  Just to mention it: it is
  653. perfectly O.K. to replace the tools with their counterparts from a DOS
  654. binary distribution; on the on hand, they execute significantly faster
  655. without the extender's overhead, and on the other hand, they do not need
  656. the extended memory provided by the extender.
  657.  
  658. \begin{table*}[htp]
  659. \begin{center}\begin{tabular}{|l|l|}
  660. \hline
  661. File              & Function \\
  662. \hline
  663. \hline
  664. {\bf Directory MAN} & \\
  665. \hline
  666. ASL.1             & quick reference for \asname{} \\
  667. PLIST.1           & quick reference for PLIST \\
  668. PBIND.1           & quick reference for PBIND \\
  669. P2HEX.1           & quick reference for P2HEX \\
  670. P2BIN.1           & quick reference for P2BIN \\
  671. \hline
  672. \hline
  673. {\bf Directory BIN} & \\
  674. \hline
  675. DPMI16BI.OVL   & DPMI server for the assembler \\
  676. RTM.EXE        & runtime module of the extender \\
  677. \hline
  678. \end{tabular}\end{center}
  679. \caption{Additional Files in a DPMI Binary Distribution
  680.         \label{TabDPMIPackageList}}
  681. \end{table*}
  682.  
  683. An OS/2 binary distribution \marginpar{{\em OS/2}} contains in addition to
  684. the base files a set of DLLs belonging to the runtime environment of the
  685. emx compiler used to build \asname{} (table \ref{TabOS2PackageList}).  In case
  686. you already have these DLLs (or newer versions of them), you may delete
  687. these and use your ones insted.
  688.  
  689. \begin{table*}[htp]
  690. \begin{center}\begin{tabular}{|l|l|}
  691. \hline
  692. File              & function \\
  693. \hline
  694. \hline
  695. {\bf Directory BIN} & \\
  696. \hline
  697. EMX.DLL           & runtime libraries for \asname{} and \\
  698. EMXIO.DLL         & its tools \\
  699. EMXLIBC.DLL       & \\
  700. EMXWRAP.DLL       & \\
  701. \hline
  702. \end{tabular}\end{center}
  703. \caption{Additional Files in an OS/2 binary distribution
  704.         \label{TabOS2PackageList}}
  705. \end{table*}
  706.  
  707. %%---------------------------------------------------------------------------
  708.  
  709. \section{Installation}
  710.  
  711. There is no need for a \marginpar{{\em DOS}} special installation prior to
  712. usage of \asname{}.  It is sufficient to unpack the archive in a fitting place
  713. and to add a few minor settings.  For example, this is an installation a
  714. user used to UNIX-like operating systems might choose:
  715.  
  716. Create a directory \verb!c:\as! an (I will assume in the following that
  717. you are going to install \asname{} on drive C), change to this directory and
  718. unpack the archiv, keeping the path names stored in the archive (when
  719. using PKUNZIP, the command line option \verb!-d! is necessary for that).
  720. You now should have the following directory tree:
  721. \begin{verbatim}
  722. c:\as
  723. c:\as\bin
  724. c:\as\include
  725. c:\as\lib
  726. c:\as\man
  727. c:\as\doc
  728. c:\as\demos
  729. \end{verbatim}
  730. Now, append the directory \verb!c:\as\bin! to the \tty{PATH} statement in
  731. your \tty{AUTOEXEC.BAT}, which allows the system to find \asname{} and its tools.
  732. With your favourite text editor, create a file named \tty{AS.RC} in the
  733. \tty{lib} directory with the following contents:
  734. \begin{verbatim}
  735. -i c:\as\include
  736. \end{verbatim}
  737. This so-called {\em key file} tells \asname{} where to search for its include
  738. files.  The following statement must be added to your \tty{AUTOEXEC.BAT}
  739. to tell \asname{} to read this file:
  740. \begin{verbatim}
  741. set ASCMD=@c:\as\lib\as.rc
  742. \end{verbatim}
  743. There are many more things you can preset via the key file; they are
  744. listed in the following section.
  745.  
  746. The installation of the DPMI version \marginpar{{\em DPMI}} should
  747. principally take the same course as for the pure DOS version; as soon as
  748. the PATH contains the {\tt bin} directory, the DOS extender's files will
  749. be found automatically and you should not notice anything of this
  750. mechanism (except for the longer startup time...).  When working on an
  751. 80286-based computer, it is theoretically possible tha you get confronted
  752. with the following message upon the first start:
  753. \begin{verbatim}
  754.  machine not in database (run DPMIINST)
  755. \end{verbatim}
  756. Since the DPMIINST tool ins not any more included in newer versions of
  757. Borland's DOS extender, I suppose that this is not an item any more...in
  758. case you run into this, contact me!
  759.  
  760. The installation of the OS/2 version \marginpar{{\em OS/2}} can generally
  761. be done just like for the DOS version, with the addition that the DLLs
  762. have to be made visible for the operating system. In case you do not want
  763. to extend the {\tt LIBPATH} entry in your {\tt CONFIG.SYS}, it is of
  764. course also valid to move the DLLs into a directory already listed in {\tt
  765. LIBPATH}.
  766.  
  767. As already mentioned, the installation instructions in this section limit
  768. themselves to binary distributions.  Since an installation under Unix
  769. \marginpar{{\em UNIX}} is currently alway a source-based installation, the
  770. only hint I can give here is a reference to appendix \ref{ChapSource}.
  771.  
  772. %%---------------------------------------------------------------------------
  773.  
  774. \section{Start-Up Command, Parameters}
  775. \label{SectCallConvention}
  776.  
  777. \asname{} is a command line driven program, i.e. all parameters and file
  778. options are to be given in the command line.
  779.  
  780. A couple of message files belongs to \asname{} (recognizable by their suffix {\tt
  781. MSG}) \asname{} accesses to dynamically load the messages appropriate for the
  782. national language.  \asname{} searches the following directories for these files:
  783. \begin{itemize}
  784. \item{the current directory;}
  785. \item{the EXE-file's directory;}
  786. \item{the directory named in the {\tt AS\_MSGPATH} environment variable,
  787.      or alternitavely the directories listed in the {\tt PATH} environment
  788.      variable;}
  789. \item{the directory compiled into \asname{} via the {\tt LIBDIR} macro.}
  790. \end{itemize}
  791. These files are {\em indispensable} for a proper operation of \asname{}, i.e. \asname{}
  792. will terminate immediately if these files are not found.
  793.  
  794. The language selection (currently only German and English) is based on the
  795. {\tt COUNTRY} setting under DOS and OS/2 respectively on the {\tt LANG}
  796. environment variable under Unix.
  797.  
  798. In order to fulfill \marginpar{{\em DOS}} \asname{}'s memory requirements under
  799. DOS, the various code generator modules of the DOS version were moved into
  800. an overlay which is part of the EXE file.  A separate OVR file like in
  801. earlier versions of \asname{} therefore dose not exist any more, \asname{} will however
  802. still attempt to reduce the overlaying delays by using eventually
  803. available EMS or XMS memory.  In case this results in
  804. trouble, you may suppress usage of EMS or XMS by setting the environment
  805. variable \tty{USEXMS} or \tty{USEEMS} to \tty{n}.  E.g., it is possible to
  806. suppress the using of XMS by the command:
  807. \begin{verbatim}
  808.   SET USEXMS=n
  809. \end{verbatim}
  810. Since \asname{} performs all in- and output via the operating system (and
  811. therefore it should run also on not 100\% compatible DOS-PC's) and
  812. needs some basic display control, it emits ANSI control sequences
  813. during the assembly.
  814. In case you \marginpar{{\em DOS/}} should see strange characters in the
  815. messages displayed by \asname{}, your \tty{CONFIG.SYS} is obviously lacking a
  816. line like this:
  817. \begin{verbatim}
  818.   device=ansi.sys
  819. \end{verbatim}
  820. but the further \marginpar{{\em DPMI}} functions of \asname{} will not be
  821. influenced hereby.  Alternatively you are able to suppress the output of
  822. ANSI sequences completely by setting the environment variable
  823. \tty{USEANSI} to \tty{n}.
  824.  
  825. The DOS extender of the DPMI version \marginpar{{\em DPMI}} can be
  826. influenced in its memory allocation strategies by a couple of environment
  827. variables; if you need to know their settings, you may look up them in the
  828. file \tty{DPMIUSER.DOC}.  It is additionally able to extend the available
  829. memory by a swap file.  To do this, set up an environment variable
  830. \tty{ASXSWAP} in the following way:
  831. \begin{verbatim}
  832.  SET ASXSWAP=<size>[,file name]
  833. \end{verbatim}
  834. The size specification has to be done in megabytes and \bb{has} to be done.
  835. The file name in contrast is optional; if it is missing, the file is
  836. named \tty{ASX.TMP} and placed in the current directory.  In any case, the
  837. swap file is deleted after program end.
  838.  
  839. The command line parameters can roughly be divided into three categories:
  840. switches, key file references (see below) and file specifications.
  841. Parameters of these two categories may be arbitrarily mixed in the command
  842. line.  The assembler evaluates at first all parameters and then assembles
  843. the specified files.  From this follow two things:
  844. \begin{itemize}
  845. \item{the specified switches affect all specified source files. If
  846.      several source files shall be assembled with different switches,
  847.      this has to be done in separate runs.}
  848. \item{it is possible to assemble more than one file in one shot and to
  849.      bring it to the top, it is allowed that the file specs contain
  850.      wildcards.}
  851. \end{itemize}
  852. Parameter switches are recognized by \asname{} by starting with
  853. a slash (/) or hyphen (-).  There are switches that are only one
  854. character long and additionally switches composed of a whole word.
  855. Whenever \asname{} cannot interpret a switch as a whole word, it tries to
  856. interprete every letter as an individual switch.  For example, if you
  857. write
  858. \begin{verbatim}
  859. -queit
  860. \end{verbatim}
  861. instead of
  862. \begin{verbatim}
  863. -quiet
  864. \end{verbatim}
  865. \asname{} will take the letters \tty{q, u, e, i}, and \tty{t} as individual
  866. switches.  Multiple-letter switches additionally have the difference to
  867. single-letter switches that \asname{} will accept an arbitrary mixture of upper
  868. and lower casing, whereas single-letter switches may have a different
  869. meaning depending on whether upper or lower case is used.
  870.  
  871. At the moment, the following switches are defined:
  872. \ttindex{SHARED}
  873. \begin{itemize}
  874. \item{\tty{l}: sends assembler listing to console terminal (mostly screen).
  875.      In case several passes have to be done, the listing of all
  876.      passes will be send to the console (in opposite to the next
  877.      option).}
  878. \item{\tty{L}: writes assembler listing into a file. The list file will get
  879.      the same name as the source file, only the extension is
  880.      replaced by \tty{LST}.  Except one uses... }
  881. \item{\tty{OLIST}: with a fiel name as argument allows to redirect the
  882.      listing to a different file or a different path.  This option may
  883.      be used multiple times in case multiple files are assembled with
  884.      one execution.}
  885. \item{\label{listradix}\tty{LISTRADIX}: By default, all numeric output in the listing
  886.      (addresses, generated code, symbol values) is written in hexadecimal
  887.      notation.  This switch requests usage of a different number system in the
  888.      range of 2 to 36.  For instance, '-listradix 8' requests octal output.
  889.      If the radix value is written with a leading zero (e.g. 08 instead of 8),
  890.      the program counter's current value is prited with leading zeros in
  891.      the listing.}
  892. \item{\tty{SPLITBYTE [character]}: Display numbers in the listing in byte groups,
  893.      separated by the given character.  A period is used as separator if
  894.      no explicit character is given.  This option is usually used in conjunction
  895.      with the \tty{LISTRADIX} option.  For instance, list radix 8 with a
  896.      period as character results in the so-called 'split octal' notation.}
  897. \item{\tty{o}: Sets the new name of the code file generated by \asname{}.  If this
  898.      option is used multiple times, the names will be assigned, one
  899.      after the other, to the source files which have to be
  900.      assembled.  A negation (see below) of this option in
  901.      connection with a name erases this name from the list.  A
  902.      negation without a name erases the whole list.}
  903. \item{\tty{SHAREOUT}:ditto for a SHARE file eventually to be created.}
  904. \item{\tty{c}: SHARED-variables will be written in a format which permits
  905.      an easy integration into a C-source file.  The extension of
  906.      the file is \tty{H}.}
  907. \item{\tty{p}: SHARED-variables will be written in a format which permits
  908.      easy integration into the CONST-block of a Pascal program.
  909.      The extension of the file is \tty{INC}.}
  910. \item{\tty{a}: SHARED-variables will be written in a format which permits
  911.      easy integration into an assembler source file. The
  912.      extension of the file is \tty{INC}.}
  913. \end{itemize}
  914. Concerning effect and function of the SHARED-symbols please see
  915. chapters \ref{ChapShareMain} resp. \ref{ChapShareOrder}.
  916. \begin{itemize}
  917. \item{\tty{g [format]}: This switch instructs \asname{} to create an additional
  918.      file that contains debug information for the program.  Allowed
  919.      formats are the \asname{}-specific MAP format ({\tt format=MAP}), a
  920.      NoICE-compatible command file ({\tt format=NOICE}), and the Atmel
  921.      format used by the AVR tools ({\tt format=ATMEL}). The information
  922.      stored in the MAP format is comprised of a symbol table and a table
  923.      describing the assignment of source lines to machine addresses.  A
  924.      more detailed description of the MAP format can be found in section
  925.      \ref{SectDebugFormat}  The file's extension is \tty{MAP}, \tty{NOI},
  926.      resp. \tty{OBJ}, depending on the chosen format.  If no explicit
  927.      format specification is done, the MAP format is chosen.}
  928. \item{\tty{noicemask [value]}: By default, \asname{} lists only symbols from the
  929.      CODE segment in NoICE debug info files.  With this option and an
  930.      integer value interpreted as a bit mask, symbols fom other segments
  931.      may be added.  The assignment of segments to bit positions may
  932.      be taken from table \ref{TabSegmentNums}.}
  933. \item{\tty{w}: suppress issue of warnings;}
  934. \item{\tty{E [file]}: error messages and warnings produced by \asname{} will be
  935.      redirected to a file. Instead of a file, the 5 standard
  936.      handles (STDIN..STDPRN) can also be specified as
  937.      \tty{!0} to \tty{!4} . Default is \tty{!2}, meaning STDERR.  If the
  938.      file option is left out, the name of the error file
  939.      is the same as of the source file, but with the
  940.      extension \tty{LOG}.}
  941. \item{\tty{q}: This switch suppresses all messages of \asname{}, the exceptions are
  942.      error messages and outputs which are are forced from the
  943.      source file.  The time needed for assembly is slightly reduced
  944.      hereby and if you call \asname{} from a shell there is no redirection
  945.      required.  The disadvantage is that you may ''stay in the dark''
  946.      for several minutes ... It is valid to write \tty{quiet} instead
  947.      of \tty{q}.}
  948. \item{\tty{v}: This is verbose, i.e. the opposite of quiet operation.  The
  949.      only additional information that is currently printed is the version
  950.      info.}
  951. \item{\tty{version}: Prints version information and exits.}
  952. \item{\tty{h}: write hexadecimal numbers in lowercase instead of capital
  953.      letters. This option is primarily a question of personal
  954.      taste.}
  955. \item{\tty{i $<$path list$>$}: issues a list of directories where the
  956.      assembler shall automatically search for include
  957.      files, in case it didn't find a file in the
  958.      current directory.  The different directories
  959.      have to be separated by semicolons.}
  960. \item{\tty{u}: calculate a list of areas which are occupied in the segments.
  961.      This option is effective only in case a listing is
  962.      produced. This option requires considerable additional
  963.      memory and computing performance. In normal operation it
  964.      should be switched off.}
  965. \item{\tty{C}: generates a list of cross references.  It lists which (global)
  966.      symbols are used in files and lines.  This list will also be
  967.      generated only in case a listing is produced.  This option
  968.      occupies, too, additional memory capacity during assembly.}
  969. \item{\tty{s}: issues a list of all sections (see chapter
  970.      \ref{ChapLocSyms}).  The nesting is indicated  by indentations
  971.      (Pascal like).}
  972. \item{\tty{t}: by means of this switch it is possible to separate single
  973.      components of the standard issued assembler-listing.  The assignment
  974.      of bits to parts can be found in the next section, where the exact
  975.      format of the assembly listing is explained.}
  976. \item{\tty{D}: defines symbols.  The symbols which are specified behind this
  977.      option and separated by commas are written to the
  978.      global symbol table before starting the assembly.  As default
  979.      these symbols are written as integer numbers with the
  980.      value TRUE, by means of an appended equal sign, however, you
  981.      can select other values.  The expression following the equals
  982.      sign may include operators or internal functions, but \bb{not}
  983.      any further symbols, even if these should have been defined
  984.      before in the list!  Together with the commands for
  985.      conditional assembly (see there) you may produce different
  986.      program versions out of one source file by command line
  987.      inputs. {\bf CAUTION!} If the case-sensitive mode is used, this has
  988.      to be specified in the command line {\em before} any symbol
  989.      definitions, otherwise symbol names will be converted to upper
  990.      case at this place!}
  991. \item{\tty{A}: stores the list of global symbols in another, more compact
  992.      form.  Use this option if the assembler crashes with a stack
  993.      overflow because of too long symbol tables.  Sometimes this
  994.      option can increase the processing speed of the assembler, but
  995.      this depends on the sources.}
  996. \item{\tty{x}: Sets the level of detail for error messages.  The level
  997.      is increased resp. decreased by one each time this option is given.
  998.      While on level 0 (default) only the error message itself is printed,
  999.      an extended message is added beginning at level 1 that should
  1000.      simplify the identification of the error's cause.  Appendix
  1001.      \ref{ChapErrMess} lists which error messages carry which extended
  1002.      messages.  At level 2 (maximum), the source line containing the
  1003.      error is additionally printed.}
  1004. \item{\tty{n}: If this option is set, the error messages will be issued
  1005.      additionally with their error number (see appendix
  1006.      \ref{ChapErrMess}).  This is primarily intended for use with shells
  1007.      or IDE's to make the identification of errors easier by those
  1008.      numbers.}
  1009. \item{\tty{U}: This option switches \asname{} to the case-sensitive mode, i.e.
  1010.      upper and lower case in the names of symbols, sections, macros,
  1011.      character sets, and user-defined functions will be distinguished.
  1012.      This is not the case by default.}
  1013. \item{\tty{P}: Instructs \asname{} to write the source text processed by macro
  1014.      processor and conditional assembly into a file.  Additional
  1015.      blank and pure comment lines are missing in this file.  The
  1016.      extension of this file is \tty{I}.}
  1017. \item{\tty{M}: If this switch is given, \asname{} generates a file, that contains
  1018.      definitions of macros defined in the source file that did not
  1019.      use the \tty{NOEXPORT} option.  This new file has the same name as
  1020.      the source file, only the extension is modified into \tty{MAC}.}
  1021. \item{\tty{G}: this switch defines whether \asname{} should produce code or not.
  1022.      If switched off, the processing will be stopped after the macro
  1023.      processor. This switch is activated by default (logically,
  1024.      otherwise you would not get a code file). This switch can be
  1025.      used in conjunction with the \tty{P} switch, if only the macro
  1026.      processor of \asname{} shall be used.}
  1027. \item{\tty{r [n]}: issue warnings if situations occur that force a further
  1028.      pass. This information can be used to reduce the number of
  1029.      passes.  You may optionally specify the number of the
  1030.      first pass where issuing of such messages shall start.
  1031.      Without this argument, warnings will come starting with
  1032.      the first pass.  Be prepared for a bunch of messages!!}
  1033. \item{\tty{bigendian}: This switch sets big endian mode for values placed
  1034.      in memory right from the program's beginning, given the target
  1035.      architecture supports the pseudo instruction of same name (see
  1036.      \ref{SectBIGENDIAN}).}
  1037. \item{\tty{plainbase}: This switch enables omission of an empty index
  1038.      argument right from the program's beginning (see \ref{SectPLAINBASE}).}
  1039. \item{\tty{underscrore-macroargs}: This switch enables usage of underscore characters
  1040.      in macro argument names (see \ref{SectMacros}).}
  1041. \item{\tty{relaxed}: this switch enables the RELAXED mode right from the
  1042.      beginning of the program, which otherwise has to be enabled by the
  1043.      pseudo instruction of sane name(see section \ref{SectRELAXED}).}
  1044. \item{\tty{supmode}: this switch enables right from the beginning of the
  1045.      program usage of machine instructions that may only be used in the
  1046.      processor's supervisor mode (see section \ref{SectSUPMODE}).}
  1047. \item{\tty{Y}: This switch instructs \asname{} to to suppress all messages about
  1048.      out-of-branch conditions, once the necessity for another pass is given.
  1049.      See section \ref{ForwRefs} for the (rare) situations that might make
  1050.      use of this switch necessary.}
  1051. \item{\tty{cpu $<$name$>$}: this switch allows to set the target processor
  1052.      \asname{} shall generate code for, in case the source file does not contain
  1053.      a {\tt CPU} instruction.  If the selected target
  1054.      supports CPU arguments (see section \ref{SectCPU}), they may be used
  1055.      on the command line as well.  Using this switch with \verb!?! or {\tt list}
  1056.      as argument lists all implemented targets.}
  1057. \item{\tty{alias $<$new$>$=$<$old$>$}:
  1058.      defines the processor type \tty{$<$new$>$} to be an alias for the
  1059.      type \tty{$<$old$>$}.  See section \ref{SectAlias} for the sense of
  1060.      processor aliases.}
  1061. \item{{\tt gnuerrors}: display messages about errors resp. warnings not
  1062.      in the \asname{} standard format, but instead in a format similar to the
  1063.      GNU C compiler.  This simplifies the integration of \asname{} into
  1064.      environments tuned for this format, however also suppresses the
  1065.      display of precise error positions in macro bodies!}
  1066. \item{{\tt maxerrors [n]}: instructs the assembler to terminate
  1067.      assembly after the given number of errors.}
  1068. \item{{\tt maxerrors [n]}: instructs the assembler to terminate
  1069.      assembly if the include nesting level exceeds the given limit
  1070.      (default is 200).}
  1071. \item{{\tt Werror}: instructs the assembler to treat warnings as errors.}
  1072. \item{\tty{compmode}: This switch instructs the assembler to operate by
  1073.      default in compatibility mode.  See section \ref{SectCompMode} for
  1074.      more information about this mode.}
  1075. \item{\tty{packing}: This switch overrides the architecture specific
  1076.      default of the {\tt PACKING} option (see section \ref{SectPACKING}).}
  1077. \end{itemize}
  1078. As long as switches require no arguments and their concatenation does
  1079. not result in a multi-letter switch, it is possible to specify several
  1080. switches at one time, as in the following example :
  1081. \begin{verbatim}
  1082. as test*.asm firstprog -cl /i c:\as\8051\include
  1083. \end{verbatim}
  1084. All files \tty{TEST*.ASM} as well as the file \tty{FIRSTPROG.ASM} will be
  1085. assembled, whereby listings of all files are displayed on the
  1086. console terminal.  Additional sharefiles will be generated in the C-
  1087. format.  The assembler should search for additional include files
  1088. in the directory \verb!C:\AS\8051\INCLUDE!.
  1089.  
  1090. This example shows that the assembler assumes \tty{ASM} as the default
  1091. extension for source files.
  1092.  
  1093. A bit of caution should be applied when using switches that have
  1094. optional arguments: if a file specification immediately follows such
  1095. a switch without the optional argument, \asname{} will try to interprete the
  1096. file specification as argument - what of course fails:
  1097. \begin{verbatim}
  1098. as -g test.asm
  1099. \end{verbatim}
  1100. The solution in this case would either be to move the -g option the
  1101. end or to specify an explicit MAP argument.
  1102.  
  1103.  
  1104. Beside from specifying options in the command line, permanently
  1105. needed options may be placed in the environment variable \tty{ASCMD}.  For
  1106. example, if someone always wants to have assembly listings and has a
  1107. fixed directory for include files, he can save a lot of typing with
  1108. the following command:
  1109. \begin{verbatim}
  1110. set ascmd=-L -i c:\as\8051\include
  1111. \end{verbatim}
  1112. The environment options are processed before the command line,
  1113. so options in the command line can override contradicting ones in the
  1114. environment variable.
  1115.  
  1116. In the case of very long path names, space in the \tty{ASCMD} variable may
  1117. become a problem.  For such cases a key file may be the alternative,
  1118. in which the options can be written in the same way as in the command
  1119. line or the \tty{ASCMD}-variable.  But this file may contain several lines
  1120. each with a maximum length of 255 characters.  In a key file it is
  1121. important, that for options which require an argument, switches and
  1122. argument have to be written in the \bb{same} line.  \asname{} gets informed of
  1123. the name of the key file by a \tty{@} aheaded in the \tty{ASCMD} variable,
  1124. e.g.
  1125. \begin{verbatim}
  1126. set ASCMD=@c:\as\as.key
  1127. \end{verbatim}
  1128. In order to neutralize options in the \tty{ASCMD} variable (or in the
  1129. key file), prefix the option with a plus sign.  For example, if you
  1130. do not want to generate an assembly listing in an individual case,
  1131. the option can be retracted in this way:
  1132. \begin{verbatim}
  1133. as +L <file>
  1134. \end{verbatim}
  1135. Naturally it is not consequently logical to deny an option by a
  1136. plus sign....  UNIX soit qui mal y pense.
  1137.  
  1138. References to key files may not only come from the {\tt ASCMD} variable,
  1139. but also directly from the command line.  Similarly to the {\tt ASCMD}
  1140. variable, prepend the file's name with a \@ character:
  1141. \begin{verbatim}
  1142. as @<file> ....
  1143. \end{verbatim}
  1144. The options read from a key file in this situation are processed as if
  1145. they had been written out in the command line in place of the reference,
  1146. {\em not} like the key file referenced by the {\tt ASCMD} variable that is
  1147. processed prior to the command line options.
  1148.  
  1149. Referencing a key file from a key file itself is not allowed and will be
  1150. answered wit an error message by \asname{}.
  1151.  
  1152. In case that you like to start \asname{} from another program or a shell and
  1153. this shell hands over only lower-case or capital letters in the
  1154. command line, the following workaround exists: if a tilde (\verb!~!) is put
  1155. in front of an option letter, the following letter is always
  1156. interpreted as a lower-case letter.  Similarly a \tty{\#} demands the
  1157. interpretation as a capital letter.  For example, the following
  1158. transformations result for:
  1159. \begin{verbatim}
  1160. /~I ---> /i
  1161. -#u ---> -U
  1162. \end{verbatim}
  1163. In dependence of the assembly's outcome, the assembler ends with
  1164. the following return codes:
  1165. \begin{description}
  1166. \item[0]{error free run, at maximum warnings occurred}
  1167. \item[1]{The assembler displayed only its command-line parameters and
  1168.         terminated immediately afterwards.}
  1169. \item[2]{Errors occurred during assembly, no code file has been produced.}
  1170. \item[3]{A fatal error occurred what led to immediate termination of the run.}
  1171. \item[4]{An error occurred already while starting the assembler.
  1172.         This may be a parameter error or a faulty overlay file.}
  1173. \item[255]{An internal error occurred during initialization that should not
  1174.         occur in any case...reboot, try again, and contact me if the
  1175.         problem is reproducible!}
  1176. \end{description}
  1177. Similar to UNIX, OS/2 \marginpar{{\em OS/2}} extends an application's data
  1178. segment on demand when the application really needs the memory.
  1179. Therefore, an output like
  1180. \begin{verbatim}
  1181.  511 KByte available memory
  1182. \end{verbatim}
  1183. does not indicate a shortly to come system crash due to memory lack,
  1184. it simply shows the distance to the limit when OS/2 will push up the
  1185. data segment's size again...
  1186.  
  1187. As there is no compatible way in C \marginpar{{\em UNIX}} under different
  1188. operating systens to find out the amount of available memory resp. stack,
  1189. both lines are missing completely from the statistics the C version prints.
  1190.  
  1191. %%---------------------------------------------------------------------------
  1192.  
  1193. \section{Format of the Input Files}
  1194. \label{AttrTypes}
  1195.  
  1196. Like most assemblers, \asname{} expects exactly one instruction per line
  1197. (blank lines are naturally allowed as well).  The lines must not be
  1198. longer than 255 characters, additional characters are discarded.
  1199.  
  1200. A single line has following format:
  1201. \begin{verbatim}
  1202. [label[:]] <mnemonic>[.attr] [param[,param..]] [;comment]
  1203. \end{verbatim}
  1204. A line may also be split over several lines in the source file,
  1205. continuation characters chain these parts together to a single line.  One
  1206. must however consider that, due to the internal buffer structure, the
  1207. total line must not be longer than 256 characters.  Line references in
  1208. error messages always relate to the last line of such a composed source
  1209. line.
  1210. \par
  1211. The colon for the label is optional, in case the label starts in the
  1212. first column (the consequence is that a machine or pseudo
  1213. instruction must not start in column 1).  It is necessary to set the
  1214. colon in case the label does not start in the first column so that \asname{}
  1215. is able to distinguish it from a mnemonic.  In the latter case, there
  1216. must be at least one space between colon and mnemonic if the processor
  1217. belongs to a family that supports an attribute that denotes an
  1218. instruction format and is separated from the mnemonic by a colon.  This
  1219. restriction is necessary to avoid ambiguities: a distinction between a
  1220. mnemonic with format and a label with mnemonic would otherwise be
  1221. impossible.
  1222.  
  1223. Some signal processor families from Texas Instruments optionally use
  1224. a double line (\verb!||!) in place of the label to signify the
  1225. parallel execution with the previous instruction(s).  If these two
  1226. assembler instructions become a single instruction word at machine
  1227. level (C3x/C4x), an additional label in front of the second
  1228. instruction of course does not make sense and is not allowed.  The
  1229. situation is different for the C6x with its instruction packets of
  1230. variable length: If someone wants to jump into the middle of an
  1231. instruction packet (bad style, if you ask me...), he has to place the
  1232. necessary label {\em before} into a separate line.  The same is valid
  1233. for conditions, which however may be combined with the double line in
  1234. a single source line.
  1235.  
  1236. The attribute is used by a couple of processors to specify variations or
  1237. different codings of a certain instruction.  The most prominent usage of
  1238. the attibute is is the specification of the operand size, for example in
  1239. the case of the 680x0 family (table \ref{TabAttrs}).
  1240. \begin{table*}[htb]
  1241. \begin{center}\begin{tabular}{|l|l|l|}
  1242. \hline
  1243. attribute & arithmetic-logic instruction & jump instruction\\
  1244. \hline
  1245. \hline
  1246. B     & byte (8 bits)                       &  8-bit-displacement \\
  1247. W     & word (16 bits)                      &  16-bit-displacement \\
  1248. L     & long word (32 bits)                 &  16-bit-displacement \\
  1249. Q     & quad word (64 bits)                 &  --------- \\
  1250. C     & half precision (16 bits)            &  --------- \\
  1251. S     & single precision (32 bits)          &  8-bit-displacement \\
  1252. D     & double precision (64 bits)          &  --------- \\
  1253. X     & extended precision (80/96 bits)     &  32-bit-displacement \\
  1254. P     & decimal floating point (80/96 bits) &  --------- \\
  1255. \hline
  1256. \end{tabular}\end{center}
  1257. \caption{Allowed Attributes (Example 680x0) \label{TabAttrs}}
  1258. \end{table*}
  1259. \par
  1260. Since this manual is not also meant as a user's manual for the processor
  1261. families supported by \asname{}, this is unfortunately not the place to enumerate
  1262. all possible attributes for all families.  It should however be mentioned
  1263. that in general, not all instructions of a given instruction set allow all
  1264. attributes and that the omission of an attribute generally leads to the
  1265. usage of the ''natural'' operand size of a processor family. For more
  1266. thorough studies, consult a reasonable programmer's manual, e.g.
  1267. \cite{Williams} for the 68K's.
  1268.  
  1269. In the case of TLCS-9000, H8/500, and M16(C), the attribute serves
  1270. both as an operand size specifier (if it is not obvious from the
  1271. operands) and as a description of the instruction format to be used.
  1272. A colon has to be used to separate the format from the operand size,
  1273. e.g. like this:
  1274. \begin{verbatim}
  1275.    add.w:g   rw10,rw8
  1276. \end{verbatim}
  1277. This example does not show that there may be a format specification
  1278. without an operand size.  In contrast, if an operand size is used
  1279. without a format specification, \asname{} will automatically use the
  1280. shortest possible format.  The allowed formats and operand sizes
  1281. again depend on the machine instruction and may be looked up e.g. in
  1282. \cite{Tosh900}, \cite{HitH8_5}, \cite{MitM16}, resp. \cite{MitM16C}.
  1283.  
  1284. The number of instruction parameters depends on the mnemonic and is
  1285. principally located between 0 and 20.  The separation of the parameters
  1286. from each other is to be performed only by commas (exception: DSP56xxx,
  1287. its parallel data transfers are separated with blanks).  Commas that
  1288. are included in brackets or quotes, of course, are not taken into
  1289. consideration.
  1290.  
  1291. Instead of a comment at the end, the whole line can consist of
  1292. comment if it starts in the first column with a semicolon.
  1293.  
  1294. To separate the individual components you may also use tabulators
  1295. instead of spaces.
  1296.  
  1297. %%---------------------------------------------------------------------------
  1298.  
  1299. \section{Format of the Listing}
  1300.  
  1301. The listing produced by \asname{} using the command line options i or I is
  1302. roughly divisible into the following parts :
  1303. \begin{enumerate}
  1304. \item{issue of the source code assembled;}
  1305. \item{symbol list;}
  1306. \item{usage list;}
  1307. \item{cross reference list.}
  1308. \end{enumerate}
  1309. The two last ones are only generated if they have been demanded by
  1310. additional command line options.
  1311.  
  1312. In the first part, \asname{} lists the complete contents of all source files
  1313. including the produced code.  A line of this listing has the following
  1314. form:
  1315. \begin{verbatim}
  1316. [<n>] <line>/<address> <code> <source>
  1317. \end{verbatim}
  1318. In the field \tty{n}, \asname{} displays the include nesting level.  The main file
  1319. (the file where assembly was started) has the depth 0, an included
  1320. file from there has depth 1 etc..  Depth 0 is not displayed: for source lines
  1321. in the main file, this field is replaced by an appropriate amount of spaces,
  1322. or is omitted entirely if no include statements have been used so far.  The
  1323. 'memory' whether there have been include statements and up to which level,
  1324. spans more than one pass.  This way, the assembler 'learns' the maximum
  1325. include depth in the first pass and is able to print this field with
  1326. consistent width throughout the whole listing.
  1327.  
  1328. In the field \tty{line}, the source line number of the referenced file is
  1329. issued. The first line of a file has the number 1.  The address to
  1330. which the code generated from this line is written follows after the
  1331. slash in the field \tty{address}.  The number system used for the address
  1332. is set via the {\tt listradix} command line option (\ref{listradix}), also
  1333. whether the address is printed with leading zeros or not.  The currently
  1334. used target defines the width of this field by the size of the address
  1335. space: for a processor with a 64K address space, four hex digits are
  1336. sufficient, while eight digits are needed if the address space's size
  1337. is 4 GBytes.
  1338.  
  1339. The code produced is written behind \tty{address} in the field \tty{code},
  1340. in hexadecimal notation. Depending on the processor type and actual
  1341. segment the values are formatted either as bytes or 16/32-bit-words.
  1342. If more code is generated than the field can take, additional lines
  1343. will be  generated, in which case only this field is used.
  1344.  
  1345. Finally, in the field \tty{source}, the line of the source file is issued in
  1346. its original form.
  1347.  
  1348. The symbol table was designed in a way that it can be displayed on an
  1349. 80-column display whenever possible. For symbols of ''normal length'',
  1350. a double column output is used.  If symbols exceed (with their name
  1351. and value) the limit of 40 columns (characters), they will be issued
  1352. in a separate line. The output is done in alphabetical order.
  1353. Symbols that have been defined but were never used are marked with a
  1354. star (*) as prefix.
  1355.  
  1356. The parts mentioned so far as well as the list of all macros/functions
  1357. defined can be selectively masked out from the listing.
  1358. This can be done by the already mentioned command line switch \tty{-t}.
  1359. There is an internal byte inside \asname{} whose bits represent which parts
  1360. are to be written.  The assignment of bits to parts of the listing is
  1361. listed in table \ref{TabTBits}.
  1362. \par
  1363. \begin{table*}[htb]
  1364. \begin{center}\begin{tabular}{|l|l|}
  1365. \hline
  1366. bit &  part \\
  1367. \hline
  1368. \hline
  1369. 0   & source file(s) + produced code \\
  1370. 1   & symbol table \\
  1371. 2   & macro list \\
  1372. 3   & function list \\
  1373. 4   & line numbering \\
  1374. 5   & register symbol list \\
  1375. 7   & character set table \\
  1376. \hline
  1377. \end{tabular}\end{center}
  1378. \caption{Assignment of Bits to Listing Components\label{TabTBits}}
  1379. \end{table*}
  1380. All bits are set to 1 by default, when using the switch
  1381. \begin{verbatim}
  1382. -t <mask>
  1383. \end{verbatim}
  1384. Bits set in \tty{$<$mask$>$} are cleared, so that the respective listing
  1385. parts are suppressed.  Accordingly it is possible to switch on single
  1386. parts again with a plus sign, in case you had switched off too much
  1387. with the \tty{ASCMD} variable... If someone wants to have, for example,
  1388. only the symbol table, it is enough to write:
  1389. \begin{verbatim}
  1390. -t 2
  1391. \end{verbatim}
  1392. The usage list issues the occupied areas hexadecimally for every
  1393. single segment.  If the area has only one address, only this is written,
  1394. otherwise the first and last address.
  1395.  
  1396. The cross reference list issues any defined symbol in alphabetical
  1397. order and has the following form:
  1398. \begin{verbatim}
  1399. symbol <symbol name> (=<value>,<file>/<line>):
  1400.  file <file 1>:
  1401.  <n1>[(m1)]  ..... <nk>[(mk)]
  1402.  .
  1403.  .
  1404.  file <file l>:
  1405.  <n1>[(m1)]  ..... <nk>[(mk)]
  1406. \end{verbatim}
  1407. The cross reference list lists for every symbol in which files and lines
  1408. it has been used.  If a symbol was used several times in the same line,
  1409. this would be indicated by a number in brackets behind the line number.
  1410. If a symbol was never used, it would not appear in the list; The same is
  1411. true for a file that does not contain any references for the symbol in
  1412. question.
  1413.  
  1414. \bb{CAUTION!}  \asname{} can only print the listing correctly if it was
  1415. previously informed about the output media's page length and width!
  1416. This has to be done with the \tty{PAGE} instruction (see \ref{SectPAGE}).  The
  1417. preset default is a length of 60 lines and an unlimited line width.
  1418.  
  1419. %%---------------------------------------------------------------------------
  1420.  
  1421. \section{Symbol Conventions}
  1422. \label{SectSymConv}
  1423.  
  1424. Symbols are allowed to be up to 255 characters long (as hinted already
  1425. in the introduction) and are being distinguished on the whole
  1426. length, but the symbol names have to meet some conventions:
  1427.  
  1428. Symbol names are allowed to consist of a random combination of
  1429. letters, digits, underlines and dots, whereby the first character must
  1430. not be a digit. The dot is only allowed to meet the MCS-51 notation of
  1431. register bits and should - as far as possible - not be used in own symbol
  1432. names.  To separate symbol names in any case the underline (\tty{\_}) and not
  1433. the dot (\tty{.}) should be used .
  1434.  
  1435. \asname{} is by default not case-sensitive, i.e. it does not matter whether
  1436. one uses upper or lower case characters.  The command line switch \tty{U}
  1437. however allows to switch \asname{} into a mode where upper and lower case
  1438. makes a difference.  The predefined symbol \tty{CASESENSITIVE} signifies
  1439. whether \asname{} has been switched to this mode: TRUE means case-sensitiveness,
  1440. and FALSE its absence.
  1441.  
  1442. Table \ref{TabPredefined} shows the most important symbols which are
  1443. predefined by \asname{}.
  1444. \begin{table*}[htb]
  1445. \begin{center}\begin{tabular}{|l|l|}
  1446. \hline
  1447. name          & meaning \\
  1448. \hline
  1449. \hline
  1450. TRUE          & logically ''true'' \\
  1451. FALSE         & logically ''false'' \\
  1452. CONSTPI       & Pi (3.1415.....) \\
  1453. VERSION       & version of \asname{} in BCD-coding, \\
  1454.              & e.g. 1331 hex for version 1.33p1 \\
  1455. ARCHITECTURE  & target platform \asname{} was compiled for, in \\
  1456.              & the style processor-manufacturer-operating \\
  1457.              & system \\
  1458. DATE          & date and \\
  1459. TIME          & time of the assembly (start) \\
  1460. MOMCPU        & current target CPU \\
  1461.              & (see the CPU instruction) \\
  1462. MOMFILE       & current source file \\
  1463. MOMLINE       & line number in source file \\
  1464. MOMPASS       & number of the currently running pass \\
  1465. MOMSECTION    & name of the current section \\
  1466.              & or an empty string \\
  1467. \verb!*!, ,. \$ resp. PC & current value of program counter \\
  1468. \hline
  1469. \end{tabular}\end{center}
  1470. \caption{Predefined Symbols\label{TabPredefined}}
  1471. \end{table*}
  1472. \bb{CAUTION!}  While it does not matter in case-sensitive mode which
  1473. combination of upper and lower case to use to reference predefined
  1474. symbols, one has to use exactly the version given above (only upper
  1475. case) when \asname{} is in case-sensitive mode!
  1476. Additionally some pseudo instructions define symbols that reflect the
  1477. value that has been set  with these instructions.  Their descriptions
  1478. are explained at the individual commands belonging to them.
  1479. A hidden feature (that has to be used with care) is that symbol names
  1480. may be assembled from the contents of string symbols.  This can be
  1481. achieved by framing the string symbol's name with curly braces and
  1482. inserting it into the new symbol's name.  This allows for example to
  1483. define a symbol's name based on the value of another symbol:
  1484. \begin{verbatim}
  1485. cnt             set     cnt+1
  1486. temp            equ     "\{CNT}"
  1487.                jnz     skip{temp}
  1488.                .
  1489.                .
  1490. skip{temp}:     nop
  1491. \end{verbatim}
  1492. \bb{CAUTION:} The programmer has to assure that only valid symbol names
  1493. are generated!
  1494. A complete list of all symbols predefined by \asname{} can be found in
  1495. appendix \ref{AppInternSyms}.
  1496. Apart from its value, every symbol also owns a marker which signifies to
  1497. which {\em segment} it belongs.  Such a distinction is mainly needed for
  1498. processors that have more than one address space.  The additional
  1499. information allows \asname{} to issue a warning when a wrong instruction is used
  1500. to access a symbol from a certain address space.  A segment attribute is
  1501. automatically added to a symbol when is gets defined via a label or a
  1502. special instruction like \tty{BIT}; a symbol defined via the ''allround
  1503. instructions'' \tty{SET} resp. \tty{EQU} is however ''typeless'', i.e. its
  1504. usage will never trigger warnings.  A symbol's segment attribute may be
  1505. queried via the buit-in function \tty{SYMTYPE}, e.g.:
  1506. \begin{verbatim}
  1507. Label:
  1508.        .
  1509.        .
  1510. Attr    equ     symtype(Label)  ; results in 1
  1511. \end{verbatim}
  1512. The individual segment types have the assigned numbers listed in table
  1513. \ref{TabSegNums}.  Register symbols which do not really fit into the order
  1514. of normal symbols are explained in section \ref{SectRegSyms}.  The
  1515. \tty{SYMTYPE} function delivers -1 as result when called with an undefined
  1516. symbol as argument.  However, if all you want to know is whether a symbol
  1517. is defined or not, you may as well use the \tty{DEFINED} function.
  1518. \begin{table}[htb]
  1519. \begin{center}
  1520. \begin{tabular}{|l|c|}
  1521. \hline
  1522. segment & return value \\
  1523. \hline
  1524. $<$none$>$ & 0 \\
  1525. CODE & 1 \\
  1526. DATA & 2 \\
  1527. IDATA & 3 \\
  1528. XDATA & 4 \\
  1529. YDATA & 5 \\
  1530. BITDATA & 6 \\
  1531. IO & 7 \\
  1532. REG & 8 \\
  1533. ROMDATA & 9 \\
  1534. EEDATA & 10 \\
  1535. $<$Register Symbol$>$ & 128 \\
  1536. \hline
  1537. \end{tabular}
  1538. \end{center}
  1539. \caption{return values of the \tty{SYMTYPE} function\label{TabSegNums}}
  1540. \end{table}
  1541.  
  1542. %%---------------------------------------------------------------------------
  1543.  
  1544. \section{Temporary Symbols}
  1545.  
  1546. Especially when dealing with programs that contain sequences of loops of
  1547. if-like statements, one is continuously faced with the problem of
  1548. inventing new names for labels - labels of which you know exactly that you
  1549. will never need to reference them again afterwards and you really would
  1550. like to get 'rid' of them somehow.  A simple solution if you don't want to
  1551. swing the large hammer of sections (see chapter \ref{ChapLocSyms}) are
  1552. {\em temporary} symbols which remain valid as long as a new,
  1553. non-temporary symbol gets defined.  Other assemblers offer a similar
  1554. mechanism which is commonly referred as 'local symbols'; however, for the
  1555. sake of a better distinction, I want to stay with the term 'temporary
  1556. symbols'.  \asname{} knows three different types of temporary symbols, in the
  1557. hope to offer everyone 'switching' to \asname{} a solution that makes conversion
  1558. as easy as possible.  However, practically every assembler has its own
  1559. interpretation of this feature, so there will be only few cases where a
  1560. 1:1 solution for existing code:
  1561.  
  1562. \section{Named Temporary Symbols}
  1563.  
  1564. A symbol whose name starts with two dollar signs (something that is
  1565. neither allowed for non-temporary symbols nor for constants) is a named
  1566. temporary symbol.  \asname{} keeps an internal counter which is reset to 0 before
  1567. assembly begins and which gets incremented upon every definition of a
  1568. non-temporary symbol.  When a temporary symbol is defined or referenced,
  1569. both leading dollar signs are discarded and the counter's current value is
  1570. appended.  This way, one regains the used symbol names with every
  1571. definition of a non-temporary symbol - but you also cannot reach the
  1572. previously symbols any more! Temporary symbols are therefore especially
  1573. suited for usage in small instruction blocks, typically a dozen of machine
  1574. instructions, definitely not more than one screen.  Otherwise, one easily
  1575. gets confused...
  1576.  
  1577. Here is a small example:
  1578. \begin{verbatim}
  1579. $$loop: nop
  1580.        dbra    d0,$$loop
  1581. split:
  1582. $$loop: nop
  1583.        dbra    d0,$$loop
  1584. \end{verbatim}
  1585. Without the non-temporary label between the loops, of course an error
  1586. message about a double-defined symbol would be the result.
  1587.  
  1588. \subsection{Nameless Temporary Symbols}
  1589.  
  1590. For all those who regard named temporary symbols still as too complicated,
  1591. there is an even simpler variant: If one places a single puls or minus
  1592. sign as a label, this is converted to symbol names of {\tt \_\_forwnn}
  1593. respectively {\tt \_\_backmm}, with {\tt nn} respectively {\tt mm} being
  1594. counters that start counting at zero.  Those symbols are referenced via
  1595. the special names {\tt - -- ---} respectively {\tt + ++ +++}, which refer
  1596. to the three last 'minus symbols' and the next three 'plus symbols'.
  1597. Therefore, the selection between these two variants depends on whether one
  1598. wants to forward- or backward-reference a symbol.
  1599.  
  1600. Apart from plus and minus, {\em defining} nameless temporary symbols also
  1601. exists in a third variant, namely a slash (/).  A temporary symbol defined
  1602. in this way may be referenced both backward and forward, i.e. it is
  1603. treated either as a plus or a minus, depending on the way it is being
  1604. referenced.
  1605.  
  1606. Nameless temporary symbols are usually used in constructs that fit on one
  1607. screen page, like skipping a few machine instructions or tight loops -
  1608. things would becone to puzzling otherwise (this only a good advice,
  1609. however...).  An example for this is the following piece of code, this
  1610. time as 65xx code:
  1611. \begin{verbatim}
  1612.        cpu     6502
  1613.  
  1614. -       ldx     #00
  1615. -       dex
  1616.        bne     -           ; branch to 'dex'
  1617.        lda     RealSymbol
  1618.        beq     +           ; branch to 'bne --'
  1619.        jsr     SomeRtn
  1620.        iny
  1621. +       bne     --          ; branch to 'ldx #00'
  1622.  
  1623. SomeRtn:
  1624.        rts
  1625.  
  1626. RealSymbol:
  1627.        dfs     1
  1628.  
  1629.         inc     ptr
  1630.         bne     +           ; branch to 'tax'
  1631.         inc     ptr+1
  1632. +       tax
  1633.  
  1634.         bpl     ++          ; branch to 'dex'
  1635.         beq     +           ; branch forward to 'rts'
  1636.         lda     #0
  1637. /       rts                 ; slash used as wildcard.
  1638. +       dex
  1639.         beq     -           ; branch backward to 'rts'
  1640.  
  1641. ptr:    dfs     2
  1642. \end{verbatim}
  1643.  
  1644. \subsection{Composed Temporary Symbols}
  1645.  
  1646. This is maybe the type of temporary symbols that is nearest to the concept
  1647. of local symbols and sections.  Whenever a symbol's name begins with a dot
  1648. (.), the symbol is not directly stored with this name in the symbol table.
  1649. Instead, the name of the most recently-defined symbol not beginning with a
  1650. dot is prepended to the symbols name.  This way, 'non-dotted' symbols take
  1651. the role of section separators and 'dotted' symbol names may be reused
  1652. after a 'non-dotted' symbol has been defined.  Take a look at the
  1653. following little example:
  1654. \begin{verbatim}
  1655. proc1:                          ; non-temporary symbol 'proc1'
  1656.  
  1657. .loop   moveq   #20,d0          ; actually defines 'proc1.loop'
  1658.         dbra    d0,.loop
  1659.         rts
  1660.  
  1661. proc2:                          ; non-temporary symbol 'proc2'
  1662.  
  1663. .loop   moveq   #10,d1          ; actually defines 'proc2.loop'
  1664.         jsr     proc1
  1665.         dbra    d1,.loop
  1666.         rts
  1667. \end{verbatim}
  1668. Note that it is still possible to access all temporary symbols, even
  1669. without being in the same 'area', by simply using the composed name (like
  1670. 'proc2.loop' in the previous example).
  1671.  
  1672. It is principally possible to combine composed temporary symbols with
  1673. sections, which makes them also to local symbols.  Take however into
  1674. account that the most recent non-temporary symbol is not stored
  1675. per-section, but simply globally.  This may change however in a future
  1676. version, so one shouldn't rely on the current behaviour.
  1677.  
  1678. %%---------------------------------------------------------------------------
  1679.  
  1680. \section{Formula Expressions}
  1681.  
  1682. In most places where the assembler expects numeric inputs, it is
  1683. possible to specify not only simple symbols or constants, but also
  1684. complete formula expressions.  The components of these formula
  1685. expressions can be either single symbols and constants.  Constants may be
  1686. either integer, floating point, or string constants.
  1687.  
  1688. \subsection{Integer Constants}
  1689. \label{SectIntConsts}
  1690.  
  1691. Integer constants describe non-fractional numbers.  They are witten as a
  1692. sequence of digits.  This may be done in different numbering systems (see
  1693. table \ref{TabSystems}).
  1694. \par
  1695. \begin{table*}[htb]
  1696. \begin{center}\begin{tabular}{|l|c|c|c|c|}
  1697. \hline
  1698.          & Intel Mode    & Motorola Mode & C Mode    & IBM Mode \\
  1699. \hline
  1700. \hline
  1701. Decimal   & Direct        & Direct      & Direct      & Direct \\
  1702. Hex       & Suffix H      & Prefix \$   & Prefix 0x   & X'..' or H'..' \\
  1703. \ii{Ident}& \tty{hexh}    & \tty{\$hex} & \tty{0xhex} & \tty{x'hex'} \\
  1704.          &               &             &             & \tty{h'hex'} \\
  1705. Binary    & Suffix B      & Prefix \%   & Prefix 0b   & O'..' \\
  1706. \ii{Ident}& \tty{binb}    & \tty{\%bin} & \tty{0bbin} & \tty{b'bin'} \\
  1707. Octal     & Suffix O or Q & Prefix @    & Prefix 0    & B'..' \\
  1708. \ii{Ident}& \tty{octo}    & \tty{@oct}  & \tty{0oct}  & \tty{o'oct'} \\  
  1709.          & \tty{octq}    &             &             & \\
  1710. ASCII     &               &             &             & A'..' \\
  1711. \ii{Ident}&               &             &             & \tty{a'asc'} \\
  1712. \hline
  1713. \end{tabular}\end{center}
  1714. \caption{Defined Numbering Systems and Notations\label{TabSystems}}
  1715. \end{table*}
  1716. In case the numbering system has not been explicitly stated by adding the
  1717. special control characters listed in the table, \asname{} assumes the base given
  1718. with the {\tt RADIX} statement (which has itself 10 as default).  This
  1719. statement allows to set up 'unusual' numbering systems, i.e. others than
  1720. 2, 8, 10, or 16.
  1721.  
  1722. Valid digits are numbers from 0 to 9 and letters from A to Z (value 10 to
  1723. 35) up to the numbering system's base minus one. An exception from this is
  1724. the ASCII represenation: For this variant, a character's ASCII value (or its
  1725. code in the currently active code page, see section \ref{SectCHARSET})
  1726. describes a whole byte.  Therefore, integer constants written this way
  1727. are identical to multi character constants.  These two expressions:
  1728. \begin{verbatim}
  1729. 'ABCD'
  1730. A'ABCD'
  1731. \end{verbatim}
  1732. are identical, the 'A' prefix is redundant.  One may enable this syntax
  1733. for existing code, because there are a few original assemblers (e.g.
  1734. for the Signetics 2650) that support this syntax.
  1735.  
  1736. Independent of the target, \asname{} implements multi character constants
  1737. in big endian order, which means that 'ABCD' results in an integer
  1738. value of 0x41424344.  Why this? Well, \asname{}'s first target was the
  1739. Motorola 60008, and no one ever objected...the only exception from
  1740. this is the PDP-11 (and the WD16 which uses an LSI-11): For better
  1741. compatibility to DEC's MACRO-11, multi character are little endian
  1742. if this target is used.  For instance, 'AB' results in ain integer
  1743. value of 0x4241.
  1744.  
  1745. The usage of letters in integer constants however brings along some ambiguities
  1746. since symbol names are also sequences of numbers and letters: a symbol name
  1747. however must not start with a character from 0 to 9.  This means that an
  1748. integer constant which is not clearly marked a such with a special prefix
  1749. character must not begin with a letter.  One has to add an additional,
  1750. otherwise superfluous zero in front in such cases.  The most prominent case
  1751. is the writing of hexadecimal constants in Intel mode:  If the leftmost digit
  1752. is between A and F, the trailing H doesn't help to clarify, an additional 0
  1753. has to be prefixed (e.g. 0F0H instead of F0H).  The Motorola and C syntaxes
  1754. which both mark the numbering system at the front of a constant do not have
  1755. this issue.
  1756.  
  1757. Quite tricky is furthermore that the higher the default numbering system
  1758. set via {\tt RADIX} becomes, the more letters used to denote numbering
  1759. systems in Intel and C syntax become 'eaten'.  For example, you cannot
  1760. write binary constants anymore after a {\tt RADIX 16}, and starting at
  1761. {\tt RADIX 18}, the Intel syntax even doesn't allow to write hexadecimal
  1762. constants any more.  Therefore {\bf CAUTION!}
  1763.  
  1764. Appendix \ref{SectPseudoInst} lists which syntax is used by which target
  1765. by default.  Independent of this default, there is always the option to
  1766. add or delete individual syntax variants via the \tty{INTSYNTAX} instruction
  1767. (see section \ref{SectINTSYNTAX}).  The names listed as \ii{Ident},
  1768. prefixed with a plus or minus sign, serve as arguments to this instruction.
  1769.  
  1770. The \tty{RELAXED} instruction (see section \ref{SectRELAXED}) serves as
  1771. a sort 'global enable switch': in relaxed mode, all notations may be used,
  1772. independent of the selected target processor.  The result is that an arbitrary
  1773. syntax may be used (possibly loosing compatibility to standard assemblers).
  1774.  
  1775. Both \tty{INTSYNTAX} and \tty{RELAXED} specifically enable usage of the
  1776. 'IBM syntax' for all targets, which is sometimes found on other assemblers:
  1777.  
  1778. This notation puts the actual value into apostrophes and prepends
  1779. the numbering system ('x' or 'h' for hexadecimal, 'o' for octal and 'b'
  1780. for binary).  So, the integer constant 305419896 can be written in the
  1781. following ways:
  1782. \begin{verbatim}
  1783. x'12345678'
  1784. h'12345678'
  1785. o'2215053170'
  1786. b'00010010001101000101011001111000'
  1787. \end{verbatim}
  1788. Another variant of this notation for some targets is to leave away the
  1789. closing apostrophe, to allow simpler porting of existing code.  It is
  1790. not recommended for new programs.
  1791.  
  1792. \subsection{Floating Point Constants}
  1793.  
  1794. Floating point constants are to be written in the usual scientific
  1795. notation, which is known in the most general form:
  1796. \begin{verbatim}
  1797. [-]<integer digits>[.post decimal positions][E[-]exponent]
  1798. \end{verbatim}
  1799. \bb{CAUTION!} The assembler first tries to interprete a constant as an
  1800. integer constant and makes a floating-point format try only in case
  1801. the first one failed.  If someone wants to enforce the evaluation as
  1802. a floating point number, this can be done by dummy post decimal
  1803. positions, e.g.  \tty{2.0} instead of \tty{2}.
  1804.  
  1805. \subsection{String Constants}
  1806. \label{SectStringConsts}
  1807.  
  1808. String constants have to be enclosed in single or double quotation marks.
  1809. In order to make it possible to include quotation marks or special characters
  1810. in string constants, an ''escape mechanism'' has been implemented, which
  1811. should sound familiar for C programmers:
  1812.  
  1813. The assembler understands a backslash (\verb!\!) with a following decimal
  1814. number of three digits maximum in the string as a character with the
  1815. according decimal ASCII value.  The numerical value may alternitavely be
  1816. written in hexadecimal or octal notation if it is prefixed with an x resp.
  1817. a 0.  In case of hexadecimal notation, the maximum number of digits is
  1818. limited to 2.  For example, it is possible to include an ETC character by
  1819. writing {\tt\verb!\!3}.  But be careful with the definition of NUL
  1820. characters!  The C \marginpar{{\em UNIX}} version currently uses C strings
  1821. to store strings internally.  As C strings use a NUL character for
  1822. termination, the usage of NUL characters in strings is currently not
  1823. portable!
  1824.  
  1825. Some frequently used control characters can also be reached with the
  1826. following abbreviations:
  1827. \begin{verbatim}
  1828. \b : Backspace           \a : Bell         \e : Escape
  1829. \t : Tabulator           \n : Linefeed     \r : Carriage Return
  1830. \\ : Backslash           \' or \H : Apostrophe
  1831. \" or \I : Quotation marks
  1832. \end{verbatim}
  1833. Both upper and lower case characters may be used for the
  1834. identification letters.
  1835.  
  1836. By means of this escape character, you can even work formula
  1837. expressions into a string, if they are enclosed by curly braces: e.g.
  1838. \begin{verbatim}
  1839.     message "root of 81 : \{sqrt(81)}"
  1840. \end{verbatim}
  1841. results in
  1842. \begin{verbatim}
  1843.              root of 81 : 9
  1844. \end{verbatim}
  1845. \asname{} chooses with the help of the formula result type the correct
  1846. output format, further string constants, however, are to be avoided
  1847. in the expression.  Otherwise the assembler will get mixed up at the
  1848. transformation of capitals into lower case letters.  Integer results will
  1849. by default be written in hexadecimal notation, which may be changed via
  1850. the \tty{OUTRADIX} instruction.
  1851.  
  1852. Except for the insertion of formula expressions, you can use this
  1853. ''escape-mechanism'' as well in ASCII defined integer constants,
  1854. like this:
  1855. \begin{verbatim}
  1856.     move.b   #'\n',d0
  1857. \end{verbatim}
  1858. However, everything has its limits, because the parser with higher
  1859. priority, which disassembles a line into op-code and parameters, does
  1860. not know what it is actually working with, e.g. here:
  1861. \begin{verbatim}
  1862.     move.l   #'\'abc',d0
  1863. \end{verbatim}
  1864. After the third apostrophe, it will not find the comma any more,
  1865. because it presumes that it is the start of a further character
  1866. constant. An error message about a wrong parameter number is the result.
  1867. A workaround would be to write e.g., \verb!\i! instead of \verb!\'!.
  1868.  
  1869. \subsection{String to Integer Conversion and Character Constants}
  1870.  
  1871. Earlier versions of \asname{} strictly distinguished between character
  1872. strings and so-called ''character constants'': At first glance, a
  1873. character constant looks like a string, the characters are however
  1874. enclosed in single instead of double quotation marks.  Such an object had
  1875. the data type 'Integer', i.e. it represented a number with the value
  1876. given by the (ASCII) code of the character, and it was something
  1877. completely different:
  1878.  
  1879. \begin{verbatim}
  1880.   move.b   #65,d0
  1881.   move.b   #'A',d0      ; equal to first instruction
  1882.   move.b   #"A",d0      ; not allowed in older versions!
  1883. \end{verbatim}
  1884.  
  1885. This strict differentiation {\em no longer exists}, so it is irrelevant
  1886. whether single or double quotes are used.  If an integer value
  1887. is expected as argument, and a string is used, the conversion via the
  1888. character's (ASCII) value is done ''on the fly'' at this place. This
  1889. means that in the example given, {\em all three lines} result in the
  1890. same machine code.
  1891.  
  1892. Such an implicit conversion to integer values also take place for strings
  1893. consisting of multiple constancs, which are sometimes called ''multi
  1894. character constants'':
  1895. \begin{verbatim}
  1896. 'A'    ==$41
  1897. 'AB'   ==$4142
  1898. 'ABCD' ==$41424344
  1899. \end{verbatim}
  1900. Multi character constants are the only case where using single or double
  1901. quotes still makes a difference.  Many targets define pseudo instructions
  1902. to dispose constants in memory, and which accept different data types.
  1903. In such a case, it is still necessary to use double quotes if a character
  1904. string shall be placed in memory:
  1905. \begin{verbatim}
  1906.    dc.w    "ab"  ; disposes two words (0x0041,0x0042)
  1907.    dc.w    'ab'  ; disposes one word (0x4142)
  1908. \end{verbatim}
  1909. Important: using the correct quotation is not necessary if the character
  1910. string is longer than the used operand size, which is two characters or
  1911. 16 bits in this example.
  1912. \subsection{Evaluation}
  1913. The calculation of intermediary results within formula expressions is
  1914. always done with the highest available resolution, i.e. 32 or 64 bits for
  1915. integer numbers, 80 bit for floating point numbers and 255 characters
  1916. for strings.  An possible test of value range overflows is done only
  1917. on the final result.
  1918. The portable C version \marginpar{{\em UNIX}} only supports floating
  1919. point values up to 64 bits (resulting in a maximum value of roughly
  1920. $10^{308}$), but in turn features integer lengths of 64 bits on some
  1921. platforms.
  1922. \subsection{Operators}
  1923. The assembler provides the operands listed in table \ref{TabOps} for
  1924. combination.
  1925. \begin{table*}[htbp]
  1926. \begin{center}\begin{tabular}{|c|l|c|c|c|c|c|c|}
  1927. \hline
  1928. Operand & Function            & \#Args & Int & Float & String & Reg & Rank \\
  1929. \hline
  1930. \hline
  1931. $<>$        & inequality       & 2 & yes   & yes & yes & yes & 14 \\
  1932. $!=$        & alias for $<>$   &   &       &     &     &     &    \\
  1933. $>=$        & greater or equal & 2 & yes   & yes & yes & yes & 14 \\
  1934. $<=$        & less or equal    & 2 & yes   & yes & yes & yes & 14 \\
  1935. $<$         & truly smaller    & 2 & yes   & yes & yes & yes & 14 \\
  1936. $>$         & truly greater    & 2 & yes   & yes & yes & yes & 14 \\
  1937. $=$         & equality         & 2 & yes   & yes & yes & yes & 14 \\
  1938. $==$        & alias for $=$    &   &       &     &     &     &    \\
  1939.            & & & & & &  \\
  1940. $!!$        & log. XOR         & 2 & yes   & no  & no  & no  & 13 \\
  1941. $||$        & log. OR          & 2 & yes   & no  & no  & no  & 12 \\
  1942. \&\&        & log. AND         & 2 & yes   & no  & no  & no  & 11 \\
  1943. \verb! ~~ ! & log. NOT         & 1 & yes   & no  & no  & no  & 2 \\
  1944.            & & & & & &  \\
  1945. -           & difference       & 2 & yes   & yes & no  & no  & 10 \\
  1946. +           & sum              & 2 & yes   & yes & yes & no  & 10 \\
  1947. \#          & modulo division  & 2 & yes   & no  & no  & no  & 9 \\
  1948. /           & quotient         & 2 & yes*) & yes & no  & no  & 9 \\
  1949. \verb! * !  & product          & 2 & yes   & yes & no  & no  & 9 \\
  1950. \verb! ^ !  & power            & 2 & yes   & yes & no  & no  & 8 \\
  1951.            & & & & & &  \\
  1952. $!$         & binary XOR       & 2 & yes   & no  & no  & no  & 7 \\
  1953. $|$         & binary OR        & 2 & yes   & no  & no  & no  & 6 \\
  1954. \&          & binary AND       & 2 & yes   & no  & no  & no  & 5 \\
  1955. $><$        & mirror of bits   & 2 & yes   & no  & no  & no  & 4 \\
  1956. $>>$        & log. shift right & 2 & yes   & no  & no  & no  & 3 \\
  1957. $<<$        & log. shift left  & 2 & yes   & no  & no  & no  & 3 \\
  1958. \verb! ~ !  & binary NOT       & 1 & yes   & no  & no  & no  & 1 \\
  1959. \hline
  1960. \multicolumn{8}{|l|}{*) remainder will be discarded} \\
  1961. \hline
  1962. \end{tabular}\end{center}
  1963. \caption{Operators Predefined by \asname{}\label{TabOps}}
  1964. \end{table*}
  1965. ''Rank'' is the priority of an operator at the separation of expressions
  1966. into subexpressions.  The operator with the highest rank will be
  1967. evaluated at the very end.  The order of evaluation can be defined by
  1968. new bracketing.
  1969. The comparison operators deliver TRUE in case the condition fits,
  1970. and FALSE in case it doesn't.  For the logical operators an expression
  1971. is TRUE in case it is not 0, otherwise it is FALSE.
  1972. Two details have to be kept im mind when comparing register symbols.
  1973. First, two register symbols are equal if they refer to the same
  1974. register.  Some processors have alias names for registers, and these
  1975. aliases are regarded as equal.  Fr instance, the {\tt A7} register
  1976. of a 68000 may also be referred to as {\tt SP}, and those two register
  1977. symbols are equal.  On the other hand, some processors have more than
  1978. one set of registers.  The 68040, fo rinstance, has 'normal' (integer)
  1979. and floating point registers.  There is no greater or smaller relation
  1980. between registers from different groups, the corresponding operators
  1981. always return FALSE.  Only a test for equality or inequality makes
  1982. sense.
  1983. The mirroring of bits probably needs a little bit of explanation: the
  1984. operator mirrors the lowest bits in the first operand and leaves the
  1985. higher priority bits unchanged.  The number of bits which is to be
  1986. mirrored is given by the right operand and may be between 1 and 32 .
  1987. A small pitfall is hidden in the binary complement: As the
  1988. computation is always done with 32 resp. 64 bits, its application on
  1989. e.g. 8-bit masks usually results in values taht do not fit into 8-bit
  1990. numbers any more due to the leading ones.  A binary AND with a
  1991. fitting mask is therefore unavoidable!
  1992. \subsection{Functions}
  1993. In addition to the operators, the assembler defines another line of
  1994. primarily transcendental functions with floating point arguments which are
  1995. listed in tables \ref{TabFuncs1} and \ref{TabFuncs2}.
  1996. \begin{table*}[htbp]
  1997. \begin{center}\begin{tabular}{|l|l|l|l|}
  1998. \hline
  1999. name     & meaning              & argument             & result \\
  2000. \hline
  2001. \hline
  2002. SQRT     & square root          & $arg \geq 0$         & floating point \\
  2003.         &                      &                      & \\
  2004. SIN      & sine                 & $arg \in \rz$        & floating point \\
  2005. COS      & cosine               & $arg \in \rz$        & floating point \\
  2006. TAN      & tangent              & $arg \neq (2n+1)*\frac{\pi}{2}$ & floating point \\
  2007. COT      & cotangent            & $arg \neq n*\pi$     & floating point \\
  2008.         &                      &                      & \\
  2009. ASIN     & inverse sine         & $\mid arg \mid \leq 1$ & floating point \\
  2010. ACOS     & inverse cosine       & $\mid arg \mid \leq 1$ & floating point \\
  2011. ATAN     & inverse tangent      & $arg \in \rz$        & floating point \\
  2012. ACOT     & inverse cotangent    & $arg \in \rz$        & floating point \\
  2013.         &                      &                      & \\
  2014. EXP      & exponential function & $arg \in \rz$        & floating point \\
  2015. ALOG     & 10 power of argument & $arg \in \rz$        & floating point \\
  2016. ALD      & 2 power of argument  & $arg \in \rz$        & floating point \\
  2017. SINH     & hyp. sine            & $arg \in \rz$        & floating point \\
  2018. COSH     & hyp. cosine          & $arg \in \rz$        & floating point \\
  2019. TANH     & hyp. tangent         & $arg \in \rz$        & floating point \\
  2020. COTH     & hyp. cotangent       & $arg \neq 0$         & floating point \\
  2021.         &                      &                      & \\
  2022. LN       & nat. logarithm       & $arg > 0$            & floating point \\
  2023. LOG      & dec. logarithm       & $arg > 0$            & floating point \\
  2024. LD       & bin. logarithm       & $arg > 0$            & floating point \\
  2025. ASINH    & inv. hyp. Sine       & $arg \in \rz$        & floating point \\
  2026. ACOSH    & inv. hyp. Cosine     & $arg \geq 1$         & floating point \\
  2027. ATANH    & inv. hyp. Tangent    & $arg < 1$            & floating point \\
  2028. ACOTH    & inv. hyp. Cotangent  & $arg > 1$            & floating point \\
  2029.         &                      &                      & \\
  2030. INT      & integer part         & $arg \in \rz$        & floating point \\
  2031. \hline
  2032. BITCNT   & number of one's      & integer              & integer \\
  2033. FIRSTBIT & lowest 1-bit         & integer              & integer \\
  2034. \hline
  2035. \end{tabular}\end{center}
  2036. \caption{Functions Predefined by \asname{} - Part 1 (Integer and
  2037.         Floating Point Functions \label{TabFuncs1}}
  2038. \end{table*}
  2039. \begin{table*}[htbp]
  2040. \begin{center}\begin{tabular}{|l|l|l|l|}
  2041. \hline
  2042. name        & meaning              & argument & result \\
  2043. \hline
  2044. \hline
  2045. LASTBIT     & highest 1-bit        & integer              & integer \\
  2046. BITPOS      & unique 1-bit         & integer              & integer \\
  2047.            &                      &                      & \\
  2048. SGN         & sign (0/1/-1)        & floating point       & integer \\
  2049.            &                      & or integer           & \\
  2050. ABS         & absolute value       & integer or           & integer or \\
  2051.            &                      & floating point       & floating point \\
  2052. TOUPPER     & matching capital     & integer              & integer \\
  2053. TOLOWER     & matching lower case  & integer              & integer \\
  2054.            &                      &                      & \\
  2055. UPSTRING    & changes all          & string               & string \\
  2056.            & characters           &                      & \\
  2057.            & into capitals        &                      & \\
  2058.            &                      &                      & \\
  2059. LOWSTRING   & changes all          & string               & string \\
  2060.            & characters           &                      & \\
  2061.            & into to lower case   &                      & \\
  2062.            &                      &                      & \\
  2063. STRLEN      & returns the length   & string               & integer \\
  2064.            & of a string          &                      & \\
  2065.            &                      &                      & \\
  2066. SUBSTR      & extracts parts of a  & string,              & string \\
  2067.            & string               & integer,             & \\
  2068.            &                      & integer              & \\
  2069. CHARFROMSTR & extracts a character & string,              & integer \\
  2070.            & from a string        & integer              & \\
  2071. STRSTR      & searches a substring & string,              & integer \\
  2072.            & in a string          & string               & \\
  2073. VAL         & evaluates contents   & string               & depends on \\
  2074.            & as expression        &                      & argument \\
  2075. EXPRTYPE    & delivers type of     & integer,             & 0 \\
  2076.            & argument             & float,               & 1 \\
  2077.            &                      & string               & 2 \\
  2078. \hline
  2079. \end{tabular}\end{center}
  2080. \caption{Functions Predefined by \asname{} - Part 2 (Integer and
  2081.         String Functions \label{TabFuncs2}}
  2082. \end{table*}
  2083. The functions \tty{FIRSTBIT}, \tty{LASTBIT}, and \tty{BITPOS} return -1 as
  2084. result if no resp. not exactly one bit is set.  \tty{BITPOS} additionally
  2085. issues an error message in such a case.
  2086. The string function \tty{SUBSTR} expects the source string as first
  2087. parameter, the start position as second and the number of characters to be
  2088. extracted as third parameter (a 0 means to extract all characters up to
  2089. the end).  Similarly, \tty{CHARFROMSTR} expects the source string as
  2090. first argument and the character position as second argument.  In case the
  2091. position argument is larger or equal to the source string's length,
  2092. \tty{SUBSTR} returns an empty string while \tty{CHARFROMSTR} returns -1.
  2093. A position argument smaller than zero is treated as zero by \tty{SUBSTR},
  2094. while \tty{CHARFROMSTR} will return -1 also in this case.
  2095. Here is an example how to use these both functions.  The task is to put a
  2096. string into memory, with the string end being signified by a set MSB in
  2097. the last character:
  2098. \begin{verbatim}
  2099. dbstr   macro   arg
  2100.        if      strlen(arg) > 1
  2101.         db     substr(arg, 0, strlen(arg) - 1)
  2102.        endif
  2103.        if      strlen(arg) > 0
  2104.         db     charfromstr(arg, strlen(arg) - 1) | 80h
  2105.        endif
  2106.        endm
  2107. \end{verbatim}
  2108. \tty{STRSTR} returns the first occurence of the second string
  2109. within the first one resp. -1 if the search pattern was not found.
  2110. Similarly to \tty{SUBSTR} and  \tty{CHARFROMSTR}, the first character
  2111. has the position 0.
  2112. If a function expects floating point arguments, this does not mean it
  2113. is impossible to write e.g.
  2114. \begin{verbatim}
  2115.    sqr2 equ sqrt(2)
  2116. \end{verbatim}
  2117. In such cases an automatic type conversion is engaged. In the reverse
  2118. case the \tty{INT}-function has to be applied to convert a floating point
  2119. number to an integer.  When using this function, you have to pay
  2120. attention that the result produced always is a signed integer and
  2121. therefore has a value range of approximately +/-2.0E9.
  2122. When \asname{} is switched to case-sensitive mode, predefined functions may be
  2123. accessed with an arbitrary combination of upper and lower case (in
  2124. contrast to predefined symbols).  However, in the case of user-defined
  2125. functions (see section \ref{SectFUNCTION}), a distinction between upper
  2126. and lower case is made.  This has e.g. the result that if one defines a
  2127. function \tty{Sin}, one can afterwards access this function via \tty{Sin}, but all
  2128. other combinations of upper and lower case will lead to the predefined
  2129. function.
  2130. For a correct conversion \marginpar{{\em DOS/DPMI}} of lower case letters
  2131. into capital letters a DOS version $\geq$ 3.30 is required.
  2132.  
  2133. %%---------------------------------------------------------------------------
  2134.  
  2135. \section{Forward References and Other Disasters}
  2136. \label{ForwRefs}
  2137.  
  2138. This section is the result of a significant amount of hate on the
  2139. (legal) way some people program.  This way can lead to trouble in
  2140. conjunction with \asname{} in some cases.  The section will deal with
  2141. so-called 'forward references'.  What makes a forward reference
  2142. different from a usual reference?  To understand the difference, take
  2143. a look at the following programming example (please excuse my bias
  2144. for the 68000 family that is also present in the rest of this
  2145. manual):
  2146. \begin{verbatim}
  2147.        move.l  #10,d0
  2148. loop:   move.l  (a1),d1
  2149.        beq     skip
  2150.        neg.l   d1
  2151. skip:   move.l  d1,(a1+)
  2152.        dbra    d0,loop
  2153. \end{verbatim}
  2154. If one overlooks the loop body with its branch statement, a program
  2155. remains that is extremely simple to assemble: the only reference is
  2156. the branch back to the body's beginning, and as an assembler
  2157. processes a program from the beginning to the end, the symbol's value
  2158. is already known before it is needed the first time.  If one has a
  2159. program that only contains such backward references, one has the nice
  2160. situation that only one pass through the source code is needed to
  2161. generate a correct and optimal machine code.  Some high level
  2162. languages like Pascal with their strict rule that everything has to
  2163. be defined before it is used exploit exactly this property to speed
  2164. up the compilation.
  2165.  
  2166. Unfortunately, things are not that simple in the case of assembler,
  2167. because one sometimes has to jump forward in the code or there are
  2168. reasons why one has to move variable definitions behind the code.
  2169. For our example, this is the case for the conditional branch that is
  2170. used to skip over another instruction.  When the assembler hits the
  2171. branch instruction in the first pass, it is confronted with the
  2172. situation of either leaving blank all instruction fields related to
  2173. the target address or offering a value that ''hurts noone'' via the
  2174. formula parser (which has to evaluate the address argument).  In case
  2175. of a ''simple'' assembler that supports only one target architecture
  2176. with a relatively small number of instructions to treat, one will
  2177. surely prefer the first solution, but the effort for \asname{} with its
  2178. dozens of target architectures would have become extremely high.
  2179. Only the second way was possible: If an unknown symbol is detected in
  2180. the first pass, the formula parser delivers the program counter's
  2181. current value as result!  This is the only value suitable to offer an
  2182. address to a branch instruction with unknown distance length that
  2183. will not lead to errors.  This answers also a frequently asked
  2184. question why a first-pass listing (it will not be erased e.g. when \asname{}
  2185. does not start a second pass due to additional errors) partially
  2186. shows wrong addresses in the generated binary code - they are the
  2187. result of unresolved forward references.
  2188.  
  2189. The example listed above however uncovers an additional difficulty of
  2190. forward references: Depending on the distance of branch instruction
  2191. and target in the source code, the branch may be either long or
  2192. short.  The decision however about the code length - and therefore
  2193. about the addresses of following labels - cannot be made in the first
  2194. pass due to missing knowledge about the target address.  In case the
  2195. programmer did not explicitly mark whether a long or short branch
  2196. shall be used, genuine 2-pass assemblers like older versions of MASM
  2197. from Microsoft ''solve'' the problem by reserving space for the longest
  2198. version in the first pass (all label addresses have to be fixed after
  2199. the first pass) and filling the remaining space with \tty{NOP}s in the
  2200. second pass.  \asname{} versions up to 1.37 did the same before I switched
  2201. to the multipass principle that removes the strict separation into
  2202. two passes and allows an arbitrary number of passes.  Said in detail,
  2203. the optimal code for the assumed values is generated in the first
  2204. pass.  In case \asname{} detects that values of symbols changed in the second
  2205. pass due to changes in code lengths, simply a third pass is done, and
  2206. as the second pass'es new symbol values might again shorten or
  2207. lengthen the code, a further pass is not impossible.  I have seen
  2208. 8086 programs that needed 12 passes to get everything correct and
  2209. optimal.  Unfortunately, this mechanism does not allow to specify a
  2210. maximum number passes; I can only advise that the number of passes
  2211. goes down when one makes more use of explicit length specifications.
  2212.  
  2213. Especially for large programs, another situation might arise: the
  2214. position of a forward directed branch has moved so much in the second
  2215. pass relative to the first pass that the old label value still valid
  2216. is out of the allowed branch distance.  \asname{} knows of such situations
  2217. and suppresses all error messages about too long branches when it is
  2218. clear that another pass is needed.  This works for 99\% of all cases,
  2219. but there are also constructs where the first critical instruction
  2220. appears so early that \asname{} had no chance up to now to recognize that
  2221. another pass is needed.  The following example constructs such a
  2222. situation with the help of a forward reference (and was the reason
  2223. for this section's heading...):
  2224. \begin{verbatim}
  2225.        cpu   6811
  2226.  
  2227.        org     $8000
  2228.        beq     skip
  2229.        rept    60
  2230.         ldd    Var
  2231.        endm
  2232. skip:   nop
  2233. Var     equ     $10
  2234. \end{verbatim}
  2235. Due to the address position, \asname{} assumes long addresses in the first
  2236. pass for the \tty{LDD} instructions, what results in a code length of 180
  2237. bytes and an out of branch error message in the second pass (at the
  2238. point of the \tty{BEQ} instruction, the old value of \tty{skip} is still valid,
  2239. i.e. \asname{} does not know at this point that the code is only 120 bytes
  2240. long in reality) is the result.  The error can be avoided in three
  2241. different ways:
  2242. \begin{enumerate}
  2243. \item{Explicitly tell \asname{} to use short addressing for the \tty{LDD}
  2244.      instructions (\tty{ldd <Var})}
  2245. \item{Remove this damned, rotten forward reference and place the \tty{EQU}
  2246.      statement at the beginning where it has to be (all right, I'm
  2247.      already calming down...)}
  2248. \item{For real die-hards: use the \tty{-Y} command line option.  This
  2249.      option tells \asname{} to forget the error message when the address
  2250.      change has been detected.  Not pretty, but...}
  2251. \end{enumerate}
  2252. Another tip regarding the \tty{EQU} instruction: \asname{} cannot know in which
  2253. context a symbol defined with \tty{EQU} will be used, so an \tty{EQU} containing
  2254. forward references will not be done at all in the first pass.  Thus,
  2255. if the symbol defined with \tty{EQU} gets forward-referenced in the second
  2256. pass:
  2257. \begin{verbatim}
  2258.        move.l  #sym2,d0
  2259. sym2    equ     sym1+5
  2260. sym1    equ     0
  2261. \end{verbatim}
  2262. one gets an error message due to an undefined symbol in the second
  2263. pass...but why on earth do people do such things?
  2264.  
  2265. Admittedly, this was quite a lengthy excursion, but I thought it was
  2266. necessary.  Which is the essence you should learn from this section?
  2267. \begin{enumerate}
  2268. \item{\asname{} always tries to generate the shortest code possible.  A
  2269.      finite number of passes is needed for this.  If you do not tweak
  2270.      \asname{} extremely, \asname{} will know no mercy...}
  2271. \item{Whenever sensible and possible, explicitly specify branch and
  2272.      address lengths.  There is a chance of significantly reducing the
  2273.      number of passes by this.}
  2274. \item{Limit forward references to what is absolutely needed.  You make
  2275.      your and \asname{}'s live much easier this way!}
  2276. \end{enumerate}
  2277.  
  2278. %%---------------------------------------------------------------------------
  2279.  
  2280. \section{Register Symbols}
  2281. \label{SectRegSyms} \ttindex{Register Symbols}
  2282.  
  2283. {\em valid for: PowerPC, M-Core, XGate, 4004/4040, MCS-48/(2)51, 80C16x,
  2284.     AVR, XS1, Z8, KCPSM, Mico8, MSP430(X), ST9, M16, M16C, H8/300,
  2285.     H8/500, SH7x00, H16, i960, XA, 29K, TLCS-9000, KENBAK, SC/MP}
  2286.  
  2287. Sometimes it is desirable not only to assign symbolic names to memory
  2288. addresses or constants, but also to a register, to emphasize its function
  2289. in a certain program section.  This is no problem for processors that
  2290. treat registers simply as another address space, as this allows to use
  2291. numeric expressions and one can use simple \tty{EQU}s to define such
  2292. symbols.  (e.g. for the MCS-96 or TMS70000).  However, for most
  2293. processors, register identifiers are fixed literals which are seperately
  2294. treated by \asname{} for speed reasons.  Therefore, registers symbols (sometime
  2295. also called 'register aliases') are also a separate type of symbols in
  2296. the symbol table.  Just like other symbols, they may be defined or re-defined
  2297. with \tty{EQU} or \tty{SET}, and there is a specialized \tty{REG} instruction
  2298. which accepts only symbols and expressions of this type.
  2299.  
  2300. On the other hand, register symbols are subject of a couple of restrictions: the
  2301. number of literals is limited and depends on the selected target processor, and
  2302. arithmetic operations are not possibl eon registers A construct like tihs:
  2303. \begin{verbatim}
  2304. myreg   reg     r17         ; definition of register symbol
  2305.        addi    myreg+1,3   ; does not work!
  2306. \end{verbatim}
  2307. is {\em not} valid.  Simple assignments are however possible:
  2308. \begin{verbatim}
  2309. myreg   reg     r17         ; definition of register symbol
  2310. myreg2  reg     myreg       ; myreg2 -> r17
  2311. \end{verbatim}
  2312. Furthermore, forward references are even more critical than for other
  2313. types of symbols.  If a symbol is not (yet) defined, \asname{} does not know
  2314. which type it is going to have,a nd will decide for a plain integer number.
  2315. For most target processors, a number is the equivalent of absolute
  2316. memory addressing, and on most processors, usage of memory operands
  2317. is more limited than of registers.  Depending on situation, one will
  2318. get an error message about a non-allowed addressing mode, and no second
  2319. pass will be started...
  2320.  
  2321. Analogous to ordinary symbols, register symbols are local to sections and
  2322. it is possible to access a register symbol from a specific section by
  2323. appending the section's name enclosed in brackets.
  2324.  
  2325. %%---------------------------------------------------------------------------
  2326.  
  2327. \section{Share File}
  2328. \label{ChapShareMain}
  2329. \ttindex{SHARED}
  2330.  
  2331. This function is a by-product from the old pure-68000 predecessors of
  2332. \asname{}, I have kept them in case someone really needs it.  The basic
  2333. problem is to access certain symbols produced during assembly,
  2334. because possibly someone would like to access the memory of the
  2335. target system via this address information.  The assembler allows to
  2336. export symbol values by means of \tty{SHARED} pseudo commands (see there).
  2337. For this purpose, the assembler produces a text file with the required
  2338. symbols and its values in the second pass.  This file may be included
  2339. into a higher-level language or another assembler program.  The
  2340. format of the text file (C, Pascal or Assembler) can be set by the
  2341. command line switches \tty{p, c} or, \tty{a}.
  2342.  
  2343. \bb{CAUTION!} If none of the switches is given, no file will be
  2344. generated and it makes no difference if \tty{SHARED}-commands are in the
  2345. source text or not!
  2346.  
  2347. When creating a Sharefile, \asname{} does not check if a file with the
  2348. same name already exists, such a file  will be simply overwritten.
  2349. In my opinion a request does not make sense, because \asname{} would
  2350. ask at each run if it should overwrite the old version of the
  2351. Sharefile, and that would be really annoying...
  2352.  
  2353. %%---------------------------------------------------------------------------
  2354.  
  2355. \section{Processor Aliases}
  2356. \label{SectAlias}
  2357.  
  2358. Common microcontroller families are like rabbits: They become more at
  2359. a higher speed than you can provide support for them.  Especially the
  2360. development of processor cores as building blocks for ASICs and of
  2361. microcontroller families with user-definable peripherals has led to a
  2362. steeply rising number of controllers that only deviate from a
  2363. well-known type by a slightly modified peripheral set.  But the
  2364. distinction among them is still important, e.g. for the design of
  2365. include files that only define the appropriate subset of peripherals.
  2366. I have struggled up to now to integrate the most important
  2367. reperesentatives of a processor family into \asname{} (and I will continue
  2368. to do this), but sometimes I just cannot keep pace with the
  2369. development...there was an urgent need for a mechanism to extend the
  2370. list of processors by the user.
  2371.  
  2372. The result are processor aliases: the alias command line option allows to
  2373. define a new processor type, whose instruction set is equal to another
  2374. processor built into \asname{}.  After switching to this processor via the
  2375. \tty{CPU} instruction, \asname{} behaves exactly as if the original processor had
  2376. been used, with a single difference: the variables \tty{MOMCPU} resp.
  2377. \tty{MOMCPUNAME} are set to the alias name, which allows to use the new
  2378. name for differentiation, e.g. in include files.
  2379.  
  2380. There were two reasons to realize the definition of aliases by the
  2381. command line and not by pseudo instructions: first, it would anyway be
  2382. difficult to put the alias definitions together with register definitions
  2383. into a single include file, because a program that wants to use such a
  2384. file would have to include it before and after the CPU instruction - an
  2385. imagination that lies somewhere between inelegant and impossible.  Second,
  2386. the definition in the command line allows to put the definitions in a key
  2387. file that is executed automatically at startup via the \tty{ASCMD}
  2388. variable, without a need for the program to take any further care about
  2389. this.
  2390.  
  2391. %%===========================================================================
  2392.  
  2393. \cleardoublepage
  2394. \chapter{Pseudo Instructions}
  2395.  
  2396. Not all pseudo instructions are defined for all processors.  A note
  2397. that shows the range of validity is therefore prepended to every
  2398. individual description.
  2399.  
  2400. %%---------------------------------------------------------------------------
  2401.  
  2402. \section{Definitions}
  2403.  
  2404. %%- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  2405.  
  2406. \subsection{SET, EQU, and CONSTANT}
  2407. \ttindex{SET}\ttindex{EQU}
  2408. \ttindex{.SET}\ttindex{.EQU}
  2409. \ttindex{CONSTANT}
  2410.  
  2411. {\em valid for: all processors, {\tt CONSTANT} only for KCPSM(3)}
  2412.  
  2413. \tty{SET} and \tty{EQU} allow the definition of typeless constants, i.e.  they
  2414. will not be assigned to a segment and their usage will not generate warnings
  2415. because of segment mixing.  \tty{EQU} defines constants which can not be
  2416. modified (by \tty{EQU}) again, but \tty{SET} permits the definition of
  2417. variables, which can be modified during the assembly.  This is useful e.g.
  2418. for the allocation of resources like interrupt vectors, as shown in the
  2419. following example:
  2420. \begin{verbatim}
  2421. VecCnt  set     0       ; somewhere at the beginning
  2422.        .
  2423.        .
  2424.        .
  2425. DefVec  macro   Name    ; allocate a new vector
  2426. Name    equ     VecCnt
  2427. VecCnt  set     VecCnt+4
  2428.        endm
  2429.        .
  2430.        .
  2431.        .
  2432.        DefVec  Vec1    ; results in Vec1=0
  2433.        DefVec  Vec2    ; results in Vec2=4
  2434. \end{verbatim}
  2435. constants and variables are internally stored in the same way, the only
  2436. difference is that they are marked as unchangeable if defined via \tty{EQU}.
  2437. Trying to change a constant with \tty{SET} will result in an error
  2438. message.
  2439.  
  2440. \tty{EQU/SET} allow to define constants of all possible types, e.g.
  2441. \begin{verbatim}
  2442. IntTwo   equ    2
  2443. FloatTwo equ    2.0
  2444. \end{verbatim}
  2445. Some processors unfortunately have already a \tty{SET} instruction. For
  2446. these targets, \tty{EVAL} must be used instead of \tty{SET} if no
  2447. differentiation via the argument count is possible.  As an alternative,
  2448. it is always possible to explicitly invoke the pseudo instruction
  2449. by prepending a period (\tty{.SET} instead of  \tty{SET}).
  2450.  
  2451. A single equation sign or \tty{.EQU} may be used instead of \tty{EQU}.
  2452. Similarly, one may simply write \tty{:=} instead of \tty{SET} resp.
  2453. \tty{EVAL}. Furthermore, there is an 'alternate' syntax that does not
  2454. take the symbol's name from the label field, but instead from the
  2455. first argument.  So for instance, it is valid to write:
  2456. \begin{verbatim}
  2457.          EQU   IntTwo,2
  2458.          EQU   FloatTwo,2.0
  2459. \end{verbatim}
  2460.  
  2461. For compatibility reasons to the original assembler, the KCPSM target also
  2462. knows the {\tt CONSTANT} statement, which - in contrast to \tty{EQU} -
  2463. always expects name and value as arguments.  For example:
  2464. \begin{verbatim}
  2465.      CONSTANT  const1, 2
  2466. \end{verbatim}
  2467. {\tt CONSTANT} is however limited to integer constants.
  2468.  
  2469. Symbols defined with \tty{SET} or \tty{EQU} are typeless by default, but
  2470. optionally a segment name (\tty{CODE, DATA, IDATA, XDATA, YDATA, BITDATA,
  2471. IO}, or \tty{REG}) or \tty{MOMSEGMENT} for the currently active segment
  2472. may be given as a second or third parameter, allowing to assign the symbol to a
  2473. specific address space.  \asname{} does not check at this point if the used
  2474. address space exists on the currently active target processor!
  2475.  
  2476. A little hidden extra feature allows to set the program counter via
  2477. \tty{SET} or \tty{EQU}, something one would ordinarily do via \tty{ORG}.
  2478. To accomplish this, use the special value as symbol name that may also
  2479. be used to query the current program counter's value.  Depending on the
  2480. selected target architecture, this is either an asterisk, a dollar sign,
  2481. a period, or \tty{PC}.
  2482.  
  2483. In case the target architecture supports instruction attributes to define
  2484. the operand size (e.g. on 680x0), those are also allowed for \tty{SET} and
  2485. \tty{EQU}.  The operand size will be stored along with the symbol's value in
  2486. the symbol table.  Its use is architecture-dependant.
  2487.  
  2488. %%- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  2489.  
  2490. \subsection{SFR and SFRB}
  2491. \ttindex{SFR}\ttindex{SFRB}
  2492.  
  2493. {\em valid for: various, \tty{SFRB} only MCS-51}
  2494.  
  2495. These instructions act like \tty{EQU}, but symbols defined with them are
  2496. assigned to the directly addressable data resp. I/O segment, i.e. they are
  2497. preferrably used for the definition of (as the name lets guess) hardware
  2498. registers mapped into the data res. I/O area.  The allowed range of values
  2499. is equal to the range allowed for \tty{ORG} in the data segment (see
  2500. section \ref{SectORG}).  The difference between \tty{SFR} and \tty{SFRB}
  2501. is that \tty{SFRB} marks the register as bit addressable, which is why \asname{}
  2502. generates 8 additional symbols which will be assigned to the bit segment
  2503. and carry the names xx.0 to xx.7, e.g.
  2504. \begin{verbatim}
  2505. PSW     sfr     0d0h    ; results in PSW = D0H (data segment)
  2506.  
  2507. PSW     sfrb    0d0h    ; results in extra PSW.0 = D0H (bit)
  2508.                        ;               to PSW.7 = D7H (bit)
  2509. \end{verbatim}
  2510. The \tty{SFRB} instruction is not any more defined for the 80C251 as it
  2511. allows direct bit access to all SFRs without special bit symbols; bits
  2512. like \tty{PSW.0} to \tty{PSW.7} are automatically present.
  2513.  
  2514. Whenever a bit-addressable register is defined via \tty{SFRB}, \asname{} checks
  2515. if the memory address is bit addressable (range 20h..3fh resp. 80h, 88h,
  2516. 90h, 98h...0f8h).  If it is not bit-addressable, a warning is issued and
  2517. the generated bit symbols are undefined.
  2518.  
  2519. %%- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  2520.  
  2521. \subsection{XSFR and YSFR}
  2522. \ttindex{XSFR}\ttindex{YSFR}
  2523.  
  2524. {\em valid for: DSP56xxx}
  2525.  
  2526. Also the DSP56000 has a few peripheral registers memory-mapped to the RAM,
  2527. but the affair becomes complicated because there are two data areas, the
  2528. X- and Y-area.  This architecture allows on the one hand a higher
  2529. parallelism, but forces on the other hand to divide the normal \tty{SFR}
  2530. instruction into the two above mentioned variations.  They works
  2531. identically to \tty{SFR}, just that \tty{XSFR} defines a symbol in the X-
  2532. addressing space and YSFR a corresponding one in the Y-addressing space.
  2533. The allowed value range is 0..\$ffff.
  2534.  
  2535. %%- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  2536.  
  2537. \subsection{LABEL}
  2538. \ttindex{LABEL}
  2539.  
  2540. {\em valid for: all processors}
  2541.  
  2542. The function of the \tty{LABEL} instruction is identical to \tty{EQU}, but
  2543. the symbol does not become typeless, it gets the attribute ''code''.
  2544. \tty{LABEL} is needed exactly for one purpose: Labels are normally local
  2545. in macros, that means they are not accessible outside of a macro.  With an
  2546. \tty{EQU} instruction you could get out of it nicely, but the phrasing
  2547. \begin{verbatim}
  2548. <name>  label   $
  2549. \end{verbatim}
  2550. generates a symbol with correct attributes.
  2551.  
  2552. %%- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  2553.  
  2554. \subsection{BIT}
  2555. \ttindex{BIT}
  2556.  
  2557. {\em valid for: MCS/(2)51, XA, 80C166, 75K0, ST9, AVR, S12Z, SX20/28, H16,
  2558.                H8/300, H8/500, KENBAK, Padauk}
  2559.  
  2560. \tty{BIT} serves to equate a single bit of a memory cell with a symbolic
  2561. name.  This instruction varies from target platform to target platform due
  2562. to the different ways in which processors handle bit manipulation and
  2563. addressing:
  2564.  
  2565. The MCS/51 family has an own address space for bit operands.  The function
  2566. of \tty{BIT} is therefore quite similar to \tty{SFR}, i.e. a simple integer
  2567. symbol with the specified value is generated and assigned to the
  2568. \tty{BDATA} segment.  For all other processors, bit addressing is done in
  2569. a two-dimensional fashion with address and bit position.  In these cases,
  2570. \asname{} packs both parts into an integer symbol in a way that depends on the
  2571. currently active target processor and separates both parts again when the
  2572. symbol is used.  The latter is is also valid for the 80C251: While an
  2573. instruction like
  2574. \begin{verbatim}
  2575. My_Carry bit    PSW.7
  2576. \end{verbatim}
  2577. would assign the value 0d7h to \tty{My\_Carry} on an 8051, a value of
  2578. 070000d0h would be generated on an 80C251, i.e. the address is located in
  2579. bits 0..7 and the bit position in bits 24..26.  This procedure is equal to
  2580. the way the \tty{DBIT} instruction handles things on a TMS370 and is also
  2581. used on the 80C166, with the only difference that bit positions may range
  2582. from 0..15:
  2583. \begin{verbatim}
  2584. MSB     BIT     r5.15
  2585. \end{verbatim}
  2586. On a Philips XA, the bit's address is located in bits 0..9 just with
  2587. the same coding as used in machine instructions, and the 64K bank of
  2588. bits in RAM memory is placed in bits 16..23.
  2589.  
  2590. The \tty{BIT} instruction of the 75K0 family even goes further: As bit
  2591. expressions may not only use absolute base addresses, even expressions
  2592. like
  2593. \begin{verbatim}
  2594. bit1    BIT     @h+5.2
  2595. \end{verbatim}
  2596. are allowed.
  2597.  
  2598. The ST9 in turn allows to invert bits, what is also allowed in the
  2599. \tty{BIT} instruction:
  2600. \begin{verbatim}
  2601. invbit  BIT     r6.!3
  2602. \end{verbatim}
  2603. More about the ST9's \tty{BIT} instruction can be found in the processor
  2604. specific hints.
  2605.  
  2606. In case of H16, note that the address and bit position arguments are swapped.
  2607. This was done to make the syntax of BIT consistent with the machine instructions
  2608. that maipulate individual bits.
  2609.  
  2610. %%- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  2611.  
  2612. \subsection{DBIT}
  2613. \ttindex{DBIT}
  2614.  
  2615. {\em valid for: TMS 370xxx}
  2616.  
  2617. Though the TMS370 series does not have an explicit bit segment, single bit
  2618. symbols may be simulated with this instruction.  \tty{DBIT} requires two
  2619. operands, the address of the memory cell that contains the bit and the
  2620. exact position of the bit in the byte.  For example,
  2621. \begin{verbatim}
  2622. INT3        EQU  P019
  2623. INT3_ENABLE DBIT 0,INT3
  2624. \end{verbatim}
  2625. defines the bit that enables interrupts via the INT3 pin.  Bits defined
  2626. this way may be used in the instructions \tty{SBIT0, SBIT1, CMPBIT,
  2627. JBIT0}, and \tty{JBIT}.
  2628.  
  2629. %%- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  2630.  
  2631. \subsection{DEFBIT and DEFBITB}
  2632. \ttindex{DEFBIT}
  2633. \ttindex{DEFBITB}
  2634.  
  2635. \subsubsection{S12Z}
  2636.  
  2637. The S12Z family's processor core provides instructions to manipulate
  2638. individual bits in registers or memory cells.  To conveniently
  2639. address bits in the CPU's I/O area (first 4 Kbytes of the address
  2640. space), a bit may be given a symbolic name.  The bit is defined by
  2641. its memory address and the bit position:
  2642. \begin{verbatim}
  2643. <name>         defbit[.size]   <address>,<position>
  2644. \end{verbatim}
  2645. The \tty{address} must be located within the first 4 Kbytes, and the
  2646. operand size may be 8, 16, or 32 bits (\tty{size}=b/w/l).
  2647. Consequently, the \tty{position} may at most be 7, 15 or 31.  If no
  2648. operand size is given, byte size (.b) is assumed.  A bit defined
  2649. this way may be used as argument for the instructions {\tt BCLR,
  2650. BSET, BTGL, BRSET,} and {\tt BRCLR}:
  2651. \begin{verbatim}
  2652. mybit   defbit.b  $200,4
  2653.        bclr.b    $200,#4
  2654.        bclr      mybit
  2655. \end{verbatim}
  2656. Both uses of {\tt bclr} in this example generate identical code.
  2657. Since a bit defined this way ''knows'' its size, the size attribute
  2658. may be omitted when using it.
  2659.  
  2660. It is also possible to define bits that are located within a
  2661. structure's element:
  2662. \begin{verbatim}
  2663. mystruct struct    dots
  2664. reg      ds.w      1
  2665. flag     defbit    reg,4
  2666.         ends
  2667.  
  2668.         org       $100
  2669. data     mystruct
  2670.         bset      data.flag  ; same as bset.w $100,#4
  2671. \end{verbatim}
  2672.  
  2673. \subsubsection{Super8}
  2674.  
  2675. Opposed to the 'classic' Z8, the Super8 core supports instructions to operate
  2676. on bits in working or general registers.  ONe however has to to regard that
  2677. some of them can only operate on bits in one of the 16 working registers.
  2678. The \tty{DEFBIT} instruction allows to define bits of either type:
  2679. \begin{verbatim}
  2680. workbit defbit  r3,#4
  2681. slow    defbit  emt,#6
  2682. \end{verbatim}
  2683. Bits that have been defined this way may be used just like a argument duple of
  2684. register and bit position:
  2685. \begin{verbatim}
  2686.        ldb     r3,emt,#6
  2687.        ldb     r3,slo          ; same result
  2688.  
  2689.        bitc    r3,#4
  2690.        bitc    workbit         ; same result
  2691. \end{verbatim}
  2692.  
  2693. \subsubsection{Z8000}
  2694.  
  2695. The Z8000 features instructions to set and clear bits, however they cannot access
  2696. addresses in I/O space.  For this reason, both {\tt DEFBIT} and {\tt DEFBITB}
  2697. only allow to define bit objects in memory space.  The differentiation in operand
  2698. size is important because the Z8000 is a big endian processor: bit {\em n} of a
  2699. 16 bit word at address {\em m} corresponds to bit {\em n} of an 8-bit byte at
  2700. address {\em m+1}.
  2701.  
  2702. \subsubsection{$\mu$PD7807...$\mu$PD7809}
  2703.  
  2704. The lowest 16 bytes of the working area and special registers with an address
  2705. less than 16 are bit addressable.
  2706.  
  2707. %%- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  2708.  
  2709. \subsection{DEFBITFIELD}
  2710. \ttindex{DEFBITFIELD}
  2711.  
  2712. {\em valid for: S12Z}
  2713.  
  2714. The S12Z family's CPU core not only deals with individual bits, it
  2715. is also able to extract a field of consecutive bits from an
  2716. 8/16/24/32 value or to insert a bit field into such a value. Similar
  2717. to \tty{DEFBIT}, a bit field may be defined symbolically:
  2718. \begin{verbatim}
  2719. <Name>     defbitfield[.size] <address>,<width>:<position>
  2720. \end{verbatim}
  2721. Opposed to individual bits, an operand size of 24 bits (.p) is also
  2722. alloweed.  The range of \tty{position} and \tty{width} is accordingly
  2723. 0 to 23 resp. 1 to 24.  It is also allowed to define bit fields as
  2724. parts of structures:
  2725. \begin{verbatim}
  2726. mystruct struct      dots
  2727. reg      ds.w        1
  2728. clksel   defbitfield reg,4:8
  2729.         ends
  2730.  
  2731.         org       $100
  2732. data     mystruct
  2733.         bfext     d2,data.clksel ; fetch $100.w bits 4..11
  2734.                                  ; to D2 bits 0..7
  2735.         bfins     data.clksel,d2 ; insert D2 bits 0..7 into
  2736.                                  ; $100.w bits 4..11
  2737. \end{verbatim}
  2738. The internal representation of bits defined via \tty{DEFBIT} is
  2739. equivalent to bit fields with a width of one.  Therefore, a
  2740. symbolically defined bit may also be used as argument for
  2741. \tty{BFINS} and \tty{BFEXT}.
  2742.  
  2743. %%- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  2744.  
  2745. \subsection{PORT}
  2746. \ttindex{PORT}
  2747.  
  2748. {\em valid for: PALM, 8008/8080/8085/8086, XA, Z80, Z8000, 320C2x/5x, TLCS-47, AVR,
  2749.     F8, IMP-16}
  2750.  
  2751. \tty{PORT} works similar to \tty{EQU}, just the symbol becomes assigned to the
  2752. I/O-address range.  Allowed values are 0..7 for the 3201x and 8008, 0..15 for the
  2753. 320C2x and PALM, 0..65535 for the 8086, Z8000, and 320C5x, 0..63 for the AVR, and 0..255
  2754. for the rest.
  2755.  
  2756. Example : an 8255 PIO is located at address 20H:
  2757. \begin{verbatim}
  2758. PIO_port_A port 20h
  2759. PIO_port_B port PIO_port_A+1
  2760. PIO_port_C port PIO_port_A+2
  2761. PIO_ctrl   port PIO_port_A+3
  2762. \end{verbatim}
  2763.  
  2764. %%- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  2765.  
  2766. \subsection{REG and NAMEREG}
  2767. \ttindex{REG}\ttindex{NAMEREG}
  2768.  
  2769. {\em valid for: 680x0, AVR, M*Core, ST9, 80C16x, Z8000, KCPSM, \\
  2770.     PDP-11, WD16 \\
  2771.     ({\tt NAMEREG} valid only for KCPSM(3)), LatticeMico8, MSP430(X)}
  2772.  
  2773. Though it always has the same syntax, this instruction has a slightly
  2774. different meaning from processor to processor:  If the processor uses a
  2775. separate addressing space for registers, \tty{REG} has the same effect as
  2776. a simple \tty{EQU} for this address space (e.g. for the ST9).  \tty{REG}
  2777. defines register symbols for all other processors whose function is
  2778. described in section \ref{SectRegSyms}.
  2779.  
  2780. {\tt NAMEREG} exists for compatibility reasons to the original KCPSM
  2781. assembler.  It has an identical function, however both register and
  2782. symbolic name are given as arguments, for example:
  2783. \begin{verbatim}
  2784.     NAMEREG  s08, treg
  2785. \end{verbatim}
  2786.  
  2787. On the PDP-11, \tty{REG} may additionally be used without a name in the
  2788. label field.  It then expects a single \tty{ON} or \tty{OFF} as argument
  2789. and enables or disables the built-in register aliases (\tty{Rn} = \tty{\%n},
  2790. \tty{SP} = \tty{R6}, \tty{PC} = \tty{R7}).  They are available by default,
  2791. and should only be disabled if they conflict with own synmbol names in a
  2792. program. The current setting may be read from the symbol \tty{DEFAULT\_REGSYMS}.
  2793.  
  2794. %%- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  2795.  
  2796. \subsection{LIV and RIV}
  2797. \ttindex{LIV}\ttindex{RIV}
  2798.  
  2799. {\em valid for: 8X30x}
  2800.  
  2801. \tty{LIV} and \tty{RIV} allow to define so-called ''IV bus objects''.
  2802. These are
  2803. groups of bits located in a peripheral memory cell with a length of 1
  2804. up to 8 bits, which can afterwards be referenced symbolically.  The
  2805. result is that one does not anymore have to specify address,
  2806. position, and length separately for instructions that can refer to
  2807. peripheral bit groups.  As the 8X30x processors feature two
  2808. peripheral address spaces (a ''left'' and a ''right'' one), there are two
  2809. separate pseudo instructions.  The parameters of these instructions
  2810. are however equal: three parameters have to be given that specify
  2811. address, start position and length.  Further hints for the usage of
  2812. bus objects can be found in section \ref{8X30xSpec} .
  2813.  
  2814. %%- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  2815.  
  2816. \subsection{CHARSET}
  2817. \label{SectCHARSET}
  2818. \ttindex{CHARSET}\ttindex{CODEPAGE\_VAL}
  2819.  
  2820. {\em valid for: all processors}
  2821.  
  2822. Single board systems, especially when driving LCDs, frequently use
  2823. character sets different to ASCII.  So it is probably purely coincidental
  2824. that the umlaut coding corresponds with the one used by the PC.  And there
  2825. are of course also (historical) systems that use some variant of EBCDIC...to avoid
  2826. error-prone manual encoding in the source code, the assembler contains a translation table
  2827. for characters which assigns a target character to each (ASCII) character
  2828. in the source code.  Use the \tty{CHARSET} instruction to modify this
  2829. table, which initial translates one-to-one.  \tty{CHARSET} may be used with
  2830. a variety of arguments:
  2831.  
  2832. A simple
  2833. \begin{quote}{\tt
  2834.        CHARSET
  2835. }\end{quote}
  2836. without any argument resets the table to the one-to-one default.
  2837.  
  2838. If only a single argument is given, it has to be a string expression which is
  2839. interpreted as a file name by \asname{}:
  2840. \begin{verbatim}
  2841.        CHARSET  "mapping.bin"
  2842. \end{verbatim}
  2843. \asname{} reads the first 256 bytes from this table and copies them into the translation
  2844. table.  This allows to activate complex, externally generated tables with a single
  2845. statement.
  2846.  
  2847. All other variants modify a single entry or a sequence of entries in the
  2848. table.  Use two (integer) arguments to change a single entry:
  2849. \begin{quote}{\tt
  2850.       CHARSET  '\"a',128
  2851. }\end{quote}
  2852. means that the target system codes the '\"a'  into the number 128.  It is
  2853. als possible to define that a certain character is unavailable on the target
  2854. system.  Leave the second argument empty to define this:
  2855. \begin{quote}{\tt
  2856.        CHARSET '[',
  2857. }\end{quote}
  2858. If the 'deleted' character shall be disposed in memory, this reported as
  2859. an error.
  2860.  
  2861. Use three arguments to remap a whole range of characters.  The first and
  2862. second argument define the character range, and the third one defines
  2863. the mapping of the first character.  For instance, if the target system
  2864. does not support lower case characters,
  2865. \begin{verbatim}
  2866.        CHARSET 'a','z','A'
  2867. \end{verbatim}
  2868. translates all lower-case characters automatically into the matching
  2869. capital letters.  Similar to a single character, it is also possible to
  2870. 'unmap' a range of characters:
  2871. \begin{verbatim}
  2872.        CHARSET 'a','z',
  2873. \end{verbatim}
  2874. forbids usage of lower case letters.
  2875.  
  2876. The last variant (again only with two arguments), a string defines the
  2877. mapping of a sequence of characters.  Mapping of lower to upper case may
  2878. therefore also be written like this:
  2879. be written as
  2880. \begin{verbatim}
  2881.        CHARSET 'a',"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
  2882. \end{verbatim}
  2883.  
  2884. \bb{CAUTION!} \tty{CHARSET} not only affects string constants stored in
  2885. memory, but also multi character constants, i.e. integer constants written
  2886. as ''ASCII''.  This means that an already modified translation table can
  2887. lead to different results in the examples mentioned above!
  2888.  
  2889. The built-in function \tty{CODEPAGE\_VAL} allows to query the translation
  2890. of a single character in the current code page.  It will return -1 for
  2891. unmapped characters.
  2892.  
  2893. %%- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  2894.  
  2895. \subsection{CODEPAGE}
  2896. \ttindex{CODEPAGE}
  2897.  
  2898. {\em valid for: all processors}
  2899.  
  2900. Though the \tty{CHARSET} statement gives unlimited freedom in the
  2901. character assignment between host and target platform, switching among
  2902. different character {\em sets} can become quite tedious if several
  2903. character sets have to be supported on the target platform.  The
  2904. \tty{CODEPAGE} instruction however allows to define and keep different
  2905. character sets and to switch with a single statement among them.
  2906. \tty{CODEPAGE} expects one or two arguments: the name of the set to be
  2907. used hereafter and optionally the name of another table that defines its
  2908. initial contents (the second parameter therefore only has a meaning for
  2909. the first switch to the table when \asname{} automatically creates it).  If the
  2910. second parameter is missing, the initial contents of the new table are
  2911. copied from the previously active set.  All subsequent \tty{CHARSET}
  2912. statements {\em only} modify the new set.
  2913.  
  2914. At the beginning of a pass, \asname{} automatically creates a single character
  2915. set with the name \tty{STANDARD} with a one-to-one translation.  If no
  2916. \tty{CODEPAGE} instructions are used, all settings made via \tty{CHARSET}
  2917. refer to this table.
  2918.  
  2919. %%- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  2920.  
  2921. \subsection{ENUM, NEXTENUM, and ENUMCONF}
  2922. \ttindex{ENUM}
  2923. \ttindex{NEXTENUM}
  2924. \ttindex{ENUMCONF}
  2925.  
  2926. {\em valid for: all processors}
  2927.  
  2928. Similar to the same-named instruction known from C, \tty{ENUM} is used to
  2929. define enumeration types, i.e. a sequence of integer constants that
  2930. are assigned sequential values starting at 0.  The parameters are the
  2931. names of the symbols, like in the following example:
  2932. \begin{verbatim}
  2933.        ENUM    SymA,SymB,SymC
  2934. \end{verbatim}
  2935. This instruction will assign the values 0, 1, and 2 to the symbols
  2936. \tty{SymA, SymB,} and \tty{SymC}.
  2937.  
  2938. If you want to split an enumeration over more than one line, use
  2939. \tty{NEXTENUM} instead of \tty{ENUM} for the second and all
  2940. following lines.  The internal counter that assigns sequential
  2941. values to alls symbols will then not be reset to zero, like in the
  2942. following case:
  2943. \begin{verbatim}
  2944.        ENUM     January=1,February,March,April,May,June
  2945.        NEXTENUM July,August,September,October
  2946.        NEXTENUM November,December
  2947. \end{verbatim}
  2948. This example also demonstrates that it is possible to assign
  2949. explicit values to individual symbols.  The internal counter will
  2950. be updated accordingly if this feature is used.
  2951.  
  2952. A definition of a symbol with \tty{ENUM} is equal to a definition with
  2953. \tty{EQU}, i.e. it is not possible to assign a new value to a symbol that
  2954. already exists.
  2955.  
  2956. The \tty{ENUMCONF} statement allows to influence the behaviour of
  2957. \tty{ENUM}.  \tty{ENUMCONF} accepts one or two arguments.  The
  2958. first argument is always the value the internal counter is
  2959. incremented for every symbol in an enumeration.  For instance,
  2960. the statement
  2961. \begin{verbatim}
  2962.      ENUMCONF 2
  2963. \end{verbatim}
  2964. has the effect that symbols get the values 0,2,4,6... instead of
  2965. 0,1,2,3...
  2966.  
  2967. The second (optional) argument of \tty{ENUMCONF} rules which
  2968. address space the defined symbols are assigned to.  By default,
  2969. symbols defined by \tty{ENUM} are typeless.  For instance, the
  2970. statement
  2971. \begin{verbatim}
  2972.      ENUMCONF 1,CODE
  2973. \end{verbatim}
  2974. defines that they should be assigned to the instruction address
  2975. space.  The names of the address spaces are the same as for the
  2976. \tty{SEGMENT} instruction (\ref{SEGMENT}), with the addition of
  2977. \tty{NOTHING} to generate typeless symbols again.
  2978.  
  2979. %%- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  2980.  
  2981. \subsection{PUSHV and POPV}
  2982. \ttindex{PUSHV}\ttindex{POPV}
  2983.  
  2984. {\em valid for: all processors}
  2985.  
  2986. \tty{PUSHV} and \tty{POPV} allow to temporarily save the value of a symbol
  2987. (that is not macro-local) and to restore it at a later point of time.  The
  2988. storage is done on stacks, i.e. Last-In-First-Out memory structures.  A
  2989. stack has a name that has to fulfill the general rules for symbol names
  2990. and it exists as long as it contains at least one element: a stack that
  2991. did not exist before is automatically created upon \tty{PUSHV}, and a
  2992. stack becoming empty upon a \tty{POPV} is deleted automatically.  The name
  2993. of the stack that shall be used to save or restore symbols is the first
  2994. parameter of \tty{PUSH} resp. \tty{POPV}, followed by a list of symbols as
  2995. further parameters.  All symbols referenced in the list already have to
  2996. exist, it is therefore \bb{not} possible to implicitly define symbols with
  2997. a \tty{POPV} instruction.
  2998.  
  2999. Stacks are a global resource, i.e. their names are not local to
  3000. sections.
  3001.  
  3002. It is important to note that symbol lists are \bb{always} processed from
  3003. left to right.  Someone who wants to pop several variables from a stack
  3004. with a \tty{POPV} therefore has to use the exact reverse order used in the
  3005. corresponding \tty{PUSHV}!
  3006.  
  3007. The name of the stack may be left blank, like this:
  3008. \begin{verbatim}
  3009.        pushv   ,var1,var2,var3
  3010.        .
  3011.        .
  3012.        popv    ,var3,var2,var1
  3013. \end{verbatim}
  3014. \asname{} will then use a predefined internal default stack.
  3015.  
  3016. \asname{} checks at the end of a pass if there are stacks that are not empty and
  3017. issues their names together with their ''filling level''.  This allows to
  3018. find out if there are any unpaired \tty{PUSHVs} or \tty{POPVs}.  However,
  3019. it is in no case possible to save values in a stack beyond the end of a
  3020. pass: all stacks are cleared at the beginning of a pass!
  3021.  
  3022. %%---------------------------------------------------------------------------
  3023.  
  3024. \section{Code Modification}
  3025.  
  3026. %%- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  3027.  
  3028. \subsection{ORG}
  3029. \label{SectORG}
  3030. \ttindex{ORG}
  3031.  
  3032. {\em valid for: all processors}
  3033.  
  3034. \tty{ORG} allows to load the internal address counter (of the assembler)
  3035. with a new value. The value range depends on the currently selected
  3036. segment and on the processor type (table \ref{TabORG}).
  3037. The lower bound is always zero, and the upper bound is the given value
  3038. minus 1.
  3039. \par
  3040. {\bf CAUTION}: If the \tty{PHASE} instruction is also used, one
  3041. has to keep in mind that the argument of \tty{ORG} always is the
  3042. {\em load address} of the code.  Expressions using the \$ or \*
  3043. symbol to refer to the current program counter however deliver
  3044. the {\em execution address} of the code and do not yield the
  3045. desired result when used as argument for \tty{ORG}.  The
  3046. \tty{RORG} statement (\ref{SectRORG}) should be used in such cases.
  3047. \hfuzz=60pt
  3048. \small
  3049. \begin{longtable}{|l|c|c|c|c|c|c|c|c|c|c|}
  3050. \hline
  3051. \tin{Target} & \tin{CODE} & \tin{DATA} & \tin{I-}   & \tin{X-}   & \tin{Y-}   & \tin{BIT-} & \tin{IO} & \tin{REG} & \tin{ROM-}  & \tin{EE-}  \\
  3052.             &            &            & \tin{DATA} & \tin{DATA} & \tin{DATA} & \tin{DATA} &          &           & \tin{DATA}  & \tin{DATA} \\
  3053. \hline
  3054. \hline
  3055. \endhead
  3056. \input{../doc_COM/taborg.tex}
  3057. \\ \hline
  3058. \multicolumn{11}{|l|}{$^{1}$ Initial value 80h.} \\
  3059. \multicolumn{11}{|l|}{   As the 8051 does not have any RAM beyond 80h, this value has to be} \\
  3060. \multicolumn{11}{|l|}{   adapted with ORG for the 8051 as target processor!}\\
  3061. \hline
  3062. \multicolumn{11}{|l|}{$^{2}$ As the Z180 still can address only 64K logically, the whole}\\
  3063. \multicolumn{11}{|l|}{   address space can only be reached via \tty{PHASE} instructions!}\\
  3064. \hline
  3065. \multicolumn{11}{|l|}{$^{3}$ initial value 400h.}\\
  3066. \hline
  3067. \multicolumn{11}{|l|}{$^{4}$ initial value 800h resp. 0C00h} \\
  3068. \hline
  3069. \multicolumn{11}{|l|}{$^{5}$ area for program code is limited to 1 MByte} \\
  3070. \hline
  3071. \multicolumn{11}{|l|}{$^{6}$ size depends on target processor} \\
  3072. \hline
  3073. \multicolumn{11}{|l|}{$^{7}$ size and availibility depend on target processor} \\
  3074. \hline
  3075. \multicolumn{11}{|l|}{$^{8}$ only on variants supporting the \tty{MOVX} instruction} \\
  3076. \hline
  3077. \multicolumn{11}{|l|}{$^{9}$ device dependant} \\
  3078. \hline
  3079. \multicolumn{11}{|l|}{$^{10}$ model dependent} \\
  3080. \hline
  3081. \caption{Address Ranges for \tty{ORG}}
  3082. \label{TabORG}
  3083. \end{longtable}
  3084. \normalsize
  3085. \hfuzz=0pt
  3086.  
  3087. In case that different variations in a processor family have address
  3088. spaces of different size, the maximum range is listed for each.
  3089.  
  3090. \tty{ORG} is mostly needed to give the code a new starting address or to
  3091. put different, non-continuous code parts into one source file.  In case
  3092. there is no explicit other value listet in a table entry, the initial
  3093. address for this segment (i.e. the start address used without {\tt ORG})
  3094. is 0.
  3095.  
  3096. %%- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  3097.  
  3098. \subsection{RORG}
  3099. \label{SectRORG}
  3100. \ttindex{RORG}
  3101.  
  3102. {\em valid for: all processors}
  3103.  
  3104. \tty{RORG} modifies the program counter just like \tty{ORG},
  3105. however it does not expect an absolute address as argument.
  3106. Instead, it expects a relative value (positive or negative) that
  3107. is added to the current program counter.  A possible application
  3108. of this statement is the reservation of a certain amount of
  3109. address space, or the use in code parts that are included
  3110. multiple times (e.g. via macros or includes) and that shall be
  3111. position-independent.  Another application is the use in code
  3112. that has an execution address different from the load address
  3113. (i.e. the \tty{PHASE} statement is used).  There is no symbol to
  3114. refer to the current {\em load address}, but it can be referred
  3115. to indirectly via the \tty{RORG} statement.
  3116.  
  3117. %%- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  3118.  
  3119. \subsection{CPU}
  3120. \label{SectCPU}
  3121. \ttindex{CPU}
  3122.  
  3123. {\em valid for: all processors}
  3124.  
  3125. This command rules for which processor the further code shall be
  3126. generated.  Instructions of other processor families are not
  3127. accessible afterwards and will produce error messages!
  3128.  
  3129. The processors can roughly be distinguished in families, inside the
  3130. families different types additionally serve for a detailed
  3131. distinction:
  3132. %%-----------
  3133. \begin{quote}
  3134. \begin{tabbing}
  3135. \hspace{0.7cm} \= \kill
  3136. a) \> 68008 $\rightarrow$ 68000 $\rightarrow$ 68010 $\rightarrow$ 68012 $\rightarrow$ \\
  3137.   \> MCF5202 $\rightarrow$ MCF5204 $\rightarrow$ MCF5206 $\rightarrow$ MCF5208$\rightarrow$ \\
  3138.   \> MCF52274 $\rightarrow$ MCF52277 $\rightarrow$ MCF5307 $\rightarrow$ MCF5329 $\rightarrow$ \\
  3139.   \> MCF5373 $\rightarrow$ MCF5407 $\rightarrow$ MCF5470 $\rightarrow$ MCF5471 $\rightarrow$ \\
  3140.   \> MCF5472 $\rightarrow$ MCF5473 $\rightarrow$ MCF5474 $\rightarrow$ MCF5475 $\rightarrow$ \\
  3141.   \> MCF51QM $\rightarrow$ \\
  3142.   \> 68332 $\rightarrow$ 68340 $\rightarrow$ 68360 $\rightarrow$ \\
  3143.   \> 68020 $\rightarrow$ 68030 $\rightarrow$ 68040
  3144. \end{tabbing}
  3145. \end{quote}
  3146. The differences in this family are additional instructions and
  3147. addressing modes (starting from the 68020).  A small exception is the step
  3148. to the 68030 that misses two instructions: \tty{CALLM} and \tty{RTM}.  The
  3149. three representatives of the 683xx family have the same processor core (a
  3150. slightly reduced 68020 CPU), however completely different peripherals.
  3151. MCF5xxx represents various ColdFire variants from Motorola/Freescale/NXP,
  3152. RISC processors downwardly binary compatible to the 680x0.  For the 68040,
  3153. additional control registers (reachable via \tty{MOVEC}) and instructions
  3154. for control of the on-chip MMU and caches were added.
  3155. %%-----------
  3156. \begin{quote}
  3157. b) 56000 $\longrightarrow$ 56002 $\longrightarrow$ 56300
  3158. \end{quote}
  3159. While the 56002 only adds instructions for incrementing and decrementing
  3160. the accumulators, the 56300 core is almost a new processor: all address
  3161. spaces are enlarged from 64K words to 16M and the number of instructions
  3162. almost has been doubled.
  3163. %%-----------
  3164. \begin{quote}
  3165. c) PPC403 $\rightarrow$ MPPC403 $\rightarrow$ MPC505 $\rightarrow$ MPC601 $\rightarrow$ MPC821 $\rightarrow$ RS6000
  3166. \end{quote}
  3167. The PPC403 is a reduced version of the PowerPC line without a floating
  3168. point unit, which is why all floating point instructions are disabled for
  3169. him; in turn, some microcontroller-specific instructions have been added
  3170. which are unique in this family.  The GC variant of the PPC403
  3171. incorporates an additional MMU and has therefore some additional
  3172. instructions for its control.  The MPC505 (a microcontroller variant
  3173. without a FPU) only differ in its peripheral registers from the 601 as
  3174. long as I do not know it better - \cite{Mot505} is a bit reluctant in this
  3175. respect...  The RS6000 line knows a few instructions more (that are
  3176. emulated on many 601-based systems), IBM additionally uses different
  3177. mnemonics for their pure workstation processors, as a reminiscence of 370
  3178. mainframes...
  3179. %%-----------
  3180. \begin{quote}
  3181. d) IBM5100, IBM5110, IBM5120
  3182. \end{quote}
  3183. These three types currently all reference to the same (PALM)
  3184. prozessor core.
  3185. %%-----------
  3186. \begin{quote}
  3187. e) MCORE
  3188. \end{quote}
  3189. %%-----------
  3190. \begin{quote}
  3191. f) XGATE
  3192. \end{quote}
  3193. %%-----------
  3194. \begin{quote}
  3195. g) 6800 $\rightarrow$ 6801 $\rightarrow$ 6301 $\rightarrow$ 6811
  3196. \end{quote}
  3197. While the 6801 only offers a few additional instructions (and the
  3198. 6301 even a few more), the 6811 provides a second index register and
  3199. much more instructions.
  3200. %%-----------
  3201. \begin{quote}
  3202. h) 6809/6309 and 6805/68HC(S)08
  3203. \end{quote}
  3204. These processors are partially source-code compatible to the other
  3205. 68xx processors, but they have a different binary code format and a
  3206. significantly reduced (6805) resp. enhanced (6809) instruction set.
  3207. The 6309 is a CMOS version of the 6809 which is officially only
  3208. compatible to the 6809, but inofficially offers more registers and a
  3209. lot of new instructions (see \cite{Kaku}).
  3210. %%-----------
  3211. \begin{quote}
  3212. i) 68HC12 $\longrightarrow$ 68HC12X
  3213. \end{quote}
  3214. The 12X core offers a couple of new instructions, and existing
  3215. instructions were were enriched with new addressing modes.
  3216. %%-----------
  3217. \begin{quote}
  3218. j) S912ZVC19F0MKH, S912ZVC19F0MLF,\\
  3219.   S912ZVCA19F0MKH, S912ZVCA19F0MLF,\\
  3220.   S912ZVCA19F0WKH, S912ZVH128F2CLQ,\\
  3221.   S912ZVH128F2CLL, S912ZVH64F2CLQ,\\
  3222.   S912ZVHY64F1CLQ, S912ZVHY32F1CLQ,\\
  3223.   S912ZVHY64F1CLL, S912ZVHY32F1CLL,\\
  3224.   S912ZVHL64F1CLQ, S912ZVHL32F1CLQ,\\
  3225.   S912ZVHL64F1CLL, S912ZVHL32F1CLL,\\
  3226.   S912ZVFP64F1CLQ, S912ZVFP64F1CLL,\\
  3227.   S912ZVH128F2VLQ, S912ZVH128F2VLL,\\
  3228.   S912ZVH64F2VLQ, S912ZVHY64F1VLQ,\\
  3229.   S912ZVHY32F1VLQ, S912ZVHY64F1VL,\\
  3230.   S912ZVHY32F1VLL, S912ZVHL64F1VLQ
  3231. \end{quote}
  3232. All variants contain the same processor core and the same
  3233. instruction set, only the on-chip peripherals and the
  3234. amount of built-in memory (RAM, Flash-ROM, EEPROM)
  3235. vary from device to device.
  3236. %%-----------
  3237. \begin{quote}
  3238. k) 68HC16
  3239. \end{quote}
  3240. %%-----------
  3241. \begin{quote}
  3242. l) 052001
  3243. \end{quote}
  3244. This chip is an own creation of Konami and similar to the
  3245. Motorola 6809 in architecture an instruction set.  However,
  3246. it is not binary compatible and does not provide all instructions
  3247. and addressing modes of its 'role model'.
  3248. %%-----------
  3249. \begin{quote}
  3250. m) HD6413308 $\rightarrow$ HD6413309
  3251. \end{quote}
  3252. These both names represent the 300 and 300H variants of the H8
  3253. family; the H version owns a larger address space (16 Mbytes instead
  3254. of 64 Kbytes), double-width registers (32 bits), and knows a few more
  3255. instructions and addressing modes.  It is still binary upward
  3256. compatible.
  3257. %%-----------
  3258. \begin{quote}
  3259. n) HD6475328 $\rightarrow$ HD6475348 $\rightarrow$ HD6475368 $\rightarrow$ HD6475388
  3260. \end{quote}
  3261. These processors all share the same CPU core; the different types are
  3262. only needed to include the correct subset of registers in the file
  3263. \tty{REG53X.INC}.
  3264. %%-----------
  3265. \begin{quote}
  3266. o) SH7000 $\rightarrow$ SH7600 $\longrightarrow$ SH7700
  3267. \end{quote}
  3268. The processor core of the 7600 offers a few more instructions that
  3269. close gaps in the 7000's instruction set (delayed conditional and
  3270. relative and indirect jumps, multiplications with 32-bit operands and
  3271. multiply/add instructions).  The 7700 series (also known as SH3)
  3272. furthermore offers a second register bank, better shift instructions, and
  3273. instructions to control the cache.
  3274. %%-----------
  3275. \begin{quote}
  3276. p)HD614023 $\longrightarrow$ HD614043 $\longrightarrow$ HD614081
  3277. \end{quote}
  3278. These three variants of the HMCS400 series differ by the size of
  3279. the internal ROM and RAM.
  3280. %%-----------
  3281. \begin{quote}
  3282. q) HD641016
  3283. \end{quote}
  3284. This is currently the only target with H16 core.
  3285. %%-----------
  3286. \begin{quote}
  3287. r) 6502 $\rightarrow$ 65(S)C02 \\
  3288.   $\rightarrow$ 65CE02 / W65C02S / 65C19 / MELPS740 / HUC6280 / 6502UNDOC
  3289. \end{quote}
  3290. The CMOS version defines some additional instructions, as well as a number of
  3291. some instruction/addressing mode combinations were added which were not
  3292. possible on the 6502.  The W65C02S adds two opcodes to the 65C02 instruction
  3293. set to give more fine-grained control over how to stop the CPU for low power
  3294. modes.  The 65SC02 lacks the bit manipulation instructions of the
  3295. 65C02.  The 65CE02 adds branch instructions with 16-bit displacement, a Z
  3296. register, a 16 bit stack pointer, a programmable base page, and a couple of
  3297. new instructions.
  3298.  
  3299. The 65C19 is {\em not} binary upward compatible to the original
  3300. 6502! Some addressing modes have been replaced by others.
  3301. Furthermore, this processor contains instruction set extensions
  3302. that facilitate digital signal processing.
  3303.  
  3304. The Mitsubishi micro controllers in opposite expand
  3305. the 6502 instruction set primarily to bit operations and multiplication /
  3306. division instructions.  Except for the unconditional jump and instructions
  3307. to increment/decrement the accumulator, the instruction extensions
  3308. have nothing in common.
  3309.  
  3310. For the HuC 6280, the feature that sticks out most is the larger
  3311. address space of 2 MByte instead of 64 KBytes.  This is achieved
  3312. with a buil-tin banking mechanism.  Furthermore, it features some
  3313. special instructions to communicate with a video processor (this
  3314. chip was used in video games) and to copy memory areas.
  3315.  
  3316. The 6502UNDOC processor type enables access to the "undocumented"
  3317. 6502 instructions, i.e. the operations that result from the usage of bit
  3318. combinations in the opcode that are not defined as instructions.  The
  3319. variants supported by \asname{} are listed in the appendix containing processor-specific
  3320. hints.
  3321. %%-----------
  3322. \begin{quote}
  3323. s) MELPS7700, 65816
  3324. \end{quote}
  3325. Apart from a '16-bit-version' of the 6502's instruction set, these
  3326. processors both offer some instruction set extensions.  These are
  3327. however orthogonal as they are oriented along their 8-bit
  3328. predecessors (65C02 resp. MELPS-740).  Partially, different
  3329. mnemonics are used for the same operations.
  3330. %%-----------
  3331. \begin{quote}
  3332. t) PPS-4
  3333. \end{quote}
  3334. %%-----------
  3335. \begin{quote}
  3336. u) MELPS4500
  3337. \end{quote}
  3338. %%-----------
  3339. \begin{quote}
  3340. v) M16
  3341. \end{quote}
  3342. %%-----------
  3343. \begin{quote}
  3344. w) M16C
  3345. \end{quote}
  3346. %%-----------
  3347. \begin{quote}
  3348. x) PDP-11/03, PDP-11/04, PDP-11/05, PDP-11/10,\\
  3349.   PDP-11/15, PDP-11/20, PDP-11/23, PDP-11/24,\\
  3350.   PDP-11/34, PDP-11/35, PDP-11/40, PDP-11/44,\\
  3351.   PDP-11/45, PDP-11/50, MicroPDP-11/53,\\
  3352.   PDP-11/55, PDP-11/60, PDP-11/70, MicroPDP-11/73,\\
  3353.   MicroPDP-11/83, PDP-11/84, MicroPDP-11/93,\\
  3354.   PDP-11/94, T-11
  3355. \end{quote}
  3356. The various models of the PDP-11 series differ in instruction
  3357. set (both in built-in instructions as well as in available extensions)
  3358. and the supported address space (64, 256, or 4096 KBytes).
  3359. %%-----------
  3360. \begin{quote}
  3361. y) WD16
  3362. \end{quote}
  3363. The WD16 uses the same processor as the LSI-11, however
  3364. with different microcode.  As a consequence, register set
  3365. and addressing modes are the same as for a PDP-11, however
  3366. the instruction set is slightly different and instructions
  3367. also available on the PDP-11 have different machine codes.
  3368. %%-----------
  3369. \begin{quote}
  3370. z) CP-3F, LP8000, M380
  3371. \end{quote}
  3372. The chipset's processor element was sold by AEG/Olympia, GI,
  3373. and SGS-Ates under the respective names.  There are no differences
  3374. in the instruction set and address spaces.
  3375. %%-----------
  3376. \begin{quote}
  3377. aa) 4004 $\rightarrow$ 4040
  3378. \end{quote}
  3379. In comparison to its predecessor, the 4040 features about a dozen
  3380. additional machine instructions.
  3381. %%-----------
  3382. \begin{quote}
  3383. ab) 8008 $\rightarrow$ 8008NEW
  3384. Intel redefined the mnemonics around 1975, the second variant reflects
  3385. this new instruction set.  A simultaneous support of both sets was not
  3386. possible due to mnemonic conflicts.
  3387. \end{quote}
  3388. %%-----------
  3389. \begin{quote}
  3390. ac) 8021, 8022, \\
  3391.    8401, 8411, 8421, 8461, \\
  3392.    8039, (MSM)80C39, 8048, (MSM)80C48, 8041, 8042, 80C382
  3393. \end{quote}
  3394. For the ROM-less versions 8039 and 80C39, the commands which are
  3395. using the BUS (port 0) are forbidden.  The 8021 and 8022 are special
  3396. versions with a strongly shrinked instruction set, for which the 8022
  3397. has two A/D- converters and the necessary control-commands.  The
  3398. instruction set of the MAB8401 to 8461 (designed by Philips) is
  3399. somewhere in between the 8021/8022 and a ''complete'' MC-48 instruction
  3400. set.  On the other hand, they provide serial ports and up to 8 KBytes
  3401. of program memory.
  3402.  
  3403. It is possible to transfer the CMOS-versions with the \tty{IDL} resp.
  3404. \tty{HALT} command into a stop mode with lower current consumption.
  3405. The 8041 and 8042 have some additional instructions for controlling the
  3406. bus interface, but in turn a few other commands were omitted.
  3407. The code address space of 8041, 8042, 84x1, 8021, and 8022 is not externally
  3408. extendable, and so \asname{} limits the code segment of these processors to
  3409. the size of the internal ROM.  The (SAB)80C382 is a variant especially
  3410. designed by Siemens for usage in telephones.  It also knows a
  3411. \tty{HALT} instruction, plus ist supports indirect addressing for
  3412. \tty{DJNZ} and \tty{DEC}.  In turn, several instructions of the
  3413. 'generic' 8048 were left out.  The OKI variants (MSM...) also
  3414. feature indirect addressing for \tty{DJNZ} and \tty{DEC}, plus
  3415. enhanced control of power-down modes, plus the full basic MCS-48
  3416. instrucion set.
  3417. %%-----------
  3418. \begin{quote}
  3419. \begin{tabbing}
  3420. \hspace{0.7cm} \= \kill
  3421. ad) \> 87C750 $\rightarrow$ 8051, 8052, 80C320, 80C501, 80C502, \\
  3422.    \> 80C504, 80515, and 80517 \\
  3423.    \> $\rightarrow$ 80C390 \\
  3424.    \> $\rightarrow$ 80C251
  3425. \end{tabbing}
  3426. \end{quote}
  3427. The 87C750 can only access a maximum of 2 Kbytes program memory which is
  3428. why it lacks the \tty{LCALL} and \tty{LJMP} instructions.  \asname{} does not
  3429. make any distinction among the processors in the middle, instead it only
  3430. stores the different names in the \tty{MOMCPU} variable (see below), which
  3431. allows to query the setting with \tty{IF} instructions.  An exception is
  3432. the 80C504 that has a mask flaw in its current versions.  This flaw shows
  3433. up when an \tty{AJMP} or \tty{ACALL} instruction starts at the second last
  3434. address of a 2K page.  \asname{} will automatically use long instructions or
  3435. issues an error message in such situations.  The 80C251 in contrast
  3436. represents a drastic progress in the the direction 16/32 bits, larger
  3437. address spaces, and a more orthogonal instruction set.  One might call the
  3438. 80C390 the 'small solution': Dallas Semiconductor modified instruction set
  3439. and architecture only as far as it was necessary for the 16 Mbytes large
  3440. address spaces.
  3441. %%-----------
  3442. \begin{quote}
  3443. ae) 8096 $\rightarrow$ 80196 $\rightarrow$ 80196N $\rightarrow$ 80296
  3444. \end{quote}
  3445. Apart from a different set of SFRs (which however strongly vary from
  3446. version to version), the 80196 knows several new instructions and
  3447. supports a 'windowing' mechanism to access the larger internal RAM.
  3448. The 80196N family extends the address space to 16 Mbytes and
  3449. introduces a set of instructions to access addresses beyond 64Kbytes.
  3450. The 80296 extends the CPU core by instructions for signal processing
  3451. and a second windowing register, however removes the Peripheral
  3452. Transaction Server (PTS) and therefore looses again two machine
  3453. instructions.
  3454. %%-----------
  3455. \begin{quote}
  3456. af) 8080 $\rightarrow$ V30EMU $\rightarrow$ 8085 $\rightarrow$ 8085UNDOC
  3457. \end{quote}
  3458. The 8085 knows the additional commands \tty{RIM} and \tty{SIM} for
  3459. controlling the interrupt mask and the two I/O-pins.  The type {\tt
  3460. 8085UNDOC} enables additional instructions that are not documented
  3461. by Intel.  These instructions are documented in section \ref{8085Spec}.
  3462.  
  3463. {\tt V30EMU} as target behaves like an 8080, with the addition of
  3464. the instructions {\tt RETEM} and {\em CALLN}.  These allow to
  3465. end or interrupt the 8080 emulation on a V20/V30/V40/V50.
  3466. %%-----------
  3467. \begin{quote}
  3468. ag) 8088,8086 \\
  3469. $\rightarrow$ 80188,80186 \\
  3470. $\rightarrow$ V20,V30,V40,V50 \\
  3471. $\rightarrow$ V33,V53 \\
  3472. $\rightarrow$ V25,V35 \\
  3473. $\rightarrow$ V55 \\
  3474. $\rightarrow$ V55SC \\
  3475. $\rightarrow$ V55PI
  3476. \end{quote}
  3477. Processors listed in the same line feature an identical CPU core and therefore
  3478. identical instruction set.  Going down the lines, new instructions are added,
  3479. with the NEC CPUs going different 'branches', coming from the 'V20 basic
  3480. instruction set'.
  3481. %%-----------
  3482. \begin{quote}
  3483. ah) 80960
  3484. \end{quote}
  3485. %%-----------
  3486. \begin{quote}
  3487. ai) 8X300 $\rightarrow$ 8X305
  3488. \end{quote}
  3489. The 8X305 features a couple of additional registers that miss on the
  3490. 8X300.  Additionally, it can do new operations with these registers
  3491. (like direct writing of 8 bit values to peripheral addresses).
  3492. %%-----------
  3493. \begin{quote}
  3494. aj) XAG1, XAG2, XAG3
  3495. \end{quote}
  3496. These processors only differ in the size of their internal ROM which
  3497. is defined in \tty{STDDEFXA.INC}.
  3498. %%-----------
  3499. \begin{quote}
  3500. ak) AT90S1200, AT90S2313, AT90S2323, AT90S233,\\
  3501.    AT90S2343, AT90S4414, AT90S4433, AT90S4434,\\
  3502.    AT90S8515, AT90C8534, AT90S8535,\\
  3503.    ATTINY4, ATTINY5, ATTINY9,\\
  3504.    ATTINY10, ATTINY11, ATTINY12, ATTINY13, ATTINY13A,\\
  3505.    ATTINY15, ATTINY20, ATTINY24(A), ATTINY25,\\
  3506.    ATTINY26, ATTINY28, ATTINY40, ATTINY44(A),\\
  3507.    ATTINY45, ATTINY48, ATTINY84(A), ATTINY85,\\
  3508.    ATTINY87, ATTINY88, ATTINY102, ATTINY104,\\
  3509.    ATTINY167, ATTINY261, ATTINY261A, ATTINY43U,\\
  3510.    ATTINY441, ATTINY461, ATTINY461A, ATTINY828,\\
  3511.    ATTINY841, ATTINY861, ATTINY861A, ATTINY1634,\\
  3512.    ATTINY2313, ATTINY2313A, ATTINY4313, ATMEGA48,\\
  3513.    ATMEGA8, ATMEGA8515, ATMEGA8535, ATMEGA88,\\
  3514.    ATMEGA8U2, ATMEGA16U2, ATMEGA32U2,\\
  3515.    ATMEGA16U4, ATMEGA32U4, ATMEGA32U6, AT90USB646,\\
  3516.    AT90USB647, AT90USB1286, AT90USB1287, AT43USB355,\\
  3517.    ATMEGA16, ATMEGA161, ATMEGA162, ATMEGA163,\\
  3518.    ATMEGA164, ATMEGA165, ATMEGA168, ATMEGA169,\\
  3519.    ATMEGA32, ATMEGA323, ATMEGA324, ATMEGA325,\\
  3520.    ATMEGA3250, ATMEGA328, ATMEGA329, ATMEGA3290,\\
  3521.    ATMEGA406, ATMEGA64, ATMEGA640, ATMEGA644,\\
  3522.    ATMEGA644RFR2, ATMEGA645, ATMEGA6450,\\
  3523.    ATMEGA649, ATMEGA6490, ATMEGA103, ATMEGA128,\\
  3524.    ATMEGA1280, ATMEGA1281, ATMEGA1284,\\
  3525.    ATMEGA1284RFR2, ATMEGA2560, ATMEGA2561
  3526. \end{quote}
  3527. The various AVR chip variants mainly differ in the amount of
  3528. on-chip memory (flash, SRAM, EEPROM) an the set of built-in
  3529. peripherals (GPIO, timers, UART, A/D converter...).  Compared to
  3530. the AT90... predecessors, the ATmega chip also provide additional
  3531. instructions, while the ATtinys do not support the multiplication
  3532. instructions.
  3533. %%-----------
  3534. \begin{quote}
  3535. al) AM29245 $\rightarrow$ AM29243 $\rightarrow$ AM29240 $\rightarrow$ AM29000
  3536. \end{quote}
  3537. The further one moves to the right in this list, the fewer the
  3538. instructions become that have to be emulated in software.  While e.g.
  3539. the 29245 not even owns a hardware multiplier, the two representors in
  3540. the middle only lack the floating point instructions.  The 29000
  3541. serves as a 'generic' type that understands all instructions in
  3542. hardware.
  3543. %%-----------
  3544. \begin{quote}
  3545. am) 80C166 $\rightarrow$ 80C167,80C165,80C163
  3546. \end{quote}
  3547. 80C167 and 80C165/163 have an address space of 16 Mbytes instead of 256
  3548. Kbytes, and furthermore they know some additional instructions for
  3549. extended addressing modes and atomic instruction sequences.  They are
  3550. 'second generation' processors and differ from each other only in the
  3551. amount of on-chip peripherals.
  3552. %%-----------
  3553. \begin{quote}
  3554. an) LR35902/GBZ80 $\rightarrow$ Z80 $\rightarrow$ Z80UNDOC \\
  3555.    $\rightarrow$ Z180 $\rightarrow$ Z380
  3556. \end{quote}
  3557. While there are only a few additional instructions for the Z180, the
  3558. Z380 owns 32-bit registers, a linear address space of 4 Gbytes, a
  3559. couple of instruction set extensions that make the overall
  3560. instruction set considerably more orthogonal, and new addressing
  3561. modes (referring to index register halves, stack relative).  These
  3562. extensions partially already exist on the Z80 as undocumented
  3563. extensions and may be switched on via the Z80UNDOC variant.  A list
  3564. with the additional instructions can be found in the chapter
  3565. with processor specific hints.
  3566.  
  3567. The processor built into the Gameboy (official designation LR35092,
  3568. commonly referred to as ''Gameboy Z80'') is a mixture of an 8080
  3569. and Z80.  It lacks the IX/IY registers, the I/O address space,
  3570. the second register bank and a couple of 16 bit instructions.
  3571. %%-----------
  3572. \begin{quote}
  3573. ao) Z8601, Z8603, z86C03, z86E03, Z86C06, Z86E06, \\
  3574.    Z86C08, Z86C21, Z86E21, Z86C30, Z86C31, Z86C32 Z86C40 \\
  3575.    $\rightarrow$ Z88C00, Z88C01 \\
  3576.    $\rightarrow$ eZ8, Z8F0113, Z8F011A, Z8F0123, Z8F012A, \\
  3577.    Z8F0130, Z8F0131, Z8F0213, Z8F021A, Z8F0223, Z8F022A, \\
  3578.    Z8F0230, Z8F0231, Z8F0411, Z8F0412, Z8F0413, Z8F041A, \\
  3579.    Z8F0421, Z8F0422, Z8F0423, Z8F042A, Z8F0430, Z8F0431, \\
  3580.    Z8F0811, Z8F0812, Z8F0813, Z8F081A, Z8F0821, Z8F0822, \\
  3581.    Z8F0823, Z8F082A, Z8F0830, Z8F0831, Z8F0880, Z8F1232, \\
  3582.    Z8F1233, Z8F1621, Z8F1622, Z8F1680, Z8F1681, Z8F1682, \\
  3583.    Z8F2421, Z8F2422, Z8F2480, Z8F3221, Z8F3222, Z8F3281, \\
  3584.    Z8F3282, Z8F4821, Z8F4822, Z8F4823, Z8F6081, Z8F6082, \\
  3585.    Z8F6421, Z8F6422, Z8F6423, Z8F6481, Z8F6482
  3586. \end{quote}
  3587. The variants with Z8 core only differ in internal memory size and
  3588. on-chip peripherals, i.e. the choice does not have an effect on the
  3589. supported instruction set.  Super8 and eZ8 are substantially different,
  3590. each with an instruction set that was vastly extended (into different
  3591. directions), and they are not fully upward-compatible on source code
  3592. level as well.
  3593. %%-----------
  3594. \begin{quote}
  3595. ap) Z8001, Z8002, Z8003, Z8004
  3596. \end{quote}
  3597. The operation mode (segmented for Z8001 and Z8003, non-segmented for
  3598. Z8002 and Z8004) is selected via the processor type.  There is currently
  3599. no further differentiation between Z8001/8002 and Z8003/8004.
  3600. %%-----------
  3601. \begin{quote}
  3602. aq) KCPSM
  3603. \end{quote}
  3604. Both processor cores are not available as standalone components, they are
  3605. provided as logic cores for gate arrays made by Xilinx The -3 variant
  3606. offers a larger address space and some additional instructions.  Note that
  3607. it is not binary upward-compatible!
  3608. %%-----------
  3609. \begin{quote}
  3610. ar) MICO8\_05, MICO8\_V3, MICO8\_V31
  3611. \end{quote}
  3612. Lattice unfortunately changed the machine instructions more than once, so
  3613. different targets became necessary to provide continued support for older
  3614. projects.  The first variant is the one described in the 2005 manual, the
  3615. two other ones represent versions 3.0 resp. 3.1.
  3616. %%-----------
  3617. \begin{quote}
  3618. as) 96C141, 93C141
  3619. \end{quote}
  3620. These two processors represent the two variations of the processor
  3621. family: TLCS-900 and TLCS-900L.  The differences of these two variations
  3622. will be discussed in detail in section \ref{TLCS900Spec}.
  3623. %%-----------
  3624. \begin{quote}
  3625. at) 90C141
  3626. \end{quote}
  3627. %%-----------
  3628. \begin{quote}
  3629. au) 87C00, 87C20, 87C40, 87C70
  3630. \end{quote}
  3631. The processors of the TLCS-870 series have an identical CPU core, but
  3632. different peripherals depending on the type.  In part registers with
  3633. the same name are located at different addresses.  The file
  3634. \tty{STDDEF87.INC} uses, similar to the MCS-51-family, the distinction
  3635. possible by different types to provide the correct symbol set
  3636. automatically.
  3637. %%-----------
  3638. av) TLCS-870/C
  3639. Currently, only the processor core of the TLCS-870/C family is
  3640. implemented.
  3641. %%-----------
  3642. \begin{quote}
  3643. aw) 47C00 $\rightarrow$ 470C00 $\rightarrow$ 470AC00
  3644. \end{quote}
  3645. These three variations of the TLCS-47-family have on-chip RAM and ROM
  3646. of different size, which leads to several bank switching instructions
  3647. being added or suppressed.
  3648. %%-----------
  3649. \begin{quote}
  3650. ax) 97C241
  3651. \end{quote}
  3652. %%-----------
  3653. \begin{quote}
  3654. ay) TC9331
  3655. \end{quote}
  3656. %%-----------
  3657. \begin{quote}
  3658. az) 16C54 $\rightarrow$ 16C55 $\rightarrow$ 16C56 $\rightarrow$ 16C57
  3659. \end{quote}
  3660. These processors differ by the available code area, i.e. by the address
  3661. limit after which \asname{} reports overruns.
  3662. %%-----------
  3663. \begin{quote}
  3664. ba) 16C84, 16C64
  3665. \end{quote}
  3666. Analog to the MCS-51 family, no distinction is made in the code generator,
  3667. the different numbers only serve to include the correct SFRs in
  3668. \tty{STDDEF18.INC}.
  3669. %%-----------
  3670. \begin{quote}
  3671. bb) 17C42
  3672. \end{quote}
  3673. %%-----------
  3674. \begin{quote}
  3675. bc) SX20, SX28
  3676. \end{quote}
  3677. The SX20 uses a smaller housing and lacks port C.
  3678. %%-----------
  3679. \begin{quote}
  3680. bd) ST6200, ST6201, ST6203, ST6208, ST6209,\\
  3681.    ST6210, ST6215, ST6218, ST6220, ST6225,\\
  3682.    ST6228, ST6230, ST6232, ST6235, ST6240,\\
  3683.    ST6242, ST6245, ST6246, ST6252, ST6253,\\
  3684.    ST6255, ST6260, ST6262, ST6263, ST6265,\\
  3685.    ST6280, ST6285
  3686. \end{quote}
  3687. The various ST6 derivates differ in the amount of
  3688. on-chip peripherals and built-in memory.
  3689. %%-----------
  3690. \begin{quote}
  3691. be) ST7 \\
  3692.    ST72251G1, ST72251G2, ST72311J2, ST72311J4, \\
  3693.    ST72321BR6, ST72321BR7, ST72321BR9, ST72325S4, \\
  3694.    ST72325S6, ST72325J7, ST72325R9, ST72324J6, \\
  3695.    ST72324K6, ST72324J4, ST72324K4, ST72324J2, \\
  3696.    ST72324JK21, ST72325S4, ST72325J7, ST72325R9, \\
  3697.    ST72521BR6, ST72521BM9, ST7232AK1, ST7232AK2, \\
  3698.    ST7232AJ1, ST7232AJ2, ST72361AR4, ST72361AR6, \\
  3699.    ST72361AR7, ST72361AR9, ST7FOXK1, ST7FOXK2, \\
  3700.    ST7LITES2Y0, ST7LITES5Y0, ST7LITE02Y0, \\
  3701.    ST7LITE05Y0, ST7LITE09Y0 \\
  3702.    ST7LITE10F1, ST7LITE15F1, ST7LITE19F1, \\
  3703.    ST7LITE10F0, ST7LITE15F0, ST7LITE15F1, \\
  3704.    ST7LITE19F0, ST7LITE19F1, \\
  3705.    ST7LITE20F2, ST7LITE25F2, ST7LITE29F2, \\
  3706.    ST7LITE30F2, ST7LITE35F2, ST7LITE39F2, \\
  3707.    ST7LITE49K2, \\
  3708.    ST7MC1K2, ST7MC1K4, ST7MC2N6, ST7MC2S4, \\
  3709.    ST7MC2S6, ST7MC2S7, ST7MC2S9, ST7MC2R6, \\
  3710.    ST7MC2R7, ST7MC2R9, ST7MC2M9, \\
  3711.    STM8 \\
  3712.    STM8S001J3, STM8S003F3, STM8S003K3, STM8S005C6,\\
  3713.    STM8S005K6, STM8S007C8, STM8S103F2, STM8S103F3,\\
  3714.    STM8S103K3, STM8S105C4, STM8S105C6, STM8S105K4,\\
  3715.    STM8S105K6, STM8S105S4, STM8S105S6, STM8S207MB,\\
  3716.    STM8S207M8, STM8S207RB, STM8S207R8, STM8S207R6,\\
  3717.    STM8S207CB, STM8S207C8, STM8S207C6, STM8S207SB,\\
  3718.    STM8S207S8, STM8S207S6, STM8S207K8, STM8S207K6,\\
  3719.    STM8S208MB, STM8S208RB, STM8S208R8, STM8S208R6,\\
  3720.    STM8S208CB, STM8S208C8, STM8S208C6, STM8S208SB,\\
  3721.    STM8S208S8, STM8S208S6, STM8S903K3, STM8S903F3,\\
  3722.    STM8L050J3, STM8L051F3, STM8L052C6, STM8L052R8,\\
  3723.    STM8L001J3, STM8L101F1, STM8L101F2, STM8L101G2,\\
  3724.    STM8L101F3, STM8L101G3, STM8L101K3, STM8L151C2,\\
  3725.    STM8L151K2, STM8L151G2, STM8L151F2, STM8L151C3,\\
  3726.    STM8L151K3, STM8L151G3, STM8L151F3, STM8L151C4,\\
  3727.    STM8L151C6, STM8L151K4, STM8L151K6, STM8L151G4,\\
  3728.    STM8L151G6, STM8L152C4, STM8L152C6, STM8L152K4,\\
  3729.    STM8L152K6, STM8L151R6, STM8L151C8, STM8L151M8,\\
  3730.    STM8L151R8, STM8L152R6, STM8L152C8, STM8L152K8,\\
  3731.    STM8L152M8, STM8L152R8, STM8L162M8, STM8L162R8,\\
  3732.    STM8AF6366, STM8AF6388, STM8AF6213, STM8AF6223,\\
  3733.    STM8AF6226, STM8AF6246, STM8AF6248, STM8AF6266,\\
  3734.    STM8AF6268, STM8AF6269, STM8AF6286, STM8AF6288,\\
  3735.    STM8AF6289, STM8AF628A, STM8AF62A6, STM8AF62A8,\\
  3736.    STM8AF62A9, STM8AF62AA, STM8AF5268, STM8AF5269,\\
  3737.    STM8AF5286, STM8AF5288, STM8AF5289, STM8AF528A,\\
  3738.    STM8AF52A6, STM8AF52A8, STM8AF52A9, STM8AF52AA,\\
  3739.    STM8AL3136, STM8AL3138, STM8AL3146, STM8AL3148,\\
  3740.    STM8AL3166, STM8AL3168, STM8AL3L46, STM8AL3L48,\\
  3741.    STM8AL3L66, STM8AL3L68, STM8AL3188, STM8AL3189,\\
  3742.    STM8AL318A, STM8AL3L88, STM8AL3L89, STM8AL3L8A,\\
  3743.    STM8TL52F4, STM8TL52G4, STM8TL53C4, STM8TL53F4,\\
  3744.    STM8TL53G4
  3745. \end{quote}
  3746. The STM8 core extends the address space to 16 Mbytes and introduces
  3747. a couple of new instructions.  Though many instructions have the same
  3748. machine code as for ST7, it is not binary upward compatible.
  3749. %%-----------
  3750. \begin{quote}
  3751. bf) ST9020, ST9030, ST9040, ST9050
  3752. \end{quote}
  3753. These 4 names represent the four ''sub-families'' of the ST9 family,
  3754. which only differ in their on-chip peripherals.  Their processor
  3755. cores are identical, which is why this distinction is again only used
  3756. in the include file containing the peripheral addresses.
  3757. %%-----------
  3758. \begin{quote}
  3759. bg) 6804
  3760. \end{quote}
  3761. %%-----------
  3762. \begin{quote}
  3763. bh) 32010$\rightarrow$32015
  3764. \end{quote}
  3765. The TMS32010 owns just 144 bytes of internal RAM, and so \asname{} limits
  3766. addresses in the data segment just up to this amount.  This restriction
  3767. does not apply for the 32015, the full range from 0..255 can be used.
  3768. %%-----------
  3769. \begin{quote}
  3770. bi) 320C25 $\rightarrow$ 320C26 $\rightarrow$ 320C28
  3771. \end{quote}
  3772. These processors only differ slightly in their on-chip peripherals
  3773. and in their configuration instructions.
  3774. %%-----------
  3775. \begin{quote}
  3776. bj) 320C30, 320C31 $\rightarrow$ 320C40, 320C44
  3777. \end{quote}
  3778. The 320C31 is a reduced version with the same instruction set,
  3779. however fewer peripherals.  The distinction is exploited in
  3780. \tty{STDDEF3X.INC}.  The C4x variants are sourcecode upward
  3781. compatible, the machine codes of some instructions are however
  3782. slightly different.  Once again, the C44 is a stripped-down
  3783. version of the C40, with less peripherals and a smaller address
  3784. space.
  3785. %%-----------
  3786. \begin{quote}
  3787. bk) 320C203 $\rightarrow$ 320C50, 320C51, 320C53
  3788. \end{quote}
  3789. The first one represents the C20x family of signal processors which
  3790. implement a subset of the C5x instruction set.  The distinction among the
  3791. C5x processors is currently not used by \asname{}.
  3792. %%-----------
  3793. \begin{quote}
  3794. bl) 320C541
  3795. \end{quote}
  3796. This one at the moment represents the TMS320C54x family...
  3797. %%-----------
  3798. \begin{quote}
  3799. bm) TI990/4, TI990/10, TI990/12 \\
  3800.    TMS9900, TMS9940, TMS9995, TMS99105, TMS99110
  3801. \end{quote}
  3802. The TMS99xx/99xxx processors are basically single chip implementations
  3803. of the TI990 minicomputers.  Some TI990 models are even based on such
  3804. a processor instead of a discrete CPU.  The individual models differ in their
  3805. instruction set (the TI990/12 has the largest one) and the presence of a
  3806. privileged mode.
  3807. %%-----------
  3808. \begin{quote}
  3809. \begin{tabbing}
  3810. \hspace{0.7cm} \= \kill
  3811. bn) \> TMS70C00, TMS70C20, TMS70C40,\\
  3812.    \> TMS70CT20, TMS70CT40,\\
  3813.    \> TMS70C02, TMS70C42, TMS70C82,\\
  3814.    \> TMS70C08, TMS70C48\\
  3815. \end{tabbing}
  3816. \end{quote}
  3817. All members of this family share the same CPU core, they therefore do not
  3818. differ in their instruction set.  The differences manifest only in the
  3819. file \tty{REG7000.INC} where address ranges and peripheral addresses are
  3820. defined.  Types listed in the same row have the same amount of internal
  3821. RAM and the same on-chip peripherals, they differ only in the amount of
  3822. integrated ROM.
  3823. %%-----------
  3824. \begin{quote}
  3825. bo) 370C010, 370C020, 370C030, 370C040 and 370C050
  3826. \end{quote}
  3827. Similar to the MCS-51 family, the different types are only used to
  3828. differentiate the peripheral equipment in \tty{STDDEF37.INC}; the
  3829. instruction set is always the same.
  3830. %%-----------
  3831. \begin{quote}
  3832. bp) MSP430 $\rightarrow$ MSP430X
  3833. The X variant of the CPU core extends the address space from 64
  3834. KiBytes to 1 MiByte and augments the instruction set, e.g. by
  3835. prefixed to repeat instructions.
  3836. \end{quote}
  3837. %%-----------
  3838. \begin{quote}
  3839. bq) TMS1000, TMS1100, TMS1200, TMS1300
  3840. \end{quote}
  3841. TMS1000 and TMS1200 each provide 1 KByte of ROM and 64 nibbles of
  3842. RAM, while TMS1100 and TMS1300 provide twice the amount of RAM
  3843. and ROM.  Furthermore, TI has defined a significantly different
  3844. default instruction set fot TMS1100 and TMS1300(\asname{} only knows the
  3845. default instruction sets!)
  3846. %%-----------
  3847. \begin{quote}
  3848. br) IMP-16C/200, IMP-16C/300, IMP-16P/200, IMP-16P/300, IMP-16L
  3849. \end{quote}
  3850. The IMP-16L defines a few additional bits in its status register,
  3851. plus more branch conditions.  It supports the extended instruction
  3852. set just like the /300 variants.
  3853. %%-----------
  3854. \begin{quote}
  3855. bs) IPC-16, INS8900
  3856. \end{quote}
  3857. The INS8900 is just a re-implementation of PACE in a more modern
  3858. NMOS manufacturing process; there are no differences in instruction
  3859. set.
  3860. %%-----------
  3861. \begin{quote}
  3862. bt) SC/MP
  3863. \end{quote}
  3864. %%-----------
  3865. \begin{quote}
  3866. bu) 8070
  3867. \end{quote}
  3868. This processor represents the whole 807x family (which consists at least
  3869. of the 8070, 8072, and 8073), which however shares identical CPU cores.
  3870. %%-----------
  3871. \begin{quote}
  3872. bv) COP87L84
  3873. \end{quote}
  3874. This is the only member of National Semiconductor's COP8 family that
  3875. is currently supported.  I know that the family is substantially
  3876. larger and that there are representors with differently large
  3877. instruction sets which will be added when a need occurs.  It is a
  3878. beginning, and National's documentation is quite extensive...
  3879. %%-----------
  3880. \begin{quote}
  3881. bw) COP410 $\rightarrow$ COP420 $\rightarrow$ COP440 $\rightarrow$ COP444
  3882. The COP42x derivates offer some additional instructions, plus other
  3883. instructions have an extended operand range.
  3884. \end{quote}
  3885. %%-----------
  3886. \begin{quote}
  3887. \begin{tabbing}
  3888. \hspace{0.7cm} \= \kill
  3889. bx) \> SC14400, SC14401, SC14402, SC14404, SC14405, \\
  3890.    \> SC14420, SC14421, SC14422, SC14424 \\
  3891. \end{tabbing}
  3892. \end{quote}
  3893. This series of DECT controllers differentiates itself by the amount of
  3894. instructions, since each of them supports different B field formats and
  3895. their architecture has been optimized over time.
  3896. %%-----------
  3897. \begin{quote}
  3898. by) NS16008, NS32008, NS08032, NS16032, NS32016, NS32032, \\
  3899.    NS32332, NS32CG16, NS32532
  3900. \end{quote}
  3901. National renamed the first-generation CPUs several times in the early
  3902. years, NS16008/NS32008/NS08032 resp. NS16032/NS32016 are the same chips.
  3903. NS32332 and NS32532 support an address space of  4 GBytes instead of 16
  3904. MBytes, and the NS32CG16 is an embedded variant with additional instructions
  3905. for bit block transfers.
  3906. %%-----------
  3907. \begin{quote}
  3908. bz) ACE1101, ACE1202
  3909. \end{quote}
  3910. %%-----------
  3911. \begin{quote}
  3912. ca) F3850, MK3850, \\
  3913.    MK3870, MK3870/10, MK3870/12, "MK3870/20, MK3870/22, \\
  3914.    MK3870/30, MK3870/32, MK3870/40, MK3870/42, \\
  3915.    MK3872, MK3873, MK3873/10, MK3873/12, MK3873/20, \\
  3916.    MK3873/22, MK3874, MK3875, MK3875/22, MK3875/42, \\
  3917.    MK3876, MK38P70/02, MK38C70, MK38C70/10, \\
  3918.    MK38C70/20, MK97400, MK97410, MK97500, MK97501, \\
  3919.    MK97503
  3920. \end{quote}
  3921. This huge amount of variants partially results from the fact that
  3922. Mostek renamed some variants in the early 80s.  The new naming scheme
  3923. allows to deduce the amount of internal ROM (0 to 4 for 0 to 4 Kbytes)
  3924. and executable RAM (0 or 2 for 0 or 64 bytes) from the suffix.  3850
  3925. and MK975xx support a 64K address space, which is only 4 Kbytes for all
  3926. other variants.  P variants have an EEPROM piggyback socket for prototyping,
  3927. C variants are fabricated in CMOS technology and feature two new machine
  3928. instructions (HET and HAL). The MK3873's feature is a built-in serial port,
  3929. while the MK3875 offers a second supply voltage pin to buffer the internal
  3930. memory in standby mode.
  3931. %%-----------
  3932. \begin{quote}
  3933. cb) 7800, 7801, 7802 \\
  3934. 78C05, 78C06 \\
  3935. 7807, 7808, 7809 \\
  3936. 7810$\rightarrow$78C10, 78C11, 78C12, 78C14, 78C17, 78C18
  3937. \end{quote}
  3938. $\mu$PD7800 to $\mu$PD7802 represent the ''first generation'' of the
  3939. uCOM87 family from NEC.  $\mu$PD78C05 and $\mu$PD78C06 are reduced
  3940. variants that implement only a subset of the instruction set. 7807 to
  3941. 7809 represent the uCOM87 series, whose instruction set was vastly
  3942. extended.  All $\mu$PD781x variants belong to the uCOM87AD series, which
  3943. adds an A/D converter - however, instructions for bit processing were
  3944. again removed.  \bb{NOTE:} The instruction set is in general only
  3945. partially binary upward compatible! The NMOS version $\mu$PD7810 has
  3946. no stop-mode; the respective command and the ZCM register are omitted.
  3947. \bb{CAUTION!}  NMOS and CMOS version partially differ in the reset
  3948. values of some registers!
  3949. %%-----------
  3950. \begin{quote}
  3951. cc) 7500 $\leftrightarrow$ 7508
  3952. \end{quote}
  3953. There are two different types of CPU cores in the $\mu$PD75xx
  3954. family: the 7566 represents the the 'instruction set B', which
  3955. provides less instructions, less registers and smaller address
  3956. spaces.  The 7508 represents the 'full' instruction set A.  {\bf
  3957. CAUTION!} These instruction sets are not 100\% binary compatible!
  3958. %%-----------
  3959. \begin{quote}
  3960. \begin{tabbing}
  3961. \hspace{0.7cm} \= \kill
  3962. cd) \> 75402,\\
  3963.    \> 75004, 75006, 75008,\\
  3964.    \> 75268,\\
  3965.    \> 75304, 75306, 75308, 75312, 75316,\\
  3966.    \> 75328,\\
  3967.    \> 75104, 75106, 75108, 75112, 75116,\\
  3968.    \> 75206, 75208, 75212, 75216,\\
  3969.    \> 75512, 75516\\
  3970. \end{tabbing}
  3971. \end{quote}
  3972. This 'cornucopia' of processors differs only by the RAM size in one
  3973. group; the groups themselves again differ by their on-chip
  3974. peripherals on the one hand and by their instruction set's power on
  3975. the other hand.
  3976. %%-----------
  3977. \begin{quote}
  3978. ce) 78070
  3979. \end{quote}
  3980. This is currently the only member of NEC's 78K0 family I am familiar
  3981. with.  Similar remarks like for the COP8 family apply!
  3982. %%-----------
  3983. \begin{quote}
  3984. cf) 78214
  3985. \end{quote}
  3986. This is currently the representor of NEC's 78K2 family.
  3987. %%-----------
  3988. \begin{quote}
  3989. cg) 78310
  3990. \end{quote}
  3991. This is currently the representor of NEC's 78K3 family.
  3992. %%-----------
  3993. \begin{quote}
  3994. ch) 784026
  3995. \end{quote}
  3996. This is currently the representor of NEC's 78K4 family.
  3997. %%-----------
  3998. \begin{quote}
  3999. ci) 7720 $\rightarrow$ 7725
  4000. \end{quote}
  4001. The $\mu$PD7725 offers larger address spaces and som more instructions
  4002. compared to his predecessor. {\bf CAUTION!}  The processors are not binary
  4003. compatible to each other!
  4004. %%-----------
  4005. \begin{quote}
  4006. cj) 77230
  4007. \end{quote}
  4008. %%-----------
  4009. \begin{quote}
  4010. ck) 70616
  4011. \end{quote}
  4012. This is currently the representor of NEC's V60 family.
  4013. %%-----------
  4014. \begin{quote}
  4015. \begin{tabbing}
  4016. cl) \= SYM53C810, SYM53C860, SYM53C815, SYM53C825, \\
  4017.    \> SYM53C875, SYM53C895
  4018. \end{tabbing}
  4019. \end{quote}
  4020. The simpler members of this family of SCSI processors lack some
  4021. instruction variants, furthermore they are different in their set of
  4022. internal registers.
  4023. %%-----------
  4024. \begin{quote}
  4025. cm) MB89190
  4026. \end{quote}
  4027. This processor type represents Fujitsu's F$^{2}$MC8L series...
  4028. %%-----------
  4029. \begin{quote}
  4030. cn) MB9500
  4031. \end{quote}
  4032. ...just like this one does it currently for the 16-bit variants from
  4033. Fujitsu!
  4034. %%-----------
  4035. \begin{quote}
  4036. co) MSM5840, MSM5842, MSM58421, MSM58422, MSM5847
  4037. \end{quote}
  4038. These variants of the OLMS-40 family differ in their instruction
  4039. set and in the amount of internal program and data memory.
  4040. %%-----------
  4041. \begin{quote}
  4042. cp) MSM5054, MSM5055, MSM5056, MSM6051, MSM6052
  4043. \end{quote}
  4044. The as for the OLMS-40 family: differences in instruction
  4045. set and the amount of internal program and data memory.
  4046. %%-----------
  4047. \begin{quote}
  4048. cq) MN1610[ALT] $\rightarrow$ MN1613[ALT]
  4049. \end{quote}
  4050. In addition to its predecessor's features, the MN1613 offers a larger
  4051. address space, a floating point unit and a couple of new machine
  4052. instructions.
  4053. %%-----------
  4054. \begin{quote}
  4055. cr) RXV1, RX110, RX111, RX113, RX130, RX210,\\
  4056.    RX21A, RX220, RX610, RX621, RX62N, RX630,\\
  4057.    RX631 $\longrightarrow$ \\
  4058.    RXV2, RX140, RX230, RX231, RX64M,\\
  4059.    RX651 $\longrightarrow$ \\
  4060.    RXV3, RX660, RX671, RX72M, RX72N
  4061. \end{quote}
  4062. Controllers of the RX series can coarsely be classified
  4063. into three groups or generations.  From generation to
  4064. generation (RXv1, RXv2, RXv3), new machine instructions
  4065. were added.
  4066. %%-----------
  4067. \begin{quote}
  4068. cs) PMC150, PMS150, PFS154, PMC131, PMS130, PMS131 \\
  4069.    PMS132, PMS132B, PMS152, PMS154B, PMS154C, PFS173 \\
  4070.    PMS133, PMS134, DF69, MCS11, PMC232, PMC234, PMC251 \\
  4071.    PMC271,PMC884, PMS232, PMS234, PMS271
  4072. \end{quote}
  4073. The Padauk controllers differ in the size of the internal
  4074. (ROM/RAM) memory, the type of internal ROM (erasable or OTP),
  4075. the built-in peripherals, and their instruction set (both
  4076. extent and binary coding).
  4077. %%-----------
  4078. \begin{quote}
  4079. ct) 1802 $\rightarrow$ 1804, 1805, 1806 $\rightarrow$ 1804A,
  4080. 1805A, 1806A
  4081. \end{quote}
  4082. 1804, 1805, and 1806 feature an instruction set that is slightly
  4083. enhanced, compared to the 'original' 1802, plus on-chip RAM and
  4084. an integrated timer.  The A variants extend the instruction set by
  4085. \tty{DSAV}, \tty{DBNZ}, and instructions for addition and
  4086. subtraction in BCD format.
  4087. %%-----------
  4088. \begin{quote}
  4089. cu) XS1
  4090. \end{quote}
  4091. This type represents the XCore-"family".
  4092. %%-----------
  4093. \begin{quote}
  4094. cv) 1750
  4095. \end{quote}
  4096. MIL STD 1750 is a standard, therefore there is only one
  4097. (standard) variant...
  4098. %%-----------
  4099. \begin{quote}
  4100. cw) KENBAK
  4101. \end{quote}
  4102. Since there has never been a KENBAK-2, the target is simply KENBAK...
  4103. %%-----------
  4104. \begin{quote}
  4105. cx) CP-1600
  4106. \end{quote}
  4107. %%-----------
  4108. \begin{quote}
  4109. cy) HPNANO
  4110. \end{quote}
  4111. %%-----------
  4112. \begin{quote}
  4113. cz) 6100 $\rightarrow$ 6120
  4114. \end{quote}
  4115. The IM6120 supports a larger address space (32K
  4116. instead of 4K) and additional machine instructions.
  4117. \begin{quote}
  4118. da) SC61860
  4119. \end{quote}
  4120. This is the processor used in the Sharp PC-12xx...PC-15xx pocket computers.
  4121. %%-----------
  4122. \begin{quote}
  4123. db) SC62015
  4124. \end{quote}
  4125. This is the processor used in the  Sharp PC-E500.
  4126.  
  4127. NONE is a special target that has not been mentioned so far.  This is the
  4128. default target if no target has been defined on the command line via
  4129. {\tt -cpu}, and if no {\tt CPU} statement has been encountered so far.
  4130. target independent pseudo instructions are still possible in this situation,
  4131. however it is not possible to create any code, neither via machine
  4132. instructions, nor via placing data in memory.  In principle, it is
  4133. also possible to explicitly select this target via {\tt -cpu} or
  4134. {\tt CPU}.  The practical use of this is however limited.
  4135.  
  4136. The \tty{CPU} instruction needs the processor type as a simple literal, a
  4137. calculation like:
  4138. \begin{verbatim}
  4139.        CPU     68010+10
  4140. \end{verbatim}
  4141. is not allowed.  Valid calls are e.g.
  4142. \begin{verbatim}
  4143.        CPU     8051
  4144. \end{verbatim}
  4145. or
  4146. \begin{verbatim}
  4147.        CPU     6800
  4148. \end{verbatim}
  4149. Regardless of the processor type currently set, the integer variable
  4150. \tty{MOMCPU} contains the current status as a hexadecimal number.  For
  4151. example, \tty{MOMCPU}=\$68010 for the 68010 or \tty{MOMCPU}=80C48H for the
  4152. 80C48.  As one cannot express all letters as hexadecimal digits (only A..F
  4153. are possible), all other letters must must be omitted in the hex notation;
  4154. for example, \tty{MOMCPU}=80H for the Z80.
  4155. You can take advantage of this feature to generate different code
  4156. depending on the processor type.  For example, the 68000 does not have a
  4157. machine instruction for a subroutine return with stack correction.  With
  4158. the variable \tty{MOMCPU} you can define a macro that uses the machine
  4159. instruction or emulates it depending on the processor type:
  4160. \begin{verbatim}
  4161. myrtd   macro   disp
  4162.        if      MOMCPU<$68010 ; emulate for 68008 & 68000
  4163.         move.l (sp),disp(sp)
  4164.         lea    disp(sp),sp
  4165.         rts
  4166.        elseif
  4167.         rtd    #disp         ; direct use on >=68010
  4168.        endif
  4169.        endm
  4170.  
  4171.  
  4172.        cpu     68010
  4173.        myrtd   12            ; results in RTD #12
  4174.  
  4175.        cpu     68000
  4176.        myrtd   12            ; results in MOVE../LEA../RTS
  4177. \end{verbatim}
  4178. As not all processor names are built only out of numbers and letters
  4179. from A..F, the full name is additionally stored in the string
  4180. variable named \tty{MOMCPUNAME}.
  4181.  
  4182. The assembler implicitly switches back to the \tty{CODE} segment when a
  4183. \tty{CPU} instruction is executed.  This is done because \tty{CODE} is the
  4184. only segment all processors support.
  4185.  
  4186. Note that 68008 is no longer the default target.  If no {\tt -cpu}
  4187. command line argument has been given, the target is set to the reserved
  4188. value \tty{NONE} up to the first \tty{CPU} statement.  Target-independent
  4189. pseudo instructions are still allowed in this situation, like defining
  4190. constants or macros.  It is however not possible to generate any code,
  4191. neither by machine instructions nor by disposing data in memory.
  4192.  
  4193. Some targets define options or variants that are so fundamental for
  4194. operation, that they have to be selected with the \tty{CPU} instruction.
  4195. Such options are appended to the argument, separated by double
  4196. colons:
  4197. \begin{verbatim}
  4198.  CPU <CPU Name>:<var1>=<val1>:<var2>=<val2>:...
  4199. \end{verbatim}
  4200. See the respective section with processor-specific hints to check whether a
  4201. certain target supports such options.
  4202.  
  4203. %%- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  4204.  
  4205. \subsection{SUPMODE, FPU, PMMU, CUSTOM}
  4206. \ttindex{SUPMODE}\ttindex{FPU}\ttindex{PMMU}\ttindex{CUSTOM}
  4207. \label{SectSUPMODE}
  4208.  
  4209. {\em
  4210. \begin{itemize}
  4211. \item{SUPMODE valid for: 680x0, NS32xxx, PDP-11, i960, TLCS-900,
  4212.      SH7000, i960, 29K, XA, PowerPC, M*Core, V60, and TMS9900}
  4213. \item{FPU valid for: 680x0, NS32xxx, 80x86}
  4214. \item{PMMU valid for: 680x0, NS32xxx}
  4215. \item{CUSTOM valid for: NS32xxx}
  4216. \end{itemize}
  4217. }
  4218.  
  4219. These three switches allow to define which parts of the instruction set
  4220. shall be disabled because the necessary preconditions are not valid for
  4221. the following piece of code.  The parameter for these instructions may be
  4222. either \tty{ON} or \tty{OFF}, the current status can be read out of a
  4223. variable which is either TRUE or FALSE.
  4224.  
  4225. The commands have the following meanings in detail:
  4226. \begin{itemize}
  4227. \item{\tty{SUPMODE}: allows or prohibits commands, for whose execution the
  4228.      processor has to be within the supervisor mode.  The status
  4229.      variable is called \tty{INSUPMODE}.}
  4230. \item{\tty{FPU}: allows or prohibits the commands of the numerical
  4231.      coprocessors 8087, NS32081/32381 resp. 68881 or 68882.  The status
  4232.      variable is called \tty{FPUAVAIL}.  For NS32xxx as target, specifying
  4233.      the explicit FPU type (\tty{NS32081}, \tty{NS32181}, \tty{NS32381},
  4234.      or \tty{NS32580}) is also possible, to enable or disable the additional
  4235.      registers and instructions.}
  4236. \item{\tty{PMMU}: allows or prohibits the commands of the memory
  4237.      management unit 68851 resp. of  the built-in MMU of the 68030.
  4238.      \bb{CAUTION!} The 68030-MMU supports only a relatively small subset
  4239.      of the 68851 instructions.  This is controlled via the \tty{FULLPMMU}
  4240.      statement. The status variable is called \tty{PMMUAVAIL}. For NS32xxx
  4241.      as target, specifying the explicit MMU type as target (\tty{NS32082},
  4242.      \tty{NS32381}, or \tty{NS32352}) is also possible, to enable access to
  4243.      the MMU-type-specific register set.}
  4244. \item{\tty{CUSTOM}: allows or prohibits the commands reserved for custom
  4245.      slave processors.}
  4246. \end{itemize}
  4247. The usage of of instructions prohibited in this manner will generate a
  4248. warning at \tty{SUPMODE}, at \tty{PMMU} and \tty{FPU} a real error
  4249. message.
  4250.  
  4251. %%- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  4252.  
  4253. \subsection{CIS, EIS, FIS and FP11}
  4254. \ttindex{CIS}\ttindex{EIS}\ttindex{FIS}\ttindex{FP11}
  4255.  
  4256. {\em
  4257. \begin{itemize}
  4258. \item{valid for: PDP-11}
  4259. \end{itemize}
  4260. }
  4261.  
  4262. These stetements enable or disable the availibility of certain PDP-11
  4263. instruction set extensions.  For one of these statements to be available,
  4264. the respective instructions must not be part of the machine's basic
  4265. instruction set, and there must have been an upgrade option to add them.
  4266. In detail:
  4267.  
  4268. \begin{itemize}
  4269. \item{{\tt CIS}: ,,Commercial Instruction Set'', i.e. instructions to
  4270.      operate on packed and non-packed BCD numbers with variable length.
  4271.      They were available as an option on the LSI-11 and the PDP-11/44.}
  4272. \item{{\tt EIS}: The instructions {\tt MUL, DIV, ASH} und {\tt ASHC},
  4273.      which were not part of the base instruction set on older or
  4274.      smaller PDP-11 systems.  They were available as an option on the
  4275.      LSI-11 resp. the PDP-11/35 and PDP-11/40.}
  4276. \item{{\tt FIS}: Stack oriented instructions implementing the basic
  4277.      mathematic operations on floating point numbers in F format (32 bits).
  4278.      They were available as an option on the LSI-11 resp. the PDP-11/35
  4279.      and PDP-11/40.}
  4280. \item{{\tt FP11}: Full floating point support with separate FPU registers
  4281.      in F and D format (32/64 bits).}
  4282. \end{itemize}
  4283.  
  4284. %%- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  4285.  
  4286. \subsection{FULLPMMU}
  4287. \ttindex{FULLPMMU}
  4288.  
  4289. {\em valid for: 680x0}
  4290.  
  4291. Motorola integrated the MMU into the processor starting with the 68030, but
  4292. the built-in FPU is equipped only with a relatively small subset of the
  4293. 68851 instruction set.  \asname{} will therefore disable all extended MMU
  4294. instructions when the target processor is 68030 or higher.  It is however
  4295. possible that the internal MMU has been disabled in a 68030-based system
  4296. and the processor operates with an external 68851.  One can the use a
  4297. \tty{FULLPMMU ON} to tell \asname{} that the complete MMU instruction set is
  4298. allowed.  Vice versa, one may use a \tty{FULLPMMU OFF} to disable all
  4299. additional instruction in spite of a 68020 target platform to assure that
  4300. portable code is written.  The switch between full and reduced instruction
  4301. set may be done as often as needed, and the current setting may be read
  4302. from a symbol with the same name.  \bb{CAUTION!} The \tty{CPU} instruction
  4303. implicitly sets or resets this switch when its argument is a 68xxx
  4304. processor!  \tty{FULLPMMU} therefore has to be written after the \tty{CPU}
  4305. instruction!
  4306.  
  4307. %%- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  4308.  
  4309. \subsection{PADDING}
  4310. \ttindex{PADDING}
  4311.  
  4312. {\em valid for: 680x0, 68xx, M*Core, XA, H8, SH7000, MSP430(X), TMS9900,\\
  4313.      ST7/STM8, AVR (only if code segment granularity is 8 bits)}
  4314.  
  4315. Various processor families have a requirement that objects of more than
  4316. one byte length must be located on a n even address.  Aside from data
  4317. objects, this may also include instruction words.  For instance, word
  4318. accesses to an odd address result in an exception on a 68000, while other
  4319. processors like the H8 force the lowest address bit to zero.
  4320.  
  4321. The \tty{PADDING} instruction allows to activate a mechanism that tries to
  4322. avoid such misalignments.  If the situation arises that an instruction
  4323. word, or a data object of 16 bits or more (created e.g. via \tty{DC}) would
  4324. be stored on an odd address, a padding byte is automatically inserted before.
  4325. Such a padding byte is displayed in the listing in a separate line that
  4326. contains the remark
  4327. \begin{verbatim}
  4328. <padding>
  4329. \end{verbatim}
  4330. If the source line also contained a label, the label still points to the
  4331. address of the code or data object, i.e. right behind the pad byte.  The same
  4332. is true for a label in a source line immediately before, as long as this
  4333. line {\em} only holds the label and no other instruction.  So, in the
  4334. follwing example:
  4335. \begin{verbatim}
  4336.       padding  on
  4337.       org      $1000
  4338.  
  4339.       dc.b     1
  4340. adr1:  nop
  4341.  
  4342.       dc.b     1
  4343. adr2:
  4344.       nop
  4345.  
  4346.       dc.b     1
  4347. adr3:  equ      *
  4348.       nop
  4349. \end{verbatim}
  4350. the labels \tty{adr1} and \tty{adr2} hold the addresses of the respective
  4351. \tty{NOP} instructions, which were made even by inserting a pad byte.
  4352. \tty{adr3} in contrast holds the address of the pad byte preceding the
  4353. third \tty{NOP}.
  4354.  
  4355. Similar to the previous instructions, the argument to \tty{PADDING} may be
  4356. either \tty{ON} or \tty{OFF}, and the current setting may be read from a
  4357. symbol with the same name.  \tty{PADDING} is by default only enabled for
  4358. the 680x0 family, it has to be turned on explicitly for all other families.
  4359.  
  4360. %%- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  4361.  
  4362. \subsection{PACKING}
  4363. \ttindex{PACKING}\label{SectPACKING}
  4364.  
  4365. {\em valid for: 56000, AVR, TMS3203x/4x, TMS3206x, MN1610, CP1600,
  4366.     $\mu$PD7720/7725, $\mu$PD77230}
  4367.  
  4368. In some way, {\tt PACKING} is similar to {\tt PADDING}, it just has a
  4369. somewhat opposite effect: While {\tt PADDING} extends the disposed data to
  4370. get full words and keep a possible alignment, {\tt PACKING} squeezes
  4371. several values into a single word.  This makes sense for the AVR's code
  4372. segment since the CPU has a special instruction ({\tt LPM}) to access
  4373. single bytes within a 16-bit word.  In case this option is turned on
  4374. (argument {\tt ON}), two byte values are packed into a single word by {\tt
  4375. DATA}, similar to the single characters of string arguments.  The value
  4376. range of course reduces to -128...+255.  If this option is turned off
  4377. (argument {\tt OFF}), each integer argument obtains its own word and may
  4378. take values from -32768...+65535.
  4379.  
  4380. This distinctin is only made for integer arguments of {\tt DATA}, strings
  4381. will always be packed..  Keep further in mind that packing of values only
  4382. works within the arguments of a {\tt DATA} statement; if one has
  4383. subsequent {\tt DATA} statements, there will still be half-filled words
  4384. when the argument count is odd!
  4385.  
  4386. %%- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  4387.  
  4388. \subsection{MAXMODE}
  4389. \ttindex{MAXMODE}
  4390.  
  4391. {\em valid for: TLCS-900, H8}
  4392.  
  4393. The processors of the TLCS-900-family are able to work in 2 modes, the
  4394. minimum and maximum mode.  Depending on the actual mode, the execution
  4395. environment and the assembler are a little bit different. Along with this
  4396. instruction and the parameter \tty{ON} or \tty{OFF}, \asname{} is informed that the
  4397. following code will run in maximum resp. minimum mode.  The actual setting
  4398. can be read from the variable \tty{INMAXMODE}.  Presetting is \tty{OFF},
  4399. i.e. minimum mode.
  4400.  
  4401. Similarly, one uses this instruction to tell \asname{} in H8 mode whether the
  4402. address space is 64K or 16 Mbytes.  This setting is always \tty{OFF} for
  4403. the 'small' 300 version and cannot be changed.
  4404.  
  4405. %%- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  4406.  
  4407. \subsection{EXTMODE and LWORDMODE}
  4408. \ttindex{EXTMODE}\ttindex{LWORDMODE}
  4409.  
  4410. {\em valid for: Z380}
  4411.  
  4412. The Z380 may operate in altogether 4 modes, which are the result of
  4413. setting two flags: The XM flag rules whether the processor shall operate
  4414. wit an address space of 64 Kbytes or 4 Gbytes and it may only be set to 1
  4415. (after a reset, it is set to 0 for compatibility with the Z80).  The LW
  4416. flag in turn rules whether word operations shall work with a word size of
  4417. 16 or 32 bits.  The setting of these two flags influences range checks of
  4418. constants and addresses, which is why one has to tell \asname{} the setting of
  4419. these two flags via these instructions.  The default assumption is that
  4420. both flags are 0, the current setting (\tty{ON} or \tty{OFF}) may be read
  4421. from the predefined symbols \tty{INEXTMODE} resp. \tty{INLWORDMODE.}
  4422.  
  4423. %%- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  4424.  
  4425. \subsection{SRCMODE}
  4426. \ttindex{SRCMDE}
  4427.  
  4428. {\em valid for: MCS-251}
  4429.  
  4430. Intel substantially extended the 8051 instruction set with the 80C251, but
  4431. unfortunately there was only a single free opcode for all these new
  4432. instructions.  To avoid a processor that will be eternally crippled by a
  4433. prefix, Intel provided two operating modes: the binary and the source
  4434. mode.  The new processor is fully binary compatible to the 8051 in binary
  4435. mode, all new instructions require the free opcode as prefix.  In source
  4436. mode, the new instructions exchange their places in the code tables with
  4437. the corresponding 8051 instructions, which in turn then need a prefix.
  4438. One has to inform \asname{} whether the processor operates in source mode
  4439. (\tty{ON}) or binary mode (\tty{OFF}) to enable \asname{} to add prefixes when
  4440. required.  The current setting may be read from the variable
  4441. \tty{INSRCMODE}.  The default is \tty{OFF}.
  4442.  
  4443. %%- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  4444. \subsection{PLAINBASE}
  4445. \ttindex{PLAINBASE}\label{SectPLAINBASE}
  4446.  
  4447. {\em valid for: 6809}
  4448.  
  4449. Historically, \asname{} allows to omit an empty first argument on indexed
  4450. address expressions.  An
  4451. \begin{verbatim}
  4452.  lda  x
  4453. \end{verbatim}
  4454. for instance was equivalent to
  4455. \begin{verbatim}
  4456.  lda  ,x
  4457. \end{verbatim}
  4458. Though meant as a feature, this wa occasionally rather seen as a bug.  Current
  4459. versios therefore no longer allow to omit an empty index argument and will
  4460. instead emit a wrong argument count error message.  If this feature is still
  4461. desired or needed for existing code, it may be enabled via a
  4462. \begin{verbatim}
  4463.  plainbase on
  4464. \end{verbatim}
  4465. statement.  The current setting may be read from a symbol of same name.
  4466.  
  4467. %%- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  4468.  
  4469. \subsection{BIGENDIAN}
  4470. \ttindex{ENDIAN}\ttindex{BIGENDIAN}\label{SectBIGENDIAN}
  4471.  
  4472. {\em valid for: MCS-51/251, PowerPC, SC/MP, 2650, NS32000}
  4473.  
  4474. Intel broke with its own principles when the 8051 series was designed: in
  4475. contrast to all traditions, the processor uses big-endian ordering for all
  4476. multi-byte values!  While this was not a big deal for MCS-51 processors
  4477. (the processor could access memory only in 8-bit portions, so everyone was
  4478. free to use whichever endianess one wanted), it may be a problem for the
  4479. 251 as it can fetch whole (long-)words from memory and expects the MSB to
  4480. be first.  As this is not the way of constant disposal earlier versions of
  4481. \asname{} used, one can use this instruction to toggle between big and
  4482. little endian mode for the instructions \tty{DB, DW, DD, DQ,} and
  4483. \tty{DT}.  \tty{BIGENDIAN OFF} (the default) puts the LSB first into
  4484. memory as it used to be on earlier versions of \asname{}, \tty{BIGENDIAN ON}
  4485. engages the big-endian mode compatible to the MCS-251.  One may of course
  4486. change this setting as often as one wants; the current setting can be read
  4487. from the symbol with the same name.
  4488.  
  4489. The Renesas RX as target also supports a selectable endianess.  For
  4490. compatibility to the original assembler, the statement is named \tty{ENDIAN}
  4491. and accepts \tty{LITTLE} or \tty{BIG} as argument.
  4492.  
  4493. %%- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  4494.  
  4495. \subsection{WRAPMODE}
  4496. \ttindex{WRAPMODE}
  4497.  
  4498. {\em valid for: Atmel AVR}
  4499.  
  4500. After this switch has been set to {\tt ON}, \asname{} will assume that the
  4501. processor's program counter does not have the full length of 16 bits given
  4502. by the architecture, but instead a length that is exactly sufficient to
  4503. address the internal ROM.  For example, in case of the AT90S8515, this
  4504. means 12 bits, corresponding to 4 Kwords or 8 Kbytes.  This assumption
  4505. allows relative branches from the ROM's beginning to the end and vice
  4506. versa which would result in an out-of-branch error when using strict
  4507. arithmetics.  Here, they work because the carry bits resulting from the
  4508. target address computation are discarded.  Assure that the target
  4509. processor you are using works in the outlined way before you enable this
  4510. option!  In case of the abovementioned AT90S8515, this option is even
  4511. necessary because it is the only way to perform a direct jump through
  4512. the complete address space...
  4513.  
  4514. This switch is set to {\tt OFF} by default, and its current setting may be
  4515. read from a symbol with same name.
  4516.  
  4517. %%- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  4518.  
  4519. \subsection{PANEL}
  4520. \ttindex{PANEL}
  4521.  
  4522. {\em valid for: IM61x0}
  4523.  
  4524. This switch is used to inform the assembler whether the following code is
  4525. executet with a set or cleared {\em Control Panel Flip-Flop}.  A couple
  4526. of {\tt IOT} instructions are only allowed if the flip-flop has a certain
  4527. state.  Usage of these instructions in the other state will be reported
  4528. as an error by the assembler.
  4529.  
  4530. The current setting may be read from the symbol {\tt INPANEL}.
  4531.  
  4532. %%- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  4533.  
  4534. \subsection{SEGMENT}
  4535. \ttindex{SEGMENT}
  4536. \label{SEGMENT}
  4537.  
  4538. {\em valid for: all processors}
  4539.  
  4540. Some microcontrollers and signal processors know various address ranges,
  4541. which do not overlap with each other and require also different
  4542. instructions and addressing modes for access.  To manage these ones also,
  4543. the assembler provides various program counters, you can switch among
  4544. them to and from by the use of the \tty{SEGMENT} instruction.  For subroutines
  4545. included with \tty{INCLUDE}, this e.g. allows to define data used by the
  4546. main program or subroutines near to the place they are used.  In detail,
  4547. the following segments with the following names are supported:
  4548. \begin{itemize}
  4549. \item{\tty{CODE}: program code;}
  4550. \item{\tty{DATA}: directly addressable data (including SFRs);}
  4551. \item{\tty{XDATA}: data in externally connected RAM or
  4552.      X-addressing space of the DSP56xxx or ROM data for the $\mu$PD772x;}
  4553. \item{\tty{YDATA}: Y-addressing space of the DSP56xxx;}
  4554. \item{\tty{IDATA}: indirectly addressable (internal) data; }
  4555. \item{\tty{BITDATA}: the part of the 8051-internal RAM that is bitwise
  4556.      addressable;}
  4557. \item{\tty{IO}: I/O-address range;}
  4558. \item{\tty{REG}: register bank of the ST9;}
  4559. \item{\tty{ROMDATA}: constant ROM of the NEC signal processors;}
  4560. \item{\tty{EEDATA}: built-in EEPROM.}
  4561. \end{itemize}
  4562. See also section \ref{SectORG} (\tty{ORG}) for detailed information about
  4563. address ranges and initial values of the segments. Depending on the
  4564. processor family, not all segment types will be permitted.
  4565.  
  4566. The bit segment is managed as if it would be a byte segment, i.e. the
  4567. addresses will be incremented by 1 per bit.
  4568.  
  4569. Labels get the same type as attribute as the segment that was active
  4570. when the label was defined.  So the assembler has a limited ability
  4571. to check whether you access symbols of a certain segment with wrong
  4572. instructions.  In such cases the assembler issues a warning.
  4573.  
  4574. Example:
  4575. \begin{verbatim}
  4576.        CPU     8051    ; MCS-51-code
  4577.  
  4578.        segment code    ; test code
  4579.  
  4580.        setb    flag    ; no warning
  4581.        setb    var     ; warning : wrong segment
  4582.  
  4583.        segment data
  4584.  
  4585. var     db      ?
  4586.  
  4587.        segment bitdata
  4588.  
  4589. flag    db      ?
  4590. \end{verbatim}
  4591.  
  4592. %%- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  4593.  
  4594. \subsection{PHASE and DEPHASE}
  4595. \ttindex{PHASE}\ttindex{DEPHASE}
  4596.  
  4597. {\em valid for: all processors}
  4598.  
  4599. For some applications (especially on Z80 systems), the code must be moved
  4600. to another address range before execution.  If the assembler didn't know
  4601. about this, it would align all labels to the load address (not the start
  4602. address).  The programmer is then forced to write jumps within this area
  4603. either independent of location or has to add the offset at each symbol
  4604. manually.  The first one is not possible for some processors, the last one
  4605. is extremely error-prone.  With the commands \tty{PHASE} and
  4606. \tty{DEPHASE}, it is possible to inform the assembler at which address the
  4607. code will really be executed on the target system:
  4608. \begin{verbatim}
  4609.        phase   <address>
  4610. \end{verbatim}
  4611. informs the assembler that the following code shall be executed at the
  4612. specified address.  The assembler calculates thereupon the difference to
  4613. the real program counter and adds this difference for the following
  4614. operations:
  4615. \begin{itemize}
  4616. \item{address values in the listing}
  4617. \item{filing of label values}
  4618. \item{program counter references in relative jumps and address expressions}
  4619. \item{readout of the program counter via the symbols * or \$}
  4620. \end{itemize}
  4621. By using the instruction
  4622. \begin{verbatim}
  4623.        DEPHASE
  4624. \end{verbatim}
  4625. , this ''shifting'' is reverted to the value previous to the most
  4626. recent \tty{PHASE} instruction.  \tty{PHASE} und \tty{DEPHASE} may be used
  4627. in a nested manner.
  4628. \par
  4629. The assembler keeps phase values for all defined segments, although
  4630. this instruction pair only makes real sense in the code segment.
  4631.  
  4632. %%- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  4633.  
  4634. \subsection{SAVE and RESTORE}
  4635. \ttindex{SAVE}\ttindex{RESTORE}
  4636. \ttindex{.SAVE}\ttindex{.RESTORE}
  4637. \ttindex{SAVEENV}\ttindex{RESTOREENV}
  4638.  
  4639. {\em valid for: all processors}
  4640.  
  4641. The command \tty{SAVE} forces the assembler to push the contents of
  4642. following variables onto an internal stack:
  4643. \begin{itemize}
  4644. \item{currently selected processor type (set by \tty{CPU});}
  4645. \item{currently active memory area (set by \tty{SEGMENT});}
  4646. \item{the flag whether listing is switched on or off (set by \tty{LISTING});}
  4647. \item{the flags that define which part of expanded macros shall be
  4648.      printed in the assembly listing (set by
  4649.      \tty{/MACEXP\_DFT/MACEXP\_OVR}).}
  4650. \item{currently active character translation table (set by
  4651.      \tty{CODEPAGE}).}
  4652. \end{itemize}
  4653. The counterpart \tty{RESTORE} pops the values saved last from this stack.
  4654. These two commands were primarily designed for include files, to change
  4655. the above mentioned variables in any way inside of these files, without
  4656. loosing their original content.  This may be helpful e.g. in include files
  4657. with own, fully debugged subroutines, to switch the listing generation
  4658. off:
  4659. \begin{verbatim}
  4660.        SAVE            ; save old status
  4661.  
  4662.        LISTING OFF     ; save paper
  4663.  
  4664.        .               ; the actual code
  4665.        .
  4666.  
  4667.        RESTORE         ; restore
  4668. \end{verbatim}
  4669. In opposite to a simple \tty{LISTING OFF .. ON}-pair, the correct status
  4670. will be restored, in case the listing generation was switched off already
  4671. before.
  4672.  
  4673. The assembler checks if the number of \tty{SAVE}-and
  4674. \tty{RESTORE}-commands corresponds and issues error messages in the
  4675. following cases:
  4676. \begin{itemize}
  4677. \item{\tty{RESTORE}, but the internal stack is empty;}
  4678. \item{the stack not empty at the end of a pass.}
  4679. \end{itemize}
  4680. In case the currently used target has machine instructions named \tty{SAVE} or
  4681. \tty{RESTORE}, this functionality may be reached via \tty{SAVEENV} resp.
  4682. \tty{RESTOREENV}.  As an alternative, it is always possible to explicitly invoke
  4683. the pseudo instructions by prepending a period (\tty{.SAVE} resp. \tty{.RESTORE}).
  4684.  
  4685. %%- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  4686.  
  4687. \subsection{ASSUME}
  4688. \ttindex{ASSUME}
  4689.  
  4690. {\em valid for: various}
  4691.  
  4692. This instruction allows to tell \asname{} the current setting of certain
  4693. registers whose contents cannot be described with a simple \tty{ON} or
  4694. \tty{OFF}.  These are typically registers that influence addressing modes
  4695. and whose contents are important to know for \asname{} in order to generate
  4696. correct addressing.  It is important to note that \tty{ASSUME} only
  4697. informs \asname{} about these, \bb{no} machine code is generated that actually
  4698. loads these values into the appropriate registers!
  4699.  
  4700. A value defined with \tty{ASSUME} can be queried or integrated
  4701. into expressions via the built-in function \tty{ASSUMEDVAL}.
  4702. This is the case for all architectures listed in the following
  4703. sub-sections except for the 8086.
  4704.  
  4705. %%. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
  4706.  
  4707. \subsubsection{65CE02}
  4708.  
  4709. The 65CE02 features a a register named 'B' that is used to set the 'base page'.
  4710. In comparison to the original 6502, this allows the programmer to place the
  4711. memory page addressable with short (8 bit) addresses anywhere in the 64K address
  4712. space.  This register is set to zero after a reset, so the 65CE02 behaves like
  4713. its predecessor.  A base page at zero is also the default assumption of the
  4714. assembler.  It may be informed about its actual contents via a \tty{ASSUME B:xx}
  4715. statement.  Addresses located in this page will then automatically be addressed
  4716. via short addressing modes.
  4717.  
  4718. %%. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
  4719.  
  4720. \subsubsection{6809}
  4721.  
  4722. In contrast to its 'predecessors' like the 6800 and 6502, the position of
  4723. the direct page, i.e. the page of memory that can be reached with
  4724. single-byte addresses, can be set freely.  This is done via the 'direct
  4725. page register' that sets the page number.  One has to assign a
  4726. corresponding value to this register via \tty{ASSUME} is the contents are
  4727. different from the default of 0, otherwise wrong addresses will be
  4728. generated!
  4729.  
  4730. %%. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
  4731.  
  4732. \subsubsection{68HC11K4}
  4733.  
  4734. Also for the HC11, the designers finally weren't able to avoid banking, to
  4735. address more than 64 Kbytes with only 16
  4736. address lines.  The registers {\tt MMSIZ}, {\tt MMWBR}, {\tt MM1CR}, and
  4737. {\tt MM2CR} control whether and how the additional 512K address ranges are
  4738. mapped into the CPU's address space.  \asname{} initially assumes the reset
  4739. state of these registers, i.e. all are set to \$00 and windowing is
  4740. disabled.
  4741.  
  4742. Furthermore, the settings of the registers {\tt CONFIG}, {\tt INIT}, and
  4743. {\tt INIT2} may be specified.  This enables the assembler to deduce the mapping
  4744. of I/O registers, internal RAM and EEPROM into CPU address space, which
  4745. has priority over mapping of memory via windowing.
  4746.  
  4747. %%. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
  4748.  
  4749. \subsubsection{68HC12X}
  4750.  
  4751. Similar to its cousin without the appended 'X', the HC12X supports a short
  4752. direct addressing mode.  In this case however, it can be used to address
  4753. more than just the first 256 bytes of the address space.  The {\tt DIRECT}
  4754. register specifices which 256 byte page of the address space is addressed
  4755. by this addressing mode.  {\tt ASSUME} is used to tell \asname{} the current
  4756. value of this register, so it is able to automatically select the most
  4757. efficient address ing mode when absolute addresses are used.  The default
  4758. is 0, which corresponds to the reset state.
  4759.  
  4760. %%. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
  4761.  
  4762. \subsubsection{68HC16}
  4763.  
  4764. The 68HC16 employs a set of bank registers to address a space of 1
  4765. Mbyte with its registers that are only 16 bits wide.  These registers
  4766. supply the upper 4 bits.  Of these, the EK register is responsible
  4767. for absolute data accesses (not jumps!).  \asname{} checks for each absolute
  4768. address whether the upper 4 bits of the address are equal to the
  4769. value of EK specified via \tty{ASSUME}.  \asname{} issues a warning if they
  4770. differ.  The default for EK is 0.
  4771.  
  4772. %%. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
  4773.  
  4774. \subsubsection{H8/500}
  4775.  
  4776. In maximum mode, the extended address space of these processors is
  4777. addressed via a couple of bank registers.  They carry the names DP
  4778. (registers from 0..3, absolute addresses), EP (register 4 and 5), and TP
  4779. (stack).  \asname{} needs the current value of DP to check if absolute addresses
  4780. are within the currently addressable bank; the other two registers are
  4781. only used for indirect addressing and can therefore not be monitored; it
  4782. is a question of personal taste whether one specifies their values or not.
  4783. The BR register is in contrast important because it rules which 256-byte
  4784. page may be accessed with short addresses.  It is common for all registers
  4785. that \asname{} does not assume \bb{any} default value for them as they are
  4786. undefined after a CPU reset.  Everyone who wants to use absolute addresses
  4787. must therefore assign values to at least DR and DP!
  4788.  
  4789. %%. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
  4790.  
  4791. \subsubsection{MELPS740}
  4792.  
  4793. Microcontrollers of this series know a ''special page'' addressing mode
  4794. for the \tty{JSR} instruction that allows a shorter coding for jumps into
  4795. the last page of on-chip ROM.  The size of this ROM depends of course
  4796. on the exact processor type, and there are more derivatives than it
  4797. would be meaningful to offer via the CPU instruction...we therefore
  4798. have to rely on \tty{ASSUME} to define the address of this page, e.g.
  4799. \begin{verbatim}
  4800.        ASSUME  SP:$1f
  4801. \end{verbatim}
  4802. in case the internal ROM is 8K.
  4803.  
  4804. %%. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
  4805.  
  4806. \subsubsection{MELPS7700/65816}
  4807.  
  4808. These processors contain a lot of registers whose contents \asname{} has to know
  4809. in order to generate correct machine code.  These are the registers
  4810. in question:
  4811. \begin{center}\begin{tabular}{|l|l|l|l|}
  4812. \hline
  4813. name   & function             & value range   & default \\
  4814. \hline
  4815. \hline
  4816. DT/DBR & data bank            & 0-\$ff        &  0 \\
  4817. PG/PBR & code Bank            & 0-\$ff        &  0 \\
  4818. DPR    & directly addr. page  & 0-\$ffff      &  0 \\
  4819. X      & index register width & 0 or 1        &  0 \\
  4820. M      & accumulator width    & 0 or 1        &  0 \\
  4821. \hline
  4822. \end{tabular}\end{center}
  4823. \par
  4824. To avoid endless repetitions, see section \ref{MELPS7700Spec} for
  4825. instructions how to use these registers.  The handling is otherwise
  4826. similar to the 8086, i.e. multiple values may be set with one instruction
  4827. and no code is generated that actually loads the registers with the given
  4828. values.  This is again up to the programmer!
  4829.  
  4830. %%. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
  4831.  
  4832. \subsubsection{MCS-196/296}
  4833.  
  4834. Starting with the 80196, all processors of the MCS-96 family have a
  4835. register 'WSR' that allows to map memory areas from the extended
  4836. internal RAM or the SFR range into areas of the register file which
  4837. may then be accessed with short addresses.  If one informs \asname{} about
  4838. the value of the WSR register, it can automatically find out whether
  4839. an absolute address can be addressed with a single-byte address via
  4840. windowing; consequently, long addresses will be automatically generated
  4841. for registers covered by windowing.  The 80296 contains an additional
  4842. register WSR1 to allow simultaneous mapping of two memory areas into
  4843. the register file.  In case it is possible to address a memory cell
  4844. via both areas, \asname{} will always choose the way via WSR!
  4845.  
  4846. For indirect addressing, displacements may be either short (8 bits,
  4847. -128 to +127) or long (16 bits).  The assembler will automatically
  4848. use the shortest possible encoding for a given displacement.  It
  4849. is however possible to enforce a 16-bit coding by prefixing the
  4850. displacement argument with a bigger sign ((\verb!>!).  Similarly,
  4851. absolute addresses in the area from 0ff80h to 0ffffh may be reached
  4852. via a short offset relative to the "null register".
  4853.  
  4854. %%. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
  4855.  
  4856. \subsubsection{8086}
  4857.  
  4858. The 8086 is able to address data from all segments in all
  4859. instructions, but it however needs so-called ''segment prefixes'' if
  4860. another segment register than DS shall be used.  In addition it is
  4861. possible that the DS register is adjusted to another segment, e.g. to
  4862. address data in the code segment for longer parts of the program.  As
  4863. \asname{} cannot analyze the code's meaning, it has to informed via this
  4864. instruction to what segments the segment registers point at the
  4865. moment, e.g.:
  4866. \begin{verbatim}
  4867.        ASSUME  CS:CODE, DS:DATA    .
  4868. \end{verbatim}
  4869. It is possible to assign assumptions to all four segment registers in
  4870. this way.  This instruction produces \bb{no} code, so the program itself
  4871. has to do the actual load of the registers with the values.
  4872.  
  4873. The usage of this instruction has on the one hand the result that \asname{} is
  4874. able to automatically put ahead prefixes at sporadic accesses into the
  4875. code segment, or on the other hand, one can inform \asname{} that the DS-register
  4876. was modified and you can save explicit \tty{CS:}-instructions.
  4877.  
  4878. Valid arguments behind the colon are \tty{CODE}, \tty{DATA} and
  4879. \tty{NOTHING}.  The latter value informs \asname{} that a segment register
  4880. contains no usable value (for \asname{}).  The following values are
  4881. preinitialized:
  4882. \begin{verbatim}
  4883.  CS:CODE, DS:DATA, ES:NOTHING, SS:NOTHING
  4884. \end{verbatim}
  4885.  
  4886. %%. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
  4887.  
  4888. \subsubsection{Z180}
  4889.  
  4890. The Z180 contains a built-in MMU whicht maps the CPU core's ''logical''
  4891. address space of 64 KBytes to a physical address space of 512 KBytes.  The
  4892. precise mappig is defined via the the registers {\tt CBAR}, {\tt CBR} and
  4893. {\tt BBR}.  Opposed to the 68HC11K4, the assembler will not perform any
  4894. automatic translations of physical to logical addresses; only an internal
  4895. mapping table is kept.  It is however possible to access this table via
  4896. the {\tt phys2cpu()} function.
  4897.  
  4898. %%. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
  4899.  
  4900. \subsubsection{XA}
  4901.  
  4902. The XA family has a data address space of 16 Mbytes, a process however
  4903. can always address within a 64K segment only that is given by the DS
  4904. register.  One has to inform \asname{} about the current value of this
  4905. register in order to enable it to check accesses to absolute
  4906. addresses.
  4907.  
  4908. %%. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
  4909.  
  4910. \subsubsection{29K}
  4911.  
  4912. The processors of the 29K family feature a register RBP that allows
  4913. to protect banks of 16 registers against access from user mode.  The
  4914. corresponding bit has to be set to achieve the protection.  \tty{ASSUME}
  4915. allows to tell \asname{} which value RBP currently contains.  \asname{} can warn
  4916. this way in case a try to access protected registers from user mode
  4917. is made.
  4918.  
  4919. %%. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
  4920.  
  4921. \subsubsection{80C166/167}
  4922.  
  4923. Though none of the 80C166/167's registers is longer than sixteen bits,
  4924. this processor has 18/24 address lines and can therefore address up
  4925. to 256Kbytes/16Mbytes.  To resolve this contradiction, it neither
  4926. uses the well-known (and ill-famed) Intel method of segmentation nor
  4927. does it have inflexible bank registers...no, it uses paging!  To accomplish
  4928. this, the logical address space of 64 Kbytes is split into 4 pages of
  4929. 16 Kbytes, and for each page there is a page register (named
  4930. DPP0..DPP3) that rules which of the 16/1024 physical pages shall be
  4931. mapped to this logical page.  \asname{} always tries to present the address
  4932. space with a size of 256Kbytes/16MBytes in the sight of the
  4933. programmer, i.e. the physical page is taken for absolute accesses and
  4934. the setting of bits 14/15 of the logical address is deduced.  If no
  4935. page register fits, a warning is issued.  \asname{} assumes by default that
  4936. the four registers linearly map the first 64 Kbytes of memory, in the
  4937. following style:
  4938. \begin{verbatim}
  4939.        ASSUME  DPP0:0,DPP1:1,DPP2:2,DPP3:3
  4940. \end{verbatim}
  4941. The 80C167 knows some additional instructions that can override the
  4942. page registers' function.  The chapter with processor-specific hints
  4943. describes how these instructions influence the address generation.
  4944. \par
  4945. Some machine instructions have a shortened form that can be used if
  4946. the argument is within a certain range:
  4947. \begin{itemize}
  4948. \item{\verb!MOV Rn,#<0..15>!}
  4949. \item{\verb!ADD/ADDC/SUB/SUBC/CMP/XOR/AND/OR Rn, #<0..7>!}
  4950. \item{\verb!LOOP Rn,#<0..15>!}
  4951. \end{itemize}
  4952. The assembler automatically uses to the shorter coding if possible.
  4953. If one wants to enforce the longer coding, one may place a 'bigger'
  4954. character right before the expression (behind the double cross character!).
  4955. Vice versa, a 'smaller' character can be used to assure the shorter
  4956. coding is used.  In case the operand does not fulfill the range
  4957. restrictions for the shorter coding, an error is generated.  This syntax
  4958. may also be used for branches and calls which may either have a short
  4959. displacement or a long absolute argument.
  4960.  
  4961. %%. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
  4962.  
  4963. \subsubsection{TLCS-47}
  4964.  
  4965. The direct data address space of these processors (it makes no
  4966. difference whether you address directly or via the HL register) has a
  4967. size of only 256 nibbles.  Because the ''better'' family members have
  4968. up to 1024 nibbles of RAM on chip, Toshiba was forced to introduce a
  4969. banking mechanism via the DMB register.  \asname{} manages the data segment
  4970. as a continuous addressing space and checks at any direct addressing
  4971. if the address is in the currently active bank.  The bank \asname{}
  4972. currently expects can be set by means of
  4973. \begin{verbatim}
  4974.        ASSUME  DMB:<0..3>
  4975. \end{verbatim}
  4976. The default value is 0.
  4977.  
  4978. %%. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
  4979.  
  4980. \subsubsection{IPC-16/INS8900}
  4981. \label{PACEAssume}
  4982.  
  4983. The processor provides an input pin named {\tt BPS} to select which address
  4984. range shall be directly addressable: either the first 256 words, or both
  4985. the lowest and topmost 128 words.  The first variant is the default, an
  4986. {\tt ASSUME BPS:1} switches to the second variant.
  4987.  
  4988. %%. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
  4989.  
  4990. \subsubsection{ST6}
  4991. \label{ST6Assume}
  4992.  
  4993. The microcontrollers of the ST62 family are able to map a part (64 bytes)
  4994. of the code area into the data area, e.g. to load constants from the ROM.
  4995. This means also that at one moment only one part of the ROM can be
  4996. addressed.  A special register rules which part it is.  \asname{} cannot check
  4997. the contents of this register directly, but it can be informed by this
  4998. instruction that a new value has been assigned to the register.  \asname{} then
  4999. can test and warn if necessary, in case addresses of the code segment are
  5000. accessed, which are not located in the ''announced'' window.  If, for
  5001. example, the variable \tty{VARI} has the value 456h, so
  5002. \begin{verbatim}
  5003.        ASSUME  ROMBASE:VARI>>6
  5004. \end{verbatim}
  5005. sets the \asname{}-internal variable to 11h, and an access to \tty{VARI}
  5006. generates an access to address 56h in the data segment.
  5007.  
  5008. It is possible to assign a simple \tty{NOTHING} instead of a value, e.g.
  5009. if the bank register is used temporarily as a memory cell.  This value is
  5010. also the default.
  5011.  
  5012. The program counter of these controller only has a width of 12 bits.  This
  5013. means that some sort of banking scheme had to be introduced if a device
  5014. includes more than 4 KBytes of program memory.  The banking scheme splits
  5015. both proram space and program memory in pages of 2 KBytes.  Page one of the
  5016. program space always accesses page one of program memory.  The \tty{PRPR}
  5017. register present on such devices selects which page of program memory is
  5018. accessed via addresses 000h to 7ffh of program space.  As an initial
  5019. approcimation, \asname{} regards program space to be linear and of the size of
  5020. program memory.  If a jump or call from page one is made to code in one
  5021. of the other pages, it checks whether the assumed contents of the \tty{PRPR}
  5022. register match the destination address.  If a jump or call is done from
  5023. one of the other pages to an address outside of page one, it checks whether
  5024. the destination address is within the same page.  {\bf IMPORTANT}: The
  5025. program counter itself is only 12 bits wide.  It is therefore not possible
  5026. to jump from one page to another one, without an intermediate step of
  5027. jumping back to page one.  Changing the \tty{PRPR} register while operating
  5028. outside of page one would result in ''pulling out'' the code from under
  5029. one's feet.
  5030.  
  5031. %%. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
  5032.  
  5033. \subsubsection{ST9}
  5034.  
  5035. The ST9 family uses exactly the same instructions to address code and
  5036. data area.  It depends on the setting of the flag register's DP flag
  5037. which address space is referenced.  To enable \asname{} to check if one
  5038. works with symbols from the correct address space (this of course
  5039. \bb{only} works with absolute accesses!), one has to inform \asname{} whether the
  5040. DP flag is currently 0 (code) or 1 (data).  The initial value of this
  5041. assumption is 0.
  5042.  
  5043. %%. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
  5044.  
  5045. \subsubsection{78K2}
  5046.  
  5047. 78K2 is an 8/16 bit architecture, which has later been extended to a
  5048. one-megabyte addres space via banking.  Banking is realized with the
  5049. registers PM6 (normal case) resp. P6 (alternate case with \verb!&! as
  5050. prefix) that supply the missing upper four address bits.  At least for
  5051. absolute addresses, \asname{} can check whether the current, linear 20-bit
  5052. address is within the given 64K window.
  5053.  
  5054. %%. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
  5055.  
  5056. \subsubsection{78K3}
  5057.  
  5058. Processors witrh a 78K3 core have register banks that consist of
  5059. 16 registers.  These registers may be used via their numbers
  5060. (\tty{R0} to \tty{R15}) or their symbolic names (\tty{X=R0, A=R1,
  5061. C=R2, B=R3, VPL=R8, VPH=R9, UPL=R10, UPH=R11, E=R12,
  5062. D=R13, L=R14, H=R15}).  The processor core has a register select
  5063. bit (\tty{RSS}) to switch the mapping of A/X and B/C from R0..R3
  5064. to R4..R7.  This is mainly important for instructions that
  5065. implicitly use one of these registers (i.e. instruction that do
  5066. not encode the register number in the machine code).  However, it
  5067. is also possible to inform the assembler about the changed
  5068. mapping via a
  5069.  
  5070. \begin{verbatim}
  5071.  assume rss:1
  5072. \end{verbatim}
  5073.  
  5074. The assmebler will then insert the alternate register numbers
  5075. into machine instructions that explicitly encode the register
  5076. numbers.  Vice versa, \tty{R5} will be treated like \tty{A} instead
  5077. of \tty{R1} in the source code.
  5078.  
  5079. %%. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
  5080.  
  5081. \subsubsection{78K4}
  5082.  
  5083. 78K4 was designed as an 'upgrade path' from 78K3, which is why
  5084. this processor core contains the same RSS bit to control the
  5085. mapping of registers AX and BC (though NEC discourages use of it
  5086. in new code).
  5087.  
  5088. Aside from many new instructins and addressing modes, the most
  5089. significant extension is the larger address space of 16 MBytes,
  5090. of which only the first MByte may be used for program code.  The
  5091. CPU-internal RAM and all special function registers may be
  5092. positioned either at the top of the first MByte or the top of the
  5093. first 64 KByte page.  Choice is made via the \tty{LOCATION}
  5094. machine instruction that either takes a 0 or 15 as argument.
  5095. Together with remapping RAM and SFRs, the processor also switches
  5096. the address ranges that may be reached with short (8 bit)
  5097. addresses.  Parallel to using \tty{LOCATION}, one has to inform
  5098. the assembler about this setting via a \tty{ASSUME LOCATION:..}
  5099. statement.  It will then use short addressing for the proper
  5100. ranges.  The assembler will assume a default of 0 for LOCATION.
  5101.  
  5102. %%. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
  5103.  
  5104. \subsubsection{320C3x/C4x}
  5105.  
  5106. As all instruction words of this processor family are only 32 bits
  5107. long (of which only 16 bits were reserved for absolute addresses),
  5108. the missing upper 8/16 bits have to be added from the DP register.  It
  5109. is however still possible to specify a full 24/32-bit address when
  5110. addressing, \asname{} will check then whether the upper 8 bits are equal to
  5111. the DP register's assumed values.  \tty{ASSUME} is different to the
  5112. \tty{LDP} instruction in the sense that one cannot specify an arbitrary
  5113. address out of the bank in question, one has to extract the upper bits by
  5114. hand:
  5115. \begin{verbatim}
  5116.        ldp     @addr
  5117.        assume  dp:addr>>16
  5118.        .
  5119.        .
  5120.        ldi     @addr,r2
  5121. \end{verbatim}
  5122.  
  5123. %%. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
  5124.  
  5125. \subsubsection{uPD78(C)10}
  5126.  
  5127. These processors have a register (V) that allows to move the ''zero
  5128. page'', i.e. page of memory that is addressable by just one byte,
  5129. freely in the address space, within page limits.  By reasons of
  5130. comforts you don't want to work with expressions such as
  5131. \begin{verbatim}
  5132.        inrw    Lo(counter)
  5133. \end{verbatim}
  5134. so \asname{} takes over this job, but only under the premise that it is informed
  5135. via the \tty{ASSUME}-command about the contents of the V register.  If an
  5136. instruction with short addressing is used, it will be checked if the upper
  5137. half of the address expression corresponds to the expected content.  A
  5138. warning will be issued if both do not match.
  5139.  
  5140. %%. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
  5141.  
  5142. \subsubsection{75K0}
  5143.  
  5144. As the whole address space of 12 bits could not be addressed even by
  5145. the help of register pairs (8 bits), NEC had to introduce banking
  5146. (like many others too...): the upper 4 address bits are fetched from
  5147. the MBS register (which can be assigned values from 0 to 15 by the
  5148. \tty{ASSUME} instruction), which however will only be regarded if the MBE
  5149. flag has been set to 1.  If it is 0 (default), the lowest and highest
  5150. 128 nibbles of the address space can be reached without banking.  The
  5151. \tty{ASSUME} instruction is undefined for the 75402 as it contains neither
  5152. a MBE flag nor an MBS register; the initial values cannot be changed
  5153. therefore.
  5154.  
  5155. %%. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
  5156.  
  5157. \subsubsection{F$^2$MC16L}
  5158.  
  5159. Similar to many other families of microcontrollers, this family suffers
  5160. somewhat from its designers miserliness: registers of only 16 bits width
  5161. are faced with an address space of 24 bits.  Once again, bank registers
  5162. had to fill the gap.  In detail, these are PCB for the progam code, DTB
  5163. for all data accesses, ADB for indirect accesses via RW2/RW6, and SSB/USB
  5164. for the stacks.  They may all take values from 0 to 255 and are by default
  5165. assumed to be 0, with the exception of 0ffh for PCB.
  5166.  
  5167. Furthermore, a DPR register exists that specifies which memory page within
  5168. the 64K bank given by DTB may be reached with 8 bit addresses.  The
  5169. default for DPR is 1, resulting in a default page of 0001xxh when one
  5170. takes DTB's default into account.
  5171.  
  5172. %%. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
  5173.  
  5174. \subsubsection{MN1613}
  5175.  
  5176. The MN1613 is an extension of an architecture with 16 bit addresses.  The
  5177. address extension is done by a set of "segment registers" (CSBR, SSBR, TSR0, and
  5178. TSR1), each of which is four bits wide.  The contents of a segment register,
  5179. left-shifted by 14 bits, is added to the 16 bit addresses.  This way, a process may
  5180. access a memory window of 64 KWords within the address space of 256 KWords. The
  5181. assembler uses segment register values reported via \tty{ASSUME} to warn whether
  5182. an absolute address is outside the window defined by the used segment register.
  5183. If the address is within the window, it will compute the correc t16-bit offset.
  5184. Naturally, this cannot be done when indirect addressing is used.
  5185.  
  5186. %%. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
  5187.  
  5188. \subsubsection{IM61x0}
  5189.  
  5190. These micro processors implement the instruction set of a PDP/8 and therefore
  5191. fundamentally support an address space of 4 KWords. Banking allows to extend this
  5192. address to eight ''fields' of 4 KWords. Addressing of data and jumps are principally
  5193. only possible within the same field, with one exception: The IB register allows
  5194. to perform a jump to another 4K field.  It provides the upper three bits of the
  5195. 15 bit target address, if IB has been set to a value unequal to \tty{NOTHING} via
  5196. \tty{ASSUME}.
  5197.  
  5198. %%- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  5199.  
  5200. \subsection{CKPT}
  5201. \ttindex{CKPT}
  5202.  
  5203. {\em valid for: TI990/12}
  5204.  
  5205. Type 12 instructions require a {\em checkpoint register} for execution.  This
  5206. register may either be specified explicitly as fourth argument, or a default for
  5207. all following code may be given via this instruction.  If neither a \tty{CKPT}
  5208. instruction nor an explicit checkpoint register was used, an error
  5209. is reported.  The default of no default register may be restored by using
  5210. {\tt NOTHING} as argument to \tty{CKPT}.
  5211.  
  5212. %%- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  5213.  
  5214. \subsection{EMULATED}
  5215.  
  5216. {\em valid for: 29K}
  5217.  
  5218. AMD defined the 29000's series exception handling for undefined
  5219. instructions in a way that there is a separate exception vector for
  5220. each instruction.  This allows to extend the instruction set of a
  5221. smaller member of this family by a software emulation.  To avoid that
  5222. \asname{} quarrels about these instructions as being undefined, the
  5223. \tty{EMULATED} instruction allows to tell \asname{} that certain instructions are
  5224. allowed in this case.  The check if the currently set processors knows the
  5225. instruction is then skipped.  For example, if one has written a module
  5226. that supports 32-bit IEEE numbers and the processor does not have a FPU,
  5227. one writes
  5228. \begin{verbatim}
  5229.        EMULATED FADD,FSUB,FMUL,FDIV
  5230.        EMULATED FEQ,FGE,FGT,SQRT,CLASS
  5231. \end{verbatim}
  5232.  
  5233. %%- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  5234.  
  5235. \subsection{BRANCHEXT}
  5236. \ttindex{BRANCHEXT}
  5237.  
  5238. {\em valid for: XA}
  5239.  
  5240. {\tt BRANCHEXT} with either \tty{ON} or \tty{OFF} as argument tells \asname{}
  5241. whether short branches that are only available with an 8-bit displacement
  5242. shall automatically be 'extended', for example by replacing a single
  5243. instruction like
  5244. \begin{verbatim}
  5245.        bne     target
  5246. \end{verbatim}
  5247. with a longer sequence of same functionality, in case the branc target is
  5248. out of reach for the instruction's displacement.  For example, the
  5249. replacement sequence for {\tt bne} would be
  5250. \begin{verbatim}
  5251.        beq     skip
  5252.        jmp     target
  5253. skip:
  5254. \end{verbatim}
  5255. In case there is no fitting 'opposite' for an instruction, the sequence
  5256. may become even longer, e.g. for {\tt jbc}:
  5257. \begin{verbatim}
  5258.        jbc     dobr
  5259.        bra     skip
  5260. dobr:   jmp     target
  5261. skip:
  5262. \end{verbatim}
  5263. This feature however has the side effect that there is no unambigious
  5264. assignment between machine and assembly code any more.  Furthermore,
  5265. additional passes may be the result if there are forward branches.  One
  5266. should therefore use this feature with caution!
  5267.  
  5268. %%- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  5269.  
  5270. \subsection{Z80SYNTAX}
  5271. \ttindex{Z80SYNTAX}
  5272.  
  5273. {\em G"ultigkeit: 8008, 8080/8085, $\mu$PD78xx}
  5274.  
  5275. With \tty{ON} as argument, one can optionally write machine
  5276. assembler instructions in the form Zilog defined them for the Z80.
  5277. For instance, you simply use \tty{LD} with self-explaining
  5278. operands instead of \tty{MVI, LXI, MOV, STA, LDA, SHLD, LHLD,
  5279. LDAX, STAX} or \tty{SPHL}.
  5280.  
  5281. Since some mnemonics have a different meaning in 8008/8080 and Z80
  5282. syntax, it is not possible to program in 'Z80 style' all the
  5283. time, unless the '8080 syntax' is turned off entirely by using
  5284. \tty{EXCLUSIVE} as argument.  The details of this operation mode
  5285. can be looked up in section \ref{8080Spec}.
  5286.  
  5287. A built-in symbol of same name allows to query the operation mode.
  5288. The mapping is \tty{0=OFF}, \tty{1=ON}, and \tty{2=EXCLUSIVE}.
  5289.  
  5290. %%- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  5291.  
  5292. \subsection{EXPECT and ENDEXPECT}
  5293. \ttindex{EXPECT}
  5294. \ttindex{ENDEXPECT}
  5295.  
  5296. This pair of instructions may be used to frame a piece of code that
  5297. is {\em expected} to trigger one or more error or warning messages.
  5298. If the errors or warnings (identified by their numbers, see chapter
  5299. \ref{ChapErrMess}) do occur, they are suppressed and assembly continues
  5300. without any error (naturally, without creating code at the erroneous
  5301. places).  However, if warnings or errors that were expected do not
  5302. occur, \tty{ENDEXPECT} will emit errors about them.  The main usage
  5303. scenario of these instructions are the self tests in the tests/
  5304. subdirectory.  For instance, one may check this way if range
  5305. checking of operands works as expected:
  5306. \begin{verbatim}
  5307.       cpu      68000
  5308.       expect   1320     ; immediate shift only for 1..8
  5309.       lsl.l    #10,d0
  5310.       endexpect
  5311. \end{verbatim}
  5312.  
  5313.  
  5314. %%---------------------------------------------------------------------------
  5315.  
  5316. \section{Data Definitions}
  5317.  
  5318. The instructions described in this section partially overlap in their
  5319. functionality, but each processor family defines other names for the
  5320. same function.  To stay compatible with the standard assemblers, this
  5321. way of implementation was chosen.
  5322.  
  5323. If not explicitly mentioned otherwise, all instructions for data
  5324. deposition (not those for reservation of memory!) allow an arbitrary
  5325. number of parameters which are being processed from left to right.
  5326.  
  5327. %%- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  5328.  
  5329. \subsection{DC[.Size]}
  5330. \ttindex{DC}
  5331.  
  5332. {\em valid for: 680x0, M*Core, 68xx, H8, SH7x00, DSP56xxx, XA,
  5333.  ST7/STM8, MN161x, IM61x0, CP-3F, SC61860}
  5334.  
  5335. This instruction places one or several constants of the type
  5336. specified by the attribute into memory.  The attributes are the same ones as
  5337. defined in section \ref{AttrTypes}, and there is additionally the
  5338. possibility for byte constants to place string constants in memory, like
  5339. \begin{verbatim}
  5340. String  dc.B "Hello world!\0"
  5341. \end{verbatim}
  5342. The parameter count may be between 1 and 20.  A repeat count enclosed
  5343. in brackets may additionally be prefixed to each parameter; for
  5344. example, one can for example fill the area up to the next page
  5345. boundary with zeroes with a statement like
  5346. \begin{verbatim}
  5347.        dc.b    [(*+255)&$ffffff00-*]0
  5348. \end{verbatim}
  5349. \bb{CAUTION!}  This function easily allows to reach the limit of 1 Kbyte
  5350. of generated code per line!
  5351.  
  5352. The assembler can automatically add another byte of data in case the byte sum
  5353. should become odd, to keep the word alignment.  This behaviour may be
  5354. turned on and off via the \tty{PADDING} instruction.
  5355.  
  5356. Decimal floating point numbers stored with this instruction (\tty{DC.P...})
  5357. can cover the whole range of extended precision, one however has to
  5358. pay attention to the detail that the coprocessors currently available
  5359. from Motorola (68881/68882) ignore the thousands digit of the
  5360. exponent at the read of such constants!
  5361.  
  5362. The default attribute is \tty{W}, that means 16-bit-integer numbers.
  5363.  
  5364. For the DSP56xxx, the data type is fixed to integer numbers (an attribute is
  5365. therefore neither necessary nor allowed), which may be in the range
  5366. of -8M up to 16M-1.  String constants are also allowed, whereby three characters
  5367. are packed into each word.
  5368.  
  5369. Opposed to the standard Motorola assembler, it is also valid to reserve
  5370. memory space with this statement, by using a question mark as operand.
  5371. This is an extension added by some third-party suppliers for 68K
  5372. assemblers, similar to what Intel assemblers provide.  However, it should
  5373. be clear that usage of this feature may lead to portability problems.
  5374. Furthermore, question marks as operands must not be mixed with 'normal'
  5375. constants in a single statement.
  5376.  
  5377. %%- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  5378.  
  5379. \subsection{DS[.Size]}
  5380. \ttindex{DS}
  5381.  
  5382. {\em valid for: 680x0, M*Core, 68xx, H8, SH7x00, DSP56xxx, XA, ST7/STM8,
  5383.  MN161x, IM61x0, CP-3F, PPS-4, SC61860}
  5384.  
  5385. On the one hand, this instruction enables to reserve memory space for
  5386. the specified count of numbers of the type given by the attribute.
  5387. Therefore,
  5388. \begin{verbatim}
  5389.        DS.B    20
  5390. \end{verbatim}
  5391. for example reserves 20 bytes of memory, but
  5392. \begin{verbatim}
  5393.        DS.X    20
  5394. \end{verbatim}
  5395. reserves 240 bytes!
  5396.  
  5397. The other purpose is the alignment of the program counter which is
  5398. achieved by a count specification of 0.  In this way, with a
  5399. \begin{verbatim}
  5400.        DS.W    0  ,
  5401. \end{verbatim}
  5402. the program counter will be rounded up to the next even address, with
  5403. a
  5404. \begin{verbatim}
  5405.        DS.D 0
  5406. \end{verbatim}
  5407. in contrast to the next double word boundary.  Memory cells possibly
  5408. staying unused thereby are neither zeroed nor filled with NOPs, they
  5409. simply stay undefined.
  5410.  
  5411. The default for the operand length is - as usual - \tty{W}, i.e. 16 bits.
  5412.  
  5413. For the 56xxx, the operand length is fixed to words (of 24 bit),
  5414. attributes therefore do not exist just as in the case of \tty{DC}.
  5415.  
  5416. %%- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  5417.  
  5418. \subsection{BLKB, BLKW, BLKL, BLKD}
  5419. \ttindex{BLKB}\ttindex{BLKW}\ttindex{BLKL}\ttindex{BLKD}
  5420.  
  5421. {\em valid for: Renesas RX}
  5422.  
  5423. These statements are used to reserve memory on Renesas RX. The total amount
  5424. of memory reserved is the instruction's argument times the operand size
  5425. given by the instruction (1 byte for \tty{BLKB}, 2 bytes for \tty{BLKW}, 4
  5426. bytes for \tty{BLKL}, and 8 bytes for \tty{BLKD}).
  5427.  
  5428. %%- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  5429.  
  5430. \subsection{DN,DB,DW,DD,DQ, and DT}
  5431. \ttindex{DN}\ttindex{DB}\ttindex{DW}\ttindex{DD}\ttindex{DQ}\ttindex{DT}
  5432.  
  5433. {\em\begin{tabbing}
  5434. valid for: \= Intel (except for 4004/4040), Zilog, Toshiba,\\
  5435.           \> NEC, TMS370, Siemens, AMD, MELPS7700/65816,\\
  5436.           \> M16(C), National, ST9, Atmel, TMS70Cxx, TMS1000,\\
  5437.           \> Signetics, $\mu$PD77230, Fairchild, Intersil,\\
  5438.           \> XS1, SC62015
  5439. \end{tabbing}}
  5440.  
  5441. These commands are - one could say - the Intel counterpart to \tty{DS} and
  5442. \tty{DC}, and as expected, their logic is a little bit different: First,
  5443. the specification of the operand length is moved into the mnemonic:
  5444. \begin{itemize}
  5445. \item{\tty{DN}: 4-bit integer}
  5446. \item{\tty{DB}: byte or ASCII string similar to \tty{DC.B}}
  5447. \item{\tty{DW}: 16-bit integer or half precision}
  5448. \item{\tty{DD}: 32-bit integer or single precision}
  5449. \item{\tty{DQ}: double precision   (64 bits)}
  5450. \item{\tty{DT}: extended precision (80 bits)}
  5451. \end{itemize}
  5452. Second, the distinction between constant definition and memory
  5453. reservation is done by the operand.  A reservation of memory is
  5454. marked by a \tty{?} :
  5455. \begin{verbatim}
  5456.        db      ?       ; reserves a byte
  5457.        dw      ?,?     ; reserves memory for 2 words (=4 byte)
  5458.        dd      -1      ; places the constant -1 (FFFFFFFFH) !
  5459. \end{verbatim}
  5460. Reserved memory and constant definitions \bb{must not} be mixed within one
  5461. instruction:
  5462. \begin{verbatim}
  5463.        db      "hello",?       ; --> error message
  5464. \end{verbatim}
  5465. Additionally, the \tty{DUP} Operator permits the repeated placing of
  5466. constant sequences or the reservation of whole memory blocks:
  5467. \begin{verbatim}
  5468.        db      3 dup (1,2)     ; --> 1 2 1 2 1 2
  5469.        dw      20 dup (?)      ; reserves 40 bytes of memory
  5470. \end{verbatim}
  5471. As you can see, the \tty{DUP}-argument must be enclosed in parentheses,
  5472. which is also why it may consist of several components, that may
  5473. themselves be \tty{DUP}s...the stuff therefore works recursively.
  5474.  
  5475. \tty{DUP} is however also a place where one can get in touch with another
  5476. limit of the assembler: a maximum of 1024 bytes of code or data may be
  5477. generated in one line.  This is not valid for the reservation of memory,
  5478. only for the definition of constant arrays!
  5479.  
  5480. The \tty{DUP} operator only gets recognized if it is itself not enclosed
  5481. in parentheses, and if there is a non-empty argument to its left.  This
  5482. way, it is possible to use a symbol of same name as argument.
  5483.  
  5484. Several platforms define pseudo instructions with same functionality,
  5485. but different names:
  5486. \begin{itemize}
  5487. \ttindex{DEFB}\ttindex{DEFW}
  5488. \item{In order to be compatible to the M80, \tty{DEFB/DEFW} may be used
  5489.      instead of \tty{DB/DW} in Z80-mode.}
  5490. \ttindex{BYTE}\ttindex{WORD}\ttindex{ADDR}\ttindex{ADDRW}
  5491. \item{\tty{BYTE/ADDR} resp. \tty{WORD/ADDRW} in COP4/8 mode are an
  5492.      alias for \tty{DB} resp. \tty{DW}, with the pairs differing in byte
  5493.      order: instructions defined by National for address storage use big
  5494.      endian, \tty{BYTE} resp. \tty{WORD} in contrast use little endian.}
  5495. \ttindex{BYTE}\ttindex{WORD}
  5496. \item{\tty{BYTE} resp. \tty{WORD} are available on PDP-11 and WD16 as an
  5497.      alias for \tty{DB} resp. \tty{DW}.}
  5498. \ttindex{BYTE}\ttindex{WORD}\ttindex{LWORD}\ttindex{FLOAT}\ttindex{DOUBLE}
  5499. \item{The Renesas RX target provides:
  5500.      \begin{itemize}
  5501.      \item{\tty{BYTE} (like \tty{DB})}
  5502.      \item{\tty{WORD} (like \tty{DW}, only integer arguments)}
  5503.      \item{\tty{LWORD} (like \tty{DD}, only integer arguments)}
  5504.      \item{\tty{FLOAT} (like \tty{DD}, only floating point arguments)}
  5505.      \item{\tty{DOUBLE} (like \tty{DQ}, only floating point arguments)}
  5506.      \end{itemize}}
  5507. \end{itemize}
  5508.  
  5509. If \tty{DB} is used in an address space that is not byte addressable (like
  5510. the Atmel AVR's \tty{CODE} segment), bytes are packed in pairs into 16 bit
  5511. words, according to the endianess given by the architecture: for little
  5512. endian, the LSB is filled first.  If the total number of bytes is odd, one
  5513. half of the last word remains unused, just like the argument list had been
  5514. padded.  It will also not be used if another \tty{DB} immediately follows
  5515. in source code.  The analogous is true for \tty{DN}, just with the difference
  5516. that two or four nibbles are packet into a byte or 16 bit word.
  5517.  
  5518. The NEC 77230 is special with its \tty{DW} instruction: It more works like
  5519. the \tty{DATA} statement of its smaller brothers, but apart from string
  5520. and integer arguments, it also accepts floating point values (and stores
  5521. them in the processor's proprietary 32-bit format). There is {\em no}
  5522. \tty{DUP} operator!
  5523.  
  5524. %%- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  5525.  
  5526. \subsection{FLT2, FLT3, FLT4}
  5527. \ttindex{FLT2}\ttindex{FLT3}\ttindex{FLT4}
  5528.  
  5529. \tty{FLT2} and \tty{FLT4} are similar in function to \tty{DD} bzw. \tty{DQ}.
  5530. However, they only store floating point numbers (in DEC's own F and D formats)
  5531. in memory.  The WD16 uses an own, 48 bits (three machine words) long format.
  5532. Floating point numbers in this format can be stored in memory with the \tty{FLT3}
  5533. instruction.
  5534.  
  5535. %%- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  5536.  
  5537. \subsection{DS, DS8}
  5538. \ttindex{DS}
  5539. \ttindex{DS8}
  5540.  
  5541. {\em\begin{tabbing}
  5542. valid for: \= Intel, Zilog, Toshiba, NEC, TMS370, Siemens, AMD, \\
  5543.           \> M16(C), National, ST9, TMS7000, TMS1000, Intersil, \\
  5544.           \> 6502, 68xx \\
  5545. \end{tabbing}}
  5546.  
  5547. With this instruction, you can reserve a memory area:
  5548. \begin{verbatim}
  5549.        DS      <count>
  5550. \end{verbatim}
  5551. It is an abbreviation of
  5552. \begin{verbatim}
  5553.        DB      <count> DUP (?)
  5554. \end{verbatim}
  5555. Although this could easily be made by a macro, some people grown up
  5556. with Motorola CPUs (Hi Michael!) suggest \tty{DS} to be a built-in
  5557. instruction...I hope they are satisfied now \tty{;-)}
  5558.  
  5559. {\tt DS8} is defined as an alias for {\tt DS} on the National SC14xxx.
  5560. Beware that the code memory of these processors is organized in words of
  5561. 16 bits, it is therefore impossible to reserve individual bytes.  In case
  5562. the argument of {\tt DS} is odd, it will be rounded up to the next even
  5563. number.
  5564.  
  5565. %%- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  5566.  
  5567. \subsection{BYT or FCB}
  5568. \ttindex{BYT}\ttindex{FCB}
  5569.  
  5570. {\em valid for: 6502, 68xx, SC61860}
  5571.  
  5572. By this instruction, byte constants or ASCII strings are placed in
  5573. 65xx/68xx-mode, it therefore corresponds to \tty{DC.B} on the 68000 or
  5574. \tty{DB} on Intel (which ias also allowed).  Similarly to \tty{DC}, a
  5575. repetition factor enclosed in brackets ([..]) may be prepended to every
  5576. single parameter.
  5577.  
  5578. %%- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  5579.  
  5580. \subsection{BYTE}
  5581. \ttindex{BYTE}
  5582.  
  5583. {\em valid for: ST6, 320C2(0)x, 320C5x, MSP, TMS9900, CP-1600}
  5584.  
  5585. Ditto.  Note that when in 320C2(0)x/5x mode, the assembler assumes that
  5586. a label on the left side of this instruction has no type, i.e. it
  5587. belongs to no address space. This behaviour is explained in the
  5588. processor-specific hints.
  5589.  
  5590. The \tty{PADDING} instruction allows to set whether odd counts of bytes
  5591. shall be padded with a zero byte in MSP/TMS9900 mode.
  5592.  
  5593. The operation of {\tt BYTE} on CP-1600 is somewhat different: the 16-bit
  5594. integer arguments are stored byte-wise in two consecutive words of memory
  5595. (LSB first).  If individual 8-bit values shall be stored in memor (optionally
  5596. packed), use the {\tt TEXT} instruction!
  5597.  
  5598. %%- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  5599.  
  5600. \subsection{DC8}
  5601. \ttindex{DC8}
  5602.  
  5603. {\em valid for: SC144xx}
  5604.  
  5605. This statement is an alias for {\tt DB}, i.e. it may be used to dump byte
  5606. constants or strings to memory.
  5607.  
  5608. %%- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  5609.  
  5610. \subsection{ADR or FDB}
  5611. \ttindex{ADR}\ttindex{FDB}
  5612.  
  5613. {\em valid for: 6502, 68xx, SC61860}
  5614.  
  5615. \tty{ADR} resp. \tty{FDB} stores word constants when in 65xx/68xx mode.
  5616. It is therefore the equivalent to \tty{DC.W} on the 68000 or \tty{DW} on
  5617. Intel platforms (which is also allowed).  Similarly to \tty{DC}, a repetition
  5618. factor enclosed in brackets ([..]) may be prepended to every single parameter.
  5619.  
  5620. %%- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  5621.  
  5622. \subsection{DDB}
  5623. \ttindex{DDB}
  5624.  
  5625. {\em valid for: 6502, MELPS-7700}
  5626.  
  5627. This instructions works similar to \tty{ADR}, just with the difference that
  5628. the 16 bit values are stored in big endian order.
  5629.  
  5630. %%- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  5631.  
  5632. \subsection{DCM}
  5633. \ttindex{DCM}
  5634.  
  5635. {\em valid for: 6502}
  5636.  
  5637. This instructions allows to dispose floating point constants in memory, in
  5638. the format that described in \cite{AppleFloat}: An exponent of eight bits
  5639. and a mantissa of 24 bits in two's complement representation, stored in
  5640. big-endian order.
  5641.  
  5642. %%- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  5643.  
  5644. \subsection{WORD}
  5645. \ttindex{WORD}
  5646.  
  5647. {\em valid for: ST6, i960, 320C2(0)x, 320C3x/C4x/C5x, MSP, CP-1600,\\
  5648.      IMP-16, IPC-16}
  5649.  
  5650. If assembling for the 320C3x/C4x or i960, this command stores 32-bit words,
  5651. 16-bit words for the other families.  Note that when in 320C2(0)x/5x mode,
  5652. the assembler assumes that a label on the left side of this instruction
  5653. has no type, i.e. it belongs to no address space.  This behaviour is
  5654. explained at the discussion on processor-specific hints.
  5655.  
  5656. %%- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  5657.  
  5658. \subsection{DW16}
  5659. \ttindex{DW16}
  5660.  
  5661. {\em valid for: SC144xx}
  5662.  
  5663. This instruction is for SC144xx targets a way to dump word (16 bit)
  5664. constants to memory. {\tt CAUTION!!}  It is therefore an alias for {\tt
  5665. DW}.
  5666.  
  5667. %%- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  5668.  
  5669. \subsection{ACON}
  5670. \ttindex{ACON}
  5671.  
  5672. {\em valid for: 2650}
  5673.  
  5674. {\tt ACON} works the same way as {\tt DW}, the 16 bit numbers are however
  5675. stored in big endian format.
  5676.  
  5677. %%- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  5678.  
  5679. \subsection{LONG}
  5680. \ttindex{LONG}
  5681.  
  5682. {\em valid for: 320C2(0)x, 320C5x}
  5683.  
  5684. LONG stores a 32-bit integer to memory with the order LoWord-HiWord.
  5685. Note that when in 320C2(0)x/5x mode, the assembler assumes that a label
  5686. on the left side of this instruction has no type, i.e. it belongs to
  5687. no address space. This behaviour is explained in the
  5688. processor-specific hints.
  5689.  
  5690. %%- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  5691.  
  5692. \subsection{SINGLE, DOUBLE, and EXTENDED}
  5693. \ttindex{SINGLE}\ttindex{DOUBLE}\ttindex{EXTENDED}
  5694.  
  5695. {\em valid for: 320C3x/C4x (not {\tt DOUBLE}), 320C6x (not {\tt EXTENDED})}
  5696.  
  5697. Both commands store floating-point constants to memory.  In case of the
  5698. 320C3x/C4x, they are \bb{not} stored in IEEE-format.  Instead the
  5699. processor-specific formats with 32 and 40 bit are used.  In case of
  5700. \tty{EXTENDED} the resulting constant occupies two memory words.  The most
  5701. significant 8 bits (the exponent) are written to the first word while the
  5702. other ones (the mantissa) are copied into the second word.
  5703.  
  5704. %%- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  5705.  
  5706. \subsection{FLOAT and DOUBLE}
  5707. \ttindex{FLOAT}\ttindex{DOUBLE}
  5708.  
  5709. {\em valid for: 320C2(0)x, 320C5x}
  5710.  
  5711. These two commands store floating-point constants in memory using the
  5712. standard IEEE 32-bit and 64-bit IEEE formats.  The least significant
  5713. byte is copied to the first allocated memory location.  Note that
  5714. when in 320C2(0)x/5x mode the assembler assumes that all labels on the
  5715. left side of an instruction have no type, i.e. they belong to no
  5716. address space.  This behaviour is explained in the processor-specific
  5717. hints.
  5718.  
  5719. %%- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  5720.  
  5721. \subsection{SINGLE and DOUBLE}
  5722. \ttindex{SINGLE}\ttindex{DOUBLE}
  5723.  
  5724. {\em valid for: TMS99xxx}
  5725.  
  5726. These two commands store floating-point constants in memory using the
  5727. processor's floating point format, which is equal to the IBM/360
  5728. floating point format.
  5729.  
  5730. %%- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  5731.  
  5732. \subsection{EFLOAT, BFLOAT, and TFLOAT}
  5733. \ttindex{EFLOAT}\ttindex{BFLOAT}\ttindex{TFLOAT}
  5734.  
  5735. {\em valid for: 320C2(0)x, 320C5x}
  5736.  
  5737. Another three floating point commands.  All of them support non-IEEE
  5738. formats, which should be easily applicable on signal processors:
  5739. \begin{itemize}
  5740. \item{\tty{EFLOAT}: mantissa with 16 bits, exponent with 16 bits}
  5741. \item{\tty{BFLOAT}: mantissa with 32 bits, exponent with 16 bits}
  5742. \item{\tty{TFLOAT}: mantissa with 64 bits, exponent with 32 bits}
  5743. \end{itemize}
  5744. The three commands share a common storage strategy.  In all cases the
  5745. mantissa precedes the exponent in memory, both are stored as 2's
  5746. complement with the least significant byte first.  Note that when in
  5747. 320C2(0)x/5x mode the assembler assumes that all labels on the left side
  5748. of an instruction have no type, i.e.  they belong to no address
  5749. space. This behaviour is explained in the processor-specific hints.
  5750.  
  5751. %%- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  5752.  
  5753. \subsection{Qxx and LQxx}
  5754. \ttindex{Qxx}\ttindex{LQxx}
  5755.  
  5756. {\em valid for: 320C2(0)x, 320C5x}
  5757.  
  5758. \tty{Qxx} and \tty{LQxx} can be used to generate constants in a fixed
  5759. point format. \tty{xx} denotes a 2-digit number.  The operand is first
  5760. multiplied by $2^{xx}$ before converting it to binary notation.  Thus
  5761. \tty{xx} can be viewed as the number of bits which should be reserved for
  5762. the fractional part of the constant in fixed point format.  \tty{Qxx}
  5763. stores only one word (16 bit) while \tty{LQxx} stores two words (low word
  5764. first):
  5765. \begin{verbatim}
  5766.        q05     2.5     ; --> 0050h
  5767.        lq20    ConstPI ; --> 43F7h 0032h
  5768. \end{verbatim}
  5769. Please do not flame me in case I calculated something wrong on my
  5770. HP28...
  5771.  
  5772. %%- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  5773.  
  5774. \subsection{DATA}
  5775. \ttindex{DATA}
  5776.  
  5777. {\em valid for: PIC, 320xx, AVR, MELPS-4500, H8/500,
  5778.     HMCS400, 4004/4040, $\mu$PD772x, OLMS-40/50, Padauk}
  5779.  
  5780. This command stores data in the current segment.  Both integer
  5781. values as well as character strings are supported.  On
  5782. 16C5x/16C8x, 17C4x in data segment, and on the 4500, 4004, and
  5783. HMCS400 in code segment, characters occupy one word.  On AVR,
  5784. 17C4x in code segment, $\mu$PD772x in the data segments, and on
  5785. 3201x/3202x, in general two characters fit into one word (LSB
  5786. first).  The $\mu$PD77C25 can hold three bytees per word in the
  5787. code segment.  When in 320C3x/C4x, mode the assembler puts four
  5788. characters into one word (MSB first).  In contrast to this
  5789. characters occupy two memory locations in the data segment of the
  5790. 4500, similar in the 4004 and HMCS400.  The range of integer
  5791. values corresponds to the word width of each processor in a
  5792. specific segment.  This means that \tty{DATA} has the same result
  5793. than \tty{WORD} on a 320C3x/C4x (and that of \tty{SINGLE} if \asname{}
  5794. recognizes the operand as a floating-point constant).
  5795.  
  5796. %%- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  5797.  
  5798. \subsection{ZERO, CP-1600}
  5799. \ttindex{ZERO}
  5800.  
  5801. {\em valid for: PIC}
  5802.  
  5803. Generates a continuous string of zero words in memory (which equals a NOP
  5804. on PIC).
  5805.  
  5806. %%- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  5807.  
  5808. \subsection{FB and FW}
  5809. \ttindex{FB}\ttindex{FW}
  5810.  
  5811. {\em valid for: COP4/8}
  5812.  
  5813. These instruction allow to fill memory blocks with a byte or word
  5814. constant. The first operand specifies the size of the memory block
  5815. while the second one sets the filling constant itself.
  5816.  
  5817. %%- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  5818.  
  5819. \subsection{ASCII and ASCIZ}
  5820. \ttindex{ASCII}\ttindex{ASCIZ}
  5821.  
  5822. {\em valid for: ST6, \tty{ASCII} also on IMP-16/IPC-16}
  5823.  
  5824. Both commands store string constants to memory.  While \tty{ASCII} writes
  5825. the character information only, \tty{ASCIZ} additionally appends a zero to
  5826. the end of the string.
  5827.  
  5828. %%- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  5829.  
  5830. \subsection{STRING and RSTRING}
  5831. \ttindex{STRING}\ttindex{RSTRING}
  5832.  
  5833. {\em valid for: 320C2(0)x, 320C5x}
  5834.  
  5835. These commands are functionally equivalent to \tty{DATA}, but integer
  5836. values are limited to the range of byte values. This enables two
  5837. characters or numbers to be packed together into one word. Both commands
  5838. only differ in the order they use to write bytes: \tty{STRING} stores the
  5839. upper one first then the lower one, \tty{RSTRING} does this vice versa.
  5840. Note that when in 320C2(0)x/5x mode the assembler assumes that a label on the
  5841. left side of this instruction has no type, i.e. it belongs to no address
  5842. space.  This behaviour is explained in the processor-specific hints.
  5843.  
  5844. %%- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  5845.  
  5846. \subsection{FCC}
  5847. \ttindex{FCC}
  5848.  
  5849. {\em valid for: 6502, 68xx}
  5850.  
  5851. When in 65xx/68xx mode, string constants are generated using this
  5852. instruction. In contrast to the original assembler AS11 from Motorola
  5853. (this is the main reason why \asname{} understands this command, the
  5854. functionality is contained within the \tty{BYT} instruction) you must
  5855. enclose the string argument by double quotation marks instead of single
  5856. quotation marks or slashes.  Similarly to \tty{DC}, a repetition factor
  5857. enclosed in brackets ([..]) may be prepended to every single parameter.
  5858.  
  5859. %%- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  5860.  
  5861. \subsection{TEXT}
  5862.  
  5863. In CP-1600 mode, This instruction is used to store string constants in
  5864. packed format, i.e. two characters per word.
  5865.  
  5866. %%- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  5867.  
  5868. \subsection{DFS or RMB}
  5869. \ttindex{DFS}\ttindex{RMB}
  5870.  
  5871. {\em valid for: 6502, 68xx}
  5872.  
  5873. Reserves a memory block when in 6502/68xx mode.  It is therefore the
  5874. equivalent to \tty{DS.B} on the 68000 or \tty{DB ?} on Intel platforms.
  5875.  
  5876. %%- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  5877.  
  5878. \subsection{BLOCK}
  5879. \ttindex{BLOCK}
  5880.  
  5881. {\em valid for: ST6}
  5882.  
  5883. Ditto.
  5884.  
  5885. %%- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  5886.  
  5887. \subsection{SPACE}
  5888. \ttindex{SPACE}
  5889.  
  5890. {\em valid for: i960}
  5891.  
  5892. Ditto.
  5893.  
  5894. %%- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  5895.  
  5896. \subsection{RES}
  5897. \ttindex{RES}
  5898.  
  5899. {\em valid for: PIC, MELPS-4500, HMCS400, 3201x, 320C2(0)x, 320C5x, AVR,
  5900. $\mu$PD772x, OLMS-40/50, Padauk, CP-1600, PPS-4, 2650}
  5901.  
  5902. This command allocates memory.  When used in code segments the
  5903. argument counts words (10/12/14/16 bit).  In data segments it counts
  5904. bytes for PICs, nibbles for 4500, PPS-4, and OLMS-40/50 and words for the
  5905. TI devices.
  5906.  
  5907. %%- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  5908.  
  5909. \subsection{BSS}
  5910. \ttindex{BSS}
  5911.  
  5912. {\em valid for: 320C2(0)x, 320C3x/C4x/C5x/C6x, MSP}
  5913.  
  5914. \tty{BSS} works like \tty{RES}, but when in 320C2(0)x/5x mode, the assembler
  5915. assumes that a label on the left side of this instruction has no type, i.e
  5916. it belongs to no address space. This behaviour is explained in the
  5917. processor-specific hints.
  5918.  
  5919. %%- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  5920.  
  5921. \subsection{DSB and DSW}
  5922. \ttindex{DSB}\ttindex{DSW}
  5923.  
  5924. {\em valid for: COP4/8}
  5925.  
  5926. Both instructions allocate memory and ensure compatibility to ASMCOP from
  5927. National.  While \tty{DSB} takes the argument as byte count, \tty{DSW}
  5928. uses it as word count (thus it allocates twice as much memory than
  5929. \tty{DSB}).
  5930.  
  5931. %%- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  5932.  
  5933. \subsection{DS16}
  5934. \ttindex{DS16}
  5935.  
  5936. {\em valid for: SC144xx}
  5937.  
  5938. This instruction reserves memory in steps of full words, i.e. 16 bits.  It
  5939. is an alias for {\tt DW}.
  5940.  
  5941. %%- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  5942.  
  5943. \subsection{ALIGN}
  5944. \ttindex{ALIGN}
  5945.  
  5946. {\em valid for: all processors}
  5947.  
  5948. Takes the argument to align the program counter to a certain address
  5949. boundary.  \asname{} increments the program counter to the next multiple of the
  5950. argument.  So, \tty{ALIGN} corresponds to \tty{DS.x} on 68000, but is much
  5951. more flexible at the same time.
  5952.  
  5953. Example:
  5954. \begin{verbatim}
  5955.        align     2
  5956. \end{verbatim}
  5957. aligns to an even address (PC mod 2 = 0).  If Align is used in this form with
  5958. only one argument, the contents of the skipped memory space is not defined.
  5959. An optinal second argument may be used to define the (byte) value
  5960. used to fill the area.
  5961.  
  5962. %%- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  5963.  
  5964. \subsection{LTORG}
  5965. \ttindex{LTORG}
  5966.  
  5967. {\em valid for: SH7x00, IM61x0, IMP-16, IPC-16}
  5968.  
  5969. Although the SH7000 processor can do an immediate register load with
  5970. 8 bit only, \asname{} shows up with no such restriction.  This behaviour is
  5971. instead simulated through constants in memory.  Storing them in
  5972. the code segment (not far away from the register load instruction)
  5973. would require an additional jump.  \asname{} Therefore gathers the constants
  5974. an stores them at an address specified by \tty{LTORG}.  Details are
  5975. explained in the processor-specific section somewhat later.
  5976.  
  5977. %%---------------------------------------------------------------------------
  5978.  
  5979. \section{Macro Instructions}
  5980.  
  5981. {\em valid for: all processors}
  5982.  
  5983. Now we finally reach the things that make a macro assembler different
  5984. from an ordinary assembler: the ability to define macros (guessed
  5985. it !?).
  5986.  
  5987. When speaking about 'macros', I generally mean a sequence of (machine
  5988. or pseudo) instructions which are united to a block by special
  5989. statements and can then be treated in certain ways.  The assembler
  5990. knows the following statements to work with such blocks:
  5991.  
  5992. %%- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  5993.  
  5994. \subsection{MACRO}
  5995. \ttindex{MACRO}\ttindex{ENDM}
  5996. \label{SectMacros}
  5997.  
  5998. is probably the most important instruction for macro programming.
  5999. The instruction sequence
  6000. \begin{verbatim}
  6001. <name>  MACRO   [parameter list]
  6002.        <instructions>
  6003.        ENDM
  6004. \end{verbatim}
  6005. defines the macro \tty{$<$name$>$} to be the enclosed instruction sequence.
  6006. This definition by itself does not generate any code!  In turn, from
  6007. now on the instruction sequence can simply be called by the name, the
  6008. whole construct therefore shortens and simplifies programs.  A
  6009. parameter list may be added to the macro definition to make things
  6010. even more useful.
  6011. \par
  6012. While a macro's name only has to conform to the usual rules for symbol
  6013. names (see section \ref{SectSymConv}), there is the additional restriction
  6014. that parameter names may not contain underscore characters.  This may
  6015. be changed via the \tty{-underscore-macroargs} command line argument,
  6016. but sinve it has additional side effects, it should only be used if
  6017. absolutely necessary.
  6018. \par
  6019. A switch to case-sensitive mode influences both macro names and
  6020. parameters.
  6021.  
  6022. Similar to symbols, macros are local, i.e. they are only known in a
  6023. section and its subsections when the definition is done from within
  6024. a section.  This behaviour however can be controlled in wide limits
  6025. via the options \tty{PUBLIC} and \tty{GLOBAL} described below.
  6026.  
  6027. A default value may be provided for each macro parameter
  6028. (appended via an equal sign).  This value is used if there is no
  6029. argument for this parameter at macro call or if the positional
  6030. argument (see below) for this parameter is empty.
  6031.  
  6032. Apart from the macro parameters themselves, the parameter list may
  6033. contain control parameters which influence the processing of the
  6034. macro.  These parameters are distinguished from normal parameters by
  6035. being enclosed in curly braces.  The following control parameters are
  6036. defined:
  6037. \begin{itemize}
  6038. \item{\tty{EXPAND/NOEXPAND}: rule whether the enclosed code shall
  6039.      be written to the listing when the macro is expanded.  The
  6040.      default is the value set by the pseudo instruction
  6041.      \tty{MACEXP\_DFT}.}
  6042. \item{\tty{EXPIF/NOEXPIF}: rule whether instructions for
  6043.      conditional assembly and code excluded by it shall
  6044.      be written to the listing when the macro is expanded.  The
  6045.      default is the value set by the pseudo instruction
  6046.      \tty{MACEXP\_DFT}.}
  6047. \item{\tty{EXPMACRO/NOEXPMACRO}: rule whether macros defined in
  6048.      the macro's body shall be written to the listing when the macro
  6049.      is expanded.  The default is the value set by the pseudo instruction
  6050.      \tty{MACEXP\_DFT}.}
  6051. \item{\tty{EXPREST/NOEXPREST} : rule whether a macro body's lines
  6052.      not fitting into the first two categories shall be written to the
  6053.      listing when the macro is expanded. The default is the value set by
  6054.      the pseudo instruction \tty{MACEXP\_DFT}.}
  6055. \item{\tty{PUBLIC[:section name]}: assigns the macro to a parent section
  6056.      instead of the current section.  A section can make macros
  6057.      accessible for the outer code this way.  If the section
  6058.      specification is missing, the macro becomes completely global, i.e.
  6059.      it may be referenced from everywhere.}
  6060. \item{\tty{GLOBAL[:section name]}: rules that in addition to the macro
  6061.      itself, another macro shall be generated that has the same contents
  6062.      but is assigned to the specified section.  Its name is constructed by
  6063.      concatenating the current section's name to the macro name.  The
  6064.      section specified must be a parent section of the current section;
  6065.      if the specification is missing, the additional macro becomes
  6066.      globally visible.  For example, if a macro \tty{A} is defined in a
  6067.      section \tty{B} that is a child section of section \tty{C}, an additional
  6068.      global macro named \tty{C\_B\_A} would be generated.  In contrast, if
  6069.      \tty{C} had been specified as target section, the macro would be named \tty{B\_A}
  6070.      and be assigned to section \tty{C}.  This option is turned off by default
  6071.      and it only has an effect when it is used from within a section.
  6072.      The macro defined locally is not influenced by this option.}
  6073. \item{\tty{EXPORT/NOEXPORT}: rules whether the definition of this macro
  6074.      shall be written to a separate file in case the \tty{-M} command line
  6075.      option was given.  This way, definitions of 'private' macros may
  6076.      be mapped out selectively.  The default is FALSE, i.e. the
  6077.      definition will not be written to the file.  The macro will be
  6078.      written with the concatenated name if the \tty{GLOBAL} option was
  6079.      additionally present.}
  6080. \item{\tty{INTLABEL/NOINTLABEL} : rules whether a label defined in a line
  6081.      that calls this macro may be used as an additional parameter inside
  6082.      the label or not, instead of simply 'labeling' the line.}
  6083. \item{\tty{GLOBALSYMBOLS/NOGLOBALSYMBOLS} : rules whether labels
  6084.      defined in the macro's body shall be local to this macro or
  6085.      also be available outside the macro.  The default is to
  6086.      keep them local, since using a macro multiple time would be
  6087.      difficult otherwise.}
  6088. \end{itemize}
  6089. The control parameters described above are removed from the parameter
  6090. list by \asname{}, i.e. they do not have a further influence on processing
  6091. and usage.
  6092.  
  6093. When a macro is called, the parameters given for the call are
  6094. textually inserted into the instruction block and the resulting
  6095. assembler code is assembled as usual.  Zero length parameters are
  6096. inserted in case too few parameters are specified.  It is important
  6097. to note that string constants are not protected from macro
  6098. expansions.  The old IBM rule:
  6099. \begin{quote}{\it
  6100. It's not a bug, it's a feature!
  6101. }\end{quote}
  6102. applies for this detail.  The gap was left to allow checking of
  6103. parameters via string comparisons.  For example, one can analyze a
  6104. macro parameter in the following way:
  6105. \begin{verbatim}
  6106. mul     MACRO   para,parb
  6107.        IF      UpString("PARA")<>"A"
  6108.         MOV    a,para
  6109.        ENDIF
  6110.        IF      UpString("PARB")<>"B"
  6111.         MOV    b,parb
  6112.        ENDIF
  6113.        !mul     ab
  6114.        ENDM
  6115. \end{verbatim}
  6116. It is important for the example above that the assembler converts all
  6117. parameter names to upper case when operating in case-insensitive
  6118. mode, but this conversion never takes place inside of string constants.
  6119. Macro parameter names therefore have to be written in upper case when
  6120. they appear in string constants.
  6121.  
  6122. Macro parameter expansion furthermore depends on whether
  6123. parameter names may contain underscores or not.  If not
  6124. (the default), underscores in the macro body also have
  6125. a function of 'limiters' to detect parameter names.  So
  6126. in the following example:
  6127. \begin{verbatim}
  6128. setled  macro led,value
  6129.        out   led,value
  6130.        ld    led_shadow,value
  6131.        endm
  6132. \end{verbatim}
  6133. the parameter 'led' would be replaced in both source lines, whereas
  6134. only in the first one if the command line switch \tty{underscore-macroargs}
  6135. is used.  Several of the include files shipped with \asname{}
  6136. rely on the default behaviour.  This switch should therefore only
  6137. be used if absolutely necessary.
  6138.  
  6139. Macro arguments may be given in either of two forms: {\em
  6140. positional} or {\em keyword} arguments.
  6141.  
  6142. For positional arguments, the assignment of arguments to macro
  6143. parameters simply results from the position of arguments, i.e.
  6144. the first argument is assigned to the first parameter, the second
  6145. argument to the second parameter and so on.  If the number of
  6146. arguments is smaller than the number of parameters, eventually
  6147. defined default values or simply an empty string are inserted.
  6148. The same is valid for empty arguments in the argument list.
  6149.  
  6150. Keyword arguments on the other hand explicitly define which
  6151. parameter they relate to, by being prefixed with the parameter's
  6152. name:
  6153. \begin{verbatim}
  6154.       mul  para=r0,parb=r1
  6155. \end{verbatim}
  6156. Again, non-assigned parameters will use an eventually defined
  6157. default or an empty string.
  6158.  
  6159. As a difference to positional arguments, keyword arguments allow
  6160. to assign an empty string to a parameter with a non-empty
  6161. default.
  6162.  
  6163. Mixing of positional and keyword arguments in one macro call is
  6164. possible, however it is not allowed to use positional arguments
  6165. after the first keyword argument.
  6166.  
  6167. The same naming rules as for usual symbols also apply for macro
  6168. parameters, with the exception that only letters and numbers are
  6169. allowed, i.e. dots and underscores are forbidden.  This constraint
  6170. has its reason in a hidden feature: the underscore allows to
  6171. concatenate macro parameter names to a symbol, like in the following
  6172. example:
  6173. \begin{verbatim}
  6174. concat  macro   part1,part2
  6175.        call    part1_part2
  6176.        endm
  6177. \end{verbatim}
  6178. The call
  6179. \begin{verbatim}
  6180.        concat  module,function
  6181. \end{verbatim}
  6182. will therefore result in
  6183. \begin{verbatim}
  6184.        call    module_function
  6185. \end{verbatim}
  6186. Apart from the parameters explicitly declared for a macro, four more
  6187. 'implicitly' declared parameters exist.   Since they are always present,
  6188. they cannot not be redeclared as explicit parameters:
  6189. \begin{itemize}
  6190. \item{{\tt ATTRIBUTE} refers to the attribute appended to the macro call,
  6191.      in case the currently active architecture supports attributes for
  6192.      machine instructions.  See below for an example!}
  6193. \item{{\tt ALLARGS} refers to a comma-separated list of all arguments
  6194.      passed to a macro, usable e.g. to pass them on to a IRP statement.}
  6195. \item{{\tt ARGCOUNT} refers to the actual count of parameters passed to
  6196.      a macro.  Note however that this number is never lower than the
  6197.      formal parameter count of the macro, since \asname{} will fill up missing
  6198.      arguments with empty strings!}
  6199. \item{{\tt \_\_LABEL\_\_} refers to a label present in a line that calls the
  6200.      macro. This replacement only takes place if the {\tt INTLABEL}
  6201.      option was set for this macro!}
  6202. \end{itemize}
  6203. {\bf IMPORTANT:} the names of these implicit parameters are also
  6204. case-insensitive if \asname{} was told to operate case-sensitive!
  6205.  
  6206. The purpose of being able to 'internally' use a label in a macro is surely
  6207. not immediately obvious.  There might be cases where moving the macro's
  6208. entry point into its body may be useful.  The most important application
  6209. however are TI signal processors that use a double pipe symbol in the
  6210. label's column to mark parallelism, like this:
  6211. \begin{verbatim}
  6212.    instr1
  6213. ||  instr2
  6214. \end{verbatim}
  6215. (since both instructions merge into a single word of machine code, you
  6216. cannot branch to the second instruction - so occupying the label's
  6217. position doesn't hurt).  The problem is however that some 'convenience
  6218. instructions' are realized as macros.  A parallelization symbol written in
  6219. front of a macro call normally would be assigned to the macro itself, {\it
  6220. not to the macro body's first instruction}.  However, things work with
  6221. this trick:
  6222. \begin{verbatim}
  6223. myinstr    macro {INTLABEL}
  6224. __LABEL__  instr2
  6225.           endm
  6226.  
  6227.           instr1
  6228. ||         myinstr
  6229. \end{verbatim}
  6230. The result after expanding {\tt myinstr} is identical to the previous
  6231. example without macro.
  6232.  
  6233. Recursion of macros, i.e. the repeated call of a macro from within its own
  6234. body is completely legal.  However, like for any other sort of recursion,
  6235. one has to assure that there is an end at someplace.  For cases where one
  6236. forgot this, \asname{} keeps an internal counter for every macro that is
  6237. incremented when an expansion of this macro is begun and decremented again
  6238. when the expansion is completed.  In case of recursive calls, this counter
  6239. reaches higher and higher values, and at a limit settable via {\tt
  6240. NESTMAX}, \asname{} will refuse to expand. Be careful when you turn off this
  6241. emergency brake: the memory consumption on the heap may go beyond all
  6242. limits and even shut down a Unix system...
  6243.  
  6244. A small example to remove all clarities ;-)
  6245.  
  6246. A programmer braindamaged by years of programming Intel processors
  6247. wants to have the instructions \tty{PUSH/POP} also for the 68000.  He
  6248. solves the 'problem' in the following way:
  6249. \begin{verbatim}
  6250. push    macro   op
  6251.        move.ATTRIBUTE op,-(sp)
  6252.        endm
  6253.  
  6254. pop     macro   op
  6255.        move.ATTRIBUTE (sp)+,op
  6256.        endm
  6257. \end{verbatim}
  6258. If one writes
  6259. \begin{verbatim}
  6260.        push    d0
  6261.        pop.l   a2    ,
  6262. \end{verbatim}
  6263. this results in
  6264. \begin{verbatim}
  6265.        move.   d0,-(sp)
  6266.        move.l  (sp)+,a2
  6267. \end{verbatim}
  6268. A macro definition must not cross include file boundaries.
  6269.  
  6270. Labels defined in macros always are regarded as being local,
  6271. unless the \tty{GLOBALSYMBOLS} was used in the macro's
  6272. definition.  If a single label shall be made public in a macro
  6273. that uses local labels otherwise, it may be defined with a
  6274. \tty{LABEL} statement which always creates global symbols
  6275. (similar to \tty{BIT, SFR...}):
  6276. \begin{verbatim}
  6277. <Name>  label   $
  6278. \end{verbatim}
  6279. When parsing a line, the assembler first checks the macro list
  6280. afterwards looks for processor instructions, which is why macros
  6281. allow to redefine processor instructions.  However, the definition
  6282. should appear previously to the first invocation of the instruction
  6283. to avoid phase errors like in the following example:
  6284. \begin{verbatim}
  6285.        bsr     target
  6286.  
  6287. bsr     macro   targ
  6288.        jsr     targ
  6289.        endm
  6290.  
  6291.        bsr     target
  6292. \end{verbatim}
  6293. In the first pass, the macro is not known when the first \tty{BSR}
  6294. instruction is assembled; an instruction with 4 bytes of length is
  6295. generated.  In the second pass however, the macro definition is
  6296. immediately available (from the first pass), a \tty{JSR} of 6 bytes length
  6297. is therefore generated.  As a result, all labels following are too low
  6298. by 2 and phase errors occur for them.  An additional pass is
  6299. necessary to resolve this.
  6300.  
  6301. Because a machine or pseudo instruction becomes hidden when a macro
  6302. of same name is defined, there is a backdoor to reach the original
  6303. meaning: the search for macros is suppressed if the name is prefixed
  6304. with an exclamation mark (!).  This may come in handy if one wants to
  6305. extend existing instructions in their functionality, e.g. the
  6306. TLCS-90's shift instructions:
  6307. \begin{verbatim}
  6308. srl     macro   op,n            ; shift by n places
  6309.        rept    n               ; n simple instructions
  6310.         !srl   op
  6311.        endm
  6312.        endm
  6313. \end{verbatim}
  6314. From now on, the \tty{SRL} instruction has an additional parameter...
  6315.  
  6316. \subsubsection{Macro Expansion in the Listing}
  6317.  
  6318. If a macro is being called, the macro's body is included in the assembly
  6319. listing, after arguemnts have been expanded.  This can significantly increase
  6320. the listing's size and make it hard to read.  It is therefore possible to
  6321. suppress this expansion totally or in parts.  Fundamentally, \asname{} divides
  6322. the source lines contained in a macro's body into three classes:
  6323. \begin{itemize}
  6324. \item{Macro definitions, i.e. the macro is used to define another macro,
  6325.      or it contains \tty{REPT/IRP/IRPC/WHILE} blocks.}
  6326. \item{Instructions for conditional assembly plus any source lines that have
  6327.      {\it not} been assembled due to conditional assembly.  Since conditional
  6328.      assembly may depend on macro arguments, this subset may also vary.}
  6329. \item{All remaining sourc elines that do not fall under the first two
  6330.      categories.}
  6331. \end{itemize}
  6332. Which parts occur in the listing may be defined individually for every macro.
  6333. When defining a macro, the default is the set defined by the most recent
  6334. \tty{MACEXP\_DFT} instruction (\ref{MACEXPDFT}).  If one of the \tty{EXPAND/NOEXPAND},
  6335. \tty{EXPIF/NOEXPIF} \tty{EXPMACRO/NOEXPMACRO}, or \tty{EXPREST/NOEXPREST}
  6336. directives is used in the macro's definition, they act {\em additionally},
  6337. but with higher preference.  For instance, if expansion had been disabled
  6338. completely (\tty{MACEXP\_DFT OFF}), adding the directive \tty{EXPREST} has the
  6339. effect that when using this macro, only lines are written to the listing
  6340. that remain after conditional assembly and are no macro definitions themselves.
  6341.  
  6342. In consequence, changing the set via \tty{MACEXP\_DFT} has no effect on macros
  6343. that have been {\it defined before} this statement.  The listing's section shows
  6344. for defined macros the effective set of expansion directives.  The list given
  6345. in curly braces is shorted so that it only conatins the last (and therefore
  6346. valid) directive for a certain class of source lines.  A \tty{NOIF} given
  6347. via \tty{MACEXP\_DFT} will therefore not show up if the directive \tty{EXPIF}
  6348. had been given specifically for this macro.
  6349.  
  6350. There might be cases where it is useful to override the expansion rules for
  6351. a certain macro, regardless whether they were given by \tty{MACEXP\_DFT} or
  6352. individual directives.  The statement \tty{MACEXP\_OVR} (\ref{MACEXPOVR})
  6353. exists for such cases.  It only has an effects on macros subsequently being
  6354. {\it expanded}.  Once again, directives given by this instruction are regarded
  6355. in addition to a macro's rules, and they do with higher priority.  A \tty{MACEXP\_OVR}
  6356. without any arguments disables such an override.
  6357.  
  6358. %%- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  6359.  
  6360. \subsection{IRP}
  6361. \ttindex{IRP}
  6362.  
  6363. is a simplified macro definition for the case that an instruction sequence
  6364. shall be applied to a couple of operands and the the code is not needed
  6365. any more afterwards.  \tty{IRP} needs a symbol for the operand as its
  6366. first parameter, and an (almost) arbitrary number of parameters that are
  6367. sequentially inserted into the block of code.  For example, one can write
  6368. \begin{verbatim}
  6369.        irp     op, acc,b,dpl,dph
  6370.        push    op
  6371.        endm
  6372. \end{verbatim}
  6373. to push a couple of registers to the stack, what results in
  6374. \begin{verbatim}
  6375.        push    acc
  6376.        push    b
  6377.        push    dpl
  6378.        push    dph
  6379. \end{verbatim}
  6380. Analog to a macro definition, the argument list may contain the
  6381. control parameters \tty{GLOBALSYMBOLS} resp.
  6382. \tty{NOGLOBALSYMBOLS} (marked as such by being enclosed in curly
  6383. braces).  This allows to control whether used labels are local for
  6384. every pass or not.
  6385.  
  6386. %%- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  6387.  
  6388. \subsection{IRPC}
  6389. \ttindex{IRPC}
  6390.  
  6391. \tty{IRPC} is a variant of \tty{IRP} where the first argument's occurences
  6392. in the lines up to \tty{ENDM} are successively replaced by the characters
  6393. of a string instead of further parameters.  For example, an especially
  6394. complicated way of placing a string into memory would be:
  6395. \begin{verbatim}
  6396.        irpc    char,"Hello World"
  6397.        db      'CHAR'
  6398.        endm
  6399. \end{verbatim}
  6400. \bb{CAUTION!} As the example already shows, \tty{IRPC} only inserts the
  6401. pure character; it is the programmer's task to assure that valid code
  6402. results (in this example by inserting quotes, including the detail that no
  6403. automatic conversion to uppercase characters is done).
  6404.  
  6405. %%- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  6406.  
  6407. \subsection{REPT}
  6408. \ttindex{REPT}
  6409.  
  6410. is the simplest way to employ macro constructs.  The code between
  6411. \tty{REPT} and \tty{ENDM} is assembled as often as the integer argument of
  6412. \tty{REPT} specifies.  This statement is commonly used in small loops to
  6413. replace a programmed loop to save the loop overhead.
  6414.  
  6415. An example for the sake of completeness:
  6416. \begin{verbatim}
  6417.        rept    3
  6418.        rr      a
  6419.        endm
  6420. \end{verbatim}
  6421. rotates the accumulator to the right by three digits.
  6422.  
  6423. The optional control parameters \tty{GLOBALSYMBOLS}
  6424. resp. \tty{NOGLOBALSYMBOLS} (marked as such by being enclosed in curly
  6425. braces) may also be used here to decide whether labels are local to the
  6426. individual repetitions.
  6427.  
  6428. In case \tty{REPT}'s argument is equal to or smaller than 0, no expansion
  6429. at all is done.  This is different to older versions of \asname{} which used to
  6430. be a bit 'sloppy' in this respect and always made a single expansion.
  6431.  
  6432. %%- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  6433.  
  6434. \subsection{WHILE}
  6435. \ttindex{WHILE}
  6436.  
  6437. \tty{WHILE} operates similarly to \tty{REPT}, but the fixed number of
  6438. repetitions given as an argument is replaced by a boolean expression.  The
  6439. code framed by \tty{WHILE} and \tty{ENDM} is assembled until the
  6440. expression becomes logically false.  This may mean in the extreme case
  6441. that the enclosed code is not assembled at all in case the expression was
  6442. already false when the construct was found.  On the other hand, it may
  6443. happen that the expression stays true forever and \asname{} will run
  6444. infinitely...one should apply therefore a bit of accuracy when one uses
  6445. this construct, i.e. the code must contain a statement that influences the
  6446. condition, e.g. like this:
  6447. \begin{verbatim}
  6448. cnt     set     1
  6449. sq      set     cnt*cnt
  6450.        while   sq<=1000
  6451.         dc.l    sq
  6452. cnt      set     cnt+1
  6453. sq       set     cnt*cnt
  6454.        endm
  6455. \end{verbatim}
  6456. This example stores all square numbers up to 1000 to memory.
  6457.  
  6458. Currently there exists a little ugly detail for \tty{WHILE}: an additional
  6459. empty line that was not present in the code itself is added after the last
  6460. expansion.  This is a 'side effect' based on a weakness of the macro
  6461. processor and it is unfortunately not that easy to fix.  I hope noone
  6462. minds...
  6463.  
  6464. %%- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  6465.  
  6466. \subsection{EXITM}
  6467. \ttindex{EXITM}
  6468.  
  6469. \tty{EXITM} offers a way to terminate a macro expansion or one of the
  6470. instructions \tty{REPT, IRP,} or \tty{WHILE} prematurely.  Such an option
  6471. helps for example to replace encapsulations with \tty{IF-ENDIF}-ladders in
  6472. macros by something more readable.  Of course, an \tty{EXITM} itself
  6473. always has to be conditional, what leads us to an important detail: When
  6474. an \tty{EXITM} is executed, the stack of open \tty{IF} and
  6475. \tty{SWITCH} constructs is reset to the state it had just before the macro
  6476. expansion started.  This is imperative for conditional \tty{EXITM}'s as
  6477. the \tty{ENDIF} resp. \tty{ENDCASE} that frames the \tty{EXITM} statement
  6478. will not be reached any more; \asname{} would print an error message without this
  6479. trick.  Please keep also in mind that \tty{EXITM} always only terminates
  6480. the innermost construct if macro constructs are nested!  If one want to
  6481. completely break out of a nested construct, one has to use additional
  6482. \tty{EXITM}'s on the higher levels!
  6483.  
  6484. %%- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  6485.  
  6486. \subsection{SHIFT}
  6487. \ttindex{SHIFT}\ttindex{.SHIFT}\ttindex{SHFT}
  6488.  
  6489. {\tt SHIFT} is a tool to construct macros with variable argument lists: it
  6490. discards the first parameter, with the result that the second parameter
  6491. takes its place and so on.  This way one could process a variable argument
  6492. list...if you do it the right way.  For example, the following does not
  6493. work...
  6494. \begin{verbatim}
  6495. pushlist  macro reg
  6496.          rept  ARGCOUNT
  6497.          push  reg
  6498.          shift
  6499.          endm
  6500.          endm
  6501. \end{verbatim}
  6502. ...because the macro gets expanded {\tt once}, its output is captured by
  6503. {\tt REPT} and then executed n times.  Therefore, the first argument is
  6504. saved n times...the following approach works better:
  6505. \begin{verbatim}
  6506. pushlist  macro reg
  6507.          if      "REG"<>""
  6508.           push    reg
  6509.           shift
  6510.           pushlist ALLARGS
  6511.          endif
  6512.          endm
  6513. \end{verbatim}
  6514. Effectively, this is a recursion that shortens the argument list once per
  6515. step.  The important trick is that a new macro expansion is started in
  6516. each step...
  6517.  
  6518. In case {\tt SHIFT} ist already a machine instruction for a certain target,
  6519. {\tt SHFT} may be used instead, or the pseudo instruction is referenced
  6520. explicitly by prepending a period (\tty{.SHIFT} instead of \tty{SHIFT}).
  6521.  
  6522. %%- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  6523.  
  6524. \subsection{MAXNEST}
  6525. \ttindex{MAXNEST}
  6526.  
  6527. {\tt MAXNEST} allows to adjust how often a mcro may be called recursively
  6528. before \asname{} terminates with an error message.  The argument may be an
  6529. arbitrary positive integer value, with the special value 0 turning the
  6530. this security brake completely off (be careful with that...).  The default
  6531. value for the maximum nesting level is 256; its current value may be read
  6532. from the integer symbol of same name.
  6533.  
  6534. %%- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  6535.  
  6536. \subsection{FUNCTION}
  6537. \label{SectFUNCTION}
  6538. \ttindex{FUNCTION}
  6539.  
  6540. Though \tty{FUNCTION} is not a macro statement in the inner sense, I will
  6541. describe this instruction at this place because it uses similar principles
  6542. like macro replacements.
  6543.  
  6544. This instruction is used to define new functions that may then be
  6545. used in formula expressions like predefined functions.  The
  6546. definition must have the following form:
  6547. \begin{verbatim}
  6548. <name>  FUNCTION <arg>,..,<arg>,<expression>
  6549. \end{verbatim}
  6550. The arguments are the values that are 'fed into' the function.  The
  6551. definition uses symbolic names for the arguments.  The assembler
  6552. knows by this that where to insert the actual values when the
  6553. function is called.  This can be seen from the following example:
  6554. \begin{verbatim}
  6555. isdigit FUNCTION ch,(ch>='0')&&(ch<='9')
  6556. \end{verbatim}
  6557. This function checks whether the argument (interpreted as a character) is
  6558. a number in the currently valid character set (the character set can be
  6559. modified via \tty{CHARSET}, therefore the careful wording).
  6560.  
  6561. The arguments' names (\tty{CH} in this case) must conform to the stricter
  6562. rules for macro parameter names, i.e. the special characters . and \_
  6563. are not allowed.
  6564.  
  6565. User-defined functions can be used in the same way as builtin
  6566. functions, i.e. with a list of parameters, separated by commas,
  6567. enclosed in parentheses:
  6568. \begin{verbatim}
  6569.        IF isdigit(char)
  6570.         message "\{char} is a number"
  6571.        ELSEIF
  6572.         message "\{char} is not a number"
  6573.        ENDIF
  6574. \end{verbatim}
  6575. When the function is called, all parameters are calculated once and
  6576. are then inserted into the function's formula.  This is done to
  6577. reduce calculation overhead and to avoid side effects.  The
  6578. individual arguments have to be separated by commas when a function
  6579. has more than one parameter.
  6580.  
  6581. \bb{CAUTION!}  Similar to macros, one can use user-defined functions to
  6582. override builtin functions.  This is a possible source for phase
  6583. errors.  Such definitions therefore should be done before the first
  6584. call!
  6585.  
  6586. The result's type may depend on the type of the input arguments as
  6587. the arguments are textually inserted into the function's formula.
  6588. For example, the function
  6589. \begin{verbatim}
  6590. double  function x,x+x
  6591. \end{verbatim}
  6592. may have an integer, a float, or even a string as result, depending
  6593. on the argument's type!
  6594.  
  6595. When \asname{} operates in case-sensitive mode, the case matters when
  6596. defining or referencing user-defined functions, in contrast to
  6597. builtin functions!
  6598.  
  6599. %%---------------------------------------------------------------------------
  6600.  
  6601. \section{Structures}
  6602. \ttindex{STRUCT}\ttindex{ENDSTRUCT}\ttindex{UNION}\ttindex{ENDUNION}
  6603. \ttindex{STRUC}\ttindex{ENDSTRUC}\ttindex{ENDS}
  6604. \ttindex{DOTTEDSTRUCTS}
  6605.  
  6606. {\em valid for: all processors}
  6607.  
  6608. Even in assembly language programs, there is sometimes the necessity to
  6609. define composed data structures, similar to high-level languages.  \asname{}
  6610. supports both the definition and usage of structures with a couple of
  6611. statements.  These statements shall be explained in the following section.
  6612.  
  6613. \subsection{Definition}
  6614.  
  6615. The definiton of a structure is begun with the statement
  6616. \tty{STRUCT} and ends with \tty{ENDSTRUCT} (lazy people may also
  6617. write {\tt STRUC} resp.  {\tt ENDSTRUC} or {\tt ENDS} instead).
  6618. A optional label preceding these instructions is taken as the
  6619. name of the structure to be defined; it is optional at the end of
  6620. the definition and may be used to redefine the length symbol's
  6621. name (see below).  The remaining procedure is simple: Together
  6622. with \tty{STRUCT}, the cuurent program counter is saved and reset
  6623. to zero.  All labels defined between \tty{STRUCT} and
  6624. \tty{ENDSTRUCT} therefore are the offsets of the structure's data
  6625. fields.  Reserving space is done via the same instructions that
  6626. are also otherwise used for reserving space, like e.g.
  6627. \tty{DS.x} for Motorola CPUs or \tty{DB} \& co.  for Intel-style
  6628. processors.  The rules for rounding up lengths to assure certain
  6629. alignments also apply here - if one wants to define 'packed'
  6630. structures, a preceding {\tt PADDING OFF} may be necessary.  Vice
  6631. versa, alignments may be forced with {\tt ALIGN} or similar
  6632. instructions.
  6633.  
  6634. Since such a definition only represents a sort of 'prototype', only
  6635. instructions that reserve memory may be used, no instructions that dispose
  6636. constants or generate code.
  6637.  
  6638. Labels defined inside structures (i.e. the elements' names) are not
  6639. stored as-is.  Instead, the structure's name is prepended to them,
  6640. separated with a special character.  By default, this is the underbar
  6641. (\_).  This behaviour however may be modified with two arguments passed
  6642. to the
  6643. \tty{STRUCT} statement:
  6644. \begin{itemize}
  6645. \item{\tty{NOEXTNAMES} suppressed the prepending of the structure's name.
  6646.      In this case, it is the programmer's responsibility to assure that
  6647.      field names are not used more than once.}
  6648. \item{\tty{DOTS} instructs \asname{} to use the dot as connecting character
  6649.      instead of the underbar.  It should however be pointed out that
  6650.      on certain target architectures, the dot has a special meaning
  6651.      for bit addressing, which may lead to problems!}
  6652. \end{itemize}
  6653. It is futhermore possible to turn the usage of a dot on resp. off for all
  6654. following structures:
  6655. \begin{verbatim}
  6656.        dottedstructs <on|off>
  6657. \end{verbatim}
  6658.  
  6659. Aside from the element names, \asname{} also defines a further symbol with the
  6660. structure's overall length when the definition has been finished.  This
  6661. symbol has the name {\tt LEN}, which is being extended with the
  6662. structure's name via the same rules - or alternitavely with the label name
  6663. given with the \tty{ENDSTRUCT} statement.
  6664.  
  6665. In practice, this may things may look like in this example:
  6666. \begin{verbatim}
  6667. Rec     STRUCT
  6668. Ident   db      ?
  6669. Pad     db      ?
  6670. Pointer dd      ?
  6671. Rec     ENDSTRUCT
  6672. \end{verbatim}
  6673. In this example, the symbol {\tt REC\_LEN} would be assigned the value 6.
  6674.  
  6675. \subsection{Usage}
  6676.  
  6677. Once a structure has been assigned, usage is as simple as possible and
  6678. similar to a macro: a simple
  6679. \begin{verbatim}
  6680. thisrec Rec
  6681. \end{verbatim}
  6682. reserves as much memory as needed to hold an instance of the structure,
  6683. and additionally defines a symbol for every element of the structure with
  6684. its address, in this case {\tt THISREC\_IDENT, THISREC\_PAD}, and {\tt
  6685. THISREC\_POINTER}.  A label naturally must not be omitted when calling a
  6686. structure; if it is missing, an error will be emitted.
  6687.  
  6688. Additional arguments allow to reserve memory for a whole array of structures.
  6689. The dimensions (up to three) are defined via arguments in square brackets:
  6690. \begin{verbatim}
  6691. thisarray Rec [10],[2]
  6692. \end{verbatim}
  6693. In this example, space for $2*10=20$ structures is reserved. For each individual
  6694. structure in the array, proper symbols are generated that have the array
  6695. indices in their name.
  6696.  
  6697. \subsection{Nested Structures}
  6698.  
  6699. Is is perfectly valid to call an already defined structure within the
  6700. definition of another structure.  The procedure that is taking place then
  6701. is a combination of the definition and calling described in the previous
  6702. two sections: elements of the substructure are being defined, the name of
  6703. the instance is being prepended, and the name of the super-structure is
  6704. once again geing prepended to this concatenated name.  This may look like
  6705. the following:
  6706. \begin{verbatim}
  6707. TreeRec struct
  6708. left    dd         ?
  6709. right   dd         ?
  6710. data    Rec
  6711. TreeRec endstruct
  6712. \end{verbatim}
  6713.  
  6714. It is also allowed to define one structure inside of another
  6715. structure:
  6716. \begin{verbatim}
  6717. TreeRec struct
  6718. left    dd         ?
  6719. right   dd         ?
  6720. TreeData struct
  6721. name      db         32 dup(?)
  6722. id        dw         ?
  6723. TreeData endstruct
  6724. TreeRec endstruct
  6725. \end{verbatim}
  6726.  
  6727. \subsection{Unions}
  6728.  
  6729. A union is a special form of a structure whose elements are not laid out
  6730. sequentially in memory.  Instead all elements occupy the {\em same}
  6731. memory and are located at offset 0 in the structure.  Naturally, such a
  6732. definition basically does nothing more than to assign the value of zero to
  6733. a couple of symbols.  It may however be useful to clarify the overlap in a
  6734. program and therefore to make it more 'readable'.  The size of a union is
  6735. the maximum of all elements' lengths.
  6736.  
  6737. \subsection{Nameless Structures}
  6738.  
  6739. The name of a structure or union is optional if it is part of
  6740. another (named) structure or union.  Elements of this structure
  6741. will then become part of of the 'next higher' named structure.
  6742. For example,
  6743. \begin{verbatim}
  6744. TreeRec struct
  6745. left    dd         ?
  6746. right   dd         ?
  6747.        struct
  6748. name      db         32 dup(?)
  6749. id        dw         ?
  6750.        endstruct
  6751. TreeRec endstruct
  6752. \end{verbatim}
  6753. generates the symbols {\tt TREEREC\_NAME} and {\tt TREEREC\_ID}.
  6754.  
  6755. Futhermore, no symbol holding its length is generated for an
  6756. unnamed structure or union.
  6757.  
  6758. \subsection{Structures and Sections}
  6759.  
  6760. Symbols that are created in the course of defining or usage of structures
  6761. are treated just like normal symbols, i.e. when used within a section,
  6762. these symbols are local to the section.  The same is however also true for
  6763. the structures themselves, i.e. a structure defined within a section
  6764. cannot be used outside of the section.
  6765.  
  6766. \subsection{Structures and Macros}
  6767.  
  6768. If one wants to instantiate structures via macros, one has to use
  6769. the \tty{GLOBALSYMBOLS} options when defining the macro to make
  6770. the defined symbols visible outside the macro.  For instance, a
  6771. list of structures can be defined in the following way:
  6772.  
  6773. \begin{verbatim}
  6774.        irp     name,{GLOBALSYMBOLS},rec1,rec2,rec3
  6775. name    Rec
  6776.        endm
  6777. \end{verbatim}
  6778.  
  6779. %%---------------------------------------------------------------------------
  6780.  
  6781. \section{Conditional Assembly}
  6782.  
  6783. {\em valid for: all processors}
  6784.  
  6785. The assembler supports conditional assembly with the help of statements
  6786. like \tty{IF...} resp. \tty{SWITCH...} .  These statements work at
  6787. assembly time allowing or disallowing the assembly of program parts based
  6788. on conditions.  They are therefore not to be compared with IF statements
  6789. of high-level languages (though it would be tempting to extend assembly
  6790. language with structurization statements of higher level languages...).
  6791.  
  6792. The following constructs may be nested arbitrarily (until a memory
  6793. overflow occurs).
  6794.  
  6795. %%- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  6796.  
  6797. \subsection{IF / ELSEIF / ENDIF}
  6798. \ttindex{IF}
  6799. \ttindex{ENDIF}
  6800. \ttindex{ELSEIF}\ttindex{ELSE}
  6801.  
  6802. \tty{IF} is the most common and most versatile construct.  The general
  6803. style of an \tty{IF} statement is as follows:
  6804. \begin{verbatim}
  6805.        IF      <expression 1>
  6806.        .
  6807.        .
  6808.        <block 1>
  6809.        .
  6810.        .
  6811.        ELSEIF  <expression 2>
  6812.        .
  6813.        .
  6814.        <block 2>
  6815.        .
  6816.        .
  6817.        (possibly more ELSEIFs)
  6818.  
  6819.        .
  6820.        .
  6821.        ELSEIF
  6822.        .
  6823.        .
  6824.        <block n>
  6825.        .
  6826.        .
  6827.        ENDIF
  6828. \end{verbatim}
  6829. \tty{IF} serves as an entry, evaluates the first expression, and assembles
  6830. block 1 if the expression is true (i.e. not 0).  All further
  6831. \tty{ELSEIF}-blocks will then be skipped.  However, if the expression is
  6832. false, block 1 will be skipped and expression 2 is evaluated.  If this
  6833. expression turns out to be true, block 2 is assembled.  The number of
  6834. \tty{ELSEIF} parts is variable and results in an \tty{IF-THEN-ELSE} ladder
  6835. of an arbitrary length.  The block assigned to the last \tty{ELSEIF}
  6836. (without argument) only gets assembled if all previous expressions
  6837. evaluated to false; it therefore forms a 'default' branch.  It is
  6838. important to note that only \bb{one} of the blocks will be assembled: the
  6839. first one whose \tty{IF/ELSEIF} had a true expression as argument.
  6840.  
  6841. The \tty{ELSEIF} parts are optional, i.e. \tty{IF} may directly be
  6842. followed by an \tty{ENDIF}.  An \tty{ELSEIF} without parameters must be
  6843. the last branch.
  6844.  
  6845. \tty{ELSEIF} always refers to the innermost, unfinished \tty{IF} construct
  6846. in case \tty{IF}'s are nested.
  6847.  
  6848. \ttindex{IFDEF}\ttindex{IFNDEF}\ttindex{IFUSED}\ttindex{IFNUSED}
  6849. \ttindex{IFEXIST}\ttindex{IFNEXIST}\ttindex{IFB}\ttindex{IFNB}
  6850. In addition to \tty{IF}, the following further conditional statements are
  6851. defined:
  6852. \begin{itemize}
  6853. \item{\tty{IFDEF $<$symbol$>$}: true if the given symbol has been defined.
  6854.      The definition has to appear before \tty{IFDEF}.}
  6855. \item{\tty{IFNDEF $<$symbol$>$}: counterpart to \tty{IFDEF}.}
  6856. \item{\tty{IFUSED $<$symbol$>$}: true if if the given symbol has been
  6857.      referenced at least once up to now.}
  6858. \item{\tty{IFNUSED $<$symbol$>$}: counterpart to \tty{IFUSED}.}
  6859. \item{\tty{IFEXIST $<$name$>$}: true if the given file exists.  The same
  6860.           rules for search paths and syntax apply as for the
  6861.           \tty{INCLUDE} instruction (see section \ref{SectInclude}).}
  6862. \item{\tty{IFNEXIST $<$name$>$}: counterpart to \tty{IFEXIST}.}
  6863. \item{\tty{IFB $<$arg-list$>$}: true if all arguments of the parameter
  6864.           list are empty strings.}
  6865. \item{\tty{IFNB $<$arg-list$>$}: counterpart to \tty{IFB}.}
  6866. \end{itemize}
  6867.  
  6868. It is valid to write {\tt ELSE} instead of {\tt ELSEIF} since everybody
  6869. seems to be used to it...
  6870.  
  6871. For every {IF...} statement, there has to be a corresponding {\tt ENDIF}.
  6872. 'Open' constructs will lead to an error message at the end of an assembly
  6873. path.  The way \asname{} has 'paired' {\tt ENDIF} statements with {\tt IF}s may
  6874. be deduced from the assembly listing: for {\tt ENDIF}, the line number of
  6875. the corresponding {\tt IF...} will be shown.
  6876.  
  6877. %%- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  6878.  
  6879. \subsection{SWITCH / CASE / ELSECASE / ENDCASE}
  6880. \ttindex{SWITCH}\ttindex{.SWITCH}\ttindex{SELECT}
  6881. \ttindex{CASE}\ttindex{ELSECASE}\ttindex{ENDCASE}
  6882.  
  6883. \tty{CASE} is a special case of \tty{IF} and is designed for situations
  6884. when an expression has to be compared with a couple of values.  This could
  6885. of course also be done with a series of \tty{ELSEIF}s, but the following
  6886. form
  6887. \begin{verbatim}
  6888.        SWITCH  <expression>
  6889.        .
  6890.        .
  6891.        CASE    <value 1>
  6892.        .
  6893.        <block 1>
  6894.        .
  6895.        CASE    <value 2>
  6896.        .
  6897.        <block 2>
  6898.        .
  6899.        (further CASE blocks)
  6900.        .
  6901.        CASE    <value n-1>
  6902.        .
  6903.        <block n-1>
  6904.        .
  6905.        ELSECASE
  6906.        .
  6907.        <block n>
  6908.        .
  6909.        ENDCASE
  6910. \end{verbatim}
  6911. has the advantage that the expression is only written once and also only
  6912. gets evaluated once.  It is therefore less error-prone and slightly faster
  6913. than an \tty{IF} chain, but obviously not as flexible.
  6914.  
  6915. It is possible to specify multiple values separated by commas to a
  6916. \tty{CASE} statement in order to assemble the following block in multiple
  6917. cases.  The \tty{ELSECASE} branch again serves as a 'trap' for the case
  6918. that none of the \tty{CASE} conditions was met.  \asname{} will issue a warning
  6919. in case it is missing and all comparisons fail.
  6920.  
  6921. Even when value lists of \tty{CASE} branches overlap, only \bb{one} branch
  6922. is executed, which is the first one in case of ambiguities.
  6923.  
  6924. \tty{SWITCH} only serves to open the whole construct; an arbitrary number
  6925. of statements may be between \tty{SWITCH} and the first \tty{CASE} (but
  6926. don't leave other \tty{IF}s open!), for the sake of better readability
  6927. this should however not be done.
  6928.  
  6929. In case that \tty{SWITCH} is already a machine instruction on the
  6930. selected processor target, the  construct may be openend via \tty{SELECT},
  6931. or by a leading period to explicitly invoke the pseudo instruction
  6932. (\tty{.SWITCH} instead of \tty{SWITCH}).
  6933.  
  6934. Similarly to {\tt IF} constructs, there must be exactly one {\tt ENDCASE}
  6935. for every {\tt SWITCH}.  Analogous to {\tt ENDIF}, for {\tt ENDCASE} the
  6936. line number of the corresponding {\tt SWITCH} is shown in the listing.
  6937.  
  6938. %%---------------------------------------------------------------------------
  6939.  
  6940. \section{Listing Control}
  6941.  
  6942. {\em valid for: all processors}
  6943.  
  6944. %%- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  6945.  
  6946. \subsection{PAGE, PAGESIZE}
  6947. \label{SectPAGE}
  6948. \ttindex{PAGE}\ttindex{.PAGE}\ttindex{PAGESIZE}
  6949.  
  6950. \tty{PAGE} is used to tell \asname{} the dimensions of the paper that is used to
  6951. print the assembly listing.  The first parameter is thereby the
  6952. number of lines after which \asname{} shall automatically output a form
  6953. feed.  One should however take into account that this value does \bb{not}
  6954. include heading lines including an eventual line specified with
  6955. \tty{TITLE}.  The minimum number of lines is 5, and the maximum value is
  6956. 255.  A specification of 0 has the result that \asname{} will not do any form
  6957. feeds except those triggered by a \tty{NEWPAGE} instruction or those
  6958. implicitly engaged at the end of the assembly listing (e.g. prior to the
  6959. symbol table).
  6960.  
  6961. The specification of the listing's length in characters is an
  6962. optional second parameter and serves two purposes: on the one hand,
  6963. the internal line counter of \asname{} will continue to run correctly when a
  6964. source line has to be split into several listing lines, and on
  6965. the other hand there are printers (like some laser printers) that do
  6966. not automatically wrap into a new line at line end but instead simply
  6967. discard the rest.  For this reason, \asname{} does line breaks by itself,
  6968. i.e. lines that are too long are split into chunks whose lengths are
  6969. equal to or smaller than the specified width.  This may lead to
  6970. double line feeds on printers that can do line wraps on their own if
  6971. one specifies the exact line width as listing width.  The solution
  6972. for such a case is to reduce the assembly listing's width by 1.  The
  6973. specified line width may lie between 5 and 255 characters; a line
  6974. width of 0 means similarly to the page length that \asname{} shall not do
  6975. any splitting of listing lines; lines that are too long of course
  6976. cannot be taken into account of the form feed then any more.
  6977.  
  6978. The default setting for the page length is 60 lines, the default for the
  6979. line width is 0; the latter value is also assumed when \tty{PAGE} is
  6980. called with only one parameter.
  6981.  
  6982. In case \tty{PAGE} is already a machine instruction on the
  6983. selected processor target, use instead \tty{PAGESIZE} to define
  6984. the paper size.  As an alternative, it is always possible to explicitly
  6985. invoke the pseudo instruction by prepending a period (\tty{.PAGE} instead
  6986. of \tty{PAGE}).
  6987.  
  6988. \bb{CAUTION!}  There is no way for \asname{} to check whether the specified
  6989. listing length and width correspond to the reality!
  6990.  
  6991. %%- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  6992.  
  6993. \subsection{NEWPAGE}
  6994. \ttindex{NEWPAGE}
  6995.  
  6996. \tty{NEWPAGE} can be used to force a line feed though the current line is
  6997. not full up to now.  This might be useful to separate program parts
  6998. in the listing that are logically different.  The internal line
  6999. counter is reset and the page counter is incremented by one.  The
  7000. optional parameter is in conjunction with a hierarchical page
  7001. numbering \asname{} supports up to a chapter depth of 4.  0 always refers to
  7002. the lowest depth, and the maximum value may vary during the assembly
  7003. run.  This may look a bit puzzling, as the following example shows:
  7004. \begin{quote}\begin{tabbing}
  7005. \hspace{2.5cm} \= \hspace{4.5cm} \= \kill
  7006. page 1,   \> instruction \tty{NEWPAGE 0} \>  $\rightarrow$ page 2 \\
  7007. page 2,   \> instruction \tty{NEWPAGE 1} \>  $\rightarrow$ page 2.1 \\
  7008. page 2.1, \> instruction \tty{NEWPAGE 1} \>  $\rightarrow$ page 3.1 \\
  7009. page 3.1, \> instruction \tty{NEWPAGE 0} \>  $\rightarrow$ page 3.2 \\
  7010. page 3.2, \> instruction \tty{NEWPAGE 2} \>  $\rightarrow$ page 4.1.1 \\
  7011. \end{tabbing}\end{quote}
  7012. \tty{NEWPAGE $<$number$>$} may therefore result in
  7013. changes in different digits, depending on the current chapter depth.  An
  7014. automatic form feed due to a line counter overflow or a \tty{NEWPAGE}
  7015. without parameter is equal to \tty{NEWPAGE 0}.  Previous to the output of
  7016. the symbol table, an implicit \tty{NEWPAGE $<$maximum up to now$>$} is
  7017. done to start a new 'main chapter'.
  7018.  
  7019. %%- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  7020.  
  7021. \subsection{MACEXP\_DFT and MACEXP\_OVR}
  7022. \ttindex{MACEXP}
  7023. \ttindex{MACEXP\_DFT}
  7024. \ttindex{MACEXP\_OVR}
  7025. \label{MACEXPDFT}
  7026. \label{MACEXPOVR}
  7027.  
  7028. Once a macro is tested and 'done', one might not want to see it
  7029. in the listing when it is used.  As described in the section about
  7030. defining and using macros (\ref{SectMacros}), additional arguments to
  7031. the \tty{MACRO} statement allow to control whether a macro's body is
  7032. expanded upon its usage and if yes, which parts of it.  In case that
  7033. several macros are defined in a row, it is not necessary to give
  7034. these directives for every single macro.  The pseudo instruction
  7035. \tty{MACEXP\_DFT} defines for all following macros which parts shall
  7036. be expanded upon invocation of the macro:
  7037. \begin{itemize}
  7038. \item{\tty{ON} resp. \tty{OFF} enable or disable expansion
  7039.      completely.}
  7040. \item{The arguments \tty{IF} resp. \tty{NOIF} enable or disable
  7041.      expansion of instructions for conditional assembly, plus
  7042.      the expansion of code parts the were excluded because of
  7043.      conditional assembly.}
  7044. \item{Macro definitions (which includes \tty{REPT}, \tty{WHILE}
  7045.      and \tty{IRP(C)}) may be excluded from or included in the
  7046.      expanded parts via the arguments \tty{MACRO} resp.
  7047.      \tty{NOMACRO}.}
  7048. \item{All other lines not fitting into the first two categories
  7049.      may be excluded from or included in the expanded parts via
  7050.      the arguments \tty{REST} resp. \tty{NOREST}.}
  7051. \end{itemize}
  7052. The default is \tty{ON}, i.e. defined macros will be expanded
  7053. completely, of course unless specific expansion arguments were given
  7054. to individual macros.  Furthermore, arguments given to
  7055. \tty{MACEXP\_DFT} work relative to the current setting: for instance,
  7056. if expansion is turned on completely initially, the statement
  7057. \begin{verbatim}
  7058.         MACEXP_DFT  noif,nomacro
  7059. \end{verbatim}
  7060. has the result that for macros defined in succession, only code parts
  7061. that are no macro definition and that are not excluded via
  7062. conditional assembly will be listed.
  7063. \par
  7064. This instruction plus the per-macro directives provide fine-grained
  7065. per-macro over the parts being expanded.  However, there may be cases
  7066. in practice where one wants to see the expanded code of a macro at
  7067. one place and not at the other.  This is possible by using the
  7068. statement \tty{MACEXP\_OVR}: it accepts the same arguemnts like
  7069. \tty{MACEXP\_DFT}, these however act as overrides for all macros being
  7070. {\em expanded} in the following code.  This is in contrast to
  7071. \tty{MACEXP\_DFT} which influences macros being {\em defined} in the
  7072. following code.  For instance, if one defined for a macro that
  7073. neither macro definitions nor conditional assembly shall be expanded
  7074. in the listing, a
  7075. \begin{verbatim}
  7076.         MACEXP_OVR  MACRO
  7077. \end{verbatim}
  7078. re-enables expansion of macro definitions for its following usages,
  7079. while a
  7080. \begin{verbatim}
  7081.         MACEXP_OVR  ON
  7082. \end{verbatim}
  7083. forces expansion of the complete macro body in the listing.
  7084. \tty{MACEXP\_OVR} without arguments again disables all overrides,
  7085. macros will again behave as individually specified upon definition.
  7086. \par
  7087. Both statements also have an effect on other macro-like constructs
  7088. (\tty{REPT, IRP, IRPC WHILE}).  However, since these are expanded
  7089. only one and ,,in-place'', the functional difference of these two
  7090. statements becomes minimal.  In case of differences, the override set
  7091. via \tty{MACEXP\_OVR} has a higher priority.
  7092.  
  7093. The Setting currently made via \tty{MACEXP\_DFT} may be read from the
  7094. predefined symbol \tty{MACEXP}.  For backward compatibility reasons,
  7095. it is possible to use the statement \tty{MACEXP} instead of
  7096. \tty{MACEXP\_DFT}.  However, one should not make use of this in new
  7097. programs.
  7098.  
  7099. %%- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  7100.  
  7101. \subsection{LISTING}
  7102. \ttindex{LISTING}
  7103.  
  7104. works like \tty{MACEXP} and accepts the same parameters, but is much more
  7105. radical: After a
  7106. \begin{verbatim}
  7107.        listing off   ,
  7108. \end{verbatim}
  7109. nothing at all will be written to the listing.  This directive makes sense
  7110. for tested code parts or include files to avoid a paper consumption going
  7111. beyond all bounds.  \bb{CAUTION!} If one forgets to issue the counterpart
  7112. somewhere later, even the symbol table will not be written any more!  In
  7113. addition to \tty{ON} and \tty{OFF}, \tty{LISTING} also accepts
  7114. \tty{NOSKIPPED} and \tty{PURECODE} as arguments.  Program parts that were
  7115. not assembled due to conditional assembly will not be written to the
  7116. listing when \tty{NOSKIPPED} is set, while \tty{PURECODE} - as the name
  7117. indicates - even suppresses the \tty{IF} directives themselves in the
  7118. listing.  These options are useful if one uses macros that act differently
  7119. depending on parameters and one only wants to see the used parts in the
  7120. listing.
  7121.  
  7122. The current setting may be read from the symbol \tty{LISTING} (0=\tty{OFF},
  7123. 1=\tty{ON}, 2=\tty{NOSKIPPED}, 3=\tty{PURECODE}).
  7124.  
  7125. %%- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  7126.  
  7127. \subsection{PRTINIT and PRTEXIT}
  7128. \ttindex{PRTINIT}\ttindex{PRTEXIT}
  7129.  
  7130. Quite often it makes sense to switch to another printing mode (like
  7131. compressed printing) when the listing is sent to a printer and to
  7132. deactivate this mode again at the end of the listing.  The output of
  7133. the needed control sequences can be automated with these instructions
  7134. if one specifies the sequence that shall be sent to the output device
  7135. prior to the listing with \tty{PRTINIT $<$string$>$} and similarly the
  7136. deinitialization string with \tty{PRTEXIT $<$string$>$}.
  7137. \tty{$<$string$>$} has to be a string expression in both cases.  The syntax
  7138. rules for string constants allow to insert control characters into the
  7139. string without too much tweaking.
  7140.  
  7141. When writing the listing, the assembler does \bb{not} differentiate where
  7142. the listing actually goes, i.e. printer control characters are sent to the
  7143. screen without mercy!
  7144.  
  7145. Example:
  7146.  
  7147. For Epson printers, it makes sense to switch them to compressed
  7148. printing because listings are so wide.  The lines
  7149. \begin{verbatim}
  7150.        prtinit "\15"
  7151.        prtexit "\18"
  7152. \end{verbatim}
  7153. assure that the compressed mode is turned on at the beginning of the
  7154. listing and turned off afterwards.
  7155.  
  7156. %%- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  7157.  
  7158. \subsection{TITLE}
  7159. \ttindex{TITLE}
  7160.  
  7161. The assembler normally adds a header line to each page of the listing
  7162. that contains the source file's name, date, and time.  This
  7163. statement allows to extend the page header by an arbitrary additional
  7164. line.  The string that has to be specified is an arbitrary string
  7165. expression.
  7166.  
  7167. Example:
  7168.  
  7169. For the Epson printer already mentioned above, a title line shall be
  7170. written in wide mode, which makes it necessary to turn off the
  7171. compressed mode before:
  7172. \begin{verbatim}
  7173.        title   "\18\14Wide Title\15"
  7174. \end{verbatim}
  7175. (Epson printers automatically turn off the wide mode at the end of a
  7176. line.)
  7177.  
  7178. %%- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  7179.  
  7180. \subsection{RADIX}
  7181. \ttindex{RADIX}
  7182. \ttindex{DECIMAL}
  7183. \ttindex{OCTAL}
  7184.  
  7185. \tty{RADIX} with a numerical argument between 2 and 36 sets the default
  7186. numbering system for integer constants, i.e. the numbering system used if
  7187. nothing else has been stated explicitly.  The default is 10, and there are
  7188. some possible pitfalls to keep in mind which are described in section
  7189. \ref{SectIntConsts}.
  7190.  
  7191. Independent of the current setting, the argument of {\tt RADIX} is {\em
  7192. always decimal}; furthermore, no symbolic or formula expressions may be
  7193. used as argument. Only use simple constant numbers!
  7194.  
  7195. If the IM61x0 is the current target, the instructions \tty{DECIMAL} and
  7196. \tty{OCTAL} are available as shortforms for \tty{RADIX 10} respectively
  7197. \tty{RADIX 8}.
  7198.  
  7199. %%- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  7200.  
  7201. \subsection{OUTRADIX}
  7202. \ttindex{OUTRADIX}
  7203.  
  7204. \tty{OUTRADIX} can in a certain way be regarded as the opposite to
  7205. \tty{RADIX}: This statement allows to configure which numbering system to
  7206. use for integer results when \verb!\{...}! constructs are used in string
  7207. constants (see section \ref{SectStringConsts}).  Valid arguments range
  7208. again from 2 to 36, while the default is 16.
  7209.  
  7210. %%---------------------------------------------------------------------------
  7211.  
  7212. \section{Local Symbols}
  7213. \label{ChapLocSyms}
  7214.  
  7215. {\em valid for: all processors}
  7216.  
  7217. local symbols and the section concept introduced with them are a
  7218. completely new function that was introduced with version 1.39.  One
  7219. could say that this part is version ''1.0'' and therefore probably not
  7220. the optimum.  Ideas and (constructive) criticism are therefore
  7221. especially wanted.  I admittedly described the usage of sections how
  7222. I imagined it.  It is therefore possible that the reality is not
  7223. entirely equal to the model in my head.  I promise that in case of
  7224. discrepancies, changes will occur that the reality gets adapted to
  7225. the documentation and not vice versa (I was told that the latter
  7226. sometimes takes place in larger companies...).
  7227.  
  7228. \asname{} does not generate linkable code (and this will probably not change
  7229. in the near future \tty{:-(}).  This fact forces one to always assemble a
  7230. program in a whole.  In contrast to this technique, a separation into
  7231. linkable modules would have several advantages:
  7232. \begin{itemize}
  7233. \item{shorter assembly times as only the modified modules have to be
  7234.      reassembled;}
  7235. \item{the option to set up defined interfaces among modules by definition
  7236.      of private and public symbols;}
  7237. \item{the smaller length of the individual modules reduces the number of
  7238.      symbols per module and therefore allows to use shorter symbol names
  7239.      that are still unique.}
  7240. \end{itemize}
  7241. Especially the last item was something that always nagged me: once
  7242. there was a label's name defined at the beginning of a 2000-lines
  7243. program, there was no way to reuse it somehow - even not at the
  7244. file's other end where routines with a completely different context
  7245. were placed.  I was forced to use concatenated names in the style of
  7246. \begin{verbatim}
  7247.   <subprogram name>_<symbol name>
  7248. \end{verbatim}
  7249. that had lengths ranging from 15 to 25 characters and made the
  7250. program difficult to overlook.  The concept of section described in
  7251. detail in the following text was designed to cure at least the second
  7252. and third item of the list above.  It is completely optional: if you
  7253. do not want to use sections, simply forget them and continue to work
  7254. like you did with previous versions of \asname{}.
  7255.  
  7256. %%- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  7257.  
  7258. \subsection{Basic Definition (SECTION/ENDSECTION)}
  7259. \ttindex{SECTION}\ttindex{ENDSECTION}
  7260.  
  7261. A section represents a part of the assembler program enclosed by
  7262. special statements and has a unique name chosen by the programmer:
  7263. \begin{verbatim}
  7264.        .
  7265.        .
  7266.        <other code>
  7267.        .
  7268.        .
  7269.        SECTION <section's name>
  7270.        .
  7271.        .
  7272.        <code inside of the section>
  7273.        .
  7274.        .
  7275.        ENDSECTION [section's name]
  7276.        .
  7277.        .
  7278.        <other code>
  7279.        .
  7280.        .
  7281. \end{verbatim}
  7282. The name of a section must conform to the conventions for s symbol
  7283. name; \asname{} stores section and symbol names in separate tables which is
  7284. the reason why a name may be used for a symbol and a section at the
  7285. same time.  Section names must be unique in a sense that there must
  7286. not be more than one section on the same level with the same name (I
  7287. will explain in the next part what ''levels'' mean).  The argument of
  7288. \tty{ENDSECTION} is optional, it may also be omitted; if it is omitted, \asname{}
  7289. will show the section's name that has been closed with this
  7290. \tty{ENDSECTION}.  Code inside a section will be processed by \asname{} exactly
  7291. as if it were outside, except for three decisive differences:
  7292. \begin{itemize}
  7293. \item{Symbols defined within a section additionally get an internally
  7294.      generated number that corresponds to the section.  These symbols
  7295.      are not accessible by code outside the section (this can be
  7296.      changed by pseudo instructions, later more about this).}
  7297. \item{The additional attribute allows to define symbols of the same
  7298.      name inside and outside the section; the attribute makes it
  7299.      possible to use a symbol name multiple times without getting error
  7300.      messages from \asname{}.}
  7301. \item{If a symbol of a certain name has been defined inside and outside
  7302.      of a section, the ''local'' one will be preferred inside the
  7303.      section, i.e. \asname{} first searches the symbol table for a symbol of
  7304.      the referenced name that also was assigned to the section.  A
  7305.      search for a global symbol of this name only takes place if the
  7306.      first search fails.}
  7307. \end{itemize}
  7308. This mechanism e.g. allows to split the code into modules as one
  7309. might have done it with linkable code.  A more fine-grained approach
  7310. would be to pack every routine into a separate section.  Depending on
  7311. the individual routines' lengths, the symbols for internal use may
  7312. obtain very short names.
  7313.  
  7314. \asname{} will by default not differentiate between upper and lower case in
  7315. section names; if one however switches to case-sensitive mode, the
  7316. case will be regarded just like for symbols.
  7317.  
  7318. The organization described up to now roughly corresponds to what is
  7319. possible in the C language that places all functions on the same
  7320. level.  However, as my ''high-level'' ideal was Pascal and not C, I
  7321. went one step further:
  7322.  
  7323. %%- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  7324.  
  7325. \subsection{Nesting and Scope Rules}
  7326.  
  7327. It is valid to define further sections within a section.  This is
  7328. analog to the option given in Pascal to define procedures inside a
  7329. procedure or function.  The following example shows this:
  7330. \begin{verbatim}
  7331. sym     EQU        0
  7332.  
  7333.        SECTION    ModuleA
  7334.  
  7335.         SECTION    ProcA1
  7336.  
  7337. sym       EQU        5
  7338.  
  7339.         ENDSECTION ProcA1
  7340.  
  7341.         SECTION    ProcA2
  7342.  
  7343. sym       EQU        10
  7344.  
  7345.         ENDSECTION ProcA2
  7346.  
  7347.        ENDSECTION ModuleA
  7348.  
  7349.  
  7350.        SECTION    ModuleB
  7351.  
  7352. sym      EQU        15
  7353.  
  7354.         SECTION    ProcB
  7355.  
  7356.         ENDSECTION ProcB
  7357.  
  7358.        ENDSECTION ModuleB
  7359. \end{verbatim}
  7360. When looking up a symbol, \asname{} first searches for a symbol assigned to
  7361. the current section, and afterwards traverses the list of parent
  7362. sections until the global symbols are reached.  In our example, the
  7363. individual sections see the values given in table \ref{TabSymErg} for
  7364. the symbol \tty{sym}:
  7365. \begin{table*}[htb]
  7366. \begin{center}\begin{tabular}{|l|l|l|}
  7367. \hline
  7368. section        &   value &   from section... \\
  7369. \hline
  7370. \hline
  7371. Global         &     0   &   Global \\
  7372. \hline
  7373. \tty{ModuleA}  &     0   &   Global \\
  7374. \hline
  7375. \tty{ProcA1}   &     5   &   \tty{ProcA1} \\
  7376. \hline
  7377. \tty{ProcA2}   &    10   &   \tty{ProcA2} \\
  7378. \hline
  7379. \tty{ModuleB}  &    15   &   \tty{ModuleB} \\
  7380. \hline
  7381. \tty{ProcB}    &    15   &   \tty{ModuleB} \\
  7382. \hline
  7383. \end{tabular}\end{center}
  7384. \caption{Valid values for the Individual Sections\label{TabSymErg}}
  7385. \end{table*}
  7386. This rule can be overridden by explicitly appending a section's name
  7387. to the symbol's name.  The section's name has to be enclosed in
  7388. brackets:
  7389. \begin{verbatim}
  7390.        move.l  #sym[ModulB],d0
  7391. \end{verbatim}
  7392. Only sections that are in the parent section path of the current
  7393. section may be used.  The special values \tty{PARENT0..PARENT9} are allowed
  7394. to reference the n-th ''parent'' of the current section; \tty{PARENT0} is
  7395. therefore equivalent to the current section itself, \tty{PARENT1} the
  7396. direct parent and so on.  \tty{PARENT1} may be abbreviated as \tty{PARENT}.  If
  7397. no name is given between the brackets, like in this example:
  7398. \begin{verbatim}
  7399.        move.l  #sym[],d0 ,
  7400. \end{verbatim}
  7401. one reaches the global symbol.  \bb{CAUTION!}  If one explicitly
  7402. references a symbol from a certain section, \asname{} will only seek for
  7403. symbols from this section, i.e. the traversal of the parent sections
  7404. path is omitted!
  7405.  
  7406. Similar to Pascal, it is allowed that different sections have
  7407. subsections of the same name; the principle of locality avoids
  7408. irritations.  One should IMHO still use this feature as seldom as
  7409. possible: Symbols listed in the symbol resp. cross reference list are
  7410. only marked with the section they are assigned to, not with the
  7411. ''section hierarchy'' lying above them (this really would have busted
  7412. the available space); a differentiation is made very difficult this
  7413. way.
  7414.  
  7415. As a \tty{SECTION} instruction does not define a label by itself, the
  7416. section concept has an important difference to Pascal's concept of
  7417. nested procedures: a pascal procedure can automatically ''see'' its
  7418. subprocedures(functions), \asname{} requires an explicit definition of an
  7419. entry point.  This can be done e.g. with the following macro pair:
  7420. \begin{verbatim}
  7421. proc    MACRO   name
  7422.        SECTION name
  7423. name    LABEL   $
  7424.        ENDM
  7425.  
  7426. endp    MACRO   name
  7427.        ENDSECTION name
  7428.        ENDM
  7429. \end{verbatim}
  7430. This example also shows that the locality of labels inside macros
  7431. is not influenced by sections.  It makes the trick with the \tty{LABEL}
  7432. instruction necessary.
  7433.  
  7434. This does of course not solve the problem completely.  The label is
  7435. still local and not referencable from the outside.  Those who think
  7436. that it would suffice to place the label in front of the \tty{SECTION}
  7437. statement should be quiet because they would spoil the bridge to the
  7438. next theme:
  7439.  
  7440. %%- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  7441.  
  7442. \subsection{PUBLIC and GLOBAL}
  7443. \ttindex{PUBLIC}\ttindex{GLOBAL}
  7444.  
  7445. The \tty{PUBLIC} statement allows to change the assignment of a symbol to
  7446. a certain section.  It is possible to treat multiple symbols with one
  7447. statement, but I will use an example with only one symbol in the following
  7448. (not hurting the generality of this discussion).  In the simplest case,
  7449. one declares a symbol to be global, i.e. it can be referenced from
  7450. anywhere in the program:
  7451. \begin{verbatim}
  7452.        PUBLIC  <name>
  7453. \end{verbatim}
  7454. As a symbol cannot be moved in the symbol table once it has been sorted
  7455. in, this statement has to appear \bb{before} the symbol itself is
  7456. defined.  \asname{} stores all \tty{PUBLICs} in a list and removes an entry from
  7457. this list when the corresponding symbol is defined.  \asname{} prints errors at
  7458. the end of a section in case that not all \tty{PUBLICs} have been
  7459. resolved.
  7460.  
  7461. Regarding the hierarchical section concept, the method of defining a
  7462. symbol as purely global looks extremely brute.  There is fortunately
  7463. a way to do this in a bit more differentiated way: by appending a
  7464. section name:
  7465. \begin{verbatim}
  7466.        PUBLIC  <name>:<section>
  7467. \end{verbatim}
  7468. The symbol will be assigned to the referenced section and therefore also
  7469. becomes accessible for all its subsections (except they define a symbol of
  7470. the same name that hides the ''more global'' symbol).  \asname{} will naturally
  7471. protest if several subsections try to export a symbol of same name to the
  7472. same level.  The special \tty{PARENTn} values mentioned in the previous
  7473. section are also valid for \tty{$<$section$>$} to export a symbol exactly
  7474. \tty{n} levels up in the section hierarchy.  Otherwise only sections that
  7475. are parent sections of the current section are valid for
  7476. \tty{$<$section$>$}.  Sections that are in another part of the section
  7477. tree are not allowed.  If several sections in the parent section path
  7478. should have the same name (this is possible), the lowest level will be
  7479. taken.
  7480.  
  7481. This tool lets the abovementioned macro become useful:
  7482. \begin{verbatim}
  7483. proc    MACRO   name
  7484.        SECTION name
  7485.        PUBLIC  name:PARENT
  7486. name    LABEL   $
  7487.        ENDM
  7488. \end{verbatim}
  7489. This setting is equal to the Pascal model that also only allows the
  7490. ''father'' to see its children, but not the ''grandpa''.
  7491.  
  7492. \asname{} will quarrel about double-defined symbols if more than one section
  7493. attempts to export a symbol of a certain name to the same upper section.
  7494. This is by itself a correct reaction, and one needs to ''qualify'' symbols
  7495. somehow to make them distinguishable if these exports were deliberate.  A
  7496. \tty{GLOBAL} statement does just this.  The syntax of \tty{GLOBAL} is
  7497. identical to \tty{PUBLIC}, but the symbol stays local instead of being
  7498. assigned to a higher section.  Instead, an additional symbol of the same
  7499. value but with the subsection's name appended to the symbol's name is
  7500. created, and only this symbol is made public according to the section
  7501. specification.  If for example two sections \tty{A} and \tty{B} both
  7502. define a symbol named \tty{SYM} and export it with a \tty{GLOBAL}
  7503. statement to their parent section, the symbols are sorted in under the
  7504. names \tty{A\_SYM} resp. \tty{B\_SYM} .
  7505.  
  7506. In case that source and target section are separated by more than one
  7507. level, the complete name path is prepended to the symbol name.
  7508.  
  7509. %%- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  7510.  
  7511. \subsection{FORWARD}
  7512. \ttindex{FORWARD}
  7513.  
  7514. The model described so far may look beautiful, but there is an
  7515. additional detail not present in Pascal that may spoil the happiness:
  7516. Assembler allows forward references.  Forward references may lead to
  7517. situations where \asname{} accesses a symbol from a higher section in the
  7518. first pass.  This is not a disaster by itself as long as the correct
  7519. symbol is used in the second pass, but accidents of the following
  7520. type may happen:
  7521. \begin{verbatim}
  7522. loop:   .
  7523.        <code>
  7524.        .
  7525.        .
  7526.        SECTION sub
  7527.        .               ; ***
  7528.        .
  7529.        bra.s   loop
  7530.        .
  7531.        .
  7532. loop:   .
  7533.        .
  7534.        ENDSECTION
  7535.        .
  7536.        .
  7537.        jmp     loop    ; main loop
  7538. \end{verbatim}
  7539. \asname{} will take the global label \tty{loop} in the first pass and will
  7540. quarrel about an out-of-branch situation if the program part at
  7541. \tty{$<$code$>$} is long enough.  The second pass will not be
  7542. started at all.  One way to avoid the ambiguity would be to
  7543. explicitly specify the symbol's section:
  7544. \begin{verbatim}
  7545.        bra.s   loop[sub]
  7546. \end{verbatim}
  7547. If a local symbol is referenced several times, the brackets can be saved
  7548. by using a \tty{FORWARD} statement.  The symbol is thereby explicitly
  7549. announced to be local, and \asname{} will only look in the local symbol table
  7550. part when this symbol is referenced.  For our example, the statement
  7551. \begin{verbatim}
  7552.        FORWARD loop
  7553. \end{verbatim}
  7554. should be placed at the position marked with \tty{***}.
  7555.  
  7556. \tty{FORWARD} must not only be stated prior to a symbol's definition, but
  7557. also prior to its first usage in a section to make sense.  It does not
  7558. make sense to define a symbol private and public; this will be regarded as
  7559. an error by \asname{}.
  7560.  
  7561. %%- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  7562.  
  7563. \subsection{Performance Aspects}
  7564.  
  7565. The multi-stage lookup in the symbol table and the decision to which
  7566. section a symbol shall be assigned of course cost a bit of time to
  7567. compute.  An 8086 program of 1800 lines length for example took 34.5
  7568. instead of 33 seconds after a modification to use sections (80386 SX,
  7569. 16MHz, 3 passes).  The overhead is therefore limited.  As it has
  7570. already been stated at the beginning, is is up to the programmer if
  7571. (s)he wants to accept it.  One can still use \asname{} without sections.
  7572.  
  7573. %%---------------------------------------------------------------------------
  7574.  
  7575. \section{Miscellaneous}
  7576.  
  7577. %%- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  7578.  
  7579. \subsection{SHARED}
  7580. \label{ChapShareOrder}
  7581. \ttindex{SHARED}
  7582.  
  7583. {\em valid for: all processors}
  7584.  
  7585. This statement instructs \asname{} to write the symbols given in the
  7586. parameter list (regardless if they are integer, float or string
  7587. symbols) together with their values into the share file.  It depends
  7588. upon the command line parameters described in section
  7589. \ref{SectCallConvention} whether such a file is generated at all and in
  7590. which format it is written.  If \asname{} detects this instruction and no share
  7591. file is generated, a warning is the result.
  7592.  
  7593. \bb{CAUTION!}  A comment possibly appended to the statement itself will be
  7594. copied to the first line outputted to the share file (if \tty{SHARED}'s
  7595. argument list is empty, only the comment will be written).  In case a
  7596. share file is written in C or Pascal format, one has to assure that
  7597. the comment itself does not contain character sequences that close
  7598. the comment (''*/'' resp. ''*)'').  \asname{} does not check for this!
  7599.  
  7600. %%- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  7601.  
  7602. \subsection{INCLUDE}
  7603. \label{SectInclude}
  7604. \ttindex{INCLUDE}
  7605.  
  7606. {\em valid for: all processors}
  7607.  
  7608. This instruction inserts the file given as a parameter into the just as
  7609. if it would have been inserted with an editor (the file name may
  7610. optionally be enclosed with '' characters).  This instruction is
  7611. useful to split source files that would otherwise not fit into the
  7612. editor or to create ''tool boxes''.
  7613.  
  7614. In case that the file name does not have an extension, it will
  7615. automatically be extended with \tty{INC}.
  7616.  
  7617. The assmebler primarily tries to open the file in the directory
  7618. containing the source file with the \tty{INCLUDE} statenemt.  This
  7619. means that a path contained in the file specification is relative
  7620. to this file's directory, not to the directory the assembler was
  7621. called from.  Via the \tty{-i $<$path list$>$} option, one can
  7622. specify a list of directories that will automatically be searched
  7623. for the file.  If the file is not found, a \bb{fatal} error occurs,
  7624. i.e. assembly terminates immediately.
  7625.  
  7626. For compatibility reasons, it is valid to enclose the file name in ''
  7627. characters, i.e.
  7628. \begin{verbatim}
  7629.        include stddef51
  7630. \end{verbatim}
  7631. and
  7632. \begin{verbatim}
  7633.        include "stddef51.inc"
  7634. \end{verbatim}
  7635. are equivalent.  \bb{CAUTION!} This freedom of choice is the reason why
  7636. only a string constant but no string expression is allowed!
  7637.  
  7638. The search list is ignored if the file name itself contains a path
  7639. specification.
  7640.  
  7641. %%- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  7642.  
  7643. \subsection{BINCLUDE}
  7644. \ttindex{BINCLUDE}
  7645.  
  7646. {\em valid for: all processors}
  7647.  
  7648. \tty{BINCLUDE} can be used to embed binary data generated by other programs
  7649. into the code generated by \asname{} (this might theoretically even be code
  7650. created by \asname{} itself...).  \tty{BINCLUDE} has three forms:
  7651. \begin{verbatim}
  7652.        BINCLUDE <file>
  7653. \end{verbatim}
  7654. This way, the file is completely included.
  7655. \begin{verbatim}
  7656.        BINCLUDE <file>,<offset>
  7657. \end{verbatim}
  7658. This way, the file's contents are included starting at \tty{<offset>} up to
  7659. the file's end.
  7660. \begin{verbatim}
  7661.        BINCLUDE <file>,<offset>,<length>
  7662. \end{verbatim}
  7663. This way, \tty{$<$length$>$} bytes are included starting at
  7664. \tty{$<$offset$>$}.
  7665.  
  7666. The same rules regarding search paths apply as for \tty{INCLUDE}.
  7667.  
  7668. %%- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  7669.  
  7670. \subsection{MESSAGE, WARNING, ERROR, and FATAL}
  7671. \ttindex{MESSAGE}\ttindex{WARNING}\ttindex{ERROR}\ttindex{FATAL}
  7672. {\em valid for: all processors}
  7673.  
  7674. Though the assembler checks source files as strict as possible and
  7675. delivers differentiated error messages, it might be necessary from
  7676. time to time to issue additional error messages that allow an
  7677. automatic check for logical error.  The assembler distinguishes
  7678. among three different types of error messages that are accessible to
  7679. the programmer via the following three instructions:
  7680. \begin{itemize}
  7681. \item{\tty{WARNING}: Errors that hint at possibly wrong or inefficient
  7682.      code.  Assembly continues and a code file is generated.}
  7683. \item{\tty{ERROR}: True errors in a program.  Assembly continues to
  7684.      allow detection of possible further errors in the same pass.
  7685.      A code file is not generated.}
  7686. \item{\tty{FATAL}: Serious errors that force an immediate termination
  7687.      of assembly.  A code file may be generated but will be incomplete.}
  7688. \end{itemize}
  7689. All three instructions have the same format for the message that shall
  7690. be issued: an arbitrary string expression, which may be a simple string
  7691. constant, but as well a complex expression that evaluates to a string.
  7692. It also includes the feature to embed symbol values in strings, which
  7693. is described in \ref{SectSymConv}:
  7694. \begin{verbatim}
  7695.       message "Start Address is \{start_address}"
  7696. \end{verbatim}
  7697. Instructions generating warnings or errors typically only make sense
  7698. in conjunction wit conditional assembly.  For example, if there is
  7699. only a limited address space for a program, one can test for overflow
  7700. in the following way:
  7701. \begin{verbatim}
  7702. ROMSize equ     8000h   ; 27256 EPROM
  7703.  
  7704. ProgStart:
  7705.        .
  7706.        .
  7707.        <the program itself>
  7708.        .
  7709.        .
  7710. ProgEnd:
  7711.  
  7712.        if      ProgEnd-ProgStart>ROMSize
  7713.         error  "\athe program is too long!"
  7714.        endif
  7715. \end{verbatim}
  7716. Apart from the instructions generating errors, there is also an
  7717. instruction \tty{MESSAGE} that simply prints a message to the assembly
  7718. listing and th ecosole (the latter only if the quiet mode is not used).
  7719. Its usage is equal to the other three instructions.
  7720.  
  7721. %%- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  7722.  
  7723. \subsection{READ}
  7724. \ttindex{READ}
  7725.  
  7726. {\em valid for: all processors}
  7727.  
  7728. One could say that \tty{READ} is the counterpart to the previous
  7729. instruction group: it allows to read values from the keyboard during
  7730. assembly.  You might ask what this is good for.  I will break with
  7731. the previous principles and put an example before the exact
  7732. description to outline the usefulness of this instruction:
  7733.  
  7734. A program needs for data transfers a buffer of a size that should be
  7735. set at assembly time.  One could store this size in a symbol defined
  7736. with \tty{EQU}, but it can also be done interactively with \tty{READ}:
  7737. \begin{verbatim}
  7738.        IF      MomPass=1
  7739.         READ    "buffer size",BufferSize
  7740.        ENDIF
  7741. \end{verbatim}
  7742. Programs can this way configure themselves dynamically during assembly
  7743. and one could hand over the source to someone who can assemble it
  7744. without having to dive into the source code.  The \tty{IF} conditional
  7745. shown in the example should always be used to avoid bothering the
  7746. user multiple times with questions.
  7747.  
  7748. \tty{READ} is quite similar to \tty{SET} with the difference that the
  7749. value is read from the keyboard instead of the instruction's arguments.
  7750. This for example also implies that \asname{} will automatically set the symbol's
  7751. type (integer, float or string) or that it is valid to enter formula
  7752. expressions instead of a simple constant.
  7753.  
  7754. \tty{READ} may either have one or two parameters because the prompting
  7755. message is optional.  \asname{} will print a message constructed from the
  7756. symbol's name if it is omitted.
  7757.  
  7758. %%- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  7759.  
  7760. \subsection{INTSYNTAX}
  7761. \label{SectINTSYNTAX}
  7762. \ttindex{INTSYNTAX}
  7763.  
  7764. {\em valid for: all processors}
  7765.  
  7766. This instruction allows to modify the set of notations for integer constants
  7767. in various number systems. - After selection of a CPU target, a certain default
  7768. set is installed (see section \ref{SectPseudoInst}).  This set may be augmented
  7769. with other notations, or notations may be removed from it.  \tty{INTSYNTAX}
  7770. takes an arbitrary list of arguments which either begin with a plus or minus
  7771. character, followed by the notation's identifier.  For instance, the following
  7772. statement
  7773. \begin{verbatim}
  7774.       INTSYNTAX    -0oct,+0hex
  7775. \end{verbatim}
  7776. has the result that a leading zero marks a hexadecimal instead of an octal
  7777. constant, a common usage on some assemblers for the SC/MP.  The identifiers
  7778. for all notations can be found in table \ref{TabSystems}.  There is no limit on
  7779. combining notations, except when they contradict each other.  For instance, it
  7780. would not be allowed to enable \tty{0oct} and \tty{0hex} at the same time.
  7781.  
  7782. %%- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  7783.  
  7784. \subsection{RELAXED}
  7785. \label{SectRELAXED}
  7786. \ttindex{RELAXED}
  7787.  
  7788. {\em valid for: all processors}
  7789.  
  7790. By default, \asname{} assigns a distinct syntax for integer constants to a
  7791. processor family (which is in general equal to the manufacturer's
  7792. specifications, as long as the syntax is not too bizarre...).
  7793. Everyone however has his own preferences for another syntax and may
  7794. well live with the fact that his programs cannot be translated any
  7795. more with the standard assembler.  If one places the instruction
  7796. \begin{verbatim}
  7797.        RELAXED ON
  7798. \end{verbatim}
  7799. right at the program's beginning, one may furtherly use any syntax
  7800. for integer constants, even mixed in a program.  \asname{} tries to guess
  7801. automatically for every expression the syntax that was used.  This
  7802. automatism does not always deliver the result one might have in mind,
  7803. and this is also the reason why this option has to be enable
  7804. explicitly: if there are no prefixes or postfixes that unambiguously
  7805. identify either Intel or Motorola syntax, the C mode will be used.
  7806. Leading zeroes that are superfluous in other modes have a meaning in
  7807. this mode:
  7808. \begin{verbatim}
  7809.        move.b  #08,d0
  7810. \end{verbatim}
  7811. This constant will be understood as an octal constant and will result
  7812. in an error message as octal numbers may only contain digits from 0
  7813. to 7.  One might call this a lucky case; a number like 077 would
  7814. result in trouble without getting a message about this.  Without the
  7815. relaxed mode, both expressions unambiguously would have been
  7816. identified as decimal constants.
  7817.  
  7818. The current setting may be read from a symbol with the same name.
  7819.  
  7820. %%- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  7821.  
  7822. \subsection{COMPMODE}
  7823. \label{SectCompMode}
  7824. \ttindex{COMPMODE}
  7825.  
  7826. {\em valid for: various processors}
  7827.  
  7828. Though the assember strives to behave like the correspondig "original
  7829. assemblers", there are cases when emulating the original assembler's
  7830. behaviour would forbid code optimizations which are valid and useful in
  7831. my opinion.  Use the statement
  7832. \begin{verbatim}
  7833.        compmode on
  7834. \end{verbatim}
  7835. to switch to a 'compatibility mode' which prioritizes 'original behaviour'
  7836. to most efficient code.  See the respective section with processor-specific
  7837. hints whether there are any situations for the specific target.
  7838. \par
  7839. Compatibility mode is disabled by default, unless it was activated by the
  7840. command line switch of same name.  The current setting may be read from a
  7841. symbol with the same name.
  7842.  
  7843. %%- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  7844.  
  7845. \subsection{END}
  7846. \ttindex{END}
  7847.  
  7848. {\em valid for: all processors}
  7849.  
  7850. \tty{END} marks the end of an assembler program.  Lines that eventually
  7851. follow in the source file will be ignored.  \bb{IMPORTANT:} \tty{END} may
  7852. be called from within a macro, but the \tty{IF}-stack for conditional
  7853. assembly is not cleared automatically.  The following construct therefore
  7854. results in an error:
  7855. \begin{verbatim}
  7856.        IF      DontWantAnymore
  7857.         END
  7858.        ELSEIF
  7859. \end{verbatim}
  7860. \tty{END} may optionally have an integer expression as argument that marks
  7861. the program's entry point.  \asname{} stores this in the code file with a special
  7862. record and it may be post-processed e.g. with P2HEX.
  7863.  
  7864. \tty{END} has always been a valid instruction for \asname{}, but the only reason
  7865. for this in earlier releases of \asname{} was compatibility; \tty{END} had no
  7866. effect.
  7867.  
  7868. %%===========================================================================
  7869.  
  7870. \cleardoublepage
  7871. \chapter{Processor-specific Hints}
  7872.  
  7873. When writing the individual code generators, I strived for a maximum
  7874. amount of compatibility to the original assemblers.  However, I only did this
  7875. as long as it did not mean an unacceptable additional amount of work.
  7876. I listed important differences, details and pitfalls in the following
  7877. chapter.
  7878.  
  7879. %%---------------------------------------------------------------------------
  7880.  
  7881. \section{6811}
  7882.  
  7883. ''Where can I buy such a beast, a HC11 in NMOS?'', some of you might
  7884. ask.  Well, of course it does not exist, but an H cannot be
  7885. represented in a hexadecimal number (older versions of \asname{} would not
  7886. have accepted such a name because of this), and so I decided to omit
  7887. all the letters...
  7888. \par
  7889. \begin{quote}{\it
  7890. ''Someone stating that something is impossible should be at least as
  7891. cooperative as not to hinder the one who currently does it.''
  7892. }\end{quote}
  7893. From time to time, one is forced to revise one's opinions.  Some versions
  7894. earlier, I stated at his place that I couldn't use \asname{}'s parser in a way
  7895. that it is also possible to to separate the arguments of \tty{BSET/BCLR}
  7896. resp. \tty{BRSET/BRCLR} with spaces.  However, it seems that it can do
  7897. more than I wanted to believe...after the n+1th request, I sat down once
  7898. again to work on it and things seem to work now.  You may use either
  7899. spaces or commas, but not in all variants, to avoid ambiguities: for
  7900. every variant of an instruction, it is possible to use only commas or a
  7901. mixture of spaces and commas as Motorola seems to have defined it (their
  7902. data books do not always have the quality of the corresponding
  7903. hardware...):
  7904. \begin{verbatim}
  7905. Bxxx  abs8 #mask         is equal to Bxxx  abs8,#mask
  7906. Bxxx  disp8,X #mask      is equal to Bxxx  disp8,X,#mask
  7907. BRxxx abs8 #mask addr    is equal to BRxxx abs8,#mask,addr
  7908. BRxxx disp8,X #mask addr is equal to BRxxx disp8,X,#mask,addr
  7909. \end{verbatim}
  7910. In this list, \tty{xxx} is a synonym either for \tty{SET} or \tty{CLR};
  7911. \tty{\#mask} is the bit mask to be applied (the \# sign is optional).  Of
  7912. course, the same statements are also valid for Y-indexed expression (not
  7913. listed here).
  7914.  
  7915. With the K4 version  of the HC11, Motorola has introduced a banking
  7916. scheme, which one one hand easily allows to once again extend an
  7917. architecture that has become 'too small', but on the other hand not really
  7918. makes programmers' and tool developers' lifes simpler...how does one
  7919. sensibly map something like this on a model for a programmer?
  7920.  
  7921. The K4 architecture {\em extends} the HC11 address space by 2x512 Kbytes,
  7922. which means that we now have a total address space of 64+1024=1088 Kbytes.
  7923. \asname{} acts like this were one large unified addres space, with the following
  7924. layout:
  7925. \begin{itemize}
  7926. \item{\$000000...\$00ffff: the old HC11 address space}
  7927. \item{\$010000...\$08ffff: Window 1}
  7928. \item{\$090000...\$10ffff: Window 2}
  7929. \end{itemize}
  7930. Via the {\tt ASSUME} statement, one tells \asname{} how the banking registers are
  7931. set up, which in turn describes which extended areas are mapped to which
  7932. physical addresses.  For absolute addresses modes with addresses beyond
  7933. \$10000, \asname{} automatically computes the address within the first 64K that
  7934. is to be used.  Of course this only works for direct addressing modes, it
  7935. is the programmer's responsibility to keep the overview for indirect or
  7936. indexed addressing modes!
  7937. In case one is not really sure if the current mapping is really the
  7938. desired one, the pseudo instruction {\tt PRWINS} may be used, which prints
  7939. the assumes MMxxx register contents plus the current mapping(s), like
  7940. this:
  7941. \begin{verbatim}
  7942. MMSIZ $e1 MMWBR $84 MM1CR $00 MM2CR $80
  7943. Window 1: 10000...12000 --> 4000...6000
  7944. Window 1: 90000...94000 --> 8000...c000
  7945. \end{verbatim}
  7946. An instruction
  7947. \begin{verbatim}
  7948.        jmp     *+3
  7949. \end{verbatim}
  7950. located at \$10000 would effectively result in a jump to address \$4003.
  7951.  
  7952. %%---------------------------------------------------------------------------
  7953.  
  7954. \section{PowerPC}
  7955.  
  7956. Of course, it is a bit crazy idea to add support in \asname{} for a
  7957. processor that was mostly designed for usage in work stations.
  7958. Remember that \asname{} mainly is targeted at programmers of single board
  7959. computers.  But things that today represent the absolute high end in
  7960. computing will be average tomorrow and maybe obsolete the next day,
  7961. and in the meantime, the Z80 as the 8088 have been retired as CPUs
  7962. for personal computers and been moved to the embedded market;
  7963. modified versions are marketed as microcontrollers.  With the
  7964. appearance of the MPC505 and PPC403, my suspicion has proven to be
  7965. true that IBM and Motorola try to promote this architecture in as
  7966. many fields as possible.
  7967.  
  7968. However, the current support is a bit incomplete: Temporarily, the
  7969. Intel-style mnemonics are used to allow storage of data and the more
  7970. uncommon RS/6000 machine instructions mentioned in \cite{Mot601} are
  7971. missing (hopefully noone misses them!).  I will finish this as soon
  7972. as information about them is available!
  7973.  
  7974. %%---------------------------------------------------------------------------
  7975.  
  7976. \section{IBM PALM}
  7977.  
  7978. IBM's PALM processor has been ''Terra Incognita'' for long time, because
  7979. it never has been used outside of IBM.  Furthermore, the IBM 5100 to
  7980. 5120 that were equipped with it were exotic and expensive, and were
  7981. quickly forgotten over the success of the IBM PC.  Only Christian
  7982. Corti's extensive reverse engineering made it possible to implement
  7983. this target \cite{CortPalm}.
  7984.  
  7985. When Christian began to reverse engineer the PALM processor, he did
  7986. not know the assembler mnemonics defined by IBM, so he had to choose
  7987. his own ones.  He of course did this with the background knowledge about
  7988. decades of other processor architectures that were developed from 1973
  7989. (when PALM was constructed) until today.
  7990.  
  7991. If you compare his mnemonics with the ones from IBM (a document about
  7992. them was finally published in \cite{IBMPalm}), I see parallels to the
  7993. assembly language of the Intel 8080/8085 on the one side, and the Zilog
  7994. Z80 on the other side.  ''Intel Mnemonics'' pack the addressing mode
  7995. into the mnemonic's name (like {\tt MVI} for ''MoVe Immediate'' or {\tt
  7996. LDHD} for ''LoaD Halfword Direct'').  This is significantly easier to
  7997. parse and transform into machine language for an assembler.
  7998.  
  7999. The other mnemonics group all machine instructions doing a certain
  8000. operation under the same mnemonic, like {\tt LD} for ''LoaD'' or {\tt
  8001. MOVE} for a (16 bit) data move.  This makes usage for a programmer much
  8002. simpler, parsing the different addressing modes however results in some
  8003. more work for an assembler.
  8004.  
  8005. So, both sets of mnemonics have their justification: The IBM ones
  8006. simply because they are ''the original'' ones and are use in all vendor
  8007. documentation, and the new ones because they are simply more
  8008. understandable and easier to use.  I therefore decided to support {\em
  8009. both} sets in my assembler, and this was fortunately possible without
  8010. creating any conflicts.  Support includes the ''macro instructions''
  8011. {\tt CALL, RCALL, JMP, BRA, LWI} and {\tt RET}.  And there are a few
  8012. things I added myself:
  8013. \begin{itemize}
  8014. \item{{\tt AND} and {\tt OR} also accept an immediate operand as second
  8015.      argument. This is mapped to the {\tt SET} resp. {\tt CLR} instructions,
  8016.      and of course the value gets inverted for {\tt AND}.}
  8017. \item{{\tt MOVE} also accepts an immediate argument as source and generates
  8018.      the same machine code as {\tt LWI}.  The same is true for {\tt MOVB}
  8019.      and {\tt LBI}.}
  8020. \end{itemize}
  8021. Macro instructions consisting of more than one (half) word however
  8022. create a new problem: The only form of conditional execution supported
  8023. by the PALM processor is a conditional skip of the following
  8024. instruction word.  If such a skip is followed by a macro instruction,
  8025. it would only partially be skipped.  I have therefore added a small
  8026. state machine that attempts to detect such sequences and will issue a
  8027. warning.
  8028.  
  8029. The IBM 5110 and 5120 do not use the ASCII character set, but instead
  8030. EBCDIC as known from IBM mainframes.  The include subdirectory holds
  8031. a file that may be used to convert from ASCII to EBCDIC. IMPORTANT:
  8032. This file defines EBCDIC as an extra code page, so the translation
  8033. has to be activated with the statement
  8034. \begin{verbatim}
  8035.        codepage        cp037
  8036. \end{verbatim}
  8037.  
  8038. One more word about integer constant syntax: Christian Corti had
  8039. decided to use the ''Motorola Syntax'', i.e.  hexadecimal constants
  8040. must be prefixed with a dollar sign.  As the PALM is an IBM design, I
  8041. decided to use the ''IBM Syntax'' by default, which means that numeric
  8042. constants are enclosed in apostrophes and prefixed with an {\tt X} for
  8043. hexadecimal values.  To assemble the code examples from Christian's
  8044. pages without modifying them, add the following statement at the
  8045. program's beginning:
  8046. \begin{verbatim}
  8047.        intsyntax       +$hex,-x'hex'
  8048. \end{verbatim}
  8049.  
  8050. %%---------------------------------------------------------------------------
  8051.  
  8052. \section{DSP56xxx}
  8053.  
  8054. Motorola, which devil rode you!  Which person in your company had the
  8055. ''brilliant'' idea to separate the parallel data transfers with spaces!
  8056. In result, everyone who wants to make his code a bit more readable,
  8057. e.g. like this:
  8058. \begin{verbatim}
  8059.        move    x:var9 ,r0
  8060.        move    y:var10,r3   ,
  8061. \end{verbatim}
  8062. is p****ed because the space gets recognized as a separator for
  8063. parallel data transfers!
  8064.  
  8065. Well...Motorola defined it that way, and I cannot change it.  Using
  8066. tabs instead of spaces to separate the parallel operations is also
  8067. allowed, and the individual operations' parts are again separated
  8068. with commas, as one would expect it.
  8069.  
  8070. \cite{Mot56} states that instead of using \tty{MOVEC, MOVEM, ANDI} or
  8071. \tty{ORI}, it is also valid to use the more general Mnemonics \tty{MODE,
  8072. AND} or \tty{OR}.
  8073. \asname{} (currently) does not support this.
  8074.  
  8075. %%---------------------------------------------------------------------------
  8076.  
  8077. \section{H8/300}
  8078.  
  8079. Regarding the assembler syntax of these processors, Hitachi generously
  8080. copied from Motorola (that wasn't by far the worst choice...),
  8081. unfortunately the company wanted to introduce its own format for
  8082. hexadecimal numbers.  To make it even worse, it is a format that uses
  8083. unbalanced single quotes, just like Microchip does:
  8084. \begin{verbatim}
  8085.   mov.w #h'ff,r0
  8086. \end{verbatim}
  8087. This format is not supported by default.  Instead, one has to write
  8088. hexadecimal numbers in the well-known Motorola syntax: with a leading
  8089. dollar sign.  If you really need the 'Hitachi Syntax', e.g. to assemble
  8090. existing code, enable the RELAXED mode.  Bear in mind that this syntax has
  8091. received few testing so far.  I can therefore not guarantee that it will
  8092. work in all cases!
  8093.  
  8094. %%---------------------------------------------------------------------------
  8095.  
  8096. \section{H8/500}
  8097.  
  8098. The H8/500's {\tt MOV} instruction features an interesting and uncommon
  8099. optimization: If the target operand has a size of 16 bits, it is still possible
  8100. to use an 8-bit (immediate) source operand.  For example, for an instruction
  8101. like this:
  8102. \begin{verbatim}
  8103.   mov.w #$ffff,@$1234
  8104. \end{verbatim}
  8105. it is possible to encode the immediate source code operand just as a single
  8106. \$ff and to save one byte in code size.  The processor automatically performs
  8107. a sign extension, which turns \$ff into the desired value \$ffff.  \asname{} is aware
  8108. of this optimization and will use it, unless it was explicitly forbidden via
  8109. a \tty{:16} suffix at the immediate operand.
  8110. Feedback from users trying to assemble existing code has revealed that the
  8111. original Hitachi assembler implements this optimization in a different way:
  8112. it assumes a zero instead of a sign extension.  This means that immediate
  8113. values from 0 to 255 (\$0000 to \$00ff) and not from -128 to +127 (\$ff80 to
  8114. \$007f) are encoded as one byte.  Tests with physical hardware brought the
  8115. result that the Programmers Manual is correct: The processor performs a sign
  8116. extension.  \asname{} will therefore by default only use the shorter encoding if
  8117. a value ranging from -128 to +127 respectively \$ff80 to \$007f is used.
  8118. If you have existing code that assumes values from \$80 to \$ff are encoded
  8119. as one byte, you may activate a 'compatibility mode', either by the
  8120. statement
  8121. \begin{verbatim}
  8122.  compmode on
  8123. \end{verbatim}
  8124. in the source code or by the command line switch of same name.
  8125.  
  8126. Aside from this, the same remarks regarding hexadecimal number syntax apply
  8127. as for H8/500.
  8128.  
  8129. %%---------------------------------------------------------------------------
  8130.  
  8131. \section{SH7000/7600/7700}
  8132.  
  8133. Unfortunately, Hitachi once again used their own format for
  8134. hexadecimal numbers, and once again I was not able to reproduce this
  8135. with \asname{}...please use Motorola syntax!
  8136.  
  8137. When using literals and the \tty{LTORG} instruction, a few things have to
  8138. be kept in mind if you do not want to suddenly get confronted with strange
  8139. error messages:
  8140.  
  8141. Literals exist due to the fact that the processor is unable to load
  8142. constants out of a range of -128 to 127 with immediate addressing.
  8143. \asname{} (and the Hitachi assembler) hide this inability by the automatic
  8144. placement of constants in memory which are then referenced via
  8145. PC-relative addressing.  The question that now arises is where to
  8146. locate these constants in memory.  \asname{} does not automatically place a
  8147. constant in memory when it is needed; instead, they are collected
  8148. until an LTORG instruction occurs.  The collected constants are then
  8149. dumped en bloc, and their addresses are stored in ordinary labels
  8150. which are also visible in the symbol table.  Such a label's name is
  8151. of the form
  8152. \begin{verbatim}
  8153.    LITERAL_s_xxxx_n  .
  8154. \end{verbatim}
  8155. In this name, \tty{s} represents the literal's type.  Possible values are
  8156. \tty{W} for 16-bit constants, \tty{L} for 32-bit constants and \tty{F} for
  8157. forward references where \asname{} cannot decide in anticipation which size is
  8158. needed.  In case of \tty{s=W} or \tty{L}, \tty{xxxx} denotes the
  8159. constant's value in a hexadecimal notation, whereas \tty{xxxx} is a simple
  8160. running number for forward references (in a forward reference, one does
  8161. not know the value of a constant when it is referenced, so one obviously
  8162. cannot incorporate its value into the name).  \tty{n} is a counter that
  8163. signifies how often a literal of this value previously occurred in the
  8164. current section.  Literals follow the standard rules for localization by
  8165. sections.  It is therefore absolutely necessary to place literals that
  8166. were generated in a certain section before the section is terminated!
  8167.  
  8168. The numbering with \tty{n} is necessary because a literal may occur
  8169. multiple times in a section.  One reason for this situation is that
  8170. PC-relative addressing only allows positive offsets; Literals that
  8171. have once been placed with an \tty{LTORG} can therefore not be referenced
  8172. in the code that follows.  The other reason is that the displacement
  8173. is generally limited in length (512 resp. 1024 bytes).
  8174.  
  8175. An automatic \tty{LTORG} at the end of a program or previously to
  8176. switching to a different target CPU does not occur; if \asname{} detects unplaced
  8177. literals in such a situation, an error message is printed.
  8178.  
  8179. As the PC-relative addressing mode uses the address of the current
  8180. instruction plus 4, it is not possible to access a literal that is
  8181. stored directly after the instruction, like in the following example:
  8182. \begin{verbatim}
  8183.        mov     #$1234,r6
  8184.        ltorg
  8185. \end{verbatim}
  8186. This is a minor item since the CPU anyway would try to execute the
  8187. following data as code.  Such a situation should not occur in a real
  8188. program...another pitfall is far more real: if PC-relative addressing
  8189. occurs just behind a delayed branch, the program counter is already
  8190. set to the destination address, and the displacement is computed
  8191. relative to the branch target plus 2.  Following is an example where
  8192. this detail leads to a literal that cannot be addressed:
  8193. \begin{verbatim}
  8194.        bra     Target
  8195.        mov     #$12345678,r4        ; is executed
  8196.        .
  8197.        .
  8198.        ltorg                        ; here is the literal
  8199.        .
  8200.        .
  8201. Target: mov     r4,r7                ; execution continues here
  8202. \end{verbatim}
  8203. As \tty{Target}+2 is on an address behind the literal, a negative
  8204. displacement would result.  Things become especially hairy when one
  8205. of the branch instructions \tty{JMP, JSR, BRAF, or BSRF} is used: as \asname{}
  8206. cannot calculate the target address (it is generated at runtime from
  8207. a register's contents), a PC value is assumed that should never fit,
  8208. effectively disabling any PC-relative addressing at this point.
  8209.  
  8210. It is not possible to deduce the memory usage from the count and size
  8211. of literals.  \asname{} might need to insert a padding word to align a long
  8212. word to an address that is evenly divisible by 4; on the other hand,
  8213. \asname{} might reuse parts of a 32-bit literal for other 16-bit literals.
  8214. Of course multiple use of a literal with a certain value will create
  8215. only one entry.  However, such optimizations are completely
  8216. suppressed for forward references as \asname{} does not know anything about
  8217. their value.
  8218.  
  8219. As literals use the PC-relative addressing which is only allowed for
  8220. the \tty{MOV} instruction, the usage of literals is also limited to
  8221. \tty{MOV} instructions.  The way \asname{} uses the operand size is a bit tricky:
  8222. A specification of a byte or word move means to generate the shortest
  8223. possible instruction that results in the desired value placed in the
  8224. register's lowest 8 resp. 16 bits.  The upper 24 resp. 16 bits are treated
  8225. as ''don't care''.  However, if one specifies a longword move or omits the
  8226. size specification completely, this means that the complete 32-bit
  8227. register should contain the desired value.  For example, in the following
  8228. sequence
  8229. \begin{verbatim}
  8230.        mov.b   #$c0,r0
  8231.        mov.w   #$c0,r0
  8232.        mov.l   #$c0,r0   ,
  8233. \end{verbatim}
  8234. the first instruction will result in true immediate addressing, the
  8235. second and third instruction will use a word literal:  As bit 7 in
  8236. the number is set, the byte instruction will effectively create the
  8237. value \$FFFFFFC0 in the register.  According to the convention, this
  8238. wouldn't be the desired value in the second and third example.
  8239. However, a word literal is also sufficient for the third case because
  8240. the processor will copy a cleared bit 15 of the operand to bits
  8241. 16..31.
  8242.  
  8243. As one can see, the whole literal stuff is rather complex; I'm sorry but
  8244. there was no chance of making things simpler.  It is unfortunately a
  8245. part of its nature that one sometimes gets error messages about
  8246. literals that were not found, which logically should not occur because
  8247. \asname{} does the literal processing completely on his own.  However, if
  8248. other errors occur in the second pass, all following labels will move
  8249. because \asname{} does not generate any code any more for statements that
  8250. have been identified as erroneous.  As literal names are partially built
  8251. from other symbols' values, other errors might follow because literal
  8252. names searched in the second pass differ from the names stored in the
  8253. first pass and \asname{} quarrels about undefined symbols...if such errors
  8254. should occur, please correct all other errors first before you start
  8255. cursing on me and literals...
  8256.  
  8257. People who come out of the Motorola scene and want to use PC-relative
  8258. addressing explicitly (e.g. to address variables in a position-independent
  8259. way) should know that if this addressing mode is written like in the
  8260. programmer's manual:
  8261. \begin{verbatim}
  8262.        mov.l   @(Var,PC),r8
  8263. \end{verbatim}
  8264. \bb{no} implicit conversion of the address to a displacement will occur,
  8265. i.e. the operand is inserted as-is into the machine code (this will
  8266. probably generate a value range error...).  If you want to use
  8267. PC-relative addressing on the SH7x00, simply use ''absolute''
  8268. addressing (which does not exist on machine level):
  8269. \begin{verbatim}
  8270.        mov.l   Var,r8
  8271. \end{verbatim}
  8272. In this example, the displacement will be calculated correctly (of
  8273. course, the same limitations apply for the displacement as it was the
  8274. case for literals).
  8275.  
  8276. %%---------------------------------------------------------------------------
  8277.  
  8278. \section{HMCS400}
  8279.  
  8280. The instruction set of these 4 bit processors spontaneously reminded
  8281. me of the 8080/8085 - many mnemonics, the addressing mode (e.g.
  8282. direct or indirect) is coded into the instruction, and the
  8283. instructions are sometimes hard to memorize.  \asname{} or course
  8284. supports this syntax as Hitachi defined it.  I however
  8285. implemented another variant for most instructions that is - in my
  8286. opinion - more beautiful and better to read.  The approach is
  8287. similar to what Zilog did back then for the Z80.  For instance,
  8288. all machine instructions that transfer data in some form, may the
  8289. operands be constants, registers, or memory cells, may be used
  8290. via the \tty{LD} instruction.  Similar 'meta instructions' exist
  8291. for arithmetic and logical instructions.  A complete list of all
  8292. meta instructions and their operands can be found in the tables
  8293. \ref{TabHMCS400Meta} and \ref{TabHMCS400MetaOps}, their practical
  8294. use can be seen in the file \tty{t\_hmcs4x.asm}.
  8295.  
  8296. \begin{table*}
  8297. \begin{center}\begin{tabular}{|l|l|}
  8298. \hline
  8299. Meta Instruction          & Replaces \\
  8300. \hline
  8301. \tty{LD} {\em src, dest}        & \tty{LAI, LBI, LMID, LMIIY,} \\
  8302.                                & \tty{LAB, LBA, LAY, LASPX, LASPY, LAMR,} \\
  8303.                                & \tty{LWI, LXI, LYI, LXA, LYA, LAM, LAMD} \\
  8304.                                & \tty{LBM, LMA, LMAD, LMAIY, LMADY} \\
  8305. \tty{XCH} {\em src, dest}       & \tty{XMRA, XSPX, XSPY, XMA, XMAD, XMB} \\
  8306. \tty{ADD} {\em src, dest}       & \tty{AYY, AI, AM, AMD} \\
  8307. \tty{ADC} {\em src, dest}       & \tty{AMC, AMCD} \\
  8308. \tty{SUB} {\em src, dest}       & \tty{SYY} \\
  8309. \tty{SBC} {\em src, dest}       & \tty{SMC, SMCD} \\
  8310. \tty{OR}  {\em src, dest}       & \tty{OR, ORM, ORMD} \\
  8311. \tty{AND} {\em src, dest}       & \tty{ANM, ANMD} \\
  8312. \tty{EOR} {\em src, dest}       & \tty{EORM, EORMD} \\
  8313. \tty{CP}  {\em cond, src, dest} & \tty{INEM, INEMD, ANEM, ANEMD, BNEM,} \\
  8314.                                & \tty{YNEI, ILEM, ILEMD, ALEM, ALEMD,} \\
  8315.                                & \tty{BLEM, ALEI} \\
  8316. \tty{BSET} {\em bit}            & \tty{SEC, SEM, SEMD} \\
  8317. \tty{BCLR} {\em bit}            & \tty{REC, REM, REMD} \\
  8318. \tty{BTST} {\em bit}            & \tty{TC, TM, TMD} \\
  8319. \hline
  8320. \end{tabular}\end{center}
  8321. \caption{Meta Instructions HMCS400}
  8322. \label{TabHMCS400Meta}
  8323. \end{table*}
  8324.  
  8325. \begin{table*}
  8326. \begin{center}\begin{tabular}{|l|l|}
  8327. \hline
  8328. Operand                 & Types \\
  8329. \hline
  8330. {\em src, dest}         & \tty{A, B, X, Y, W, SPX, SPY} (register) \\
  8331.                        & \tty{M} (memory addressed by X/Y/W) \\
  8332.                        & \tty{M+} (ditto, with auto increment) \\
  8333.                        & \tty{M-} (ditto, with auto decrement) \\
  8334.                        & \tty{\#val} (2/4 bits immediate) \\
  8335.                        & \tty{addr10} (memory direct) \\
  8336.                        & \tty{MRn} (memory register 0..15) \\
  8337. {\em cond}              & \tty{NE} (unequal) \\
  8338.                        & \tty{LE} (less or equal) \\
  8339. {\em bit}               & \tty{CA} (carry) \\
  8340.                        & {\em bitpos},\tty{M} \\
  8341.                        & {\em bitpos},\tty{addr10} \\
  8342. {\em bitpos}            & \tty{0..3} \\
  8343. \hline
  8344. \end{tabular}\end{center}
  8345. \caption{Operand Types for HMCS400 Meta Instructions}
  8346. \label{TabHMCS400MetaOps}
  8347. \end{table*}
  8348.  
  8349. %%---------------------------------------------------------------------------
  8350.  
  8351. \section{H16}
  8352.  
  8353. The instruction set of the H16's core well deserves the label ''CISC'': complex
  8354. addressing modes, instructions of extremely variable length, and
  8355. there are many shortforms for instructions with common operands.  For
  8356. instance, several instructions know different ''formats'', depending
  8357. on the type of source and destination operand.  The general rule is
  8358. that \asname{} will always use the shortest possible format, unless it was
  8359. specified explicitly:
  8360. angegeben:
  8361. \begin{verbatim}
  8362.       mov.l     r4,r7     ; uses R format
  8363.       mov.l     #4,r7     ; uses RQ format
  8364.       mov.l     #4,@r7    ; uses Q format
  8365.       mov.l     @r4,@r7   ; uses G format
  8366.       mov:q.l   #4,r7     ; forces Q instead of RQ format
  8367.       mov:g.l   #4,r7     ; forces G instead of RQ format
  8368. \end{verbatim}
  8369. For immediate arguments, the ''natural' argument length is used, e.g.
  8370. 2 bytes for 16 bits.  Shorter or longer arguments may be forced by an
  8371. appended operand size (.b, .w, .l or :8, :16, :32).  However, the
  8372. rule for displacements and absolute addresses is that the shortest
  8373. form will be used if no explicit size is given.  This includes
  8374. exploiting that the processor does not output the uppermost eight
  8375. bits of an address.  Therefore, an absolute address of \$ffff80 can
  8376. be coded as a single byte (\$80).
  8377.  
  8378. Furthermore, \asname{} knows the ''accumulator bit'', i.e. the second
  8379. operand of a two-operand instruction my be left away if the
  8380. destination is register zero.  There is currently no override this
  8381. behaviour.
  8382.  
  8383. Additionally, the following optimizations are performed:
  8384. \begin{itemize}
  8385. \item{\tty{MOV R0,<ea>} gets optimized to \tty{MOVF <ea>}, unless
  8386.      \tty{<ea>} is a PC-relative expression and the size of the
  8387.      displacement would change.  This optimization may be disabled
  8388.      by specifying an explicit format.}
  8389. \item{\tty{SUB} does not support the Q format, however it may be
  8390.      replaced by \tty{ADD:Q} with a negated immediate argument,
  8391.      given the argument is in the range -127...+128.  This
  8392.      optimization may as well be disabled by specifying an explicit
  8393.      format.}
  8394. \end{itemize}
  8395.  
  8396. %%---------------------------------------------------------------------------
  8397.  
  8398. \section{OLMS-40}
  8399.  
  8400. Similar to the HMCS400, addressing modes are largely encoded (or
  8401. rather encrypted..) into into the mnemonics, and also here I
  8402. decided to provide an alternate notation that is more modern and
  8403. better to read.  A complete list of all meta instructions and
  8404. their operands can be found in the tables \ref{TabOLMS40Meta} and
  8405. \ref{TabOLMS40MetaOps}, their practical use can be seen in the
  8406. file \tty{t\_olms4.asm}.
  8407.  
  8408. \begin{table*}
  8409. \begin{center}\begin{tabular}{|l|l|}
  8410. \hline
  8411. Meta Instruction          & Replaces \\
  8412. \hline
  8413. \tty{LD} {\em dest, src}        & \tty{LAI, LLI, LHI, L,} \\
  8414.                                & \tty{LAL, LLA, LAW, LAX, LAY, LAZ,} \\
  8415.                                & \tty{LWA, LXA, LYA, LPA, LTI, RTH, RTL} \\
  8416. \tty{DEC} {\em dest}            & \tty{DCA, DCL, DCM, DCW, DCX, DCY, DCZ, DCH} \\
  8417. \tty{INC} {\em dest}            & \tty{INA, INL, INM, INW, INX, INY, INZ} \\
  8418. \tty{BSET} {\em bit}            & \tty{SPB, SMB, SC} \\
  8419. \tty{BCLR} {\em bit}            & \tty{RPB, RMB, RC} \\
  8420. \tty{BTST} {\em bit}            & \tty{TAB, TMB, Tc} \\
  8421. \hline
  8422. \end{tabular}\end{center}
  8423. \caption{Meta Instructions OLMS-40}
  8424. \label{TabOLMS40Meta}
  8425. \end{table*}
  8426.  
  8427. \begin{table*}
  8428. \begin{center}\begin{tabular}{|l|l|}
  8429. \hline
  8430. Operand                 & Types \\
  8431. \hline
  8432. {\em src, dest}         & \tty{A, W, X, Y, Z, DPL, DPH} (Register) \\
  8433.                        & \tty{T, TL, TH} (Timer, obere/untere H"alfte) \\
  8434.                        & \tty{(DP), M} (Speicher adressiert durch DPH/DPL) \\
  8435.                        & \tty{\#val} (4/8 bit immediate) \\
  8436.                        & \tty{PP} (Port-Pointer) \\
  8437. {\em bit}               & \tty{C} (Carry) \\
  8438.                        & \tty{(PP)},{\em bitpos} \\
  8439.                        & \tty{(DP)},{\em bitpos} \\
  8440.                        & \tty{(A)},{\em bitpos} \\
  8441. {\em bitpos}            & \tty{0..3} \\
  8442. \hline
  8443. \end{tabular}\end{center}
  8444. \caption{Operand Types for OLMS-40 Meta Instructions}
  8445. \label{TabOLMS40MetaOps}
  8446. \end{table*}
  8447.  
  8448. %%---------------------------------------------------------------------------
  8449.  
  8450. \section{OLMS-50}
  8451.  
  8452. The data memory of these 4 bit controllers consists of up to 128
  8453. nibbles.  However, only a very small subset of the machine
  8454. instructions have enough space to accomodate seven address bits,
  8455. which menas that - once again - banking must help out.  The
  8456. majority of instructions that address memory only contain the
  8457. lower four bits of the RAM address, and unless the lowest 16
  8458. nibbles of the memory shall be addressed, the P register delivers
  8459. the necessary upper address bits. The assembler is told about its
  8460. current value via an
  8461. \begin{verbatim}
  8462.   assume  p:<value>
  8463. \end{verbatim}
  8464. statement, e.g. directly after a \tty{PAGE} instruction.
  8465.  
  8466. Speaking of \tty{PAGE}: both \tty{PAGE} and \tty{SWITCH} are
  8467. machine instructions on these controllers, i.e. the do not have
  8468. the function known from other targets.  The pseudo instruction to
  8469. start a \tty{SWITCH/CASE} construct is \tty{SELECT} in OLMS-50
  8470. mode, and the listing's page size is set via \tty{PAGESIZE}.
  8471.  
  8472. %%---------------------------------------------------------------------------
  8473.  
  8474. \section{MELPS-4500}
  8475.  
  8476. The program memory of these microcontrollers is organized in pages of
  8477. 128 words.  Honestly said, this organization only exists because there
  8478. are on the one hand branch instructions with a target that must lie
  8479. within the same page, and on the other hand ''long'' branches that can
  8480. reach the whole address space.  The standard syntax defined by
  8481. Mitsubishi demands that page number and offset have to be written as
  8482. two distinct arguments for the latter instructions.  As this is
  8483. quite inconvenient (except for indirect jumps, a programmer has no
  8484. other reason to deal with pages), \asname{} also allows to write the target
  8485. address in a ''linear'' style, for example
  8486. \begin{verbatim}
  8487.        bl      $1234
  8488. \end{verbatim}
  8489. instead of
  8490. \begin{verbatim}
  8491.        bl      $24,$34 .
  8492. \end{verbatim}
  8493.  
  8494. %%---------------------------------------------------------------------------
  8495.  
  8496. \section{6502UNDOC}
  8497.  
  8498. Since the 6502's undocumented instructions naturally aren't listed in
  8499. any data book, they shall be listed shortly at this place.  Of
  8500. course, you are using them on your own risk.  There is no guarantee
  8501. that all mask revisions will support all variants!  They anyhow do
  8502. not work for the CMOS successors of the 6502, since they allocated
  8503. the corresponding bit combinations with "official" instructions...
  8504.  
  8505. The following symbols are used:
  8506.  
  8507. \begin{tabbing}
  8508. \hspace{2cm} \= \kill
  8509. \&           \> binary AND \\
  8510. |            \> binary OR \\
  8511. \verb!^!     \> binary XOR \\
  8512. $<<$         \> logical shift left \\
  8513. $>>$         \> logical shift right \\
  8514. $<<<$        \> rotate left \\
  8515. $>>>$        \> rotate right \\
  8516. $\leftarrow$ \> assignment \\
  8517. (..)        \> contents of .. \\
  8518. {..}        \> bits .. \\
  8519. A           \> accumulator \\
  8520. X,Y         \> index registers X,Y \\
  8521. S           \> stack pointer \\
  8522. An          \> accumulator bit n \\
  8523. M           \> operand \\
  8524. C           \> carry \\
  8525. PCH         \> upper half of program counter \\
  8526. \end{tabbing}
  8527.  
  8528. \begin{tabbing}
  8529. Addressing Modes \= : \= \kill
  8530. Instruction      \> : \> \tty{JAM} or \tty{KIL} or \tty{CRS} \\
  8531. Function         \> : \> none, prozessor is halted \\
  8532. Addressing Modes \> : \> implicit \\
  8533. \end{tabbing}
  8534.  
  8535. \begin{tabbing}
  8536. Addressing Modes \= : \= \kill
  8537. Instruction      \> : \> \tty{SLO} \\
  8538. Function         \> : \> $M\leftarrow((M)<<1)|(A)$ \\
  8539. Addressing Modes \> : \> absolute long/short, X-indexed long/short, \\
  8540.                 \>   \> Y-indexed long, X/Y-indirect \\
  8541. \end{tabbing}
  8542.  
  8543. \begin{tabbing}
  8544. Addressing Modes \= : \= \kill
  8545. Instruction      \> : \> \tty{ANC} \\
  8546. Function         \> : \> $A\leftarrow(A)\&(M), C\leftarrow A7$ \\
  8547. Addressing Modes \> : \> immediate \\
  8548. \end{tabbing}
  8549.  
  8550. \begin{tabbing}
  8551. Addressing Modes \= : \= \kill
  8552. Instruction      \> : \> \tty{RLA} \\
  8553. Function         \> : \> $M\leftarrow((M)<<1)\&(A)$ \\
  8554. Addressing Modes \> : \> absolute long/short, X-indexed long/short, \\
  8555.                 \>   \> Y-indexed long, X/Y-indirect \\
  8556. \end{tabbing}
  8557.  
  8558. \begin{tabbing}
  8559. Addressing Modes \= : \= \kill
  8560. Instruction      \> : \> \tty{SRE} \\
  8561. Function         \> : \> $M\leftarrow((M)>>1)$\verb!^!$(A)$ \\
  8562. Addressing Modes \> : \> absolute long/short, X-indexed long/short, \\
  8563.                 \>   \> Y-indexed long, X/Y-indirect \\
  8564. \end{tabbing}
  8565.  
  8566. \begin{tabbing}
  8567. Addressing Modes \= : \= \kill
  8568. Instruction      \> : \> \tty{ASR} \\
  8569. Function         \> : \> $A\leftarrow((A)\&(M))>>1$ \\
  8570. Addressing Modes \> : \> immediate \\
  8571. \end{tabbing}
  8572.  
  8573. \begin{tabbing}
  8574. Addressing Modes \= : \= \kill
  8575. Instruction      \> : \> \tty{RRA} \\
  8576. Function         \> : \> $M\leftarrow((M)>>>1)+(A)+(C)$ \\
  8577. Addressing Modes \> : \> absolute long/short, X-indexed long/short, \\
  8578.                 \>   \> Y-indexed long, X/Y-indirect \\
  8579. \end{tabbing}
  8580.  
  8581. \begin{tabbing}
  8582. Addressing Modes \= : \= \kill
  8583. Instruction      \> : \> \tty{ARR} \\
  8584. Function         \> : \> $A\leftarrow((A)\&(M))>>>1$ \\
  8585. Addressing Modes \> : \> immediate \\
  8586. \end{tabbing}
  8587.  
  8588. \begin{tabbing}
  8589. Addressing Modes \= : \= \kill
  8590. Instruction      \> : \> \tty{SAX} \\
  8591. Function         \> : \> $M\leftarrow(A)\&(X)$ \\
  8592. Addressing Modes \> : \> absolute long/short, Y-indexed short, \\
  8593.                 \>   \> Y-indirect \\
  8594. \end{tabbing}
  8595.  
  8596. \begin{tabbing}
  8597. Addressing Modes \= : \= \kill
  8598. Instruction      \> : \> \tty{ANE} \\
  8599. Function         \> : \> $M\leftarrow((A)\&\$ee)|((X)\&(M))$ \\
  8600. Addressing Modes \> : \> immediate \\
  8601. \end{tabbing}
  8602. \begin{tabbing}
  8603. Addressing Modes \= : \= \kill
  8604. Instruction      \> : \> \tty{SHA} \\
  8605. Function         \> : \> $M\leftarrow(A)\&(X)\&(PCH+1)$ \\
  8606. Addressing Modes \> : \> X/Y-indexed long \\
  8607. \end{tabbing}
  8608. \begin{tabbing}
  8609. Addressing Modes \= : \= \kill
  8610. Instruction      \> : \> \tty{SHS} \\
  8611. Function         \> : \> $X\leftarrow(A)\&(X), S\leftarrow(X), M\leftarrow(X)\&(PCH+1)$ \\
  8612. Addressing Modes \> : \> Y-indexed long \\
  8613. \end{tabbing}
  8614. \begin{tabbing}
  8615. Addressing Modes \= : \= \kill
  8616. Instruction      \> : \> \tty{SHY} \\
  8617. Function         \> : \> $M\leftarrow(Y)\&(PCH+1)$ \\
  8618. Addressing Modes \> : \> Y-indexed long \\
  8619. \end{tabbing}
  8620. \begin{tabbing}
  8621. Addressing Modes \= : \= \kill
  8622. Instruction      \> : \> \tty{SHX} \\
  8623. Function         \> : \> $M\leftarrow(X)\&(PCH+1)$ \\
  8624. Addressing Modes \> : \> X-indexed long \\
  8625. \end{tabbing}
  8626. \begin{tabbing}
  8627. Addressing Modes \= : \= \kill
  8628. Instruction      \> : \> \tty{LAX} \\
  8629. Function         \> : \> $A,X\leftarrow(M)$ \\
  8630. Addressing Modes \> : \> absolute long/short, Y-indexed long/short, \\
  8631.                 \>   \> X/Y-indirect \\
  8632. \end{tabbing}
  8633. \begin{tabbing}
  8634. Addressing Modes \= : \= \kill
  8635. Instruction      \> : \> \tty{LXA} \\
  8636. Function         \> : \> $X{04}\leftarrow(X){04}\&(M){04}$, \\
  8637.                 \>   \> $A{04}\leftarrow(A){04}\&(M){04}$ \\
  8638. Addressing Modes \> : \> immediate \\
  8639. \end{tabbing}
  8640. \begin{tabbing}
  8641. Addressing Modes \= : \= \kill
  8642. Instruction      \> : \> \tty{LAE} \\
  8643. Function         \> : \> $X,S,A\leftarrow((S)\&(M))$ \\
  8644. Addressing Modes \> : \> Y-indexed long \\
  8645. \end{tabbing}
  8646. \begin{tabbing}
  8647. Addressing Modes \= : \= \kill
  8648. Instruction      \> : \> \tty{DCP} \\
  8649. Function         \> : \> $M\leftarrow(M)-1, Flags\leftarrow((A)-(M))$ \\
  8650. Addressing Modes \> : \> absolute long/short, X-indexed long/short, \\
  8651.                 \>   \> Y-indexed long, X/Y-indirect \\
  8652. \end{tabbing}
  8653. \begin{tabbing}
  8654. Addressing Modes \= : \= \kill
  8655. Instruction      \> : \> \tty{SBX} \\
  8656. Function         \> : \> $X\leftarrow((X)\&(A))-(M)$ \\
  8657. Addressing Modes \> : \> immediate \\
  8658. \end{tabbing}
  8659. \begin{tabbing}
  8660. Addressing Modes \= : \= \kill
  8661. Instruction      \> : \> \tty{ISB} \\
  8662. Function         \> : \> $M\leftarrow(M)+1, A\leftarrow(A)-(M)-(C)$ \\
  8663. Addressing Modes \> : \> absolute long/short, X-indexed long/short, \\
  8664.                 \>   \> Y-indexed long, X/Y-indirect \\
  8665. \end{tabbing}
  8666.  
  8667. %%---------------------------------------------------------------------------
  8668.  
  8669. \section{MELPS-740}
  8670.  
  8671. Microcontrollers of this family have a quite nice, however well-hidden
  8672. feature: If one sets bit 5 of the status register with the \tty{SET}
  8673. instruction, the accumulator will be replaced with the memory cell
  8674. addressed by the X register for all load/store and arithmetic
  8675. instructions.  An attempt to integrate this feature cleanly into the
  8676. assembly syntax has not been made so far, so the only way to use it
  8677. is currently the ''hard'' way (\tty{SET}...instructions with accumulator
  8678. addressing...\tty{CLT}).
  8679.  
  8680. Not all MELPS-740 processors implement all instructions.  This is a
  8681. place where the programmer has to watch out for himself that no
  8682. instructions are used that are unavailable for the targeted
  8683. processor; \asname{} does not differentiate among the individual processors
  8684. of this family.  For a description of the details regarding special
  8685. page addressing, see the discussion of the \tty{ASSUME} instruction.
  8686.  
  8687. %%---------------------------------------------------------------------------
  8688.  
  8689. \section{MELPS-7700/65816}
  8690. \label{MELPS7700Spec}
  8691.  
  8692. As it seems, these two processor families took disjunct development
  8693. paths, starting from the 6502 via their 8 bit predecessors.  Shortly
  8694. listed, the following differences are present:
  8695. \begin{itemize}
  8696. \item{The 65816 does not have a B accumulator.}
  8697. \item{The 65816 does not have instructions to multiply or divide.}
  8698. \item{The 65816 misses the instructions \tty{SEB, CLB, BBC, BBS, CLM, SEM,
  8699.      PSH, PUL} and \tty{LDM}.  Instead, the instructions \tty{TSB, TRB, BIT, CLD,
  8700.      SED, XBA, XCE} and \tty{STZ} take their places in the opcode table.}
  8701. \end{itemize}
  8702. The following instructions have identical function, yet different
  8703. names:
  8704. \par
  8705. \begin{center}\begin{tabular}{|c|c||c|c|}
  8706. \hline
  8707.   65816  &  MELPS-7700 & 65816 &  MELPS-7700 \\
  8708. \hline
  8709. \hline
  8710.    \tty{REP}  &  \tty{CLP}  &  \tty{PHK}  &  \tty{PHG} \\
  8711.    \tty{TCS}  &  \tty{TAS}  &  \tty{TSC}  &  \tty{TSA} \\
  8712.    \tty{TCD}  &  \tty{TAD}  &  \tty{TDC}  &  \tty{TDA} \\
  8713.    \tty{PHB}  &  \tty{PHT}  &  \tty{PLB}  &  \tty{PLT} \\
  8714.    \tty{WAI}  &  \tty{WIT}  &             & \\
  8715. \hline
  8716. \end{tabular}\end{center}
  8717. \par
  8718. Especially tricky are the instructions \tty{PHB, PLB} and \tty{TSB}: these
  8719. instructions have a totally different encoding and meaning on both
  8720. processors!
  8721.  
  8722. Unfortunately, these processors address their memory in a way that is
  8723. IMHO even one level higher on the open-ended chart of perversity than
  8724. the Intel-like segmentation: They do banking!  Well, this seems to
  8725. be the price for the 6502 upward-compatibility; before one can use \asname{}
  8726. to write code for these processors, one has to inform \asname{} about the
  8727. contents of several registers (using the \tty{ASSUME} instruction):
  8728.  
  8729. The M flag rules whether the accumulators A and B should be used with
  8730. 8 bits (1) or 16 bits (0) width.  Analogously, the X flag decides the
  8731. width of the X and Y index registers.  \asname{} needs this information for
  8732. the decision about the argument's width when immediate addressing
  8733. (\verb!#<constant>!) occurs.
  8734.  
  8735. The memory is organized in 256 banks of 64 KBytes.  As all registers
  8736. in the CPU core have a maximum width of 16 bits, the upper 8 bits
  8737. have to be fetched from 2 special bank registers: DT delivers the
  8738. upper 8 bits for data accesses, and PG extends the 16-bit program
  8739. counter to 24 bits.  A 16 bits wide register DPR allows to move the
  8740. zero page known from the 6502 to an arbitrary location in the first
  8741. bank.  If \asname{} encounters an address (it is irrelevant if this address
  8742. is part of an absolute, indexed, or indirect expression), the
  8743. following addressing modes will be tested:
  8744. \begin{enumerate}
  8745. \item{Is the address in the range of DPR..DPR+\$ff?  If yes, use direct
  8746.      addressing with an 8-bit address.}
  8747. \item{Is the address contained in the page addressable via DT (resp.
  8748.      PG for branch instructions)? If yes, use absolute addressing
  8749.      with a 16-bit address.}
  8750. \item{If nothing else helps, use long addressing with a 24-bit
  8751.      address.}
  8752. \end{enumerate}
  8753. As one can see from this enumeration, the knowledge about the current
  8754. values of DT, PG and DPR is essential for a correct operation of \asname{};
  8755. if the specifications are incorrect, the program will probably do
  8756. wrong addressing at runtime.  This enumeration also implied that all
  8757. three address lengths are available; if this is not the case, the
  8758. decision chain will become shorter.
  8759. The automatic determination of the address length described above may
  8760. be overridden by the usage of prefixes.  If one prefixes the address
  8761. by a $<$, $>$, or $>>$ without a separating space, an address with 1, 2, or
  8762. 3 bytes of length will be used, regardless if this is the optimal
  8763. length.  If one uses an address length that is either not allowed for
  8764. the current instruction or too short for the address, an error
  8765. message is the result.
  8766. To simplify porting of 6502 programs, \asname{} uses the Motorola syntax for
  8767. hexadecimal constants instead of the Intel/IEEE syntax that is
  8768. the format preferred by Mitsubishi for their 740xxx series.  I still
  8769. think that this is the better format, and it looks as if the
  8770. designers of the 65816 were of the same opinion (as the \tty{RELAXED}
  8771. instruction allows the alternative use of Intel notation, this
  8772. decision should not hurt anything).  Another important detail for the
  8773. porting of programs is that it is valid to omit the accumulator A as
  8774. target for operations.  For example, it is possible to simply write
  8775. \verb!LDA #0! instead of \verb!LDA A,#0!.
  8776. A real goodie in the instruction set are the instructions \tty{MVN} resp.
  8777. \tty{MVP} to do block transfers.  However, their address specification
  8778. rules are a bit strange: bits 0--15 are stored in index registers,
  8779. bits 16--23 are part of the instruction.  When one uses \asname{}, one
  8780. simply specifies the full destination and source addresses.  \asname{} will
  8781. then automatically grab the correct bits.  This is a fine yet
  8782. important difference  Mitsubishi's assembler where you have to
  8783. extract the upper 8 bits on your own.  Things become really
  8784. convenient when a macro like the following is used:
  8785. \begin{verbatim}
  8786. mvpos   macro   src,dest,len
  8787.        if      MomCPU=$7700
  8788.         lda    #len
  8789.        elseif
  8790.         lda    #(len-1)
  8791.        endif
  8792.        ldx     #(src&$ffff)
  8793.        ldy     #(dest&$ffff)
  8794.        mvp     dest,src
  8795.        endm
  8796. \end{verbatim}
  8797. Caution, possible pitfall: if the accumulator contains the value n,
  8798. the Mitsubishi chip will transfer n bytes, but the 65816 will
  8799. transfer n+1 bytes!
  8800.  
  8801. The \tty{PSH} and \tty{PUL} instructions are also very handy because they
  8802. allow to save a user-defined set to be saved to the stack resp. to be
  8803. restored from the stack.  According to the Mitsubishi data book
  8804. \cite{Mit16}, the bit mask has to be specified as an immediate operand, so
  8805. the programmer either has to keep all bit$\leftrightarrow$register
  8806. assignments in mind or he has to define some appropriate symbols.  To make
  8807. things simpler, I decided to extend the syntax at this point: It is valid
  8808. to use a list as argument which may contain an arbitrary sequence of
  8809. register names or immediate expressions.  Therefore, the following
  8810. instructions
  8811. \begin{verbatim}
  8812.        psh     #$0f
  8813.        psh     a,b,#$0c
  8814.        psh     a,b,x,y
  8815.  
  8816. \end{verbatim}
  8817. are equivalent.  As immediate expressions are still valid, \asname{} stays
  8818. upward compatible to the Mitsubishi assemblers.
  8819.  
  8820. One thing I did not fully understand while studying the Mitsubishi
  8821. assembler is the treatment of the \tty{PER} instruction: this instruction
  8822. allows to push a 16-bit variable onto the stack whose address is
  8823. specified relative to the program counter.  Therefore, it is an
  8824. absolute addressing mode from the programmer's point of view.
  8825. Nevertheless, the Mitsubishi assembler requests immediate addressing,
  8826. and the instructions argument is placed into the code just as-is.
  8827. One has to calculate the address in his own, which is something
  8828. symbolic assemblers were designed for to avoid...as I wanted to stay
  8829. compatible, \asname{} contains a compromise:  If one chooses immediate
  8830. addressing (with a leading \# sign), \asname{} will behave like the original
  8831. from Mitsubishi.  But if the \# sign is omitted, as will calculate the
  8832. difference between the argument's value and the current program
  8833. counter and insert this difference instead.
  8834.  
  8835. A similar situation exists for the \tty{PEI} instruction that pushes the
  8836. contents of a 16-bit variable located in the zero page: Though the operand
  8837. represents an address, once again immediate addressing is required.  In
  8838. this case, \asname{} will simply allow both variants (i.e. with or without a \#
  8839. sign).
  8840.  
  8841. %%---------------------------------------------------------------------------
  8842.  
  8843. \section{M16}
  8844.  
  8845. The M16 family is a family of highly complex CISC processors with an
  8846. equally complicated instruction set.  One of the instruction set's
  8847. properties is the detail that in an instruction with two operands,
  8848. both operands may be of different sizes.  The method of appending the
  8849. operand size as an attribute of the instruction (known from Motorola
  8850. and adopted from Mitsubishi) therefore had to be extended: it is
  8851. valid to append attributes to the operands themselves.  For example,
  8852. the following instruction
  8853. \begin{verbatim}
  8854.        mov     r0.b,r6.w
  8855. \end{verbatim}
  8856. reads the lowest 8 bits of register 0, sign-extends them to 32 bits
  8857. and stores the result into register 6.  However, as one does not need
  8858. this feature in 9 out of 10 cases, it is still valid to append the
  8859. operand size to the instruction itself, e.g.
  8860. \begin{verbatim}
  8861.        mov.w   r0,r6
  8862. \end{verbatim}
  8863. Both variants may be mixed; in such a case, an operand size appended
  8864. to an operand overrules the ''default''.  An exception are instructions
  8865. with two operands.  For these instructions, the default for the
  8866. source operand is the destination operand's size.  For example, in
  8867. the following example
  8868. \begin{verbatim}
  8869.        mov.h   r0,r6.w
  8870. \end{verbatim}
  8871. register 0 is accessed with 32 bits, the size specification appended
  8872. to the instruction is not used at all.  If an instruction does not
  8873. contain any size specifications, word size (\tty{w}) will be used.
  8874. Remember: in contrast to the 68000 family, this means 32 bits instead
  8875. of 16 bits!
  8876.  
  8877. The chained addressing modes are also rather complex; the ability of
  8878. \asname{} to automatically assign address components to parts of the chain
  8879. keeps things at least halfway manageable.  The only way of influencing
  8880. \asname{} allows (the original assembler from Mitsubishi/Green Hills allows
  8881. a bit more in this respect) is the explicit setting of displacement
  8882. lengths by appending \tty{:4, :16} and \tty{:32}.
  8883.  
  8884. %%---------------------------------------------------------------------------
  8885.  
  8886. \section{CP-3F}
  8887.  
  8888. The CP-3F was developed in the early 1970, a time when development systems
  8889. were also much less powerful than today.  So when the assembly language for a
  8890. new processor was designed, it was also a design target that it should be easily
  8891. translatable into machine language.  So the CP-3F's original assembler
  8892. mnemonics group into few classes that can be treated the same by an assembler:
  8893. instructions with an immediate argument of 3, 4, or 8 bits, instructions with
  8894. a register operand, branches and instructions with no argument at all.  This is
  8895. simple to translate into machine code, the readability of the source code however
  8896. leaves to be desired by today's standards - comparable to Intel's assembly
  8897. language for the 8080.  I therefore decided to provide an alternate syntax which
  8898. more clearly expresses what an instruction does:
  8899.  
  8900. \begin{longtable}{|l|l|l|}
  8901. \hline
  8902. Original & Alternate & Function \\
  8903. \hline
  8904. \hline
  8905. \endhead
  8906. \input{../doc_COM/cp3finst.tex}
  8907. \\ \hline
  8908. \caption{Alternate Instruction Syntax for CP-3F}
  8909. \label{CP3FInst}
  8910. \end{longtable}
  8911.  
  8912. %%---------------------------------------------------------------------------
  8913.  
  8914. \section{4004/4040}
  8915.  
  8916. Thanks to John Weinrich, I now have the official Intel data sheets
  8917. describing these 'grandfathers' of all microprocessors, and the questions
  8918. about the syntax of register pairs (for 8-bit operations) have been weeded
  8919. out for the moment: It is \tty{RnRm} with \tty{n} resp. \tty{m} being even
  8920. integers in the range from 0 to E resp. 1 to F.  The equation {\tt m = n +
  8921. 1} must be fulfilled.
  8922.  
  8923. %%---------------------------------------------------------------------------
  8924.  
  8925. \section{MCS-48}
  8926.  
  8927. The maximum address space of these processors is 4 Kbytes, resp.  up to
  8928. 8 Kbytes on some Philips varaints.  This address space is not organized
  8929. in a linear way (how could this be on an Intel CPU...).  Instead, it is
  8930. split into 2 banks of 2 Kbytes.  The only way to change the program
  8931. counter from one bank to the other are the instructions \tty{CALL} and
  8932. \tty{JMP}, by setting the most significant bit of the address with the
  8933. instructions \tty{SEL MB0} to \tty{SEL MB3}.
  8934.  
  8935. The assembler may be informed about the bank currently being selected for
  8936. jumps and calls, via an {\tt \asname{}SUME} statement:
  8937. \begin{verbatim}
  8938.         \asname{}SUME MB:<0..3>
  8939. \end{verbatim}
  8940. If one tries to jump to an address in a different bank, a warnig is
  8941. issued.
  8942.  
  8943. If the special value {\tt NOTHING} is used (this is by the way the
  8944. default), an automatism uilt into \tty{JMP} and \tty{CALL} is activated.
  8945. It will insert a {\tt SEL MBx} instruction if the current program counter
  8946. and the target address are located in different banks.  Explicit usage of
  8947. \tty{SEL MBx} instructions is no longer necessary (though it remains possible),
  8948. and it might interfere with this mechanism, like in the following example:
  8949. \begin{verbatim}
  8950. 000:  SEL      MB1
  8951.       JMP      200h
  8952. \end{verbatim}
  8953. \asname{} assumes that the MB flag is 0 and therefore does not insert a \tty{SEL
  8954. MB0} instruction, with the result that the CPU jumps to address
  8955. A00h.
  8956.  
  8957. Furthermore, one should keep in mind that a jump instruction might
  8958. become longer (3 instead of 2 bytes).
  8959.  
  8960. %%---------------------------------------------------------------------------
  8961.  
  8962. \section{MCS-51}
  8963.  
  8964. The assembler is accompanied by the files \tty{STDDEF51.INC} resp.
  8965. \tty{80C50X.INC} that define all bits and SFRs of the processors 8051,
  8966. 8052, and 80515 resp. 80C501, 502, and 504.  Depending on the target
  8967. processor setting (made with the \tty{CPU} statement), the correct subset
  8968. will be included.  Therefore, the correct order for the instructions
  8969. at the beginning of a program is
  8970. \begin{verbatim}
  8971.        CPU     <processor type>
  8972.        INCLUDE stddef51.inc   .
  8973. \end{verbatim}
  8974. Otherwise, the MCS-51 pseudo instructions will lead to error
  8975. messages.
  8976.  
  8977. As the 8051 does not have instructions to to push the registers 0..7
  8978. onto the stack, one has to work with absolute addresses.  However,
  8979. these addresses depend on which register bank is currently active.
  8980. To make this situation a little bit better, the include files define
  8981. the macro \tty{USING} that accepts the symbols \tty{Bank0...Bank3} as arguments.
  8982. In response, the macro will assign the registers' correct absolute
  8983. addresses to the symbols \tty{AR0..AR7}.  This macro should be used after
  8984. every change of the register banks.  The macro itself does \bb{not}
  8985. generate any code to switch to the bank!
  8986.  
  8987. The macro also makes bookkeeping about which banks have been used.
  8988. The result is stored in the integer variable \tty{RegUsage}: bit 0
  8989. corresponds to bank 0, bit 1 corresponds to bank 1. and so on.  To
  8990. output its contents after the source has been assembled, use
  8991. something like the following piece of code:
  8992. \begin{verbatim}
  8993.        irp       BANK,Bank0,Bank1,Bank2,Bank3
  8994.         if        (RegUsage&(2^BANK))<>0
  8995.          message   "bank \{BANK} has been used"
  8996.         endif
  8997.        endm
  8998. \end{verbatim}
  8999. The multipass feature introduced with version 1.38 allowed to introduce
  9000. the additional instructions \tty{JMP} and \tty{CALL}.  If branches are
  9001. coded using these instructions, \asname{} will automatically use the variant that
  9002. is optimal for the given target address.  The options are \tty{SJMP,
  9003. AJMP}, or \tty{LJMP} for \tty{JMP} resp. \tty{ACALL} or \tty{LCALL} for
  9004. \tty{CALL}.  Of course it is still possible to use these variants
  9005. directly, in case one wants to force a certain coding.
  9006.  
  9007. %%---------------------------------------------------------------------------
  9008.  
  9009. \section{MCS-251}
  9010.  
  9011. When designing the 80C251, Intel really tried to make the move to
  9012. the new family as smooth as possible for programmers.  This
  9013. culminated in the fact that old applications can run on the new
  9014. processor without having to recompile them.  However, as soon as one
  9015. wants to use the new features, some details have to be regarded which
  9016. may turn into hidden pitfalls.
  9017.  
  9018. The most important thing is the absence of a distinct address space
  9019. for bits on the 80C251.  All SFRs can now be addressed bitwise,
  9020. regardless of their address.  Furthermore, the first 128 bytes of the
  9021. internal RAM are also bit addressable.  This has become possible
  9022. because bits are not any more handled by a separate address space
  9023. that overlaps other address spaces.  Instead, similar to other
  9024. processors, bits are addressed with a two-dimensional address that
  9025. consists of the memory location containing the bit and the bit's
  9026. location in the byte.  One result is that in an expression like
  9027. \tty{PSW.7}, \asname{} will do the separation of address and bit position itself.
  9028. Unlike to the 8051, it is not any more necessary to explicitly
  9029. generate 8 bit symbols.  This has the other result that the \tty{SFRB}
  9030. instruction does not exist any more.  If it is used in a program that
  9031. shall be ported, it may be replaced with a simple \tty{SFR} instruction.
  9032.  
  9033. Furthermore, Intel cleaned up the cornucopia of different address
  9034. spaces on the 8051: the internal RAM (\tty{DATA} resp. \tty{IDATA}), the
  9035. \tty{XDATA} space and the former \tty{CODE} space were unified to a single
  9036. \tty{CODE} space that is now 16 Mbytes large.  The internal RAM starts at
  9037. address 0, the internal ROM starts at address ff0000h, which is the
  9038. address code has to be relocated to.  In contrast, the SFRs were moved to
  9039. a separate address space (which \asname{} refers to as the \tty{IO} segment).
  9040. However, they have the same addresses in this new address space as they
  9041. used to have on the 8051.  The \tty{SFR} instructions knows of this
  9042. difference and automatically assigns symbols to either the \tty{DATA} or
  9043. \tty{IO} segment, depending on the target processor.  As there is no
  9044. \tty{BIT} segment any more, the \tty{BIT} instruction operates completely
  9045. different: Instead of a linear address ranging from 0..255, a bit symbol
  9046. now contains the byte's address in bit 0..7, and the bit position in bits
  9047. 24..26.  Unfortunately, creating arrays of flags with a symbolic address
  9048. is not that simple any more: On an 8051, one simply wrote:
  9049. \begin{verbatim}
  9050.        segment bitdata
  9051.  
  9052. bit1    db      ?
  9053. bit2    db      ?
  9054.  
  9055. or
  9056.  
  9057. defbit  macro   name
  9058. name    bit     cnt
  9059. cnt     set     cnt+1
  9060.        endm
  9061. \end{verbatim}
  9062. On a 251, only the second way still works, like this:
  9063.  \begin{verbatim}
  9064. adr     set     20h     ; start address of flags
  9065. bpos    set     0       ; in the internal RAM
  9066.  
  9067. defbit  macro   name
  9068. name    bit     adr.bpos
  9069. bpos    set     bpos+1
  9070.        if      bpos=8
  9071. bpos     set     0
  9072. adr      set     adr+1
  9073.        endif
  9074.        endm
  9075. \end{verbatim}
  9076. Another small detail: Intel now prefers \tty{CY} instead of \tty{C} as a
  9077. symbolic name for the carry, so you might have to rename an already
  9078. existing variable of the same name in your program.  However, \asname{} will
  9079. continue to understand also the old variant when using the instructions
  9080. \tty{CLR, CPL, SETB, MOV, ANL,} or \tty{ORL}.  The same is conceptually
  9081. true for the additional registers \tty{R8..R15, WR0..WR30, DR0..DR28, DR56,
  9082. DR60, DPX,} and \tty{SPX}.
  9083.  
  9084. Intel would like everyone to write absolute addresses in a syntax of
  9085. \tty{XX:YYYY}, where \tty{XX} is a 64K bank in the address space resp.
  9086. signifies addresses in the I/O space with an \tty{S}.  As one might guess,
  9087. I am not amused about this, which is why it is legal to alternitavely use
  9088. linear addresses in all places.  Only the \tty{S} for I/O addresses is
  9089. incircumventable, like in this case:
  9090. \begin{verbatim}
  9091. Carry   bit     s:0d0h.7
  9092. \end{verbatim}
  9093. Without the prefix, \asname{} would assume an address in the \tty{CODE} segment,
  9094. and only the first 128 bits in this space are bit-addressable...
  9095.  
  9096. Like for the 8051, the generic branch instructions \tty{CALL} and
  9097. \tty{JMP} exist that automatically choose the shortest machine code
  9098. depending on the address layout.  However, while \tty{JMP} also may use
  9099. the variant with a 24-bit address, \tty{CALL} will not do this for a good
  9100. reason: In contrast to \tty{ACALL} and \tty{LCALL}, \tty{ECALL} places an
  9101. additional byte onto the stack.  A \tty{CALL} instruction would result where
  9102. you would not know what it will do.  This problem does not exist for the
  9103. \tty{JMP} instructions.
  9104.  
  9105. There is one thing I did not understand: The 80251 is also able to
  9106. push immediate operands onto the stack, and it may push either single
  9107. bytes or complete words.  However, the same mnemonic (\tty{PUSH}) is
  9108. assigned to both variants - how on earth should an assembler know if
  9109. an instruction like
  9110. \begin{verbatim}
  9111.        push    #10
  9112. \end{verbatim}
  9113. shall push a byte or a word containing the value 10?  So the current
  9114. rule is that \tty{PUSH} always pushes a byte; if one wants to push a word,
  9115. simply use \tty{PUSHW} instead of \tty{PUSH}.
  9116.  
  9117. Another well-meant advise: If you use the extended instruction set,
  9118. be sure to operate the processor in source mode; otherwise, all
  9119. instructions will become one byte longer!  The old 8051 instructions
  9120. that will in turn become one byte longer are not a big matter:  \asname{}
  9121. will either replace them automatically with new, more general
  9122. instructions or they deal with obsolete addressing modes (indirect
  9123. addressing via 8 bit registers).
  9124.  
  9125. %%---------------------------------------------------------------------------
  9126.  
  9127. \section{8080/8085}
  9128. \label{8080Spec}
  9129.  
  9130. As mentioned before, the statement
  9131. \begin{verbatim}
  9132.       Z80SYNTAX <ON|OFF|EXCLUSIVE>
  9133. \end{verbatim}
  9134. makes it possible to write the vast majority of 8080/8085
  9135. instructions in 'Z80 s          tyle', i.e. with less mnemonics but with
  9136. operands that are easier to understand.  In non-exclusive mode,
  9137. the Z80 syntax is not allowed for the following instructions,
  9138. because they conflict with existing 8080 mnemonics:
  9139. \begin{itemize}
  9140. \item{\tty{CP} in 'Intel syntax' means 'Call on Positive', in
  9141.      Zilog syntax however it means 'Compare'.  If you use
  9142.      \tty{CP} with a numeric value, it is not possible for the
  9143.      assembler to recognize whether a jump to an absolute
  9144.      address or a compare with an immediate value is meant.
  9145.      The assembler will generate a jump in this case, since the
  9146.      Intel syntax has precedence in case of ambiguities. If
  9147.      one wants the comparison, one may explicitly write down the
  9148.      accumulator as destination operand, e.g. \tty{CP A,12h}
  9149.      instead of \tty{CP 12h}.}
  9150. \item{\tty{JP} in Intel syntax means 'Jump on Positive', in Zilog
  9151.      syntax however, this is the jump instruction in general.
  9152.      Conditional jumps in Zilog syntax (\tty{JP cond,addr}) are
  9153.      unambigious because of the two arguments.  With only one
  9154.      argument, the assembler will however always generate the
  9155.      conditional jump.  If you want an unconditional jump to
  9156.      an absolute address, you still have to use the Intel syntax
  9157.      ((\tty{JMP addr}).}
  9158. \end{itemize}
  9159. The 8085 supports the instructions \tty{RIM} and \tty{SIM} that are
  9160. not part of the Z80 instruction set.  They may be written in 'Z80 style'
  9161. as \tty{LD A,IM} resp. \tty{LD IM,A}.
  9162.  
  9163. %%---------------------------------------------------------------------------
  9164.  
  9165. \section{8085UNDOC}
  9166. \label{8085Spec}
  9167.  
  9168. Similarly to the Z80 or 6502, Intel did not further specify the
  9169. undocumented 8085 instructions.  This however means that other assemblers
  9170. might use different mnemonics for the same function.  Therefore, I will
  9171. list the instructions in the following.  Once again, usage of these
  9172. instructions is at one's own risk - even the Z80 which is principally
  9173. upward compatible to the 8085 uses the opcodes for entirely different
  9174. functions...
  9175.  
  9176. \begin{tabbing}
  9177. Arguments         \= : \= \kill \\
  9178. Instruction       \> : \> \tty{DSUB [reg]} \\
  9179. Z80 Syntax        \> : \> \tty{SUB HL,reg} \\
  9180. Function          \> : \> HL $\leftarrow$ HL - reg \\
  9181. Flags             \> : \> CY, S, X5, AC, Z, V, P \\
  9182. Arguments         \> : \> \tty{reg} = B for BC (optional for non-Z80 syntax) \\
  9183. \end{tabbing}
  9184.  
  9185. \begin{tabbing}
  9186. Arguments         \= : \= \kill \\
  9187. Instruction       \> : \> \tty{ARHL} \\
  9188. Z80 Syntax        \> : \> \tty{SRA HL} \\
  9189. Function          \> : \> HL,CY $\leftarrow$ HL $>>$ 1 (arithmetisch) \\
  9190. Flags             \> : \> CY \\
  9191. Arguments         \> : \> none resp. fixed for Z80 syntax \\
  9192. \end{tabbing}
  9193.  
  9194. \begin{tabbing}
  9195. Arguments         \= : \= \kill \\
  9196. Instruction       \> : \> \tty{RDEL} \\
  9197. Z80 Syntax        \> : \> \tty{RLC DE} \\
  9198. Function          \> : \> CY,DE $\leftarrow$ DE $<<$ 1 \\
  9199. Flags             \> : \> CY, V \\
  9200. Arguments         \> : \> none resp. fixed for Z80 syntax \\
  9201. \end{tabbing}
  9202.  
  9203. \begin{tabbing}
  9204. Arguments         \= : \= \kill \\
  9205. Instruction       \> : \> \tty{LDHI d8} \\
  9206. Z80 Syntax        \> : \> \tty{ADD DE,HL,d8} \\
  9207. Function          \> : \> DE $\leftarrow$ HL + {\tt d8} \\
  9208. Flags             \> : \> none \\
  9209. Arguments         \> : \> {\tt d8} = 8-bit constant, registers fixed for Z80 syntax \\
  9210. \end{tabbing}
  9211.  
  9212. \begin{tabbing}
  9213. Arguments         \= : \= \kill \\
  9214. Instruction       \> : \> \tty{LDSI d8} \\
  9215. Z80 Syntax        \> : \> \tty{ADD DE,SP,d8} \\
  9216. Function          \> : \> DE $\leftarrow$ SP + {\tt d8} \\
  9217. Flags             \> : \> none \\
  9218. Arguments         \> : \> {\tt d8} = 8-bit constant, registers fixed for Z80 syntax \\
  9219. \end{tabbing}
  9220.  
  9221. \begin{tabbing}
  9222. Arguments         \= : \= \kill \\
  9223. Instruction       \> : \> \tty{RSTflag} \\
  9224. Z80 Syntax        \> : \> \tty{RST flag} \\
  9225. Function          \> : \> restart to 40h if {\tt flag}=1 \\
  9226. Flags             \> : \> none \\
  9227. Arguments         \> : \> {\tt flag} = V for overflow bit \\
  9228. \end{tabbing}
  9229.  
  9230. \begin{tabbing}
  9231. Arguments         \= : \= \kill \\
  9232. Instruction       \> : \> \tty{SHLX [reg]} \\
  9233. Z80 Syntax        \> : \> \tty{LD (reg),HL} \\
  9234. Function          \> : \> [reg] $\leftarrow$ HL \\
  9235. Flags             \> : \> none \\
  9236. Arguments         \> : \> \tty{reg} = D/DE for DE (optional for non-Z80 syntax) \\
  9237. \end{tabbing}
  9238.  
  9239. \begin{tabbing}
  9240. Arguments         \= : \= \kill \\
  9241. Instruction       \> : \> \tty{LHLX [reg]} \\
  9242. Z80 Syntax        \> : \> \tty{LD HL,(reg)} \\
  9243. Function          \> : \> HL $\leftarrow$ [reg] \\
  9244. Flags             \> : \> none \\
  9245. Arguments         \> : \> \tty{reg} = D/DE for DE (optional for non-Z80 syntax) \\
  9246. \end{tabbing}
  9247.  
  9248. \begin{tabbing}
  9249. Arguments         \= : \= \kill \\
  9250. Instruction       \> : \> \tty{JNX5 addr} \\
  9251. Z80 Syntax        \> : \> \tty{JP NX5, addr} \\
  9252. Function          \> : \> jump to {\tt addr} if X5=0 \\
  9253. Flags             \> : \> none \\
  9254. Arguments         \> : \> {\tt addr} = absolute 16-bit address \\
  9255. \end{tabbing}
  9256.  
  9257. \begin{tabbing}
  9258. Arguments         \= : \= \kill \\
  9259. Instruction       \> : \> \tty{JX5 addr} \\
  9260. Z80 Syntax        \> : \> \tty{JP X5,addr} \\
  9261. Function          \> : \> jump to {\tt addr} if X5=1 \\
  9262. Flags             \> : \> none \\
  9263. Arguments         \> : \> {\tt addr} = absolute 16-bit address \\
  9264. \end{tabbing}
  9265.  
  9266. X5 refers to the otherwise unused bit 5 in the processor status word (PSW).
  9267.  
  9268. %%---------------------------------------------------------------------------
  9269.  
  9270. \section{8086..V35}
  9271.  
  9272. Actually, I had sworn myself to keep the segment disease of Intel's
  9273. 8086 out of the assembler.  However, as there was a request and as
  9274. students are more flexible than the developers of this processor
  9275. obviously were, there is now a rudimentary support of these
  9276. processors in \asname{}.  When saying, 'rudimentary', it does not mean that
  9277. the instruction set is not fully covered.  It means that the whole
  9278. pseudo instruction stuff that is available when using MASM, TASM, or
  9279. something equivalent does not exist.  To put it in clear words, \asname{}
  9280. was not primarily designed to write assembler programs for PC's
  9281. (heaven forbid, this really would have meant reinventing the wheel!);
  9282. instead, the development of programs for single-board computers was
  9283. the main goal (which may also be equipped with an 8086 CPU).
  9284.  
  9285. For die-hards who still want to write DOS programs with \asname{}, here is a
  9286. small list of things to keep in mind:
  9287. \begin{itemize}
  9288. \item{Only \tty{COM} files may be created.}
  9289. \item{Only use the \tty{CODE} segment, and place also all variables in
  9290.      this segment.}
  9291. \item{DOS initializes all segment registers to the code segment.
  9292.      An \tty{ASSUME DS:DATA, SS:DATA} right at the program's beginning
  9293.      is therefore necessary.}
  9294. \item{DOS loads the code to a start address of 100h.  An \tty{ORG} to this
  9295.      address is absolutely necessary.}
  9296. \item{The conversion to a binary file is done with P2BIN (see later in
  9297.      this document), with an address filter of \tty{\$-\$}.}
  9298. \end{itemize}
  9299. For these processors, \asname{} only supports a small programming model, i.e.
  9300. there is \bb{one} code segment with a maximum of 64 Kbytes and a data
  9301. segment of equal size for data (which cannot be set to initial values for
  9302. \tty{COM} files).  The \tty{SEGMENT} instruction allows to switch between
  9303. these two segments.  From this facts results that branches are always
  9304. intrasegment branches if they refer to targets in this single code
  9305. segment.  In case that far jumps should be necessary, they are possible
  9306. via \tty{CALLF} or \tty{JMPF} with a memory address or a
  9307. \tty{Segment:Offset} value as argument.
  9308.  
  9309. Another big problem of these processors is their assembler syntax,
  9310. which is sometimes ambiguous and whose exact meaning can then only be
  9311. deduced by looking at the current context.  In the following example,
  9312. either absolute or immediate addressing may be meant, depending on
  9313. the symbol's type:
  9314. \begin{verbatim}
  9315.        mov     ax,value
  9316. \end{verbatim}
  9317. When using \asname{}, an expression without brackets always is interpreted
  9318. as immediate addressing.  For example, when either a variable's
  9319. address or its contents shall be loaded, the differences listed in table
  9320. \ref{TabMASM} are present between MASM and \asname{}:
  9321. \begin{table*}
  9322. \begin{center}\begin{tabular}{|l|l|l|}
  9323. \hline
  9324. assembler  & address             & contents \\
  9325. \hline
  9326. \hline
  9327. MASM       &  \tty{mov ax,offset vari} &  \tty{mov ax,vari} \\
  9328.           &  \tty{lea ax,vari}        &  \tty{mov ax,[vari]} \\
  9329.           &  \tty{lea ax,[vari]}      & \\
  9330.           &                           & \\
  9331. \asname{}         &  \tty{mov ax,vari}        &  \tty{mov ax,[vari]} \\
  9332.           &  \tty{lea ax,[vari]}      & \\
  9333. \hline
  9334. \end{tabular}\end{center}
  9335. \caption{Differences \asname{}$\leftrightarrow$MASM Concerning Addressing
  9336.         Syntax\label{TabMASM}}
  9337. \end{table*}
  9338. \par
  9339. When addressing via a symbol, the assembler checks whether they are
  9340. assigned to the data segment and tries to automatically insert an
  9341. appropriate segment prefix.  This happens for example when symbols
  9342. from the code segment are accessed without specifying a \tty{CS} segment
  9343. prefix.  However, this mechanism can only work if the \tty{ASSUME}
  9344. instruction (see there) has previously been applied correctly.
  9345.  
  9346. The Intel syntax also requires to store whether bytes or words were
  9347. stored at a symbol's address.  \asname{} will do this only when the \tty{DB} resp.
  9348. \tty{DW} instruction is in the same source line as the label.  For any
  9349. other case, the operand size has to be specified explicitly with the
  9350. \tty{BYTE PTR, WORD PTR,...} operators.  As long as a register is the other
  9351. operator, this may be omitted, as the operand size is then clearly
  9352. given by the register's name.
  9353.  
  9354. In an 8086-based system, the coprocessor is usually synchronized via
  9355. via the processor's TEST input line which is connected to toe
  9356. coprocessor's BUSY output line.  \asname{} supports this type of handshaking
  9357. by automatically inserting a \tty{WAIT} instruction prior to every 8087
  9358. instruction.  If this is undesired for any reason, an \tty{N} has to be
  9359. inserted after the \tty{F} in the mnemonic; for example,
  9360. \begin{verbatim}
  9361.        FINIT
  9362.        FSTSW   [vari]
  9363. \end{verbatim}
  9364. becomes
  9365. \begin{verbatim}
  9366.        FNINIT
  9367.        FNSTSW  [vari]
  9368. \end{verbatim}
  9369. This variant is valid for \bb{all} coprocessor instructions.
  9370.  
  9371. %%---------------------------------------------------------------------------
  9372.  
  9373. \section{8X30x}
  9374. \label{8X30xSpec}
  9375.  
  9376. The processors of this family have been optimized for an easy manipulation
  9377. of bit groups at peripheral addresses.  The instructions \tty{LIV} and
  9378. \tty{RIV} were introduced to deal with such objects in a symbolic fashion.
  9379. They work similar to \tty{EQU}, however they need three parameters:
  9380. \begin{enumerate}
  9381. \item{the address of the peripheral memory cell that contains the bit
  9382.     group (0..255);}
  9383. \item{the number of the group's first bit (0..7);}
  9384. \item{the length of the group, expressed in bits (1..8).}
  9385. \end{enumerate}
  9386. \bb{CAUTION!} The 8X30x does not support bit groups that span over more
  9387. than one memory address.  Therefore, the valid value range for the
  9388. length can be stricter limited, depending on the start position.  \asname{}
  9389. does \bb{not} perform any checks at this point, you simply get strange
  9390. results at runtime!
  9391.  
  9392. Regarding the machine code, length and position are expressed vis a 3
  9393. bit field in the instruction word and a proper register number (\tty{LIVx}
  9394. resp. \tty{RIVx}).  If one uses a symbolic object, \asname{} will automatically
  9395. assign correct values to this field, but it is also allowed to
  9396. specify the length explicitly as a third operand if one does not work
  9397. with symbolic objects.  If \asname{} finds such a length specification in
  9398. spite of a symbolic operand, it will compare both lengths and issue
  9399. an error if they do not match (the same will happen for the MOVE
  9400. instruction if two symbolic operands with different lengths are used
  9401. - the instruction simply only has a single length field...).
  9402.  
  9403. Apart from the real machine instructions, \asname{} defines similarly to its
  9404. ''idol'' MCCAP some pseudo instructions that are implemented as builtin
  9405. macros:
  9406. \begin{itemize}
  9407. \item{\tty{NOP} is a shortform for \tty{MOVE AUX,AUX}}
  9408. \item{\tty{HALT} is a shortform for {\tt JMP \verb!*!}}
  9409. \item{\tty{XML ii} is a shortform for \tty{XMIT ii,R12} (only 8X305)}
  9410. \item{\tty{XMR ii} is a shortform for \tty{XMIT ii,R13} (only 8X305)}
  9411. \item{\tty{SEL $<$busobj$>$} is a shortform for \tty{XMIT $<$adr$>$,IVL/IVR},
  9412.   i.e. it performs the necessary preselection to access $<$busobj$>$.}
  9413. \end{itemize}
  9414. The \tty{CALL} and \tty{RTN} instructions MCCAP also implements are
  9415. currently missing due to sufficient documentation.  The same is true for a
  9416. set of pseudo instructions to store constants to memory.  Time may change
  9417. this...
  9418.  
  9419. %%---------------------------------------------------------------------------
  9420.  
  9421. \section{XA}
  9422.  
  9423. Similar to its predecessor MCS/51, but in contrast to its
  9424. 'competitor' MCS/251, the Philips XA has a separate address space for
  9425. bits, i.e. all bits that are accessible via bit instructions have a
  9426. certain, one-dimensional address which is stored as-is in the machine
  9427. code.  However, I could not take the obvious opportunity to offer
  9428. this third address space (code and data are the other two) as a
  9429. separate segment.  The reason is that - in contrast to the MCS/51 -
  9430. some bit addresses are ambiguous: bits with an address from 256 to 511
  9431. refer to the bits of memory cells 20h..3fh in the current data
  9432. segment.  This means that these addresses may correspond to different
  9433. physical bits, depending on the current state.  Defining bits with
  9434. the help of \tty{DC} instructions - something that would be possible with a
  9435. separate segment - would not make too much sense.  However, the \tty{BIT}
  9436. instruction still exists to define individual bits (regardless if
  9437. they are located in a register, the RAM or SFR space) that can then
  9438. be referenced symbolically.  If the bit is located in RAM, the
  9439. address of the 64K-bank is also stored.  This way, \asname{} can check
  9440. whether the DS register has previously be assigned a correct value
  9441. with an \tty{ASSUME} instruction.
  9442.  
  9443. In contrast, nothing can stop \asname{}'s efforts to align potential branch
  9444. targets to even addresses.  Like other XA assemblers, \asname{} does this by
  9445. inserting \tty{NOP}s right before the instruction in question.
  9446.  
  9447. %%---------------------------------------------------------------------------
  9448.  
  9449. \section{AVR}
  9450.  
  9451. In contrast to the AVR assembler, \asname{} by default uses the Intel format
  9452. to write hexadecimal contants instead of the C syntax.  All right, I
  9453. did not look into the (free) AVR assembler before, but when I started
  9454. with the AVR part, there was hardly mor einformation about the AVR
  9455. than a preliminary manual describing processor types that were never
  9456. sold...this problem can be solved with a simple RELAXED ON.
  9457.  
  9458. Optionally, \asname{} can generate so-called "object files" for the AVRs (it
  9459. also works for other CPUs, but it does not make any sense for them...).
  9460. These are files containing code and source line info what e.g. allows
  9461. a step-by-step execution on source level with the WAVRSIM simulator
  9462. delivered by Atmel.  Unfortunately, the simulator seems to have
  9463. trouble with source file names longer than approx. 20 characters:
  9464. Names are truncated and/or extended by strange special characters
  9465. when the maximum length is exceeded.  \asname{} therefore stores file name
  9466. specifications in object files without a path specification.
  9467. Therefore, problems may arise when files like includes are not in the
  9468. current directory.
  9469.  
  9470. A small specialty are machine instructions that have already been defined
  9471. by Atmel as part of the architecture, but up to now haven't been
  9472. implemented in any of the family's members.  The instructions in question
  9473. are {\tt MUL, JMP,} and {\tt CALL}.  Considering the latter ones, one may
  9474. ask himself how to reach the 4 Kwords large address space of the AT90S8515
  9475. when the 'next best' instructions {\tt RJMP} and {\tt RCALL} can only
  9476. branch up to 2 Kwords forward or backward.  The trick is named 'discarding
  9477. the upper address bits' and described in detail with the {\tt WRAPMODE}
  9478. statement.
  9479.  
  9480. All AVR targets support the optional CPU argument {\tt CODESEGSIZE}.
  9481. Like in this example,
  9482. \begin{verbatim}
  9483.   cpu atmega8:codesegsize=0
  9484. \end{verbatim}
  9485. it may be used to instruct the assembler to treat the code segment (i.e.
  9486. the internal flash ROM) as being organized in bytes instead of 16 bit words.
  9487. This is the view when the {\tt LPM} instruction is used, and which some other
  9488. (non Atmel) assemblers use in general.  It has the advantage that addresses
  9489. in the {\tt CODE} segment need not be multiplied by two if used for data
  9490. accesses.  On the other hand, care has to be taken that instructions do
  9491. not start on an odd address - this would be the equivalent of an instruction
  9492. occupying fractions of flash words.  The {\tt PADDING} option is therefore
  9493. enabled by default, while it remains possible to define arrays of bytes via
  9494. multiple uses of {\tt DB} or {\tt DATA} without the risk of padding bytes
  9495. inserted in between.  Target addresses for relative and absolute branches
  9496. automatically get divided by two in this ''byte mode''.  The default is the
  9497. organizazion in 16 bit word as used by the original Atmel assembler.  This
  9498. may explicitly be selected by using the argument \verb!codesegsize=1!.
  9499.  
  9500. %%---------------------------------------------------------------------------
  9501.  
  9502. \section{Z80UNDOC}
  9503.  
  9504. As one might guess, Zilog did not make any syntax definitions for the
  9505. undocumented instructions; furthermore, not everyone might know the
  9506. full set.  It might therefore make sense to list all instructions at
  9507. this place:
  9508.  
  9509. Similar to a Z380, it is possible to access the byte halves of IX and
  9510. IY separately.  In detail, these are the instructions that allow
  9511. this:
  9512. \begin{verbatim}
  9513. INC Rx              LD R,Rx             LD  Rx,n
  9514. DEC Rx              LD Rx,R             LD  Rx,Ry
  9515. ADD/ADC/SUB/SBC/AND/XOR/OR/CP A,Rx
  9516. \end{verbatim}
  9517. \tty{Rx} and \tty{Ry} are synonyms for \tty{IXL, IXU, IYL} or \tty{IYU}.
  9518. Keep however in mind that in the case of \tty{LD  Rx,Ry}, both registers
  9519. must be part of the same index register.
  9520.  
  9521. The coding of shift instructions leaves an undefined bit combination which
  9522. is now accessible as the tty{SL1}, \tty{SLI}, \tty{SLIA}, or \tty{SLS}
  9523. instruction.  It works like \tty{SLA} with the difference of entering a 1
  9524. into bit position 0.  \bb{CAUTION!} Some sources also name this operation
  9525. \tty{SLL}.  It decided to not offer this, since it is misleading: \tty{SLL}
  9526. translates into "shift left logically", and the operation performed by this
  9527. instruction is no logical left shift.  If one should define \tty{SLL} at
  9528. all, then as an alias for \tty{SLA}.  If you have existing code that uses
  9529. \tty{SLL} in the meaning of \tty{SL1/SLI}, define it via a macro.
  9530.  
  9531. Like all other (docummented) shift instructions, this also works in
  9532. another undocumented variant:
  9533. \begin{verbatim}
  9534.        SLIA    R,(XY+d)
  9535.        SLIA    (XY+d),R
  9536. \end{verbatim}
  9537. In this case, \tty{R} is an arbitrary 8-bit register (excluding index
  9538. register halves...), and \tty{(XY+d)} is a normal indexed address.  This
  9539. operation has the additional effect of copying the result into the
  9540. register.  This also works for the \tty{RES} and \tty{SET} instructions:
  9541. \begin{verbatim}
  9542.        SET/RES R,n,(XY+d)
  9543.        SET/RES n,(XY+d),R
  9544. \end{verbatim}
  9545. Furthermore, two hidden I/O instructions exist:
  9546. \begin{verbatim}
  9547.        IN      (C) resp. TSTI
  9548.        OUT     (C),0
  9549. \end{verbatim}
  9550. Their operation should be clear.  \bb{CAUTION!}  Noone can
  9551. guarantee that all mask revisions of the Z80 execute these
  9552. instructions, and the Z80's successors will react with traps if they
  9553. find one of these instructions.  Use them on your own risk...
  9554.  
  9555. %%---------------------------------------------------------------------------
  9556.  
  9557. \section{GB\_Z80 resp. LR35902}
  9558.  
  9559. The LR35902 SoC used in the original Gameboy  was developed by Sharp,
  9560. and the CPU core is (probably) the same as in the SM83
  9561. microcontrollers.  Regarding its instruction set, it is somewhere
  9562. ''half way'' between 8080 and Z80, however with its own omissions and
  9563. extensions.  Sharp of course defined an assembler syntax for the new
  9564. instructions.  However, variations have established itself in the
  9565. ''Gameboy scene''.  I tried to regard those as well (as far as I am
  9566. aware of them):
  9567.  
  9568. \begin{center}\begin{tabular}{|l|l|l|}
  9569. \hline
  9570. Sharp & Alternate & Function \\
  9571. \hline
  9572. \hline
  9573. LD A,(HLD)    & LD A,(HL-)  & A $\longleftarrow$ (HL), \\
  9574.              & LDD A,(HL)  & HL $\longleftarrow$ HL-1 \\
  9575. \hline
  9576. LD A,(HLI)    & LD A,(HL+)  & A $\longleftarrow$ (HL), \\
  9577.              & LDI A,(HL)  & HL $\longleftarrow$ HL+1 \\
  9578. \hline
  9579. LD (HLD),A    & LD (HL-),A  & (HL) $\longleftarrow$ A, \\
  9580.              & LDD (HL),A  & HL $\longleftarrow$ HL-1 \\
  9581. \hline
  9582. LD (HLI),A    & LD (HL+),A  & (HL) $\longleftarrow$ A, \\
  9583.              & LDI (HL),A  & HL $\longleftarrow$ HL+1 \\
  9584. \hline
  9585. LD A,(C)      & LD A,(FF00+C) & A $\longleftarrow$ (0ff00h+C) \\
  9586.              & LDH A,(C)     & \\
  9587. \hline
  9588. LD (C),A      & LD (FF00+C),A & (0ff00h+C) $\longleftarrow$ A \\
  9589.              & LDH (C),A     & \\
  9590. \hline
  9591. LD (FF00+n),A & LDH (n),A     & (0ff00h+n) $\longleftarrow$ A \\
  9592. \hline
  9593. LD A,(FF00+n) & LDH A,(n)     & A $\longleftarrow$ (0ff00h+n) \\
  9594. \hline
  9595. LDHL SP,d     & LD HL,SP+d    & HL $\longleftarrow$ SP + d \\
  9596. \hline
  9597. LDX A,(nn)    & LD A,(nn)     & A $\longleftarrow$ (nn) $^{1}$ \\
  9598. \hline
  9599. LDX (nn),A    & LD (nn),A     & (nn) $\longleftarrow$ A $^{1}$ \\
  9600. \hline
  9601. \multicolumn{3}{|l|}{$^{1}$ enforces 16 bit addressing } \\
  9602. \hline
  9603. \end{tabular}\end{center}
  9604.  
  9605. %%---------------------------------------------------------------------------
  9606.  
  9607. \section{Z380}
  9608.  
  9609. As this processor was designed as a grandchild of the still most popular
  9610. 8-bit microprocessor, it was a sine-qua-non design target to execute
  9611. existing Z80 programs without modification (of course, they execute a bit
  9612. faster, roughly by a factor of 10...).  Therefore, all extended features
  9613. can be enabled after a reset by setting two bits which are named XM
  9614. (eXtended Mode, i.e. a 32-bit instead of a 16-bit address space)
  9615. respectively LW (long word mode, i.e. 32-bit instead of 16-bit operands).
  9616. One has to inform \asname{} about their current setting with the instructions
  9617. \tty{EXTMODE} resp. \tty{LWORDMODE}, to enable \asname{} to check addresses and
  9618. constants against the correct upper limits.  The toggle between 32- and
  9619. 16-bit instruction of course only influences instructions that are
  9620. available in a 32-bit variant.  Unfortunately, the Z380 currently offers
  9621. such variants only for load and store instructions; arithmetic can only be
  9622. done in 16 bits.  Zilog really should do something about this, otherwise
  9623. the most positive description for the Z380 would be ''16-bit processor
  9624. with 32-bit extensions''...
  9625.  
  9626. The whole thing becomes complicated by the ability to override the operand
  9627. size set by LW with the instruction prefixes \tty{DDIR W} resp.
  9628. \tty{DDIR LW}.  \asname{} will note the occurrence of such instructions and will
  9629. toggle setting for the instruction following directly.  By the way, one
  9630. should never explicitly use other \tty{DDIR} variants than \tty{W} resp.
  9631. \tty{LW}, as \asname{} will introduce them automatically when an operand is
  9632. discovered that is too long.  Explicit usage might puzzle \asname{}.  The
  9633. automatism is so powerful that in a case like this:
  9634. \begin{verbatim}
  9635.        DDIR    LW
  9636.        LD      BC,12345678h   ,
  9637. \end{verbatim}
  9638. the necessary \tty{IW} prefix will automatically be merged into the previous
  9639. instruction, resulting in
  9640. \begin{verbatim}
  9641.        DDIR    LW,IW
  9642.        LD      BC,12345668h   .
  9643. \end{verbatim}
  9644. The machine code that was first created for \tty{DDIR LW} is retracted and
  9645. replaced, which is signified with an \tty{R} in the listing.
  9646.  
  9647. %%---------------------------------------------------------------------------
  9648.  
  9649. \section{Z8, Super8, and eZ8}
  9650. \label{Z8Spec}
  9651.  
  9652. The CPU core contained in the Z8 microcontrollers does not
  9653. contain any specific registers.  Instead, a block of 16
  9654. consecutive cells of the internal address space (contains RAM and
  9655. I/O registers) may be used as 'work registers' and be addressed
  9656. with 4-bit addresses.  The RP registers define which memory block
  9657. is used as work registers: on a classic Z8, bits 4 to 7 of RP
  9658. define the 'offset' that is added to a 4-bit work register
  9659. address to get a complete 8-bit address.  The Super8 core
  9660. features two register pointers (RP0 and RP1), which allow mapping
  9661. the lower and upper half of work registers to separate places.
  9662.  
  9663. Usually, one refers to work registers as R0..R15 in assembly
  9664. statements.  It is however also posssible to regard work registers as
  9665. an efficient way to address a block of memory addresses in internal
  9666. RAM.
  9667.  
  9668. The \tty{ASSUME} statement is used to inform \asname{} about the current
  9669. value of RP. \asname{} is then capable to automatically decide whether an
  9670. address in internal RAM may be reached with a 4-bit or 8-bit address.
  9671. This may be used to assign symbolic names to work registers:
  9672. \begin{verbatim}
  9673. op1     equ     040h
  9674. op2     equ     041h
  9675.  
  9676.        srp     #040h
  9677.        assume  rp:040h
  9678.  
  9679.        ld      op1,op2         ; equal to ld r0,r1
  9680. \end{verbatim}
  9681. Note that though the Super8 does not have an RP register (only
  9682. RP0 and RP1), RP as argument to \tty{ASSUME} is still allowed -
  9683. it will set the assumed values of RP0 and RP1 to $value$ resp.
  9684. $value+8$, as the \tty{SRP} machine instruction does on the Super
  9685. 8 core.
  9686.  
  9687. Opposed to the original Zilog assembler, it is not necessary to
  9688. explicitly specify 'work register addressing' with a prefixed
  9689. exclamation mark.  \asname{} however also understands this syntax - a
  9690. prefixed exclamation mark enforces 4-bit addressing, even when the
  9691. address does not lie within the 16-address block defined by RP (\asname{} will
  9692. issue a warning in that case).  Vice versa, a prefixed $>$
  9693. character enforces 8-bit addressing even when the address is within
  9694. the current 16-address block.
  9695.  
  9696. The eZ8 takes this 'game' to the next level: the internal address
  9697. space now has 12 instead of 8 bits.  To assure compatibility with the
  9698. old Z8 core, Zilog placed the additional 4 bits in the {\em lower}
  9699. four bits of RP.  For instance, an RP value of 12h defines an address
  9700. window from 210h to 21fh.
  9701.  
  9702. At the same time, the lower four bits of RP define a window of 256
  9703. addresses that can be addressed with 8-bit addresses.  The mechanism
  9704. to automatically select between 8- and 12-bit addresses is analogous.
  9705. 'Long' 12-bit addresses may be enforced by prefixing two $>$
  9706. characters.
  9707.  
  9708. %%---------------------------------------------------------------------------
  9709.  
  9710. \section{Z8000}
  9711. \label{Z8000Spec}
  9712.  
  9713. A Z8001/8003 may be operated in one of two modes:
  9714.  
  9715. \begin{itemize}
  9716. \item{{\em Non-Segmented}: The memory address space is limited to 64 KBytes,
  9717.      and all addresses are 'simple' linear 16 bit addresses.  Address
  9718.      registers are single 16 bit registers (Rn), and absolute addresses
  9719.      within instructions are one byte long.}
  9720. \item{{\em Segmented}: Memory is structured into up to 128 segments of up
  9721.      to 64 KBytes size.  Addresses consist of a 7 bit segment number and a
  9722.      16 bit offset. Address registers are register pairs (RRn).  Absolute
  9723.      addresses in instructions occupy two 16 bit words, unless the offset
  9724.      is smaller than 256.}
  9725. \end{itemize}
  9726.  
  9727. The operation mode (segmented or non-segmented) therefore has an influence
  9728. on the generated code and is selected implicitly via the selected processor
  9729. type.  For instance, if the target is a Z8001 in non-segmented mode, use
  9730. Z8002 as target.
  9731.  
  9732. However, similar to the 8086, there is no 'real' support for a segmented
  9733. memory model in \asname{}. In segmented mode, the segment number is simply interpreted
  9734. as the upper seven bits of a virtually linear address space.  Though this is
  9735. not what Zilog intended, it is the way the segment number was used on the
  9736. Z8001 if the system had no MMU.
  9737.  
  9738. \asname{} in general implements the Z8000 machine instruction syntax as it is specified
  9739. by Zilog in its manuals.  However, there are assemblers that support extensions
  9740. or variations of the syntax.  \asname{} implements a few of them as well:
  9741.  
  9742. \subsection{Conditions}
  9743.  
  9744. In addition to the conditions defined by Zilog, the following alternative names
  9745. are defined:
  9746.  
  9747. \begin{center}\begin{tabular}{|l|l|l|}
  9748. \hline
  9749. Alternate & Zilog & Meaning \\
  9750. \hline
  9751. \hline
  9752. ZR         & Z     & Z = 1 \\
  9753. CY         & C     & C = 1 \\
  9754. LLE        & ULE   & (C OR Z) = 1 \\
  9755. LGE        & UGE   & C = 0 \\
  9756. LGT        & UGT   & ((C = 0) AND (Z = 0)) = 1 \\
  9757. LLT        & ULT   & C = 1 \\
  9758. \hline
  9759. \end{tabular}\end{center}
  9760.  
  9761. \subsection{Flags}
  9762.  
  9763. \tty{SETFLG}, \tty{COMFLG} und \tty{RESFLG} accept the following alternate names
  9764. as arguments:
  9765.  
  9766. \begin{center}\begin{tabular}{|l|l|l|}
  9767. \hline
  9768. Alternate & Zilog & Meaning \\
  9769. \hline
  9770. \hline
  9771. ZR         & Z     & Zero Flag \\
  9772. CY         & C     & Carry Flag \\
  9773. \hline
  9774. \end{tabular}\end{center}
  9775.  
  9776. \subsection{Indirect Addressing}
  9777.  
  9778. It is valid to write \verb!Rn^! instead of \verb!@Rn!, if the option
  9779. \tty{AMDSyntax=1} was given to the \tty{CPU} statement.  If an I/O address
  9780. is addressed indirectly, this option even allows to write just \verb!Rn!.
  9781.  
  9782. \subsection{Direct versus Immediate Addressing}
  9783.  
  9784. The Zilog syntax mandates that immediate addressing has to be done by prefixing
  9785. the argument with a hash character.  However, if the \tty{AMDSyntax=1} option
  9786. was given to the \tty{CPU} statement, the type of argument (label or constant)
  9787. decides whether immediate or direct addressing is to be used.  Immediate addressing
  9788. may be forced by prefixing the argument with a circumflex, i.e. to load the address
  9789. of a label into a register.
  9790.  
  9791. %%---------------------------------------------------------------------------
  9792.  
  9793. \section{TLCS-900(L)}
  9794. \label{TLCS900Spec}
  9795.  
  9796. These processors may run in two operating modes: on the one hand, in
  9797. minimum mode, which offers almost complete source code compatibility
  9798. to the Z80 and TLCS-90, and on the other hand in maximum mode, which
  9799. is necessary to make full use of the processor's capabilities.  The
  9800. main differences between these two modes are:
  9801. \begin{itemize}
  9802. \item{width of the registers WA, BC, DE, and HL: 16 or 32 bits;}
  9803. \item{number of register banks: 8 or 4;}
  9804. \item{code address space: 64 Kbytes or 16 Mbytes;}
  9805. \item{length of return addresses: 16 or 32 bits.}
  9806. \end{itemize}
  9807. To allow \asname{} to check against the correct limits, one has to inform him
  9808. about the current execution mode via the \tty{MAXMODE} instruction (see
  9809. there).  The default is the minimum mode.
  9810.  
  9811. From this follows that, depending on the operating mode, the 16-bit
  9812. resp. 32-bit versions of the bank registers have to be used for
  9813. addressing, i.e. WA, BC, DE and HL for the minimum mode resp. XWA,
  9814. XBC, XDE and XHL for the maximum mode.  The registers XIX..XIZ and
  9815. XSP are \bb{always} 32 bits wide and therefore always have to to be used
  9816. in this form for addressing; in this detail, existing Z80 code
  9817. definitely has to be adapted (not including that there is no I/O
  9818. space and all I/O registers are memory-mapped...).
  9819.  
  9820. Absolute addresses and displacements may be coded in different
  9821. lengths.  Without an explicit specification, \asname{} will always use
  9822. the shortest possible coding.  This includes eliminating a zero
  9823. displacement, i.e. \verb!(XIX+0)! becomes \verb!(XIX)!.  If a certain
  9824. length is needed, it may be forced by appending a suffix (:8, :16,
  9825. :24) to the displacmenet resp. the address.
  9826.  
  9827. The syntax chosen by Toshiba is a bit unfortunate in the respect of
  9828. choosing an single quote (') to reference the previous register bank.  The
  9829. processor independent parts of \asname{} already use this character to mark
  9830. character constants.  In an instruction like
  9831. \begin{verbatim}
  9832.        ld      wa',wa   ,
  9833. \end{verbatim}
  9834. \asname{} will not recognize the comma for parameter separation.  This
  9835. problem can be circumvented by usage of an inverse single quote (`), for
  9836. example
  9837. \begin{verbatim}
  9838.        ld      wa`,wa
  9839. \end{verbatim}
  9840. Toshiba delivers an own assembler for the TLCS-900 series (TAS900),
  9841. which is different from \asname{} in the following points:
  9842.  
  9843. \subsubsection{Symbol Conventions}
  9844.  
  9845. \begin{itemize}
  9846. \item{TAS900 differentiates symbol names only on the first 32
  9847.      characters.  In contrast, \asname{} always stores symbol names with the
  9848.      full length (up to 255 characters) and uses them all for
  9849.      differentiation.}
  9850. \item{TAS900 allows to write integer constants either in Intel or C
  9851.      notation (with a 0 prefix for octal or a 0x prefix for hexadecimal
  9852.      constants).  By default, \asname{} only supports the Intel notation.
  9853.      With the help of the \tty{RELAXED} instruction, one also gets the C
  9854.      notation (among other).}
  9855. \item{\asname{} does not distinguish between upper and lower case.  In
  9856.      contrast, TAS900 differentiates between upper- and lowercase
  9857.      letters in symbol names.  One needs to engage the \tty{-u} command
  9858.      line option to force \asname{} to do this.}
  9859. \end{itemize}
  9860.  
  9861. \subsubsection{Syntax}
  9862.  
  9863. For many instructions, the syntax checking of \asname{} is less strict than
  9864. the checking of TAS900.  In some (rare) cases, the syntax is slightly
  9865. different.  These extensions and changes are on the one hand for the
  9866. sake of a better portability of existing Z80 codes, on the other hand
  9867. they provide a simplification and better orthogonality of the
  9868. assembly syntax:
  9869. \begin{itemize}
  9870. \item{In the case of \tty{LDA, JP}, and \tty{CALL}, TAS requires that address
  9871.      expressions like \tty{XIX+5} must not be placed in parentheses, as it
  9872.      is usually the case.  For the sake of better orthogonality, \asname{}
  9873.      requires parentheses for \tty{LDA}.  They are optional if \tty{JP} resp.
  9874.      \tty{CALL} are used with a simple, absolute address.}
  9875. \item{In the case of \tty{JP, CALL, JR}, and \tty{SCC}, \asname{} leaves the choice to the
  9876.      programmer whether to explicitly write out the default condition
  9877.      \tty{T} (= true) as first parameter or not.  TAS900 in contrast only
  9878.      allows to use the default condition implicitly (e.g. \tty{jp (xix+5)}
  9879.      instead of \tty{jp t,(xix+5))}.}
  9880. \item{For the \tty{EX} instruction, \asname{} allows operand combinations which are
  9881.      not listed in \cite{Tosh900} but can be reduced to a standard
  9882.      combination by swapping the operands.  Combinations like \tty{EX f`,f}
  9883.      or \tty{EX wa,(xhl)} become possible.  In contrast, TAS900 limits to
  9884.      the 'pure' combinations.}
  9885. \item{\asname{} allows to omit an increment resp. decrement of 1 when using the
  9886.      instructions \tty{INC} and \tty{DEC}.  TAS900 instead forces the programmer to
  9887.      explicit usage of '1'.}
  9888. \item{The similar is true for the shift instructions: If the operand is
  9889.      a register, TAS900 requires that even a shift count of 1 has to
  9890.      be written explicitly; however, when the operand is in memory,
  9891.      the hardware limits the shift count to 1 which must not be written
  9892.      in this case.  With \asname{}, a shift count of 1 is always optional and
  9893.      valid for all types of operands.}
  9894. \end{itemize}
  9895.  
  9896. \subsubsection{Macro Processor}
  9897.  
  9898. The macro processor of TAS900 is an external program that operates
  9899. like a preprocessor.  It consists of two components: The first one is
  9900. a C-like preprocessor, and the second one is a special macro language
  9901. (MPL) that reminds of high level languages.  The macro processor of
  9902. \asname{} instead is oriented towards ''classic'' macro assemblers like MASM
  9903. or M80 (both programs from Microsoft).  It is a fixed component of
  9904. \asname{}.
  9905.  
  9906. \subsubsection{Output Format}
  9907.  
  9908. TAS900 generates relocatable code that allows to link separately
  9909. compiled programs to a single application.  \asname{} instead generates
  9910. absolute machine code that is not linkable.  There are currently no
  9911. plans to extend \asname{} in this respect.
  9912.  
  9913. \subsubsection{Pseudo Instructions}
  9914.  
  9915. Due to the missing linker, \asname{} lacks a couple of pseudo instructions
  9916. needed for relocatable code TAS900 implements.  The following
  9917. instructions are available with equal meaning:
  9918. \begin{quote}\tt
  9919.   EQU, DB, DW, ORG, ALIGN, END, TITLE, SAVE, RESTORE
  9920. \rm\end{quote}
  9921. The latter two have an extended functionality for \asname{}.  Some TAS900
  9922. pseudo instructions can be replaced with equivalent \asname{} instructions (see
  9923. table \ref{TabTAS900}).
  9924. \par
  9925. \begin{table*}[htbp]
  9926. \begin{center}\begin{tabular}{|l|l|l|}
  9927. \hline
  9928. TAS900           & \asname{}                  &     meaning/function \\
  9929. \hline
  9930. \hline
  9931. \tty{DL} $<$Data$>$    & \tty{DD} $<$Data$>$           & define longword constants \\
  9932. \hline
  9933. \tty{DSB} $<$number$>$ & \tty{DB} $<$number$>$ \tty{DUP} (?) & reserve bytes of memory \\
  9934. \hline
  9935. \tty{DSW} $<$number$>$ & \tty{DW} $<$number$>$ \tty{DUP} (?) & reserve words of memory \\
  9936. \hline
  9937. \tty{DSD} $<$number$>$ & \tty{DD} $<$number$>$ \tty{DUP} (?) & reserve longwords of memory \\
  9938. \hline
  9939. \tty{\$MIN[IMUM]}      & \tty{MAXMODE OFF}             & following code runs \\
  9940.                       &                               & in minimum mode \\
  9941. \hline
  9942. \tty{\$MAX[IMUM]}      & \tty{MAXMODE ON}              & following code runs \\
  9943.                       &                               & in maximum mode \\
  9944. \hline
  9945. \tty{\$SYS[TEM]}       & \tty{SUPMODE ON}              & following code runs \\
  9946.                       &                               & in system mode \\
  9947. \hline
  9948. \tty{\$NOR[MAL]}       & \tty{SUPMODE OFF}             & following code runs \\
  9949.                       &                               & in user mode \\
  9950. \hline
  9951. \tty{\$NOLIST}         & \tty{LISTING OFF}             & turn off assembly listing \\
  9952. \hline
  9953. \tty{\$LIST}           & \tty{LISTING ON}              & turn on assembly listing \\
  9954. \hline
  9955. \tty{\$EJECT}          & \tty{NEWPAGE}                 & start new page in listing \\
  9956. \hline
  9957. \end{tabular}\end{center}
  9958. \caption{equivalent instructions TAS900$\leftrightarrow$\asname{}\label{TabTAS900}}
  9959. \end{table*}
  9960. Toshiba manufactures two versions of the processor core, with the L
  9961. version being an ''economy version''.  \asname{} will make the following
  9962. differences between TLCS-900 and TLCS-900L:
  9963. \begin{itemize}
  9964. \item{The instructions \tty{MAX} and \tty{NORMAL} are not allowed for the L version;
  9965.      the \tty{MIN} instruction is disabled for the full version.}
  9966. \item{The L version does not know the normal stack pointer XNSP/NSP, but
  9967.      instead has the interrupt nesting register INTNEST.}
  9968. \end{itemize}
  9969. The instructions \tty{SUPMODE} and \tty{MAXMODE} are not influenced, just as
  9970. their initial setting \tty{OFF}.  The programmer has to take care of the
  9971. fact that the L version starts in maximum mode and does not have a
  9972. normal mode.  However, \asname{} shows a bit of mercy against the L variant
  9973. by suppressing warnings for privileged instructions.
  9974.  
  9975. %%---------------------------------------------------------------------------
  9976.  
  9977. \section{TLCS-90}
  9978.  
  9979. Maybe some people might ask themselves if I mixed up the order a
  9980. little bit, as Toshiba first released the TLCS-90 as an extended Z80
  9981. and afterwards the 16-bit version TLCS-900.  Well, I discovered the
  9982. '90 via the '900 (thank you Oliver!).  The two families are quite
  9983. similar, not only regarding their syntax but also in their
  9984. architecture.  The hints for the '90 are therefore a subset of of the
  9985. chapter for the '900: As the '90 only allows shifts, increments, and
  9986. decrements by one, the count need not and must not be written as the
  9987. first argument.  Once again, Toshiba wants to omit parentheses for
  9988. memory operands of \tty{LDA, JP, and CALL}, and once again \asname{} requires them
  9989. for the sake of orthogonality (the exact reason is of course that
  9990. this way, I saved an extra in the address parser, but one does not
  9991. say such a thing aloud).
  9992.  
  9993. Principally, the TLCS-90 series already has an address space of 1
  9994. Mbyte which is however only accessible as data space via the index
  9995. registers.  \asname{} therefore does not regard the bank registers and
  9996. limits the address space to 64 Kbytes.  This should not limit too
  9997. much as this area above is anyway only reachable via indirect
  9998. addressing.
  9999.  
  10000. %%---------------------------------------------------------------------------
  10001.  
  10002. \section{TLCS-870}
  10003.  
  10004. Once again Toshiba...a company quite productive at the moment!
  10005. Especially this branch of the family (all Toshiba microcontrollers
  10006. are quite similar in their binary coding and programming model) seems
  10007. to be targeted towards the 8051 market: the method of separating the
  10008. bit position from the address expression with a dot had its root in
  10009. the 8051.  However, it creates now exactly the sort of problems I
  10010. anticipated when working on the 8051 part: On the one hand, the dot
  10011. is a legal part of symbol names, but on the other hand, it is part of
  10012. the address syntax.  This means that \asname{} has to separate address and
  10013. bit position and must process them independently.  Currently, I
  10014. solved this conflict by seeking the dot starting at the \bb{end} of the
  10015. expression.  This way, the last dot is regarded as the separator, and
  10016. further dots stay parts of the address.   I continue to urge everyone
  10017. to omit dots in symbol names, they will lead to ambiguities:
  10018. \begin{verbatim}
  10019.        LD      CF,A.7  ; accumulator bit 7 to carry
  10020.        LD      C,A.7   ; constant 'A.7' to accumulator
  10021. \end{verbatim}
  10022.  
  10023. %%---------------------------------------------------------------------------
  10024.  
  10025. \section{TLCS-47}
  10026.  
  10027. This family of 4-bit microcontrollers should mark the low end of what
  10028. is supportable by \asname{}.  Apart from the \tty{ASSUME} instruction for the data
  10029. bank register (see there), there is only one thing that is worth
  10030. mentioning: In the data and I/O segment, nibbles are reserved instead
  10031. of byte (it's a 4-bitter...).  The situation is similar to the bit
  10032. data segment of the 8051, where a \tty{DB} reserves a single bit, with the
  10033. difference that we are dealing with nibbles.
  10034.  
  10035. Toshiba defined an ''extended instruction set'' for this processor
  10036. family to facilitate the work with their limited instruction set.  In
  10037. the case of \asname{}, it is defined in the include file \tty{STDDEF47.INC}.
  10038. However, some instructions that could not be realized as macros are
  10039. ''builtins'' and are therefore also available without the include file:
  10040. \begin{itemize}
  10041. \item{the \tty{B} instruction that automatically chooses the optimal version
  10042.      of the jump instruction (\tty{BSS; BS}, or \tty{BSL});}
  10043. \item{\tty{LD} in the variant of \tty{HL} with an immediate operand;}
  10044. \item{\tty{ROLC} and \tty{RORC} with a shift amplitude higher than one.}
  10045. \end{itemize}
  10046.  
  10047. %%---------------------------------------------------------------------------
  10048.  
  10049. \section{TLCS-9000}
  10050.  
  10051. This was the first time that I implemented a processor for \asname{} which
  10052. was not yet available at that point of time.  And unfortunately,
  10053. I received back then information that Toshiba had decided no to
  10054. maket this processor at all.  This of course had the result that
  10055. the TLCS-9000 part of the assembler
  10056. \begin{enumerate}
  10057. \item{was a ''paper design'', i.e. there was so far no chance to test
  10058.      it on real hardware and}
  10059. \item{the documentation for the '9000 I could get hold of \cite{Tosh9000}
  10060.      was preliminary and was unclear in a couple of detail
  10061.      issues.}
  10062. \end{enumerate}
  10063. So i effect, this target went into 'dormant mode'...
  10064.  
  10065. ...cut, 20 years have passed: all of a sudden, people are
  10066. contacting me and tell me that Toshiba actually did sell
  10067. TLCS-9000 chips to customers, and they ask for documentation to
  10068. do reverse engineering.  Maybe this will shed some light on the
  10069. remaining unclarities.  Nevertheless, errors in this code generator
  10070. are quite possible (and will of course be fixed!).  At least the
  10071. few examples listed in \cite{Tosh9000} are assembled correctly.
  10072.  
  10073. Displacements included in machine instructions may only have a
  10074. certain maximum length (e.g. 9 or 13 bits).  In case the
  10075. displacement is longer, a prefix containing the 'upper bits' must
  10076. be prepended to the instruction.  \asname{} will automatically insert
  10077. such prefixes when necessary, however it is also possible to
  10078. force usage of a prefix by adding a leading \verb!'>'!.  An
  10079. example for this:
  10080.  
  10081. \begin{verbatim}
  10082.  ld:g.b  (0h),0       ; no prefix
  10083.  ld:g.b  (400000h),0  ; prefix added automatically
  10084.  ld:g.b  (>0h),0      ; forced prefix
  10085. \end{verbatim}
  10086.  
  10087. %%---------------------------------------------------------------------------
  10088.  
  10089. \section{TC9331}
  10090.  
  10091. Toshiba supplied a (DOS-based) assembler for this processor which
  10092. was named ASM31T.  This assembler supports a number of syntax
  10093. elements which could not be mapped on the capabilities of \asname{}
  10094. without risking incompatibilities for existing source files for
  10095. other targets.  The following issues might require changes on
  10096. programs written for ASM31T:
  10097.  
  10098. \begin{itemize}
  10099. \item{ASM31T supports C-like comments (\verb!/* ... */!) which
  10100.      may also span multiple lines.  Such comments are not
  10101.      supported by \asname{} and have to be replaced by comments
  10102.      beginning with a semicolon.}
  10103. \item{Similar to ASM31T, \asname{} supports comments with round parentheses
  10104.      (\verb!( ... )!), however only within a single command
  10105.      argument.  Should such a comment contain a comma, this
  10106.      comma will be treated like an argument separator and the
  10107.      comment will not be skipped when parsing the arguments.}
  10108. \item{ASM31T allows symbol and label names containing a dash.
  10109.      \asname{} does not allow this, because the dash is regarded to be
  10110.      the subtraction operator.  It would be unclear whether an
  10111.      expression like \verb!end-start! represents a single symbol
  10112.      or the difference of two symbols.}
  10113. \item{ASM31T requires an \tty{END} statement as the last
  10114.      statement of the program; this is optional for \asname{}.}
  10115. \end{itemize}
  10116.  
  10117. Furthermore, \asname{} currently lacks the capabilities to detect
  10118. conflicting uses of functional units in a machine instructions.
  10119. Toshiba's documentation is a bit difficult to understand in this
  10120. respect...
  10121.  
  10122. %%---------------------------------------------------------------------------
  10123.  
  10124. \section{29xxx}
  10125.  
  10126. As it was already described in the discussion of the \tty{ASSUME}
  10127. instruction, \asname{} can use the information about the current setting of
  10128. the RBP register to detect accesses to privileged registers in user
  10129. mode.  This ability is of course limited to direct accesses (i.e.
  10130. without using the registers IPA...IPC), and there is one more
  10131. pitfall: as local registers (registers with a number $>$127) are
  10132. addressed relative to the stack pointer, but the bits in RBP always
  10133. refer to absolute numbers, the check is NOT done for local registers.
  10134. An extension would require \asname{} to know always the absolute value of
  10135. SP, which would at least fail for recursive subroutines...
  10136.  
  10137. %%---------------------------------------------------------------------------
  10138.  
  10139. \section{80C16x}
  10140.  
  10141. As it was already explained in the discussion of the \tty{ASSUME}
  10142. instruction, \asname{} tries to hide the fact that the processor has more
  10143. physical than logical RAM as far as possible.  Please keep in mind
  10144. that the DPP registers are valid only for data accesses and only
  10145. have an influence on absolute addressing, neither on indirect nor on indexed
  10146. addresses.  \asname{} cannot know which value the computed address may take
  10147. at runtime...
  10148. The paging unit unfortunately does not operate for code accesses so
  10149. one has to work with explicit long or short \tty{CALL}s, \tty{JMP}s, or
  10150. \tty{RET}s.  At least for the ''universal'' instructions \tty{CALL} and
  10151. \tty{JMP}, \asname{} will automatically use the shortest variant, but at least for the RET one
  10152. should know where the call came from.  \tty{JMPS} and \tty{CALLS} principally
  10153. require to write segment and address separately, but \asname{} is written in
  10154. a way that it can split an address on its own, e.g. one can write
  10155. \begin{verbatim}
  10156.        jmps    12345h
  10157. \end{verbatim}
  10158. instead of
  10159. \begin{verbatim}
  10160.        jmps    1,2345h
  10161. \end{verbatim}
  10162. Unfortunately, not all details of the chip's internal instruction
  10163. pipeline are hidden: if CP (register bank address), SP (stack), or
  10164. one of the paging registers are modified, their value is not
  10165. available for the instruction immediately following.  \asname{} tries to
  10166. detect such situations and will issue a warning in such cases.  Once
  10167. again, this mechanism only works for direct accesses.
  10168.  
  10169. Bits defined with the \tty{BIT} instruction are internally stored as a
  10170. 12-bit word, containing the address in bits 4..11 and the bit
  10171. position in the four LSBs.  This order allows to refer the next resp.
  10172. previous bit by incrementing or decrementing the address.  This will
  10173. however not work for explicit bit specifications when a word boundary
  10174. is crossed.  For example, the following expression will result in a
  10175. range check error:
  10176. \begin{verbatim}
  10177.        bclr    r5.15+1
  10178. \end{verbatim}
  10179. We need a \tty{BIT} in this situation:
  10180. \begin{verbatim}
  10181. msb     bit     r5.15
  10182.        .
  10183.        .
  10184.        bclr    msb+1
  10185. \end{verbatim}
  10186. The SFR area was doubled for the 80C167/165/163: bit 12 flags that a bit
  10187. lies in the second part.  Siemens unfortunately did not foresee that
  10188. 256 SFRs (128 of them bit addressable) would not suffice for
  10189. successors of the 80C166.  As a result, it would be impossible to
  10190. reach the second SFR area from F000H..F1DFH with short addresses or
  10191. bit instructions if the developers had not included a toggle
  10192. instruction:
  10193. \begin{verbatim}
  10194.        EXTR    #n
  10195. \end{verbatim}
  10196. This instruction has the effect that for the next \tty{n} instructions
  10197. ($0<n<5$), it is possible to address the alternate SFR space instead of
  10198. the normal one.  \asname{} does not only generate the appropriate machine
  10199. code when it encounters this instruction.  It also sets an internal
  10200. flag that will only allow accesses to the alternate SFR space for
  10201. the next \tty{n} instructions.  Of course, they may not contain jumps...
  10202. Of course, it is always possible to define bits from either area at
  10203. any place, and it is always possible to reach all registers with
  10204. absolute addresses.  In contrast, short and bit addressing only works
  10205. for one area at a time, attempts contradicting to this will result in
  10206. an error message.
  10207.  
  10208. The situation is similar for prefix instructions and absolute resp.
  10209. indirect addressing: as the prefix argument and the address
  10210. expression cannot always be evaluated at assembly time, chances for
  10211. checking are limited and \asname{} will limit itself to warnings...in
  10212. detail, the situation is as follows:
  10213. \begin{itemize}
  10214. \item{fixed specification of a 64K bank with \tty{EXTS} or \tty{EXTSR}: the address
  10215.      expression directly contains the lower 16 bits of the target
  10216.      address.  If the prefix and the following instruction have a
  10217.      constant operand, \asname{} will check if the the prefix argument and bits
  10218.      16..23 of the target address are equal.}
  10219. \item{fixed specification of a 16K page with \tty{EXTP} or \tty{EXTPR}: the address
  10220.      expression directly contains the lower 14 bits of the target
  10221.      address.  Bits 14 and 15 are fixed to 0, as the processor ignores
  10222.      them in this mode.  If the prefix and the following instruction
  10223.      have a constant operand, \asname{} will check if the the prefix argument
  10224.      and bits 14..23 of the target address are equal.}
  10225. \end{itemize}
  10226. An example to clarify things a bit (the DPP registers have their
  10227. reset values):
  10228. \begin{verbatim}
  10229.        extp    #7,#1      ; range from 112K..128K
  10230.        mov     r0,1cdefh  ; results in address 0defh in code
  10231.        mov     r0,1cdefh  ; -->warning
  10232.        exts    #1,#1      ; range from 64K..128K
  10233.        mov     r0,1cdefh  ; results in address 0cdefh in code
  10234.        mov     r0,1cdefh  ; -->warning
  10235. \end{verbatim}
  10236.  
  10237. %%---------------------------------------------------------------------------
  10238.  
  10239. \section{PIC16C5x/16C8x}
  10240.  
  10241. Similar to the MCS-48 family, the PICs split their program memory
  10242. into several banks because the opcode does not offer enough space for
  10243. a complete address.  \asname{} uses the same automatism for the instructions
  10244. \tty{CALL} and \tty{GOTO}, i.e. the PA bits in the status word are set according
  10245. to the start and target address.  However, this procedure is far more
  10246. problematic compared to the 48's:
  10247. \begin{enumerate}
  10248. \item{The instructions are not any more one word long (up to three
  10249.      words).  Therefore, it is not guaranteed that they can be
  10250.      skipped with a conditional branch.}
  10251. \item{It is possible that the program counter crosses a page boundary
  10252.      while the program sequence is executed.  The setting of PA bits
  10253.      \asname{} assumes may be different from reality.}
  10254. \end{enumerate}
  10255. The instructions that operate on register W and another register
  10256. normally require a second parameter that specifies whether the result
  10257. shall be stored in W or the register.  Under \asname{}, it is valid to omit
  10258. the second parameter.  The assumed target then depends upon the
  10259. operation's type: For unary operations, the result is by default
  10260. stored back into the register.  These instructions are:
  10261. \begin{quote}{\tt
  10262.    COMF, DECF, DECFSZ, INCF, INCFSZ, RLF, RRF, and SWAPF
  10263. }\end{quote}
  10264. The other operations by default regard W as an accumulator:
  10265. \begin{quote}{\tt
  10266.    ADDWF, ANDWF, IORWF, MOVF, SUBWF, and XORWF
  10267. }\end{quote}
  10268. The syntax defined by Microchip to write literals is quite obscure
  10269. and reminds of the syntax used on IBM 360/370 systems (greetings from
  10270. the stone-age...).  To avoid introducing another branch into the
  10271. parser, with \asname{} one has to write constants in the Motorola syntax
  10272. (optionally Intel or C in \tty{RELAXED} mode).
  10273.  
  10274. %%---------------------------------------------------------------------------
  10275.  
  10276. \section{PIC 17C4x}
  10277.  
  10278. With two exceptions, the same hints are valid as for its two smaller
  10279. brothers: the corresponding include file only contains register
  10280. definitions, and the problems concerning jump instructions are much
  10281. smaller.  The only exception is the \tty{LCALL} instruction, which allows a
  10282. jump with a 16-bit address.  It is translated with the following
  10283. ''macro'':
  10284. \begin{verbatim}
  10285.        MOVLW   <addr15..8>
  10286.        MOWF    3
  10287.        LCALL   <addr0..7>
  10288. \end{verbatim}
  10289.  
  10290. %%---------------------------------------------------------------------------
  10291.  
  10292. \section{SX20/28}
  10293.  
  10294. The limited length of the instruction word does not permit specifying
  10295. a complete program memory address (11 bits) or data memory address (8
  10296. bits).  The CPU core augments the truncated address from the
  10297. instruction word with the PA bits from the STATUS registers,
  10298. respectively with the upper bits of the FSR register.  It is possible
  10299. to inform the assembler via \tty{ASSUME} instructions about the
  10300. contents of these two registers.  In case that addresses are used
  10301. that are inaccessible with th current values, a warning is issued.
  10302.  
  10303. %%---------------------------------------------------------------------------
  10304.  
  10305. \section{ST6}
  10306.  
  10307. These processors have the ability to map their code ROM pagewise into the
  10308. data area.  I am not keen on repeating the whole discussion of the
  10309. \tty{ASSUME} instruction at this place, so I refer to the corresponding
  10310. section (\ref{ST6Assume}) for an explanation how to read constants out of
  10311. the code ROM without too much headache.
  10312.  
  10313. Some builtin ''macros'' show up when one analyzes the instruction set a
  10314. bit more in detail.  The instructions I found are listed in table
  10315. \ref{TabHid62} (there are probably even more...):
  10316. \par
  10317. \begin{table*}[htbp]
  10318. \begin{center}\begin{tabular}{|l|l|}
  10319. \hline
  10320. instruction & in reality \\
  10321. \hline
  10322. \hline
  10323. \tty{CLR A}      & \tty{SUB A,A} \\
  10324. \tty{SLA A}      & \tty{ADD A,A} \\
  10325. \tty{CLR addr}   & \tty{LDI addr,0} \\
  10326. \tty{NOP}        & \tty{JRZ PC+1} \\
  10327. \hline
  10328. \end{tabular}\end{center}
  10329. \caption{Hidden Macros in the ST62's Instruction Set\label{TabHid62}}
  10330. \end{table*}
  10331. Especially the last case is a bit astonishing...unfortunately, some
  10332. instructions are really missing.  For example, there is an \tty{AND}
  10333. instruction but no \tty{OR}...not to speak of an \tty{XOR}.  For this reason, the
  10334. include file \tty{STDDEF62.INC} contains also some helping macros
  10335. (additionally to register definitions).
  10336.  
  10337. The original assembler AST6 delivered by SGS-Thomson partially uses
  10338. different pseudo instructions than \asname{}.  Apart from the fact that \asname{}
  10339. does not mark pseudo instructions with a leading dot, the following
  10340. instructions are identical:
  10341. \begin{verbatim}
  10342.  ASCII, ASCIZ, BLOCK, BYTE, END, ENDM, EQU, ERROR, MACRO,
  10343.  ORG, TITLE, WARNING
  10344. \end{verbatim}
  10345. Table \ref{TabAST6} shows the instructions which have \asname{} counterparts
  10346. with similar function.
  10347. \par
  10348. \begin{table*}[htbp]
  10349. \begin{center}\begin{tabular}{|l|l|l|}
  10350. \hline
  10351. AST6            & \asname{}                     & meaning/function \\
  10352. \hline
  10353. \hline
  10354. \tty{.DISPLAY}  & \tty{MESSAGE}          & output message \\
  10355. \hline
  10356. \tty{.EJECT}    & \tty{NEWPAGE}          & new page in assembly listing \\
  10357. \hline
  10358. \tty{.ELSE}     & \tty{ELSEIF}           & conditional assembly \\
  10359. \hline
  10360. \tty{.ENDC}     & \tty{ENDIF}            & conditional assembly \\
  10361. \hline
  10362. \tty{.IFC}      & \tty{IF...}            & conditional assembly \\
  10363. \hline
  10364. \tty{.INPUT}    & \tty{INCLUDE}          & insert include file \\
  10365. \hline
  10366. \tty{.LIST}     & \tty{LISTING, MACEXP\_DFT}  & settings for listing \\
  10367. \hline
  10368. \tty{.PL}       & \tty{PAGE}             & page length of listing \\
  10369. \hline
  10370. \tty{.ROMSIZE}  & \tty{CPU}              & set target processor \\
  10371. \hline
  10372. \tty{.VERS}     & \tty{VERSION} (symbol) & query version \\
  10373. \hline
  10374. \tty{.SET}      & \tty{EVAL}             & redefine variables \\
  10375. \hline
  10376. \end{tabular}\end{center}
  10377. \caption{Equivalent Instructions AST6$\leftrightarrow$\asname{}\label{TabAST6}}
  10378. \end{table*}
  10379.  
  10380. %%---------------------------------------------------------------------------
  10381.  
  10382. \section{ST7}
  10383.  
  10384. In \cite{ST7Man}, the \tty{.w} postfix to signify 16-bit addresses is only
  10385. defined for memory indirect operands.  It is used to mark that a
  10386. 16-bit address is stored at a zero page address.  \asname{} additionally
  10387. allows this postfix for absolute addresses or displacements of
  10388. indirect address expressions to force 16-bit displacements in spite
  10389. of an 8-bit value (0..255).
  10390.  
  10391. %%---------------------------------------------------------------------------
  10392.  
  10393. \section{ST9}
  10394.  
  10395. The ST9's bit addressing capabilities are quite limited: except for
  10396. the \tty{BTSET} instruction, only bits within the current set of working
  10397. registers are accessible.  A bit address is therefore of the
  10398. following style:
  10399. \begin{verbatim}
  10400.        rn.[!]b   ,
  10401. \end{verbatim}
  10402. whereby \tty{!} means an optional complement of a source operand.  If a bit
  10403. is defined symbolically, the bit's register number is stored in bits
  10404. 7..4, the bit's position is stored in bits 3..1 and the optional
  10405. complement is kept in bit 0.  \asname{} distinguishes explicit and symbolic
  10406. bit addresses by the missing dot.  A bit's symbolic name therefore
  10407. must not contain a dot, thought it would be legal in respect to the
  10408. general symbol name conventions.  It is also valid to invert a
  10409. symbolically referred bit:
  10410. \begin{verbatim}
  10411. bit2    bit     r5.3
  10412.        .
  10413.        .
  10414.        bld     r0.0,!bit2
  10415. \end{verbatim}
  10416. This opportunity also allows to undo an inversion that was done at
  10417. definition of the symbol.
  10418.  
  10419. The include file \tty{REGST9.INC} defines the symbolic names of all on-chip
  10420. registers and their associated bits. Keep however in mind that the
  10421. bit definitions only work after previously setting the working
  10422. register bank to the address of these peripheral registers!
  10423.  
  10424. In contrast to the definition file delivered with the AST9 assembler
  10425. from SGS-Thomson, the names of peripheral register names are only
  10426. defined as general registers (\tty{R...}), not also as working registers
  10427. (\tty{r...}).  The reason for this is that \asname{} does not support register
  10428. aliases; a tribute to assembly speed.
  10429.  
  10430. %%---------------------------------------------------------------------------
  10431.  
  10432. \section{6804}
  10433.  
  10434. To be honest: I only implemented this processor in \asname{} to quarrel
  10435. about SGS-Thomson's peculiar behaviour.  When I first read the 6804's
  10436. data book, the ''incomplete'' instruction set and the built-in macros
  10437. immediately reminded me of the ST62 series manufactured by the same
  10438. company.  A more thorough comparison of the opcodes gave surprising
  10439. insights: A 6804 opcode can be generated by taking the equivalent
  10440. ST62 opcode and mirroring all the bits!  So Thomson obviously did a
  10441. bit of processor core recycling...which would be all right if they
  10442. would not try to hide this:  different peripherals, motorola instead
  10443. of Zilog-style syntax, and the awful detail of \bb{not} mirroring operand
  10444. fields in the opcode (e.g. bit fields containing displacements).  The
  10445. last item is also the reason that finally convinced me to support the
  10446. 6804 in \asname{}.  I personally can only guess which department at Thomson
  10447. did the copy...
  10448.  
  10449. In contrast to its ST62 counterpart, the include file for the 6804
  10450. does not contain instruction macros that help a bit to deal with the
  10451. limited machine instruction set.  This is left as an exercise to the
  10452. reader!
  10453.  
  10454. %%---------------------------------------------------------------------------
  10455.  
  10456. \section{TMS3201x}
  10457.  
  10458. It seems that every semiconductor's ambition is to invent an own
  10459. notation for hexadecimal numbers.  Texas Instrument took an
  10460. especially eccentric approach for these processors: a $>$ sign as
  10461. prefix!  The support of such a format in \asname{} would have lead to
  10462. extreme conflicts with \asname{}'s compare and shift operators.  I therefore
  10463. decided to use the Intel notation, which is what TI also uses for the
  10464. 340x0 series and the 3201x's successors...
  10465.  
  10466. The instruction word of these processors unfortunately does not have
  10467. enough bits to store all 8 bits for direct addressing.  This is why
  10468. the data address space is split into two banks of 128 words.  \asname{}
  10469. principally regards the data address space as a linear segment of 256
  10470. words and automatically clears bit 7 on direct accesses (an exception
  10471. is the \tty{SST} instruction that can only write to the upper bank).  The
  10472. programmer has to take care that the bank flag always has the correct
  10473. value!
  10474.  
  10475. Another hint that is well hidden in the data book: The \tty{SUBC}
  10476. instruction internally needs more than one clock for completion, but
  10477. the control unit already continues to execute the next instruction.
  10478. An instruction following \tty{SUBC} therefore may not access the
  10479. accumulator.  \asname{} does not check for such conditions!
  10480.  
  10481. %%---------------------------------------------------------------------------
  10482.  
  10483. \section{TMS320C2x}
  10484.  
  10485. As I did not write this code generator myself (that does not lower
  10486. its quality by any standard), I can only roughly line out why there
  10487. are some instructions that force a prefixed label to be untyped, i.e.
  10488. not assigned to any specific address space: The 2x series of TMS
  10489. signal processors has a code and a data segment which are both 64
  10490. Kbytes large.  Depending on external circuitry, code and data space may
  10491. overlap, e.g. to allow storage of constants in the code area and
  10492. access them as data.  Data storage in the code segment may be
  10493. necessary because older versions of \asname{} assume that the data segment
  10494. only consists of RAM that cannot have a defined power-on state in a
  10495. single board system.  They therefore reject storage of contents in
  10496. other segments than \tty{CODE}.  Without the feature of making symbols
  10497. untyped, \asname{} would punish every access to a constant in code space
  10498. with a warning (''symbol out of wrong segment'').  To say it in detail,
  10499. the following instructions make labels untyped:
  10500. \begin{quote}\tt
  10501.  BSS, STRING, RSTRING, BYTE, WORD , LONG\\
  10502.  FLOAT, DOUBLE, EFLOAT, BFLOAT and TFLOAT
  10503. \rm\end{quote}
  10504. If one needs a typed label in front of one of these instructions, one
  10505. can work around this by placing the label in a separate line just
  10506. before the pseudo instruction itself.  On the other hand, it is
  10507. possible to place an untyped label in front of another pseudo
  10508. instruction by defining the label with \tty{EQU}, e.g.
  10509. \begin{verbatim}
  10510. <name>  EQU     $        .
  10511. \end{verbatim}
  10512.  
  10513. %%---------------------------------------------------------------------------
  10514.  
  10515. \section{TMS320C3x/C4x}
  10516.  
  10517. The syntax detail that created the biggest amount of headache for me
  10518. while implementing this processor family is the splitting of parallel
  10519. instructions into two separate source code lines.  Fortunately, both
  10520. instructions of such a construct are also valid single instructions.
  10521. \asname{} therefore first generates the code for the first instruction and
  10522. replaces it by the parallel machine code when a parallel construct is
  10523. encountered in the second line.  This operation can be noticed in the
  10524. assembly listing by the machine code address that does not advance
  10525. and the double dot replaced with a \tty{R}.
  10526.  
  10527. Compared to the TI assembler, \asname{} is not as flexible regarding the
  10528. position of the double lines that signify a parallel operation
  10529. (\tty{||}): One either has to place them like a label (starting in the
  10530. first column) or to prepend them to the second mnemonic.  The line
  10531. parser of \asname{} will run into trouble if you do something else...
  10532.  
  10533. %%---------------------------------------------------------------------------
  10534.  
  10535. \section{TMS9900}
  10536.  
  10537. Similar to most older TI microprocessor families, TI used an own
  10538. format for hexadecimal and binary constants.  \asname{} instead favours the
  10539. Intel syntax which is also common for newer processor designs from
  10540. TI.
  10541.  
  10542. The TI syntax for registers allows to use a simple integer number
  10543. between 0 and 15 instead of a real name (\tty{Rx} or \tty{WRx}).
  10544. This has two consequences:
  10545. \begin{itemize}
  10546. \item{\tty{R0...R15} resp. \tty{WR0..WR15} are simple predefined integer
  10547.      symbols with values from 0 to 15, and the definition of register
  10548.      aliases is a simple matter of \tty{EQU}.}
  10549. \item{In contrast to several other processors, I cannot offer the
  10550.      additional \asname{} feature that allows to omit the character sigifying
  10551.      absolute addressing (a \@ sign in this case).  As a missing
  10552.      character would mean register numbers (from 0 to 15) in this case,
  10553.      it was not possible to offer the optional omission.}
  10554. \end{itemize}
  10555. Furthermore, TI sometimes uses \tty{Rx} to name registers and \tty{WRx}
  10556. at other places...currently both variants are recognized by \asname{}.
  10557.  
  10558. %%---------------------------------------------------------------------------
  10559.  
  10560. \section{TMS70Cxx}
  10561.  
  10562. This processor family belongs to the older families developed by TI
  10563. and therefore TI's assemblers use their proprietary syntax for
  10564. hexadecimal resp. binary constants (a prefixed $<$ resp. \tty{?} character).
  10565. As this format could not be realized for \asname{}, the Intel syntax is used
  10566. by default.  This is the format TI to which also switched over when
  10567. introducing the successors, of this family, the 370 series of
  10568. microcontrollers.  Upon a closer inspection of both's machine
  10569. instruction set, one discovers that about 80\% of all instruction are
  10570. binary upward compatible, and that also the assembly syntax is almost
  10571. identical - but unfortunately only almost.  TI also took the chance to
  10572. make the syntax more orthogonal and simple.  I tried to introduce
  10573. the majority of these changes also into the 7000's instruction set:
  10574. \begin{itemize}
  10575. \item{It is valid to use the more common \tty{\#} sign for immediate addressing
  10576.      instead of the percent sign.}
  10577. \item{If a port address (\tty{P...}) is used as source or destination in a
  10578.      \tty{AND, BTJO, BTJZ, MOV, OR}, or \tty{XOR} instruction, it is not necessary
  10579.      to use the mnemonic variant with an appended \tty{P} - the general
  10580.      form is sufficient.}
  10581. \item{The prefixed \tty{@} sign for absolute or B-relative addressing may be
  10582.      omitted.}
  10583. \item{Instead of \tty{CMPA, CMP} with \tty{A} as target may be written.}
  10584. \item{Instead of \tty{LDA} resp. \tty{STA}, one can simply use the
  10585.      \tty{MOV} instruction with \tty{A} as source resp. destination.}
  10586. \item{One can write \tty{MOVW} instead of \tty{MOVD}.}
  10587. \item{It is valid to abbreviate \tty{RETS} resp. \tty{RETI} as \tty{RTS}
  10588.      resp. \tty{RTI}.}
  10589. \item{\tty{TSTA} resp. \tty{TSTB} may be written as \tty{TST A} resp.
  10590.      \tty{TST B}.}
  10591. \item{\tty{XCHB B} is an alias for \tty{TSTB}.}
  10592. \end{itemize}
  10593. An important note: these variants are only allowed for the TMS70Cxx -
  10594. the corresponding 7000 variants are not allowed for the 370 series!
  10595.  
  10596. %%---------------------------------------------------------------------------
  10597.  
  10598. \section{TMS370xxx}
  10599.  
  10600. Though these processors do not have specialized instructions for bit
  10601. manipulation, the assembler creates (with the help of the \tty{DBIT}
  10602. instruction - see there) the illusion as if single bits were
  10603. addressable.  To achieve this, the \tty{DBIT} instructions stores an
  10604. address along with a bit position into an integer symbol which may
  10605. then be used as an argument to the pseudo instructions \tty{SBIT0, SBIT1,
  10606. CMPBIT, JBIT0}, and \tty{JBIT1}.  These are translated into the instructions
  10607. \tty{OR, AND, XOR, BTJZ}, and \tty{BTJO} with an appropriate bit mask.
  10608.  
  10609. There is nothing magic about these bit symbols, they are simple
  10610. integer values that contain the address in their lower and the bit
  10611. position in their upper half.  One could construct bit symbols
  10612. without the \tty{DBIT} instruction, like this:
  10613. \begin{verbatim}
  10614. defbit  macro   name,bit,addr
  10615. name    equ     addr+(bit<<16)
  10616.        endm
  10617. \end{verbatim}
  10618. but this technique would not lead to the \tty{EQU}-style syntax defined by
  10619. TI (the symbol to be defined replaces the label field in a line).
  10620. \bb{CAUTION!} Though \tty{DBIT} allows an arbitrary address, the pseudo
  10621. instructions can only operate with addresses either in the range from
  10622. 0..255 or 1000h..10ffh.  The processor does not have an absolute
  10623. addressing mode for other memory ranges...
  10624.  
  10625. %%---------------------------------------------------------------------------
  10626.  
  10627. \section{MSP430(X)}
  10628. \label{MSPSpec}
  10629.  
  10630. The MSP was designed to be a RISC processor with a minimal power
  10631. consumption.  The set of machine instructions was therefore reduced
  10632. to the absolute minimum (RISC processors do not have a microcode ROM
  10633. so every additional instruction has to be implemented with additional
  10634. silicon that increases power consumption).  A number of instructions
  10635. that are hardwired for other processors are therefore emulated with
  10636. other instructions.  Older versions of \asname{} implemented these
  10637. instructions via macros in the file \tty{REGMSP.INC}.  If one did
  10638. not include this file, you got error messages for more than
  10639. half of the instructions defined by TI.  This has been changed in
  10640. recent versions: as part of adding the 430X instruction set,
  10641. implementation of these instructions was moved into the assmebler's
  10642. core.  \tty{REGMSP.INC} now only contains addresses of I/O
  10643. registers.  If you need the old macros for some reason, they have
  10644. been moved to the file \tty{EMULMSP.INC}.
  10645.  
  10646. Instruction emulation also covers some special cases not handled
  10647. by the original TI assembler.  For instance,
  10648. \begin{verbatim}
  10649.    rlc  @r6+
  10650. \end{verbatim}
  10651. is automatically assembled as
  10652. \begin{verbatim}
  10653.    addc @r6+,-2(r6)
  10654. \end{verbatim}
  10655.  
  10656. %%---------------------------------------------------------------------------
  10657.  
  10658. \section{TMS1000}
  10659.  
  10660. At last, world's first microcontroller finally also supported in
  10661. \asname{} - it took long to fill this gap, but now it is done.  This
  10662. target has some pitfalls that will be discussed shortly in this
  10663. section.
  10664.  
  10665. First, the instruction set of these controllers is partially
  10666. defined via the ROM mask, i.e. the function of some opcodes may
  10667. be freely defined to some degree.  \asname{} only knows the instructions
  10668. and codings that are described as default codings in
  10669. \cite{TMS1000PGMRef}.  If you have a special application with an
  10670. instruction set deviating from this, you may define and modify
  10671. instructions via macros and the \tty{DB} instruction.
  10672.  
  10673. Furthermore, keep in mind that branches and subroutine calls only
  10674. contain the lower 6 bits of the target address.  The upper 4
  10675. resp. 5 bits are fetched from page and chapter registers tha
  10676. thave to be set beforehand.  \asname{} cannot check whether these
  10677. registers have been set correctly by the programmer! At least for
  10678. the cas of staying in the same chapter, there are the assmebler
  10679. pseudo instructions \tty{CALLL} resp. \tty{BL} that combine an
  10680. \tty{LDP} and \tty{CALL/BR} instruction.  Regarding the limited
  10681. amount of program memory, this is a convenient yet inefficient
  10682. variant.
  10683.  
  10684. %%---------------------------------------------------------------------------
  10685.  
  10686. \section{COP8}
  10687. \label{COP8Spec}
  10688.  
  10689. National unfortunately also decided to use the syntax well known from
  10690. IBM mainframes (and much hated by me..) to write non-decimal integer
  10691. constants.  Just like with other processors, this does not work with
  10692. \asname{}'s parser.  ASMCOP however fortunately also seems to allow the C
  10693. syntax, which is why this became the default for the COP series and
  10694. the SC/MP...
  10695.  
  10696. %%---------------------------------------------------------------------------
  10697.  
  10698. \section{SC/MP}
  10699.  
  10700. If indirect addressing with displacement is used on the SC/MP, and
  10701. if the base or pointer register is not P0/PC, a displacement of -128
  10702. (80 hex) has a special meaning: the contents of the E register are
  10703. used as displacement instead of this value.  If using the 'classic NS
  10704. assembler', the programmer has to know about this, and even explicitly
  10705. use it:
  10706. \begin{verbatim}
  10707. ereg   equ -128
  10708.       ld  ereg(p1)
  10709. \end{verbatim}
  10710. This however bears the risk that -128 may accidentally be the result of
  10711. a computed displacement, and you might have a hard time finding out
  10712. why the program does not do what was indented. I therefore decided to
  10713. make this special value more explicit:
  10714.  
  10715. If a displacement of -128 is used, a warning is issued.  One may
  10716. simply ignore this warning.  If you want to get rid of it, use
  10717. the built-in literal \verb!E!, which explicitly references the
  10718. register of same name:
  10719. \begin{verbatim}
  10720.       ld e(p1)
  10721. \end{verbatim}
  10722. Since the SC/MP target supports register symbols, it is also possible
  10723. to define the 'own symbol' in a proper way:
  10724. \begin{verbatim}
  10725. ereg   reg e
  10726.       ld  ereg(p1)
  10727. \end{verbatim}
  10728. This should reduce the amount of necessary changes in existing code
  10729. to a minimum.
  10730.  
  10731. %%---------------------------------------------------------------------------
  10732.  
  10733. \section{SC144xxx}
  10734. \label{SC144xxspec}
  10735.  
  10736. Originally, National offered a relatively simple assembler for this series
  10737. of DECT controllers.  An much more powerful assembler has been announced
  10738. by IAR, but it is not available up to now.  However, since the development
  10739. tools made by IAR are as much target-independent as possible, one can
  10740. roughly estimate the pseudo instructions it will support by looking at
  10741. other available target platforms.  With this in mind, the (few)
  10742. SC144xx-specific instructions {\tt DC, DC8, DW16, DS, DS8, DS16, DW} were
  10743. designed.  Of course, I didn't want to reinvent the wheel for pseudo
  10744. instructions whose functionality is already part of the \asname{} core.
  10745. Therefore, here is a little table with equivalences.  The statements
  10746. \tty{ALIGN, END, ENDM, EXITM, MACRO, ORG, RADIX, SET,} and \tty{REPT} both
  10747. exist for the IAR assembler and \asname{} and have same functionality.  Changes
  10748. are needed for the following instructions:
  10749.  
  10750. \begin{table*}[htb]
  10751. \begin{center}\begin{tabular}{|l|l|l|}
  10752. \hline
  10753. IAR & \asname{} & Funktion\\
  10754. \hline
  10755. \hline
  10756. \tty{\#include} & \tty{include} & include file \\
  10757. \tty{\#define} & \tty{SET, EQU} & define symbol \\
  10758. \tty{\#elif, ELIF, ELSEIF} & \tty{ELSEIF} & start another \\
  10759.                           &              & IF branch \\
  10760. \tty{\#else, ELSE} & \tty{ELSE} & last branch of an IF \\
  10761.                   &            & construct \\
  10762. \tty{\#endif, ENDIF} & \tty{ENDIF} & ends an IF construct \\
  10763. \tty{\#error} & \tty{ERROR, FATAL} & create error message \\
  10764. \tty{\#if, IF} & \tty{IF} & start an IF construct \\
  10765. \tty{\#ifdef} & \tty{IFDEF} & symbol defined ? \\
  10766. \tty{\#ifndef} & \tty{IFNDEF} & symbol not defined ? \\
  10767. \tty{\#message} & \tty{MESSAGE} & output message \\
  10768. \tty{=, DEFINE, EQU} & \tty{=, EQU} & fixed value assignment \\
  10769. \tty{EVEN} & \tty{ALIGN 2} & force PC to be equal \\
  10770. \tty{COL, PAGSIZ} & \tty{PAGE} & set page size for listing \\
  10771. \tty{ENDR} & \tty{ENDM} & end REPT construct \\
  10772. \tty{LSTCND, LSTOUT} & \tty{LISTING} & control amount of listing \\
  10773. \tty{LSTEXP, LSTREP} & \tty{MACEXP} & list expanded macros? \\
  10774. \tty{LSTXRF} & \verb!<command line>! & generate cross reference \\
  10775. \tty{PAGE} & \tty{NEWPAGE} & new page in listing \\
  10776. \tty{REPTC} & \tty{IRPC} & repetition with character \\
  10777.            &            & replacement \\
  10778. \hline
  10779. \end{tabular}\end{center}
  10780. \end{table*}
  10781.  
  10782. There is no direct equivalent for {\tt CASEON}, {\tt CASEOFF,}
  10783. \tty{LOCAL}, \tty{LSTPAG}, \tty{\#undef,} and {\tt REPTI}.
  10784.  
  10785. A 100\% equivalent is of course impossible as long as there is no C-like
  10786. preprocessor in \asname{}.  C-like comments unfortunately are also impossible
  10787. at the moment.  Caution: When modifying IAR codes for \asname{}, do not forget to
  10788. move converted preprocessor statements out of column 1 as \asname{} reserves this
  10789. column exclusively for labels!
  10790.  
  10791. %%---------------------------------------------------------------------------
  10792.  
  10793. \section{NS32xxx}
  10794.  
  10795. As one might expect from a CISC processor, the NS32xxx series provides
  10796. sophisticated and complex addressing modes.  National defied the assembly syntax
  10797. for each of them in its manuals, and this is also the syntax \asname{} implements.
  10798. However, as for every architecture that was supported by third-party tools,
  10799. there are deviations and extensions, and I added a few of them to \asname{}:
  10800.  
  10801. The syntax to use PC-relative addressing, as defined by National, is:
  10802. \begin{verbatim}
  10803. movb r0,*+disp
  10804. \end{verbatim}
  10805. This of course quite clearly expresses what is happening at runtime, one however
  10806. has to compute the distance himself if a certain memory location is to be
  10807. addressed:
  10808. \begin{verbatim}
  10809. movb r0,*+(addr-*)
  10810. \end{verbatim}
  10811. The first simplification is that under certain conditions, it is sufficient to
  10812. just write:
  10813. \begin{verbatim}
  10814. movb r0,addr
  10815. \end{verbatim}
  10816. since absolute addressierung is marked by a \@ prefix.  This is allowed under
  10817. the following conditions:
  10818. \begin{itemize}
  10819. \item{Immediate addressierung is not allowed, e.g. because the operand is
  10820.      the destination and there is no risk os ambiguities.}
  10821. \item{An index extension is used (appended in square brackets), which must not
  10822.      be combined with immediate addressing.}
  10823. \end{itemize}
  10824. As an alterntative, \asname{} also supports the following way to use PC-relative addressing:
  10825. \begin{verbatim}
  10826. movb r0,addr(pc)
  10827. \end{verbatim}
  10828. Analog to the 68000, the distance is computed automatically.
  10829.  
  10830. The external mode, whis written this way in National syntax:
  10831. \begin{verbatim}
  10832. movb r0,ext(disp1)+disp2
  10833. \end{verbatim}
  10834. there is another supported syntax variant:
  10835. \begin{verbatim}
  10836. movb r0,disp2(disp1(ext))
  10837. \end{verbatim}
  10838. which used to be common in UNIX environments.
  10839.  
  10840. %%---------------------------------------------------------------------------
  10841.  
  10842. \section{uPD78(C)1x}
  10843. \label{78C1xSpec}
  10844.  
  10845. For relative, unconditional instructions, there is the \tty{JR} instruction
  10846. branch distance -32...+31, one byte), and the \tty{JRE} instruction (branch
  10847. distance -256...+255, two bytes).  \asname{} furthermore knows the \tty{J} pseudo
  10848. instruction, which automatically selects the shortest possible variant.
  10849.  
  10850. Architecture and instructon set of these processors are coarsely
  10851. related to the Intel 8080/8085 - thi is also true for the
  10852. mnemonics.  The adressing mode (direct, indirect, immediate) is
  10853. packed into the mnemonic, and 16 bit registers (BC, DE, HL) are
  10854. written with just one letter.  However, since NEC itself also
  10855. uses at some places written-out register names and parentheses to
  10856. signify indirect addressing, I decided to support some
  10857. alternative notations next to the 'official' ones.   Some non-NEC
  10858. tools like disassemblers seem to use these notations either:
  10859.  
  10860. \begin{itemize}
  10861. \item{It is allowed to use \tty{BC}, \tty{(B)}, or \tty{(BC)}
  10862.      instead of \tty{B}.}
  10863. \item{It is allowed to use \tty{DE}, \tty{(D)}, or \tty{(DE)}
  10864.      instead of \tty{D}.}
  10865. \item{It is allowed to use \tty{HL}, \tty{(H)}, or \tty{(HL)}
  10866.      instead of \tty{H}.}
  10867. \item{It is allowed to use \tty{DE+}, \tty{(D+)}, \tty{(DE+)},
  10868.      or \tty{(DE)+} instead of \tty{D+}.}
  10869. \item{It is allowed to use \tty{HL+}, \tty{(H+)}, \tty{(HL+)},
  10870.      or \tty{(HL)+} instead of \tty{H+}.}
  10871. \item{It is allowed to use \tty{DE-}, \tty{(D-)}, \tty{(DE-)},
  10872.      or \tty{(DE)-} instead of \tty{D-}.}
  10873. \item{It is allowed to use \tty{HL-}, \tty{(H-)}, \tty{(HL-)},
  10874.      or \tty{(HL)-} instead of \tty{H-}.}
  10875. \item{It is allowed to use \tty{DE++}, \tty{(D++)}, \tty{(DE++)},
  10876.      or \tty{(DE)++} instead of \tty{D++}.}
  10877. \item{It is allowed to use \tty{HL++}, \tty{(H++)}, \tty{(HL++)},
  10878.      or \tty{(HL)++} instead of \tty{H++}.}
  10879. \item{It is allowed to use \tty{DE--}, \tty{(D--)}, \tty{(DE--)},
  10880.      or \tty{(DE)--} instead of \tty{D--}.}
  10881. \item{It is allowed to use \tty{HL--}, \tty{(H--)}, \tty{(HL--)},
  10882.      or \tty{(HL)--} instead of \tty{H--}.}
  10883. \item{It is allowed to use \tty{HL+A}, \tty{A+H}, \tty{A+HL},
  10884.      \tty{(H+A)}, \tty{(HL+A)}, \tty{(A+H)}, or \tty{(A+HL)}
  10885.      instead of \tty{H+A}.}
  10886. \item{It is allowed to use \tty{HL+B}, \tty{B+H}, \tty{B+HL},
  10887.      \tty{(H+B)}, \tty{(HL+B)}, \tty{(B+H)}, or \tty{(B+HL)}
  10888.      instead of \tty{H+B}.}
  10889. \item{It is allowed to use \tty{HL+EA}, \tty{EA+H}, \tty{EA+HL},
  10890.      \tty{(H+EA)}, \tty{(HL+EA)}, \tty{(EA+H)}, or \tty{(EA+HL)}
  10891.      instead of \tty{H+EA}.}
  10892. \end{itemize}
  10893.  
  10894. Since architecture and instruction set are so ''8080-like'', it was
  10895. straightforward to support the {\tt Z80SYNTAX} statement, which
  10896. allows to write many machine instructions in a more intuitive and
  10897. better-known way.  However, since both the uCON87 family's architecture
  10898. and instruction set differ from the 8080 in a couple of details, it
  10899. is not possible to provide a complete one-to-one mapping.  Not all
  10900. original instructions have a ''Z80 equivalent'', and some instructions
  10901. known from 8080 and Z80 do not exist on the uCOM87.  It therefore
  10902. does not make sense to support {\tt Z80SYNTAX EXCLUSIVE}.
  10903.  
  10904. The following table lists all instructions defined in {\tt Z80SYNTAX}
  10905. mode and their equivalents in original syntax:
  10906.  
  10907. \begin{longtable}{|l|l|l|l|}
  10908. \hline
  10909. {\tt Z80SYNTAX} & Original & Operation  & CPUs \\
  10910. \hline
  10911. \hline
  10912. \endhead
  10913. \input{../doc_COM/78z80inst.tex}
  10914. \\ \hline
  10915. \multicolumn{4}{|l|}{CPU Group 1: 78C05, 78C06} \\
  10916. \multicolumn{4}{|l|}{CPU Group 2: 7800, 7801, 7802} \\
  10917. \multicolumn{4}{|l|}{CPU Group 3: 7807, 7808, 7809, 7810} \\
  10918. \multicolumn{4}{|l|}{CPU Group 4: 7810, 78C1x} \\
  10919. \hline
  10920. \caption{Instruction Variants in {\tt Z80SYNTAX} Mode}
  10921. \end{longtable}
  10922.  
  10923. %%---------------------------------------------------------------------------
  10924.  
  10925. \section{75K0}
  10926. \label{75K0Spec}
  10927.  
  10928. Similar to other processors, the assembly language of the 75 series
  10929. also knows pseudo bit operands, i.e. it is possible to assign a
  10930. combination of address and bit number to a symbol that can then be
  10931. used as an argument for bit oriented instructions just like explicit
  10932. expressions.  The following three instructions for example generate
  10933. the same code:
  10934. \begin{verbatim}
  10935. ADM     sfr     0fd8h
  10936. SOC     bit     ADM.3
  10937.  
  10938.        skt     0fd8h.3
  10939.        skt     ADM.3
  10940.        skt     SOC
  10941. \end{verbatim}
  10942. \asname{} distinguishes direct and symbolic bit accesses by the missing dot
  10943. in symbolic names; it is therefore forbidden to use dots in symbol
  10944. names to avoid misunderstandings in the parser.
  10945.  
  10946. The storage format of bit symbols mostly accepts the binary coding in
  10947. the machine instructions themselves:  16 bits are used, and there is
  10948. a ''long'' and a ''short'' format.  The short format can store the
  10949. following variants:
  10950. \begin{itemize}
  10951. \item{direct accesses to the address range from 0FBxH to 0FFxH}
  10952. \item{indirect accesses in the style of \tty{Addr.@L} (0FC0H $\leq$ \tty{Addr} $\leq$0FFFH)}
  10953. \item{indirect accesses in the style of \tty{@H+d4.bit}}
  10954. \end{itemize}
  10955. The upper byte is set to 0, the lower byte contains the bit
  10956. expression coded according to \cite{NEC75}.  The long format in contrast
  10957. only knows direct addressing, but it can cover the whole address space
  10958. (given a correct setting of MBS and MBE).  A long expression stores
  10959. bits 0..7 of the address in the lower byte, the bit position in bits
  10960. 8 and 9, and a constant value of 01 in bits 10 and 11.  The highest
  10961. bits allow to distinguish easily between long and short addresses via
  10962. a check if the upper byte is 0.  Bits 12..15 contain bits 8..11 of
  10963. the address; they are not needed to generate the code, but they have
  10964. to be stored somewhere as the check for correct banking can only
  10965. take place when the symbol is actually used.
  10966.  
  10967. %%---------------------------------------------------------------------------
  10968.  
  10969. \section{78K0}
  10970. \label{78K0Spec}
  10971.  
  10972. NEC uses different ways to mark absolute addressing in its data
  10973. books:
  10974. \begin{itemize}
  10975. \item{absolute short: no prefix}
  10976. \item{absolute long: prefix of \tty{!}}
  10977. \item{PC relative: prefix of \tty{\$}}
  10978. \end{itemize}
  10979. Under \asname{}, these prefixes are only necessary if one wants to force a
  10980. certain addressing mode and the instruction allows different
  10981. variants.  Without a prefix, \asname{} will automatically select the shortest
  10982. variant.  It should therefore rarely be necessary to use a prefix in
  10983. practice.
  10984.  
  10985. %%---------------------------------------------------------------------------
  10986.  
  10987. \section{78K2/78K3/78K4}
  10988. \label{78K234Spec}
  10989.  
  10990. Analogous to the 78K0, NEC here also uses dollar signs and exclamation
  10991. marks to specify different lengths of address expressions.  The selection
  10992. between long and short addresses is done automatically (both in RAM and
  10993. SFR areas), only relative addressing has to be selected explicitly, if an
  10994. instruction supports both variants (like {\tt BR}).
  10995.  
  10996. An additional remark (which is also true for the 78K0): Those who want to
  10997. use Motorola syntax via {\tt RELAXED}, might have to put hexadecimal
  10998. constants in parentheses, since the leading dollar sign might be
  10999. misunderstood as relative addressing...
  11000.  
  11001. %%---------------------------------------------------------------------------
  11002.  
  11003. \section{uPD772x}
  11004.  
  11005. Both the 7720 and 7725 are provided by the same code generator and are
  11006. extremely similar in their instruction set.  One should however not
  11007. beleive that they are binary compatible: To get space for the longer
  11008. address fields and additional instructions, the bit positions of some
  11009. fields in the instruction word have changed, and the instruction length
  11010. has changed from 23 to 24 bits.  The code format therefore uses different
  11011. header ids for both CPUs.
  11012.  
  11013. They both have in common that in addition to the code and data segment,
  11014. there is also a ROM for storage of constants.  In the case of \asname{}, it is
  11015. mapped onto the \tty{ROMDATA} segment!
  11016.  
  11017. %%---------------------------------------------------------------------------
  11018.  
  11019. \section{F2MC16L}
  11020.  
  11021. Along with the discussion of the {\tt ASSUME} statement, it has already
  11022. been mentioned that it is important to inform \asname{} about the correct current
  11023. values of all bank registers - if your program uses more than 64K RAM or
  11024. 64K ROM.  With these assumptions in mind, \asname{} checks every direct memory
  11025. access for attempts to access a memory location that is currently not in
  11026. reach.  Of course, standard situations only require knowledge of DTB and
  11027. DPR for this purpose, since ADB resp. SSB/USB are only used for indirect
  11028. accesses via RW2/RW6 resp. RW3/RW7 and this mechanism anyway doesn't work
  11029. for indirect accesses.  However, similar to the 8086, it is possible to
  11030. place a prefix in front of an instruction to replace DTB by a different
  11031. register.  \asname{} therefore keeps track of used segment prefixes and
  11032. toggles appropriately for the next {\em machine instruction}.  A pseudo
  11033. instruction placed between the prefix and the machine instruction does
  11034. {\em not} reset the toggle.  This is also true for pseudo instructions
  11035. that store data or modify the program counter.  Which doesn't make much
  11036. sense anyway...
  11037.  
  11038. %%---------------------------------------------------------------------------
  11039.  
  11040. \section{MN161x}
  11041.  
  11042. This target is special because there are two different code generators one may
  11043. choose from.  The first one was kindly provided by Haruo Asano and that may be
  11044. reached via the CPU names \tty{MN1610} resp.\tty{MN1613}.  The other one was
  11045. written by me and is activated via the CPU names \tty{MN1610ALT} resp.
  11046. \tty{MN1613ALT}.  If you want to use the MN1613's extended address space of
  11047. 256 KWords, or if you want to experiment with the MN1613's floating point
  11048. formant, you have to use the \tty{ALT} target.
  11049.  
  11050. %%---------------------------------------------------------------------------
  11051.  
  11052. \section{CDP180x}
  11053.  
  11054. This family of processors supports both long and short branches: a short
  11055. branch is only possible within the same 256 byte memory page, and a long branch
  11056. is possible to any target in the 64K address space.  The assembly syntax provides
  11057. different mnemonics for both variants (the long variant with a leading 'L'), but
  11058. there is no variant that would let the assembler decide itself between long
  11059. or short.  \asname{} supports such 'pseudo instructions' as an extension:
  11060. \begin{itemize}
  11061. \item{\tty{JMP} becomes \tty{BR} oder \tty{LBR}.}
  11062. \item{\tty{JZ} becomes \tty{BZ} oder \tty{LBZ}.}
  11063. \item{\tty{JNZ} becomes \tty{BNZ} oder \tty{LBNZ}.}
  11064. \item{\tty{JDF} becomes \tty{BDF} oder \tty{LBDF}.}
  11065. \item{\tty{JPZ} becomes \tty{BPZ} oder \tty{LBPZ}.}
  11066. \item{\tty{JGE} becomes \tty{BGE} oder \tty{LBGE}.}
  11067. \item{\tty{JNF} becomes \tty{BNF} oder \tty{LBNF}.}
  11068. \item{\tty{JM} becomes \tty{BM} oder \tty{LBM}.}
  11069. \item{\tty{JL} becomes \tty{BL} oder \tty{LBL}.}
  11070. \item{\tty{JQ} becomes \tty{BQ} oder \tty{LBQ}.}
  11071. \item{\tty{JNQ} becomes \tty{BNQ} oder \tty{LBNQ}.}
  11072. \end{itemize}
  11073.  
  11074.  
  11075. %%---------------------------------------------------------------------------
  11076.  
  11077. \section{KENBAK}
  11078.  
  11079. The KENBAK-1 was developed in 1970, at a time when the first microprocessor
  11080. was still three years away.  One may assume that for the few hobbyists that
  11081. could afford the kit back then, this was their first and only computer.  As
  11082. a consequence, they had nothing they could run an assembler on, the KENBAK-1
  11083. itself with its 256 bytes of memory was way too small for such a task.  The
  11084. preferred method was to use pre-printed tables, which had fields to fill in
  11085. instructions and machine codes.  Once this ''programming job'' was done, one
  11086. would enter the machine code manually via the computer's switch row.
  11087.  
  11088. The effect of this is that though the KENBAK's assembly language is described
  11089. in the manual, there is no real formal definition of it.  When Grant Stockly
  11090. released new KENBAK kits a few years ago, he did a first implementation of the
  11091. KENBAK on my assembler.  Unfortunately, this never went upstream.  I tried
  11092. to take up his ideas in my implementation, but on the other hand I also tried to
  11093. offer a syntax that should be familiar to programmers of 6502, Z80 or similar
  11094. processors.  The following table lists the syntax differences:
  11095.  
  11096. \hfuzz=60pt
  11097. \begin{center}\begin{longtable}{|l|l|l|}
  11098. \hline
  11099. Stockly & Alternativ & Bemerkung \\
  11100. \hline
  11101. \hline
  11102. \endhead
  11103. \multicolumn{3}{|l|}{\bf Arithmetic/Logic (ADD/SUB/LOAD/STORE/AND/OR/LNEG)} \\
  11104. \hline
  11105. {\it instr} {\tt Constant}, {\it Reg}, {\it Wert}, & {\it instr} {\it Reg}, {\it \#Wert} & immediate \\
  11106. {\it instr} {\tt Memory}, {\it Reg}, {\it Addr}, & {\it instr} {\it Reg}, {\it Addr} & direct \\
  11107. {\it instr} {\tt Indirect}, {\it Reg}, {\it Addr}, & {\it instr} {\it Reg}, {\it (Addr)} & direct \\
  11108. {\it instr} {\tt Indexed}, {\it Reg}, {\it Addr}, & {\it instr} {\it Reg}, {\it Addr},X & indexed \\
  11109. {\it instr} {\tt Indirect-Indexed}, {\it Reg}, {\it Addr}, & {\it instr} {\it Reg}, {\it (Addr)},X & indirect-indexed \\
  11110. \hline
  11111. \multicolumn{3}{|l|}{\bf Jumps} \\
  11112. \hline
  11113. {\tt JPD} {\it Reg}, {\it Cond}, {\it Addr} & {\tt JP} {\it Reg}, {\it Cond}, {\it Addr} & conditional-direct \\
  11114. {\tt JPI} {\it Reg}, {\it Cond}, {\it Addr} & {\tt JP} {\it Reg}, {\it Cond}, {\it (Addr)} & conditional-indirect \\
  11115. {\tt JMD} {\it Reg}, {\it Cond}, {\it Addr} & {\tt JM} {\it Reg}, {\it Cond}, {\it Addr} & conditional-direct \\
  11116. {\tt JMI} {\it Reg}, {\it Cond}, {\it Addr} & {\tt JM} {\it Reg}, {\it Cond}, {\it (Addr)} & conditional-indirect \\
  11117. {\tt JPD} {\tt Unconditional}, {\it Cond}, {\it Addr} & {\tt JP} {\it Addr} & unconditional-direct \\
  11118. {\tt JPI} {\tt Unconditional}, {\it Cond}, {\it Addr} & {\tt JP} {\it (Addr)} & unconditional-indirect \\
  11119. {\tt JMD} {\tt Unconditional}, {\it Cond}, {\it Addr} & {\tt JM} {\it Addr} & unconditional-direct \\
  11120. {\tt JMI} {\tt Unconditional}, {\it Cond}, {\it Addr} & {\tt JM} {\it (Addr)} & unconditional-indirect \\
  11121. \hline
  11122. \multicolumn{3}{|l|}{\bf Jump Conditions} \\
  11123. \hline
  11124. {\tt Non-zero} & {\tt NZ} & $\neq 0$ \\
  11125. {\tt Zero} & {\tt Z} & $= 0$ \\
  11126. {\tt Negative} & {\tt N} & $< 0$ \\
  11127. {\tt Positive} & {\tt P} & $\geq 0$ \\
  11128. {\tt Positve-Non-zero} & {\tt PNZ} & $ > 0$ \\
  11129. \hline
  11130. \multicolumn{3}{|l|}{\bf Skips} \\
  11131. \hline
  11132. {\tt SKP 0}, {\it bit}, {\it Addr} & {\tt SKP0} {\it bit}, {\it Addr} {\it [,Dest]} & \\
  11133. {\tt SKP 1}, {\it bit}, {\it Addr} & {\tt SKP1} {\it bit}, {\it Addr} {\it [,Dest]} & \\
  11134. \hline
  11135. \multicolumn{3}{|l|}{\bf Bit Manipulation} \\
  11136. \hline
  11137. {\tt SET 0}, {\it bit}, {\it Addr} & {\tt SET0} {\it bit}, {\it Addr} & \\
  11138. {\tt SET 1}, {\it bit}, {\it Addr} & {\tt SET1} {\it bit}, {\it Addr} & \\
  11139. \hline
  11140. \multicolumn{3}{|l|}{\bf Shifts/Rotates} \\
  11141. \hline
  11142. {\tt SHIFT LEFT}, {\it cnt}, {\it Reg} & {\tt SFTL} {\it [cnt,]} {\it Reg} & \\
  11143. {\tt SHIFT RIGHT}, {\it cnt}, {\it Reg} & {\tt SFTR} {\it [cnt,]} {\it Reg} & arithm. Shift \\
  11144. {\tt ROTATE LEFT}, {\it cnt}, {\it Reg} & {\tt ROTL} {\it [cnt,]} {\it Reg} & \\
  11145. {\tt ROTATE RIGHT}, {\it cnt}, {\it Reg} & {\tt ROTR} {\it [cnt,]} {\it Reg} & \\
  11146. \hline
  11147. \caption{KENBAK-Befehlssyntax \label{TabKENBAKSyntax}}
  11148. \end{longtable}\end{center}
  11149. \hfuzz=0pt
  11150.  
  11151. There is no pseudo instruction to switch between these syntax variants.  They may
  11152. both be used anytime and in an arbitrary mix.
  11153.  
  11154. The target address {\it [Dest]} that may optionally be added to skip instructions
  11155. will not become part of the machine code.  The assembler only checks whether the
  11156. processor wil actually skip to the given address.  This allows for instance to check
  11157. whether one actually tries to skip a one-byte instruction.  If the shift count
  11158. argument {\it [cnt]} is omitted, a one-bit shift/rotate is coded.
  11159.  
  11160. %%---------------------------------------------------------------------------
  11161.  
  11162. \section{HP Nanoprocessor}
  11163.  
  11164. The HP Nanoprocessor does not provide any instructions to read data from the ROM
  11165. address space.  The respective instructions {\tt LDR} and {\tt STR} rather
  11166. represent what is called ''immediate addressing'' on other processors.  For this
  11167. reson, there are pseudo instructions that would allow placing data constants
  11168. im ROM memory or to reserve space in it.
  11169.  
  11170. %%---------------------------------------------------------------------------
  11171.  
  11172. \section{IM61x0}
  11173.  
  11174. This microprocessor is effectively a single chip implementation of the PDP8/E,
  11175. which is why Digital Equipment's PAL-II is usually the ''reference assembler''
  11176. for source code samples.  The \asname{} implementation deviates from the PAL-III syntax
  11177. in a couple of areas, among other reasons also because several things only
  11178. could have been provided with huge efforts.  Here are some hints about how to
  11179. adapt existing code:
  11180.  
  11181. \begin{itemize}
  11182. \item{PAL-III marks labels by an appended comma.  \asname{} instead uses an appended
  11183.      double colon, or no special character at all if the label begins in the
  11184.      first column of a line.}
  11185. \item{Placing constants in memory is done with PAL-III simply by writing the
  11186.      numeric constant instead of a mnemonic.  \asname{} uses the \tty{DC} instruction
  11187.      to place data, which will also accept more than one word as argument.
  11188.      However, the \tty{LTORG} mechanism may be used in some cases to get
  11189.      around explicitly placing constants in memory at all.}
  11190. \item{The program counter is set by \tty{ORG address} instead of {*address}.}
  11191. \end{itemize}
  11192.  
  11193. %%===========================================================================
  11194.  
  11195. \cleardoublepage
  11196. \chapter{File Formats}
  11197.  
  11198. In this chapter, the formats of files \asname{} generates shall be explained
  11199. whose formats are not self-explanatory.
  11200.  
  11201. %%---------------------------------------------------------------------------
  11202.  
  11203. \section{Code Files}
  11204. \label{SectCodeFormat}
  11205.  
  11206. The format for code files generated by the assembler must be able to
  11207. separate code parts that were generated for different target
  11208. processors; therefore, it is a bit different from most other formats.
  11209. Though the assembler package contains tools to deal with code files,
  11210. I think is a question of good style to describe the format in short:
  11211.  
  11212. If a code file contains multibyte values, they are stored in little
  11213. endian order.  This rule is already valid for the 16-bit magic word
  11214. \$1489, i.e. every code file starts with the byte sequence \$89/\$14.
  11215. This magic word is followed by an arbitrary number of ''records''.  A
  11216. record may either contain a continuous piece of the code or certain
  11217. additional information.  Even without switching to different
  11218. processor types, a file may contain several code-containing records,
  11219. in case that code or constant data areas are interrupted by reserved
  11220. memory areas that should not be initialized.  This way, the assembler
  11221. tries to keep the file as short as possible.
  11222. Common to all records is a header byte which defines the record's type
  11223. and its contents.  Written in a PASCALish way, the record structure
  11224. can be described in the following way:
  11225. \begin{verbatim}
  11226. FileRecord = RECORD CASE Header:Byte OF
  11227.              $00:(Creator:ARRAY[] OF Char);
  11228.              $01..
  11229.              $7f:(StartAdr : LongInt;
  11230.                   Length   : Word;
  11231.                   Data     : ARRAY[0..Length-1] OF Byte);
  11232.              $80:(EntryPoint:LongInt);
  11233.              $81:(Header   : Byte;
  11234.                   Segment  : Byte;
  11235.                   Gran     : Byte;
  11236.                   StartAdr : LongInt;
  11237.                   Length   : Word;
  11238.                   Data     : ARRAY[0..Length-1] OF Byte);
  11239.             END
  11240. \end{verbatim}
  11241. This description does not express fully that the length of data
  11242. fields is variable and depends on the value of the \tty{Length} entries.
  11243.  
  11244. A record with a header byte of \$81 is a record that may contain code
  11245. or data from arbitrary segments.  The first byte (\tty{Header}) describes
  11246. the processor family the following code resp. data was generated for (see
  11247. table \ref{TabHeader}).
  11248. \begin{center}\begin{longtable}{|c|l||c|l|}
  11249. \hline
  11250. Header  & Family & Header  & Family \\
  11251. \hline
  11252. \hline
  11253. \endhead
  11254. \input{../doc_COM/tabids.tex}
  11255. \\ \hline
  11256. \caption{Header Bytes for the Different Processor Families}
  11257. \label{TabHeader}
  11258. \end{longtable}\end{center}
  11259. The \tty{Segment} field signifies the address space the following code
  11260. belongs to.  The assignment defined in table \ref{TabSegments} applies.
  11261. \begin{table*}[htbp]
  11262. \begin{center}\begin{tabular}{|c|l||c|l|}
  11263. \hline
  11264. number  & segment               & number  & segment \\
  11265. \hline
  11266. \hline
  11267. \$00    & $<$undefined$>$       & \$01    & \tty{CODE} \\
  11268. \$02    & \tty{DATA}            & \$03    & \tty{IDATA} \\
  11269. \$04    & \tty{XDATA}           & \$05    & \tty{YDATA} \\
  11270. \$06    & \tty{BDATA}           & \$07    & \tty{IO} \\
  11271. \$08    & \tty{REG}             & \$09    & \tty{ROMDATA} \\
  11272. \hline
  11273. \end{tabular}\end{center}
  11274. \caption{Codings of the {\tt Segment} Field\label{TabSegments}
  11275.         \label{TabSegmentNums}}
  11276. \end{table*}
  11277. The \tty{Gran} field describes the code's ''granularity'', i.e. the size of
  11278. the smallest addressable unit in the following set of data.  This
  11279. value is a function of processor type and segment and is an important
  11280. parameter for the interpretation of the following two fields that
  11281. describe the block's start address and its length: While the start
  11282. address refers to the granularity, the \tty{Length} value is always
  11283. expressed in bytes!  For example, if the start address is \$300 and
  11284. the length is 12, the resulting end address would be \$30b for a
  11285. granularity of 1, however \$303 for a granularity of 4!  Granularities
  11286. that differ from 1 are rare and mostly appear in DSP CPU's that are
  11287. not designed for byte processing.  For example, a DSP56K's address
  11288. space is organized in 64 Kwords of 16 bits.  The resulting storage
  11289. capacity is 128 Kbytes, however it is organized as $2^{16}$ words that
  11290. are addressed with addresses 0,1,2,...65535!
  11291.  
  11292. The start address is always 32 bits in size, independent of the
  11293. processor family.  In contrast, the length specification has only 16
  11294. bits, i.e. a record may have a maximum length of 4+4+2+(64K-1) =
  11295. 65545 bytes.
  11296.  
  11297. Data records with a Header ranging from \$01 to \$7f present a shortcut
  11298. and preserve backward compatibility to earlier definitions of the
  11299. file format: in their case, the Header directly defines the processor
  11300. type, the target segment is fixed to \tty{CODE} and the granularity is
  11301. implicitly given by the processor type, rounded up to the next power
  11302. of two.  \asname{} prefers to use these records whenever data or code should
  11303. go into the \tty{CODE} segment.
  11304.  
  11305. A record with a Header of \$80 defines an entry point, i.e. the
  11306. address where execution of the program should start.  Such a record
  11307. is the result of an \tty{END} statement with a corresponding address as
  11308. argument.
  11309.  
  11310. The last record in a file bears the Header \$00 and has only a string
  11311. as data field.  This string does not have an explicit length
  11312. specification; its end is equal to the file's end.  The string
  11313. contains only the name of the program that created the file and has
  11314. no further meaning.
  11315.  
  11316. %%---------------------------------------------------------------------------
  11317.  
  11318. \section{Debug Files}
  11319. \label{SectDebugFormat}
  11320.  
  11321. Debug files may optionally be generated by \asname{}.  They deliver important
  11322. information for tools used after assembly, like disassemblers or
  11323. debuggers.  \asname{} can generate debug files in one of three formats: On the
  11324. one hand, the object format used by the AVR tools from Atmel respectively
  11325. a NoICE-compatible command file, and on the other hand an own format.  The
  11326. first two are described in detail in \cite{AVRObj} resp. the NoICE
  11327. documentations, which is why the following description limits itself to
  11328. the \asname{}-specific MAP format:
  11329.  
  11330. The information in a MAP file is split into three groups:
  11331. \begin{itemize}
  11332. \item{symbol table}
  11333. \item{memory usage per section}
  11334. \item{machine addresses of source lines}
  11335. \end{itemize}
  11336. The second item is listed first in the file.  A single entry in this
  11337. list consists of two numbers that are separated by a \tty{:} character:
  11338. \begin{verbatim}
  11339. <line number>:<address>
  11340. \end{verbatim}
  11341. Such an entry states that the machine code generated for the source
  11342. statement in a certain line is stored at the mentioned address
  11343. (written in hexadecimal notation).  With such an information, a
  11344. debugger can display the corresponding source lines while stepping
  11345. through a program.  As a program may consist of several include
  11346. files, and due to the fact that a lot of processors have more than
  11347. one address space (though admittedly only one of them is used to
  11348. store executable code), the entries described above have to be
  11349. sorted.  \asname{} does this sorting in two levels: The primary sorting
  11350. criteria is the target segment, and the entries in one of these
  11351. sections are sorted according to files.  The sections resp.
  11352. subsections are separated by special lines in the style of
  11353. \begin{verbatim}
  11354. Segment <segment name>
  11355. \end{verbatim}
  11356. resp.
  11357. \begin{verbatim}
  11358. File <file name>   .
  11359. \end{verbatim}
  11360. The source line info is followed by the symbol table.  Similar to the
  11361. source line info, the symbol table is primarily sorted by the
  11362. segments individual symbols are assigned to.  In contrast to the
  11363. source line info, an additional section \tty{NOTHING} exists which contains
  11364. the symbols that are not assigned to any specific segment (e.g.
  11365. symbols that have been defined with a simple \tty{EQU} statement).  A
  11366. section in the symbol table is started with a line of the following
  11367. type:
  11368. \begin{verbatim}
  11369. Symbols in Segment <segment name>
  11370. \end{verbatim}
  11371. The symbols in a section are sorted according to the alphabetical
  11372. order of their names, and one symbol entry consists of exactly one
  11373. line.  Such a line consists of six fields witch are separated by at
  11374. least a single space:
  11375.  
  11376. The first field is the symbol's name, possibly extended by a section
  11377. number enclosed in brackets.  Such a section number limits the
  11378. range of validity for a symbol.  The second field designates the
  11379. symbol's type: \tty{Int} stands for integer values, \tty{Float} for floating
  11380. point numbers, and \tty{String} for character arrays.  The third field
  11381. finally contains the symbol's value.  If the symbol contains a
  11382. string, it is necessary to use a special encoding for control
  11383. characters and spaces.  Without such a coding, spaces in a string
  11384. could be misinterpreted as delimiters to the next field.  \asname{} uses the
  11385. same syntax that is also valid for assembly source files: Instead of
  11386. the character, its ASCII value with a leading backslash (\verb!\!) is
  11387. inserted.  For example, the string
  11388. \begin{verbatim}
  11389. This is a test
  11390. \end{verbatim}
  11391. becomes
  11392. \begin{verbatim}
  11393. This\032is\032\a\032test   .
  11394. \end{verbatim}
  11395. The numerical value always has three digits and has to be interpreted
  11396. as a decimal value.  Naturally, the backslash itself also has to be
  11397. coded this way.
  11398.  
  11399. The fourth field specifies - if available - the size of the data
  11400. structure placed at the address given by the symbol.   A debugger may
  11401. use this information to automatically display variables in their
  11402. correct length when they are referred symbolically.  In case \asname{} does
  11403. not have any information about the symbol size, this field simply
  11404. contains the value -1.
  11405.  
  11406. The fifth field states via the values 0 or 1 if the symbol has been
  11407. used during assembly.  A program that reads the symbol table can use
  11408. this field to skip unused symbols as they are probably unused during
  11409. the following debugging/disassembly session.
  11410.  
  11411. Finally, the sixth field states via the values 0 or 1 if the symbol
  11412. is a constant (0) or variable(1).  Constant symbols are set once, e.g.
  11413. via the \tty{EQU} statement or a label, while variables are allowed
  11414. to change their value during the course of assembly.  The MAP file
  11415. lists the final value.
  11416.  
  11417. The third section in a debug file describes the program's sections in
  11418. detail.  The need for such a detailed description arises from the
  11419. sections' ability to limit the validity range of symbols.  A symbolic
  11420. debugger for example cannot use certain symbols for a reverse
  11421. translation, depending on the current PC value.  It may also have to
  11422. regard priorities for symbol usage when a value is represented by
  11423. more than one symbol.  The definition of a section starts with a line
  11424. of the following form:
  11425. \begin{verbatim}
  11426. Info for Section nn ssss pp
  11427. \end{verbatim}
  11428. \tty{nn} specifies the section's number (the number that is also used in
  11429. the symbol table as a postfix for symbol names), \tty{ssss} gives its name
  11430. and \tty{pp} the number of its parent section.  The last information is
  11431. needed by a retranslator to step upward through a tree of sections
  11432. until a fitting symbol is found.  This first line is followed by a
  11433. number of further lines that describe the code areas used by this
  11434. section.  Every single entry (exactly one entry per line) either
  11435. describes a single address or an address range given by a lower and
  11436. an upper bound (separation of lower and upper bound by a minus sign).
  11437. These bounds are ''inclusive'', i.e. the bounds themselves also belong
  11438. to the area.  Is is important to note that an area belonging to a
  11439. section is not additionally listed for the section's parent sections
  11440. (an exception is of course a deliberate multiple allocation of address
  11441. areas, but you would not do this, would you?).  On the one hand, this
  11442. allows an optimized storage of memory areas during assembly. On the
  11443. other hand, this should not be an obstacle for symbol backtranslation
  11444. as the single entry already gives an unambiguous entry point for the
  11445. symbol search path.  The description of a section is ended by an
  11446. empty line or the end of the debug file.
  11447.  
  11448. Program parts that lie out of any section are not listed separately.
  11449. This implicit ''root section'' carries the number -1 and is also used
  11450. as parent section for sections that do not have a real parent
  11451. section.
  11452.  
  11453. It is possible that the file contains empty lines or comments (semi
  11454. colon at line start).  A program reading the file has to ignore such
  11455. lines.
  11456.  
  11457. %%===========================================================================
  11458.  
  11459. \cleardoublepage
  11460. \chapter{Utility Programs}
  11461. \label{ChapTools}
  11462.  
  11463. To simplify the work with the assembler's code format a bit, I added
  11464. some tools to aid processing of code files.  These programs are
  11465. released under the same license terms as stated in section
  11466. \ref{SectLicense}!
  11467.  
  11468. Common to all programs are the possible return codes they may deliver
  11469. upon completion (see table \ref{TabToolReturns}).
  11470. \par
  11471. \begin{table*}[h]
  11472. \begin{center}\begin{tabular}{|c|l|}
  11473. \hline
  11474. return code   & error condition \\
  11475. \hline
  11476. \hline
  11477. 0             & no errors \\
  11478. 1             & error in command line parameters \\
  11479. 2             & I/O error \\
  11480. 3             & file format error \\
  11481. \hline
  11482. \end{tabular}\end{center}
  11483. \caption{Return Codes of the Utility Programs\label{TabToolReturns}}
  11484. \end{table*}
  11485. Just like \asname{}, all programs take their input from STDIN and write
  11486. messages to STDOUT (resp. error messages to STDERR).  Therefore,
  11487. input and output redirections should not be a problem.
  11488.  
  11489. In case that numeric or address specifications have to be given in
  11490. the command line, they may also be written in hexadecimal
  11491. notation,  either ba allending a \verb!h! or prepending a dollar
  11492. character or a \tty{0x} like in C.
  11493. (e.g. \verb!10h!, \verb!$10!, or \verb!0x10! instead of 16).
  11494.  
  11495. Unix shells however \marginpar{{\em UNIX}} assign a special meaning to the
  11496. dollar sign, which makes it necessary to escape a dollar sign with a
  11497. backslash.  The \tty{0x} variant is definitely more comfortable in this case.
  11498.  
  11499. Otherwise, calling conventions and variations are equivalent to those
  11500. of \asname{} (except for PLIST and AS2MSG); i.e. it is possible to store
  11501. frequently used parameters in an environment variable (whose name is
  11502. constructed by appending CMD to the program's name, i.e. \tty{BINDCMD} for
  11503. BIND), to negate options, and to use all upper- resp. lower-case
  11504. writing (for details on this, see section \ref{SectCallConvention}).
  11505.  
  11506. Address specifications always relate to the granularity of the
  11507. processor currently in question; for example, on a PIC, an address
  11508. difference of 1 means a word and not a byte.
  11509.  
  11510. %%---------------------------------------------------------------------------
  11511.  
  11512. \section{PLIST}
  11513.  
  11514. PLIST is the simplest one of the five programs supplied: its purpose
  11515. is simply to list all records that are stored in a code file.  As the
  11516. program does not do very much, calling is quite simple:
  11517. \begin{verbatim}
  11518.    PLIST <file name>
  11519. \end{verbatim}
  11520. The file name will automatically be extended with the extension \tty{P} if
  11521. it doesn't already have one.
  11522.  
  11523. \bb{CAUTION!} At this place, no wildcards are allowed!  If there is a
  11524. necessity to list several files with one command, use the following
  11525. ''mini batch'':
  11526. \begin{verbatim}
  11527.     for %n in (*.p) do plist %n
  11528. \end{verbatim}
  11529. PLIST prints the code file's contents in a table style, whereby
  11530. exactly one line will be printed per record.  The individual rows
  11531. have the following meanings:
  11532. \begin{itemize}
  11533. \item{code type: the processor family the code has been generated for.}
  11534. \item{start address: absolute memory address that expresses the load
  11535.      destination for the code.}
  11536. \item{length: length of this code chunk in bytes.}
  11537. \item{end address: last address of this code chunk.  This address
  11538.      is calculated as start address+length-1.}
  11539. \end{itemize}
  11540. All outputs are in hexadecimal notation.
  11541.  
  11542. Finally, PLIST will print a copyright remark (if there is one in the
  11543. file), together with a summaric code length.
  11544.  
  11545. Simply said, PLIST is a sort of DIR for code files.  One can use it
  11546. to examine a file's contents before one continues to process it.
  11547.  
  11548. %%---------------------------------------------------------------------------
  11549.  
  11550. \section{BIND}
  11551.  
  11552. BIND is a program that allows to concatenate the records of several
  11553. code files into a single file.  A filter function is available that
  11554. can be used to copy only records of certain types.  Used in this way,
  11555. BIND can also be used to split a code file into several files.
  11556.  
  11557. The general syntax of BIND is
  11558. \begin{verbatim}
  11559.   BIND <source file(s)> <target file> [options]
  11560. \end{verbatim}
  11561. Just like \asname{}, BIND regards all command line arguments that do not
  11562. start with a \tty{+, -} or \tty{/} as file specifications, of which the last one
  11563. must designate the destination file.  All other file specifications
  11564. name sources, which may again contain wildcards.
  11565.  
  11566. Currently, BIND defines only one command line option:
  11567. \begin{itemize}
  11568. \item{\tty{f $<$Header[,Header]$>$}: sets a list of record headers that should
  11569.      be copied.  Records with other header IDs will
  11570.      not be copied.  Without such an option, all
  11571.      records will be copied.  The headers given in
  11572.      the list correspond to the \tty{HeaderID} field of the
  11573.      record structure described in section \ref{SectCodeFormat}.
  11574.      Individual headers in this list are separated
  11575.      with commas.}
  11576. \end{itemize}
  11577. For example, to filter all MCS-51 code out of a code file, use BIND
  11578. in the following way:
  11579. \begin{verbatim}
  11580.   BIND <source name> <target name> -f $31
  11581. \end{verbatim}
  11582. If a file name misses an extension, the extension \tty{P} will be added
  11583. automatically.
  11584.  
  11585. %%---------------------------------------------------------------------------
  11586.  
  11587. \section{P2HEX}
  11588.  
  11589. P2HEX is an extension of BIND.  It has all command line options of BIND and
  11590. uses the same conventions for file names.  In contrary to BIND, the
  11591. target file is written as a Hex file, i.e. as a sequence of lines
  11592. which represent the code as ASCII hex numbers.
  11593.  
  11594. P2HEX knows nine different target formats, which can be selected via the
  11595. command line parameter \tty{F}:
  11596. \begin{itemize}
  11597. \item{Motorola S-Records (\tty{-F Moto)})}
  11598. \item{MOS Hex \tty{(-F MOS)}}
  11599. \item{Intel Hex (Intellec-8, \tty{-F Intel})}
  11600. \item{16-Bit Intel Hex (MCS-86, \tty{-F Intel16})}
  11601. \item{32-Bit Intel Hex (\tty{-F Intel32)})}
  11602. \item{Tektronix Hex (\tty{-F Tek})}
  11603. \item{Texas Instruments DSK (\tty{-F DSK})}
  11604. \item{Atmel AVR Generic (\tty{-F Atmel}, see \cite{AVRObj})}
  11605. \item{Lattice Mico8 prom\_init (\tty{-F Mico8})}
  11606. \item{C arrays, for inclusion into C(++) source files (\tty{-F C})}
  11607. \end{itemize}
  11608. If no target format is explicitly specified, P2HEX will automatically
  11609. choose one depending in the processor type:  S-Records for Motorola
  11610. CPUs, Hitachi, and TLCS-900, MOS for 65xx/MELPS, DSK for the 16 bit
  11611. signal processors from Texas, Atmel Generic for the AVRs, and Intel Hex
  11612. for the rest.  Depending on the start addresses width, the S-Record
  11613. format will use Records of type 1, 2, or 3, however, records in one
  11614. group will always be of the same type.  This automatism can be partially
  11615. suppressed via the command line option
  11616. \begin{verbatim}
  11617.  -M <1|2|3>
  11618. \end{verbatim}
  11619. A value of 2 resp. 3 assures that that S records with a minimum type of 2
  11620. resp. 3 will be used, while a value of 1 corresponds to the full
  11621. automatism.
  11622.  
  11623. Normally, the AVR format always uses an address length of 3 bytes.  Some
  11624. programs however do not like that...which is why there is a switch
  11625. \begin{verbatim}
  11626.  -avrlen <2|3>
  11627. \end{verbatim}
  11628. that allows to reduce the address length to two bytes in case of
  11629. emergency.
  11630.  
  11631. The Mico8 format is different from all the other formats in
  11632. having no address fields - it is plain list of all instruction
  11633. words in program memory.  When using it, be sure that the used
  11634. address range (as displeyed e.g. by PLIS) starts at zero and is
  11635. continuous.
  11636.  
  11637. The Intel, MOS and Tektronix formats are limited to 16 bit addresses, the
  11638. 16-bit Intel format reaches 4 bits further.  Addresses that are to long
  11639. for a given format will be reported by P2HEX with a warning; afterwards,
  11640. they will be truncated (!).
  11641.  
  11642. For the PIC microcontrollers, the switch
  11643. \begin{verbatim}
  11644. -m <0..3>
  11645. \end{verbatim}
  11646. allows to generate the three different variants of the Intel Hex
  11647. format.  Format 0 is INHX8M which contains all bytes in a
  11648. Lo-Hi-Order.  Addresses become double as large because the PICs have
  11649. a word-oriented address space that increments addresses only by one
  11650. per word.  This format is also the default.  With Format 1 (INHX16M),
  11651. bytes are stored in their natural order.  This is the format
  11652. Microchip uses for its own programming devices.  Format 2 (INHX8L)
  11653. resp. 3 (INHX8H) split words into their lower resp. upper bytes.
  11654. With these formats, P2HEX has to be called twice to get the complete
  11655. information, like in the following example:
  11656. \begin{verbatim}
  11657.  p2hex test -m 2
  11658.  rename test.hex test.obl
  11659.  p2hex test -m 3
  11660.  rename test.hex test.obh
  11661. \end{verbatim}
  11662. For the Motorola format, P2HEX additionally uses the S5 record type
  11663. mentioned in \cite{CPM68K}.  This record contains the number of data
  11664. records (S1/S2/S3) to follow.  As some programs might not know how to
  11665. deal with this record, one can suppress it with the option
  11666. \begin{verbatim}
  11667. +5  .
  11668. \end{verbatim}
  11669. The C format is different in the sense that it always has to be
  11670. selected explicitly.  The output file is basically a complete piece of
  11671. C or C++ code that contains the data as a list of C arrays.  Additionally to
  11672. the data itself, a list of descriptors is written that describes the
  11673. start, length, and end address of each data block.  The contents of these
  11674. descriptors may be configured via the option
  11675. \begin{verbatim}
  11676. -cformat <format>
  11677. \end{verbatim}
  11678. Each letter in \verb!format! defines an element of the descriptor:
  11679. \begin{itemize}
  11680. \item{A \verb!d! or \verb!D! defines a pointer to the data itself.
  11681.      Usage of a lower or upper case letter defines whether lowercase
  11682.      or uppercase letters are used for hexadecimal constants.}
  11683. \item{An \verb!s! or \verb!S! defines the start address of the data,
  11684.      either as {\em unsigned} or {\em unsigned long}.}
  11685. \item{An \verb!l! or \verb!L! defines the length of the data,
  11686.      either as {\em unsigned} or {\em unsigned long}.}
  11687. \item{An \verb!e! or \verb!E! defines the end address of the data,
  11688.      specifically the last address used by the data, either as
  11689.      {\em unsigned} or {\em unsigned long}.}
  11690. \end{itemize}
  11691. \par
  11692. In case a source file contains code record for different processors,
  11693. the different hex formats will also show up in the target file - it
  11694. is therefore strongly advisable to use the filter function.
  11695.  
  11696. Apart form this filter function, P2HEX also supports an address
  11697. filter, which is useful to split the code into several parts (e.g.
  11698. for a set of EPROMs):
  11699. \begin{verbatim}
  11700. -r <start address>-<end address>
  11701. \end{verbatim}
  11702. The start address is the first address in the window, and the end
  11703. address is the last address in the window, \bb{not} the first address
  11704. that is out of the window.  For example, to split an 8051 program
  11705. into 4 2764 EPROMs, use the following commands:
  11706. \begin{verbatim}
  11707. p2hex <source file> eprom1 -f $31 -r $0000-$1fff
  11708. p2hex <source file> eprom2 -f $31 -r $2000-$3fff
  11709. p2hex <source file> eprom3 -f $31 -r $4000-$5fff
  11710. p2hex <source file> eprom4 -f $31 -r $6000-$7fff
  11711. \end{verbatim}
  11712. It is allowed to specifiy a single dollar character or '0x' as start
  11713. or stop address.  This means that the lowest resp. highest address found
  11714. in the source file shall be taken as start resp. stop address.  The
  11715. default range is '0x-0x', i.e. all data from the source file is
  11716. transferred.
  11717.  
  11718. \bb{CAUTION!} This type of splitting does not change the absolute
  11719. addresses that will be written into the files!  If the addresses in
  11720. the individual hex files should rather start at 0, one can force this
  11721. with the additional switch
  11722. \begin{verbatim}
  11723. -a     .
  11724. \end{verbatim}
  11725. On the other hand, to move the addresses to a different location, one may
  11726. use the switch
  11727. \begin{verbatim}
  11728. -R <value> .
  11729. \end{verbatim}
  11730. The value given is an {\em offset}, i.e. it is added to the addresses
  11731. given in the code file.
  11732. \par
  11733. By using an offset, it is possible to move a file's contents to an
  11734. arbitrary position.  This offset is simply appended to a file's name,
  11735. surrounded with parentheses.  For example, if the code in a file
  11736. starts at address 0 and you want to move it to address 1000 hex in the
  11737. hex file, append \tty{(\$1000)} to the file's name (without spaces!).
  11738. \par
  11739. In case the source file(s) not only contain data for the code segment,
  11740. the switch
  11741. \begin{verbatim}
  11742. -segment <name>
  11743. \end{verbatim}
  11744. allows to select the segment data is extracted from and converted to
  11745. HEX format.  The segment names are the same as for the \tty{SEGMENT}
  11746. pseudo instruction (\ref{SEGMENT}).  The TI DSK is a special case
  11747. since it has the ability to distinguish between data and code in one
  11748. file.  If TI DSK is the output format, P2HEX will automatically
  11749. extract data from both segments if no segment was specified explicitly.
  11750. \par
  11751. Similar to the \verb!-r! option, the argument
  11752. \begin{verbatim}
  11753. -d <start>-<end>
  11754. \end{verbatim}
  11755. allows to designate the address range that should be written as data
  11756. instead of code.
  11757. \par
  11758. The option
  11759. \begin{verbatim}
  11760. -e <address>
  11761. \end{verbatim}
  11762. is valid for the DSK, Intel, and Motorola formats.  Its purpose is to
  11763. set the entry address that will be inserted into the hex file.  If
  11764. such a command line parameter is missing, P2HEX will search a
  11765. corresponding entry in the code file.  If even this fails, no entry
  11766. address will be written to the hex file (DSK/Intel) or the field
  11767. reserved for the entry address will be set to 0 (Motorola).
  11768. Unfortunately, one finds different statements about the last line of
  11769. an Intel-Hex file in literature.  Therefore, P2HEX knows three
  11770. different variants that may be selected via the command-line
  11771. parameter \tty{i} and an additional number:
  11772. \begin{verbatim}
  11773. 0  :00000001FF
  11774. 1  :00000001
  11775. 2  :0000000000
  11776. \end{verbatim}
  11777. By default, variant 0 is used which seems to be the most common one.
  11778. If the target file name does not have an extension, an extension of
  11779. \tty{HEX} is supposed.
  11780. By default, P2HEX will print a maximum of 16 data bytes per line,
  11781. just as most other tools that output Hex files.  If you want to
  11782. change this, you may use the switch
  11783. \begin{verbatim}
  11784. -l <count>   .
  11785. \end{verbatim}
  11786. The allowed range of values goes from 2 to 254 data bytes; odd values
  11787. will implicitly be rounded down to an even count.
  11788. In most cases, the temporary code files generated by \asname{} are not of
  11789. any further need after P2HEX has been run.  The command line option
  11790. \begin{verbatim}
  11791. -k
  11792. \end{verbatim}
  11793. allows to instruct P2HEX to erase them automatically after
  11794. conversion.
  11795. In contrast to BIND, P2HEX will not produce an empty target file if
  11796. only one file name (i.e. the target name) has been given.  Instead,
  11797. P2HEX will use the corresponding code file.  Therefore, a minimal
  11798. call in the style of
  11799. \begin{verbatim}
  11800. P2HEX <name>
  11801. \end{verbatim}
  11802. is possible, to generate \tty{$<$name$>$.hex} out of \tty{$<$name$>$.p}.
  11803.  
  11804. %%---------------------------------------------------------------------------
  11805.  
  11806. \section{P2BIN}
  11807.  
  11808. P2BIN works similar to P2HEX and offers the same options (except for
  11809. the a and i options that do not make sense for binary files),
  11810. however, the result is stored as a simple binary file instead of a
  11811. hex file.  Such a file is for example suitable for programming an
  11812. EPROM.
  11813.  
  11814. P2BIN knows three additional options to influence the resulting binary
  11815. file:
  11816. \begin{itemize}
  11817. \item{\tty{l $<$8 bit number$>$}: sets the value that should be used to fill
  11818.      unused memory areas.  By default, the value
  11819.      \$ff is used.  This value assures that every
  11820.      half-way intelligent EPROM burner will skip
  11821.      these areas.  This option allows to set different values,
  11822.      for example if you want to
  11823.      generate an image for the EPROM versions of
  11824.      MCS-48 microcontrollers (empty cells of their
  11825.      EPROM array contain zeroes, so \$00 would be
  11826.      the correct value in this case).}
  11827. \item{\tty{s}:  commands the program to calculate a checksum
  11828.      of the binary file.  This sum is printed as
  11829.      a 32-bit value, and the two's complement of
  11830.      the least significant bit will be stored in
  11831.      the file's last byte.  This way, the modulus-
  11832.      256-sum of the file will become zero.}
  11833. \item{\tty{m}:  is designed for the case that a CPU with a
  11834.      16- or 32-bit data bus is used and the file
  11835.      has to be split for several EPROMs.  The
  11836.      argument may have the following values:
  11837.      \begin{itemize}
  11838.      \item{\tty{ALL}: copy everything}
  11839.      \item{\tty{ODD}: copy all bytes with an odd address}
  11840.      \item{\tty{EVEN}: copy all bytes with an even address}
  11841.      \item{\tty{BYTE0..BYTE3}: copy only bytes with an address of
  11842.            4n+0 .. 4n+3}
  11843.      \item{\tty{WORD0, WORD1}: copy only the lower resp. upper 16-
  11844.            bit word of a 32-bit word}
  11845.      \end{itemize}}
  11846. \end{itemize}
  11847. To avoid confusions: If you use this option, the resulting binary file
  11848. will become smaller because only a part of the source will be copied.
  11849. Therefore, the resulting file will be smaller by a factor of 2 or 4
  11850. compared to \tty{ALL}.  This is just natural...
  11851.  
  11852. In case the code file does not contain an entry address, one may set
  11853. it via the \tty{-e} command line option just like with P2HEX.  Upon
  11854. request, P2BIN prepends the resulting image with this address.  The
  11855. command line option
  11856. \begin{verbatim}
  11857. -S
  11858. \end{verbatim}
  11859. activates this function.  It expects a numeric specification ranging
  11860. from 1 to 4 as parameter which specifies the length of the address
  11861. field in bytes.  This number may optionally be prepended wit a \tty{L} or
  11862. \tty{B} letter to set the endian order of the address.  For example, the
  11863. specification \tty{B4} generates a 4 byte address in big endian order,
  11864. while a specification of \tty{L2} or simply \tty{2} creates a 2 byte address
  11865. in little endian order.
  11866.  
  11867. %%---------------------------------------------------------------------------
  11868.  
  11869. \section{AS2MSG}
  11870.  
  11871. AS2MSG is not a tool in the real sense, it is a filter that was
  11872. designed to simplify the work with the assembler for (fortunate)
  11873. users of Borland Pascal 7.0.  The DOS IDEs feature a 'tools' menu
  11874. that can be extended with own programs like \asname{}.  The filter allows to
  11875. directly display the error messages paired with a line
  11876. specification delivered by \asname{} in the editor window.  A new entry has
  11877. to be added to the tools menu to achieve this (Options/Tools/New).
  11878. Enter the following values:
  11879. \begin{verbatim}
  11880. - Title: ~m~acro assembler
  11881. - Program path: AS
  11882. - Command line:
  11883.      -E !1 $EDNAME $CAP MSG(AS2MSG) $NOSWAP $SAVE ALL
  11884. - assign a hotkey if wanted (e.g. Shift-F7)
  11885. \end{verbatim}
  11886. The -E option assures that Turbo Pascal will not become puzzled by
  11887. STDIN and STDERR.
  11888.  
  11889. I assume that \asname{} and AS2MSG are located in a directory listed in the
  11890. \tty{PATH} variable.  After pressing the appropriate hotkey (or selecting
  11891. \asname{} from the tools menu), as will be called with the name of the file
  11892. loaded in the active editor window as parameter.  The error messages
  11893. generated during assembly are redirected to a special window that
  11894. allows to browse through the errors.  \tty{Ctrl-Enter} jumps to an
  11895. erroneous line.  The window additionally contains the statistics \asname{}
  11896. prints at the end of an assembly.  These lines obtain the dummy line
  11897. number 1.
  11898.  
  11899. \tty{TURBO.EXE} (Real Mode) and \tty{BP.EXE} (Protected Mode) may be used for
  11900. this way of working with \asname{}.  I recommend however BP, as this version
  11901. does not have to 'swap' half of the DOS memory before before \asname{} is
  11902. called.
  11903.  
  11904. %%===========================================================================
  11905. \appendix
  11906.  
  11907. \cleardoublepage
  11908. \chapter{Error Messages of \asname{}}
  11909. \label{ChapErrMess}
  11910.  
  11911. Here is a list of all error messages emitted by \asname{}. Each error message is
  11912. described by:
  11913. \begin{itemize}
  11914. \item{the internal error number (it is displayed only if \asname{} is started with the
  11915.      \tty{-n} option)}
  11916. \item{the text of the error message}
  11917. \item{error type:
  11918.      \begin{itemize}
  11919.      \item{Warning: informs the user that a possible error was
  11920.            found, or that some inefficient binary code
  11921.            could be generated. The assembly process is not
  11922.            stopped.}
  11923.      \item{Error: an error was detected. The assembly process
  11924.            continues, but no binary code is emitted.}
  11925.      \item{Fatal: unrecoverable error. The assembly process is
  11926.            terminated.}
  11927.      \end{itemize}}
  11928. \item{reason of the error: the situation originating the error.}
  11929. \item{argument:  a further explanation of the error message.}
  11930. \end{itemize}
  11931.  
  11932. \par
  11933.  
  11934. \newcommand{\errentry}[5]
  11935.           {\item[#1]{#2
  11936.                      \begin{description}
  11937.                      \item[Type:]{\ \\#3}
  11938.                      \item[Reason:]{\ \\#4}
  11939.                      \item[Argument:]{\ \\#5}
  11940.                      \end{description}}
  11941.           }
  11942.  
  11943. \begin{description}
  11944. \errentry{   5}{useless displacement}
  11945.               {warning}
  11946.               {680x0, 6809 and COP8 CPUs: an address displacement of 0 was
  11947.                given.  An address expression without displacement is
  11948.                generated, and a convenient number of NOPs are emitted
  11949.                to avoid phasing errors.}
  11950.               {none}
  11951. \errentry{  10}{short addressing possible}
  11952.               {warning}
  11953.               {680x0-, 6502 and 68xx CPUs: a given memory location can be
  11954.                reached using short addressing. A short addressing
  11955.                instruction is emitted, together with the required
  11956.                number of NOPs to avoid phasing errors.}
  11957.               {none}
  11958. \errentry{  20}{short jump possible}
  11959.               {warning}
  11960.               {680x0- and 8086 CPUs can execute jumps using a short or long
  11961.                displacement. If a shorter jump was not explicitly
  11962.                requested, in the
  11963.                first pass room for the long jump is reserved. Then the code
  11964.                for the shorter jump is emitted, and the remaining space is
  11965.                filled with NOPs to avoid phasing errors.}
  11966.               {none}
  11967. \errentry{  30}{no sharefile created, SHARED ignored}
  11968.               {warning}
  11969.               {A \tty{SHARED} directive was found, but on the command line no
  11970.                options were specified, to generate a shared file.}
  11971.               {none}
  11972. \errentry{  40}{FPU possibly cannot read this value ($>$=1E1000)}
  11973.               {warning}
  11974.               {The BCD-floating point format used by the 680x0-FPU
  11975.                allows such a large exponent, but according to the latest
  11976.                databooks, this cannot be fully interpreted. The
  11977.                corresponding word is assembled, but the associated
  11978.                function is not expected to produce the correct result.}
  11979.               {none}
  11980. \errentry{  50}{privileged instruction}
  11981.               {warning}
  11982.               {A Supervisor-mode directive was used, that was not preceded
  11983.                by an explicit \tty{SUPMODE ON} directive}
  11984.               {none}
  11985. \errentry{  60}{distance of 0 not allowed for short jump (NOP created instead)}
  11986.               {warning}
  11987.               {A short jump with a jump distance equal to 0 is not allowed
  11988.                by 680x0 resp. COP8 processors, since the associated code word is
  11989.                used to identify long jump instruction. Instead of a
  11990.                jump instruction, \asname{} emits a NOP}
  11991.               {none}
  11992. \errentry{  70}{symbol out of wrong segment}
  11993.               {warning}
  11994.               {The symbol used as an operand comes from an address space
  11995.                that cannot be addressed together with the given instruction}
  11996.               {none}
  11997. \errentry{  75}{segment not accessible}
  11998.               {warning}
  11999.               {The symbol used as an operand belongs to an address space
  12000.                that cannot be accessed with any of the segment registers of
  12001.                the 8086}
  12002.               {The name of the inaccessible segment}
  12003. \errentry{  80}{change of symbol values forces additional pass}
  12004.               {warning}
  12005.               {A symbol changed value, with respect to previous pass. This
  12006.                warning is emitted only if the \tty{-r} option is used.}
  12007.               {name of the symbol that changed value.}
  12008. \errentry{  90}{overlapping memory usage}
  12009.               {warning}
  12010.               {The analysis of the usage list shows that part of the
  12011.                program memory was used more than once. The reason can be an
  12012.                excessive usage of \tty{ORG} directives.}
  12013.               {none}
  12014. \errentry{  95}{overlapping register usage}
  12015.               {warning}
  12016.               {The instruction uses whole registers or parts thereof in
  12017.                a non-allowed way.}
  12018.               {The offending argument}
  12019. \errentry{ 100}{none of the CASE conditions was true}
  12020.               {warning}
  12021.               {A \tty{SWITCH...CASE} directive without \tty{ELSECASE} clause was
  12022.                executed, and none of the \tty{CASE} conditions was found
  12023.                to be true.}
  12024.               {none}
  12025. \errentry{ 110}{page might not be addressable}
  12026.               {warning}
  12027.               {The symbol used as an operand was not found in the memory
  12028.                page defined by an \tty{ASSUME} directive (ST6, 78(C)10).}
  12029.               {none}
  12030. \errentry{ 120}{register number must be even}
  12031.               {warning}
  12032.               {The CPU allows to concatenate only register pairs, whose
  12033.                start address is even (RR0, RR2, ..., only for Z8).}
  12034.               {none}
  12035. \errentry{ 130}{obsolete instruction, usage discouraged}
  12036.               {warning}
  12037.               {The instruction used, although supported, was superseded by
  12038.                a new instruction. Future versions of the CPU could no more
  12039.                implement the old instruction.}
  12040.               {none}
  12041. \errentry{ 140}{unpredictable execution of this instruction}
  12042.               {warning}
  12043.               {The addressing mode used for this instruction is allowed,
  12044.                however a register is used in such a way that its contents
  12045.                cannot be predicted after the execution of the
  12046.                instruction.}
  12047.               {none}
  12048. \errentry{ 150}{localization operator senseless out of a section}
  12049.               {warning}
  12050.               {An aheaded \@ must be used, so that it is
  12051.                explicitly referred to the local symbols used in the
  12052.                section. When the operator is used out of a section, there
  12053.                are no local symbols, because this operator is useless in
  12054.                this context.}
  12055.               {none}
  12056. \errentry{ 160}{senseless instruction}
  12057.               {warning}
  12058.               {The instruction used has no meaning, or it can be
  12059.                substituted by an other instruction, shorter and more
  12060.                rapidly executed.}
  12061.               {none}
  12062. \errentry{ 170}{unknown symbol value forces additional pass}
  12063.               {warning}
  12064.               {\asname{} expects a forward definition of a symbol, i.e. a symbol
  12065.                was used before it was defined. A further pass must be
  12066.                executed. This warning is emitted only if the \tty{-r} option was
  12067.                used.}
  12068.               {none}
  12069. \errentry{ 180}{address is not properly aligned}
  12070.               {warning}
  12071.               {An address was used that is not an exact multiple of the
  12072.                operand size. Although the CPU databook forbids this, the
  12073.                address could be stored in the instruction word, so \asname{}
  12074.                simply emits a warning.}
  12075.               {none.}
  12076. \errentry{ 190}{I/O-address must not be used here}
  12077.               {warning}
  12078.               {The addressing mode or the address used are correct, but the
  12079.                address refers to the peripheral registers, and it
  12080.                cannot be used in this circumstance.}
  12081.               {none.}
  12082. \errentry{ 200}{possible pipelining effects}
  12083.               {warning}
  12084.               {A register is used in a series of instructions, so that a
  12085.                sequence of instructions probably does not generate the
  12086.                desired result. This usually happens when a register is
  12087.                used before its new content was effectively loaded in it.}
  12088.               {the register probably causing the problem.}
  12089. \errentry{ 210}{multiple use of address register in one instruction}
  12090.               {warning}
  12091.               {A register used for the addressing is used once more in the
  12092.                same instruction, in a way that results in a modification
  12093.                of the register value. The resulting address does not have a
  12094.                well defined value.}
  12095.               {the register used more than once.}
  12096. \errentry{ 220}{memory location is not bit addressable}
  12097.               {warning}
  12098.               {Via a \tty{SFRB} statement, it was tried to declare a memory cell
  12099.                as bit addressable which is not bit addressable due to the
  12100.                8051's architectural limits.}
  12101.               {none}
  12102. \errentry{ 230}{stack is not empty}
  12103.               {warning}
  12104.               {At the end of a pass, a stack defined by the program is
  12105.                not empty.}
  12106.               {the name of the stack and its remaining depth}
  12107. \errentry{ 240}{NUL character in string, result is undefined}
  12108.               {warning}
  12109.               {A string constant contains a NUL character. Though this
  12110.                works with the Pascal version, it is a problem for the
  12111.                C version of \asname{} since C itself terminates strings with
  12112.                a NUL character. i.e. the string would have its end for
  12113.                C just at this point...}
  12114.               {none}
  12115. \errentry{ 250}{instruction crosses page boundary}
  12116.               {warning}
  12117.               {The parts of a machine statement partiallly lie on
  12118.                different pages.  As the CPU's instruction counter does
  12119.                not get incremented across page boundaries, the processor
  12120.                would fetch at runtime the first byte of the old page
  12121.                instead of the instruction's following byte; the program
  12122.                would execute incorrectly.}
  12123.               {none}
  12124. \errentry{ 255}{range underflow}
  12125.               {warning}
  12126.               {A numeric value was below the allowed range.  \asname{} brought
  12127.                the value back into the allowed range by truncating upper
  12128.                bits, but it is not guaranteed that meaningful and correct
  12129.                code is generated by this.}
  12130.               {none}
  12131. \errentry{ 260}{range overflow}
  12132.               {warning}
  12133.               {A numeric value was above the allowed range.  \asname{} brought
  12134.                the value back into the allowed range by truncating upper
  12135.                bits, but it is not guaranteed that meaningful and correct
  12136.                code is generated by this.}
  12137.               {none}
  12138. \errentry{ 270}{negative argument for DUP}
  12139.               {warning}
  12140.               {The repetition argument of a DUP directive was smaller
  12141.                than 0.  Analogous to a count of exactly 0, no data is
  12142.                stored.}
  12143.               {none}
  12144. \errentry{ 280}{single X operand interpreted as indexed and not implicit
  12145.                addressing}
  12146.               {warning}
  12147.               {A single X operand may be interpreted either as register X
  12148.                or x-indexed addressing with zero displacement, since
  12149.                Motorola does not specify this variant.  \asname{} chooses the
  12150.                latter, which may not be the desired one.}
  12151.               {none}
  12152. \errentry{ 300}{bit number will be truncated}
  12153.               {warning}
  12154.               {This instruction only operates on byte resp. longword
  12155.                operands.  bit numbers beyond 7 resp. 31 will be treated
  12156.                modulo-8 resp. modulo-32 by the CPU.}
  12157.               {none}
  12158. \errentry{ 310}{invalid register pointer value}
  12159.               {warning}
  12160.               {Valid values for the RP register range from 0x00 to 0x70 resp.
  12161.                0xf0, because all other areas are unused on the Z8.}
  12162.               {none}
  12163. \errentry{ 320}{macro argument redefined}
  12164.               {warning}
  12165.               {A macro parameter was assigned two or more
  12166.                different values.  This may happen by usage of
  12167.                keyword arguments.  The last argument is actually
  12168.                used.}
  12169.               {name of the macro parameter}
  12170. \errentry{ 330}{deprecated instruction}
  12171.               {warning}
  12172.               {This instruction is deprecated and should not be used any
  12173.                more in new programs.}
  12174.               {the instruction that should be used instead.}
  12175. \errentry{ 340}{source operand is longer or same size as destination operand}
  12176.               {warning}
  12177.               {The source operand's size is larger than the destination operand's
  12178.                size, expressed in bits.  Sign or zero extension does not make sense
  12179.                with these arguments.  See the CPU's reference manual for its behaviour
  12180.                in this situation.}
  12181.               {none}
  12182. \errentry{ 350}{TRAP number represents valid instruction}
  12183.               {warning}
  12184.               {A TRAP with this number uses the same machine code as a
  12185.                machine instruction supported by the CPU.}
  12186.               {none}
  12187. \errentry{ 360}{Padding added}
  12188.               {warning}
  12189.               {The amount of bytes placed in memory is odd; one half of the last
  12190.                16 bit word remains unused.}
  12191.               {none}
  12192. \errentry{ 370}{register number wraparound}
  12193.               {warning}
  12194.               {The start register number plus the count of registers results
  12195.                in a last register beyond the end of the register bank.}
  12196.               {the argument holding the register count}
  12197. \errentry{ 380}{using indexed instead of indirect addressing}
  12198.               {warning}
  12199.               {Indirect addressing is not allowed at this place.
  12200.                Instead, indexed addressing with a dummy displacement of
  12201.                zero will be used.}
  12202.               {the argument holding the indirect addressing expression}
  12203. \errentry{ 390}{not allowed in normal mode}
  12204.               {warning}
  12205.               {This machine instruction is only allowed in panel mode,
  12206.                not during ''normal operation''.}
  12207.               {the machine instruction in question}
  12208. \errentry{ 400}{not allowed in panel mode}
  12209.               {warning}
  12210.               {This machine instruction is only allowed during ''normal
  12211.                operation'', not in panel mode.}
  12212.               {the machine instruction in question}
  12213. \errentry{ 410}{argument out of range}
  12214.               {warning}
  12215.               {The argument or the sum of two arguments is outside the
  12216.                range allowed for this instruction, though the instruction
  12217.                principally provides room for larger values.}
  12218.               {the argument in question}
  12219. \errentry{ 420}{attempt to skip multiword instruction}
  12220.               {warning}
  12221.               {The previous instruction was a skip instruction, which
  12222.                can only skip a single (half) word.  The current instruction
  12223.                is longer than one word, so a skip would jump into the middle
  12224.                of it.}
  12225.               {the multi-word instruction in question}
  12226. \errentry{ 430}{implicit sign extension}
  12227.               {warning}
  12228.               {As part of executing this instruction, the processor will
  12229.                perform a sign extension to the full register width.  For the
  12230.                given argument, this means the register's upper bits will be
  12231.                filled with ones and not zeros.  Depending on the usage that
  12232.                follows, this may be irrelevant or not.}
  12233.               {the value in question}
  12234. \errentry{ 440}{numeric value -128 means usage of E register's content (use literal 'E' to avoid this warning)}
  12235.               {warning}
  12236.               {On the SC/MP, a displacement of -128 means in this case that
  12237.                the actual displacement is not -128, but instead taken from
  12238.                the E register.  The assembler cannot decide for sure whether
  12239.                this was intended or the accidental result of a computation,
  12240.                and therefore warns.  Use the literal value 'E' or a register
  12241.                symbol defined to be 'E' to clarify your intent and avoid
  12242.                this warning.}
  12243.               {the displacement argument in question}
  12244. \errentry{ 450}{I/O address must be accessed via INS/OUTS}
  12245.               {warning}
  12246.               {I/O addresses in the range of 0 to 3 are located in the
  12247.                processor module and can only be accessed via the {\tt INS}
  12248.                and {\tt OUTS} instructios, not via {\tt IN} or {\tt OUT}.}
  12249.               {the address argument in question}
  12250. \errentry{1000}{symbol double defined}
  12251.               {error}
  12252.               {A new value is assigned to a symbol, using a label or a
  12253.                \tty{EQU, PORT, SFR, LABEL, SFRB} or \tty{BIT} instruction: however this
  12254.                can be done only using \tty{SET/EVAL}.}
  12255.               {the name of the offending symbol, and the line number where
  12256.                it was defined for the first time, according to the symbol
  12257.                table.}
  12258. \errentry{1010}{symbol undefined}
  12259.               {error}
  12260.               {A symbol is still not defined in the symbol table, also
  12261.                after a second pass.}
  12262.               {the name of the undefined symbol.}
  12263. \errentry{1020}{invalid symbol name}
  12264.               {error}
  12265.               {A symbol does not fulfill the requirements that symbols
  12266.                must have to be considered valid by \asname{}. Please pay
  12267.                attention that more stringent syntax rules exist for
  12268.                macros and function parameters.}
  12269.               {the wrong symbol}
  12270. \errentry{1090}{invalid format}
  12271.               {error}
  12272.               {The instruction format used does not exist for this
  12273.                instruction.}
  12274.               {the known formats for this command}
  12275. \errentry{1100}{useless attribute}
  12276.               {error}
  12277.               {The instruction (processor or pseudo) cannot be used with a
  12278.                point-suffixed attribute.}
  12279.               {none}
  12280. \errentry{1105}{attribute may only be one character long}
  12281.               {error}
  12282.               {The attribute following a point after an instruction must
  12283.                not be longer or shorter than one character.}
  12284.               {none}
  12285. \errentry{1107}{undefined attribute}
  12286.               {error}
  12287.               {This instruction uses an invalid attribute.}
  12288.               {none}
  12289. \errentry{1110}{wrong number of operands}
  12290.               {error}
  12291.               {The number of arguments issued for the instruction (processor or
  12292.                pseudo) does not conform with the accepted number of
  12293.                operands.}
  12294.               {the expected number of arguments resp. operands}
  12295. \errentry{1112}{failed splitting argument into parts}
  12296.               {error}
  12297.               {For some targets (e.g. DSP56000), the
  12298.                comma-separated have to be split into individual
  12299.                operands, which failed.}
  12300.               {none}
  12301. \errentry{1115}{wrong number of operations}
  12302.               {error}
  12303.               {The number of options given with this command is not
  12304.                correct.}
  12305.               {none}
  12306. \errentry{1120}{addressing mode must be immediate}
  12307.               {error}
  12308.               {The instruction can be used only with immediate operands
  12309.                (preceded by \tty{\#}).}
  12310.               {none}
  12311. \errentry{1130}{invalid operand size}
  12312.               {error}
  12313.               {Although the operand is of the right type, it does not have
  12314.                the correct length (in bits).}
  12315.               {none}
  12316. \errentry{1131}{conflicting operand sizes}
  12317.               {error}
  12318.               {The operands used have different length (in bits)}
  12319.               {none}
  12320. \errentry{1132}{undefined operand size}
  12321.               {error}
  12322.               {It is not possible to estimate, from the opcode and from
  12323.                the operands, the size of the operand (a trouble with
  12324.                8086 assembly). You must define it with a \tty{BYTE or WORD}
  12325.                \tty{PTR} prefix.}
  12326.               {none}
  12327. \errentry{1133}{expected integer or string, but got floating point number}
  12328.               {error}
  12329.               {A floating point number cannot be used as argument at this place.}
  12330.               {the argument in question}
  12331. \errentry{1134}{expected integer, but got floating point number}
  12332.               {error}
  12333.               {A floating point number cannot be used as argument at this place.}
  12334.               {the argument in question}
  12335. \errentry{1136}{expected floating point number, but got string}
  12336.               {error}
  12337.               {A string cannot be used as argument at this place.}
  12338.               {the argument in question}
  12339. \errentry{1137}{operand type mismatch}
  12340.               {Error}
  12341.               {The two arguments of an operator are not of same
  12342.                data type (integer/\-float/\-string).}
  12343.               {keines}
  12344. \errentry{1138}{expected string, but got integer}
  12345.               {error}
  12346.               {An integer cannot be used as argument at this place.}
  12347.               {the argument in question}
  12348. \errentry{1139}{expected string, but got floating point number}
  12349.               {error}
  12350.               {An floating point number cannot be used as argument at this place.}
  12351.               {the argument in question}
  12352. \errentry{1140}{too many arguments}
  12353.               {error}
  12354.               {No more than 20 arguments can be given to any instruction}
  12355.               {none}
  12356. \errentry{1141}{expected integer, but got string}
  12357.               {error}
  12358.               {A string cannot be used as argument at this place.}
  12359.               {the argument in question}
  12360. \errentry{1142}{expected integer or floating point number, but got string}
  12361.               {error}
  12362.               {A string cannot be used as argument at this place.}
  12363.               {the argument in question}
  12364. \errentry{1143}{expected string}
  12365.               {error}
  12366.               {Only a string (enclosed in single quotes) may be used as
  12367.                argument at this place.}
  12368.               {the argument in question}
  12369. \errentry{1144}{expected integer}
  12370.               {error}
  12371.               {Only an integer number may be used as argument at this place.}
  12372.               {the argument in question}
  12373. \errentry{1145}{expected integer, floating point number or string but got register}
  12374.               {error}
  12375.               {A register symbol may not be used as argument at this place.}
  12376.               {the argument in question}
  12377. \errentry{1146}{expected integer or string}
  12378.               {error}
  12379.               {A floating point number or register symbol may not be used as argument at this place.}
  12380.               {the argument in question}
  12381. \errentry{1147}{expected register}
  12382.               {error}
  12383.               {Only an register may be used as argument at this place.}
  12384.               {the argument in question}
  12385. \errentry{1148}{register symbol for different target}
  12386.               {error}
  12387.               {The used register symbol was defined for a target different from
  12388.                the current one and is not compatible.}
  12389.               {the argument in question}
  12390. \errentry{1149}{expected floating point argument but got integer}
  12391.               {error}
  12392.               {Only a floating point argument may be used at this place,
  12393.                but an integer argument was given.}
  12394.               {the argument in question}
  12395. \errentry{1151}{expected integer or floating point number but got register}
  12396.               {error}
  12397.               {Only an integer or floating point number argument may be used at this place,
  12398.                but a register was given.}
  12399.               {the argument in question}
  12400. \errentry{1152}{expected integer or string but got register}
  12401.               {error}
  12402.               {Only an integer or string argument may be used at this place,
  12403.                but a register was given.}
  12404.               {the argument in question}
  12405. \errentry{1153}{expected integer but got register}
  12406.               {error}
  12407.               {Only an integer argument may be used at this place,
  12408.                but a register was given.}
  12409.               {the argument in question}
  12410. \errentry{1200}{unknown instruction}
  12411.               {error}
  12412.               {An instruction was used that is neither an \asname{} instruction, nor a
  12413.                known macine instruction for the current processor type.}
  12414.               {none}
  12415. \errentry{1300}{number of opening/closing brackets does not match}
  12416.               {error}
  12417.               {The expression parser found an expression enclosed by
  12418.                parentheses, where the number of opening and closing
  12419.                parentheses does not match.}
  12420.               {the wrong expression}
  12421. \errentry{1310}{division by 0}
  12422.               {error}
  12423.               {An expression on the right side of a division or modulus
  12424.                operation was found to be equal to 0.}
  12425.               {none}
  12426. \errentry{1315}{range underflow}
  12427.               {error}
  12428.               {An integer word underflowed the allowed range.}
  12429.               {the value of the word and the allowed minimum (in most
  12430.                cases, maybe I will complete this one day...)}
  12431. \errentry{1320}{range overflow}
  12432.               {error}
  12433.               {An integer word overflowed the allowed range.}
  12434.               {the value of the world, and the allowed maximum (in most
  12435.                cases, maybe I will complete this one day...)}
  12436. \errentry{1322}{not a power of two}
  12437.               {error}
  12438.               {only powers of two (1,2,4,8,...) are allowed at this place.}
  12439.               {The value in question}
  12440. \errentry{1325}{address is not properly aligned}
  12441.               {error}
  12442.               {The given address does not correspond with the size needed
  12443.                by the data transfer, i.e. it is not an integral multiple of
  12444.                the operand size. Not all processor types can use unaligned
  12445.                data.}
  12446.               {none}
  12447. \errentry{1330}{distance too big}
  12448.               {error}
  12449.               {The displacement used for an address is too large.}
  12450.               {none}
  12451. \errentry{1331}{target not on same page}
  12452.               {error}
  12453.               {Instruction and operand address must be located in the
  12454.                same memory page.}
  12455.               {the address argument in question}
  12456. \errentry{1340}{short addressing not allowed}
  12457.               {error}
  12458.               {The address of the operand is outside of the address space
  12459.                that can be accessed using short-addressing mode.}
  12460.               {none}
  12461. \errentry{1350}{addressing mode not allowed here}
  12462.               {error}
  12463.               {the addressing mode used, although usually possible,
  12464.                cannot be used here.}
  12465.               {none}
  12466. \errentry{1351}{address must be even}
  12467.               {error}
  12468.               {At this point, only even addresses are allowed, since the
  12469.                low order bits are used for other purposes or are reserved.}
  12470.               {the argument in question}
  12471. \errentry{1352}{address must be aligned}
  12472.               {error}
  12473.               {At this point, only aligned (i.e. a mulitple of 2,4,8...) addresses
  12474.                are allowed, since the low order bits are used for other purposes
  12475.                or are reserved.}
  12476.               {the argument in question}
  12477. \errentry{1355}{addressing mode not allowed in parallel operation}
  12478.               {error}
  12479.               {The addressing mode(s) used are allowed in sequential,
  12480.                but not in parallel instructions}
  12481.               {none}
  12482. \errentry{1360}{undefined condition}
  12483.               {error}
  12484.               {The branch condition used for a conditional jump does not
  12485.                exist.}
  12486.               {none}
  12487. \errentry{1365}{incompatible conditions}
  12488.               {error}
  12489.               {The used combination of conditions is not possible
  12490.                in a single instruction.}
  12491.               {the condition where the incompatibility was detected.}
  12492. \errentry{1366}{unknown flag}
  12493.               {error}
  12494.               {The given flag does not exist.}
  12495.               {the argument using the flag in question}
  12496. \errentry{1367}{duplicate flag}
  12497.               {error}
  12498.               {The given flag has already been used in the list of flags.}
  12499.               {the argument duplicating the flag}
  12500. \errentry{1368}{unknown interrupt}
  12501.               {error}
  12502.               {The given interrupt does not exist.}
  12503.               {the argument using the interrupt in question}
  12504. \errentry{1369}{duplicate interrupt}
  12505.               {error}
  12506.               {The given interrupt has already been used in the list of interrupt.}
  12507.               {the argument duplicating the interrupt}
  12508. \errentry{1370}{jump distance too big}
  12509.               {error}
  12510.               {the jump instruction and destination are too apart to
  12511.                execute the jump with a single step}
  12512.               {none}
  12513. \errentry{1371}{jump distance is zero}
  12514.               {error}
  12515.               {the jump destination is right behind the jump instruction,
  12516.                and a jump distance of zero cannot be encoded.}
  12517.               {the target address in source code}
  12518. \errentry{1375}{jump distance is odd}
  12519.               {error}
  12520.               {Since instruction must only be located at even addresses,
  12521.                the jump distance between two instructions must always be
  12522.                even, and the LSB of the jump distance is used otherwise.
  12523.                This issue was not verified here. The reason is usually the
  12524.                presence of an odd number of data in bytes or a wrong
  12525.                \tty{ORG}.}
  12526.               {none}
  12527. \errentry{1376}{skip target mismatch}
  12528.               {error}
  12529.               {The gien branch target is not the address the processor would
  12530.                jump to if the skip instruction were executed.}
  12531.               {the given (intended) jump target}
  12532. \errentry{1380}{invalid argument for shifting}
  12533.               {error}
  12534.               {only a constant or a data register can be used for defining
  12535.                the shift size. (only for 680x0)}
  12536.               {none}
  12537. \errentry{1390}{operand must be in range 1..8}
  12538.               {error}
  12539.               {constants for shift size or \tty{ADDQ} argument can be only
  12540.                within the 1..8 range (only for 680x0)}
  12541.               {none}
  12542. \errentry{1400}{shift amplitude too big}
  12543.               {error}
  12544.               {(no more used)}
  12545.               {none}
  12546. \errentry{1410}{invalid register list}
  12547.               {error}
  12548.               {The register list argument of \tty{MOVEM} or \tty{FMOVEM} has a
  12549.                wrong format (only for 680x0)}
  12550.               {none}
  12551. \errentry{1420}{invalid addressing mode for CMP}
  12552.               {error}
  12553.               {The operand combination used with the \tty{CMP} instruction is
  12554.                not allowed (only for 680x0)}
  12555.               {none}
  12556. \errentry{1430}{invalid CPU type}
  12557.               {error}
  12558.               {The processor type used as argument for \tty{CPU} command is
  12559.                unknown to \asname{}.}
  12560.               {the unknown processor type}
  12561. \errentry{1431}{invalid FPU type}
  12562.               {error}
  12563.               {The co-processor type used as argument for \tty{FPU} command is
  12564.                unknown to \asname{}.}
  12565.               {the unknown co-processor type}
  12566. \errentry{1432}{invalid PMMU type}
  12567.               {error}
  12568.               {The MMU type used as argument for \tty{PMMU} command is
  12569.                unknown to \asname{}.}
  12570.               {the unknown MMU type}
  12571. \errentry{1440}{invalid control register}
  12572.               {error}
  12573.               {The control register used by a \tty{MOVEC} is not (yet) available
  12574.                for the processor defined by the \tty{CPU} command.}
  12575.               {none}
  12576. \errentry{1445}{invalid register}
  12577.               {error}
  12578.               {The register used, although valid, cannot be used in this
  12579.                context.}
  12580.               {none}
  12581. \errentry{1446}{register(s) listed more than once}
  12582.               {error}
  12583.               {A register appears more than once in the list of registers
  12584.                to be saved or restored.}
  12585.               {none}
  12586. \errentry{1447}{register bank mismatch}
  12587.               {error}
  12588.               {An address expression uses registers from different banks.}
  12589.               {the register in question}
  12590. \errentry{1448}{undefined register length}
  12591.               {error}
  12592.               {Registers of different size may be used at this place, and
  12593.                 the register length cannot be deduced from the address alone.}
  12594.               {the argument in question}
  12595. \errentry{1449}{invalid operation on register}
  12596.               {error}
  12597.               {This operation may not be applied to this register, e.g. because
  12598.                the register is read-only or write-only.}
  12599.               {the register in question}
  12600. \errentry{1450}{RESTORE without SAVE}
  12601.               {error}
  12602.               {A \tty{RESTORE} command was found, that cannot be coupled with a
  12603.                corresponding \tty{SAVE}.}
  12604.               {none}
  12605. \errentry{1460}{missing RESTORE}
  12606.               {error}
  12607.               {After the assembling pass, a \tty{SAVE} command was missing.}
  12608.               {none.}
  12609. \errentry{1465}{unknown macro control instruction}
  12610.               {error}
  12611.               {A macro option parameter is unknown to \asname{}.}
  12612.               {the dubious option.}
  12613. \errentry{1470}{missing ENDIF/ENDCASE}
  12614.               {error}
  12615.               {after the assembling, some of the \tty{IF}- or \tty{CASE}- constructs
  12616.                were found without the closing command}
  12617.               {none}
  12618. \errentry{1480}{invalid IF-structure}
  12619.               {error}
  12620.               {The command structure in a \tty{IF}- or \tty{SWITCH}- sequence is
  12621.                wrong.}
  12622.               {none}
  12623. \errentry{1483}{section name double defined}
  12624.               {error}
  12625.               {In this program module a section with the same name still
  12626.                exists.}
  12627.               {the multiple-defined name}
  12628. \errentry{1484}{unknown section}
  12629.               {error}
  12630.               {In the current scope, there are no sections with this name}
  12631.               {the unknown name}
  12632. \errentry{1485}{missing ENDSECTION}
  12633.               {error}
  12634.               {Not all the sections were properly closed.}
  12635.               {none}
  12636. \errentry{1486}{wrong ENDSECTION}
  12637.               {error}
  12638.               {The given \tty{ENDSECTION} does not refer to the most
  12639.                deeply nested one.}
  12640.               {none}
  12641. \errentry{1487}{ENDSECTION without SECTION}
  12642.               {error}
  12643.               {An \tty{ENDSECTION} command was found, but the associated section
  12644.                was not defined before.}
  12645.               {none}
  12646. \errentry{1488}{unresolved forward declaration}
  12647.               {error}
  12648.               {A symbol declared with a \tty{FORWARD} or \tty{PUBLIC} statement could
  12649.                not be resolved.}
  12650.               {the name of the unresolved symbol, plus the
  12651.                position of the forward declaration in the
  12652.                source.}
  12653. \errentry{1489}{conflicting FORWARD $<->$ PUBLIC-declaration}
  12654.               {error}
  12655.               {A symbol was defined both as public and private.}
  12656.               {the name of the symbol.}
  12657. \errentry{1490}{wrong numbers of function arguments}
  12658.               {error}
  12659.               {The number of arguments used for referencing a function
  12660.                does not match the number of arguments defined in the
  12661.                function definition.}
  12662.               {none}
  12663. \errentry{1495}{unresolved literals (missing LTORG)}
  12664.               {error}
  12665.               {At the end of the program, or just before switching to
  12666.                another processor type, unresolved literals still remain.}
  12667.               {none}
  12668. \errentry{1500}{instruction not allowed on}
  12669.               {error}
  12670.               {Although the instruction is correct, it cannot be used with
  12671.                the selected member of the CPU family.}
  12672.               {The processor variants that would support this
  12673.                instruction.}
  12674. \errentry{1501}{FPU instructions are not enabled}
  12675.               {error}
  12676.               {FPU instruction set extensions must be enabled to
  12677.                use this instruction.}
  12678.               {none}
  12679. \errentry{1502}{PMMU instructions are not enabled}
  12680.               {error}
  12681.               {PMMU instruction set extensions must be enabled
  12682.                to use this instruction.}
  12683.               {none}
  12684. \errentry{1503}{full PMMU instruction set is not enabed}
  12685.               {error}
  12686.               {This instrction is only contained in the 68851's
  12687.                instruction set, not in the reduced instruction
  12688.                set of the integrated PMMU.}
  12689.               {none}
  12690. \errentry{1504}{Z80 syntax was not allowed}
  12691.               {error}
  12692.               {This instruction is only allowed if Z80 syntax
  12693.                for 8080/8085 instructions has been enabled.}
  12694.               {none}
  12695. \errentry{1505}{addressing mode not allowed on}
  12696.               {error}
  12697.               {Although the addressing mode used is correct, it cannot be
  12698.                used with the selected member of the CPU family.}
  12699.               {The processor variants that would support this
  12700.                addressing mode.}
  12701. \errentry{1506}{not allowed in exclusive Z80 syntax mode}
  12702.               {error}
  12703.               {This instrction is no longer allowed if exclusive
  12704.                Z80 syntax mode for 8080/8085 instructions has been set.}
  12705.               {none}
  12706. \errentry{1507}{FPU instruction not supported on ...}
  12707.               {error}
  12708.               {Although this FPU instruction exists, it cannot be used on
  12709.                the selected type of FPU.}
  12710.               {The instruction in question}
  12711. \errentry{1508}{Custom instructions are not enabled}
  12712.               {error}
  12713.               {Custom instruction set extensions must be enabled
  12714.                to use this instruction.}
  12715.               {The instruction in question}
  12716. \errentry{1509}{instruction extension not enabled}
  12717.               {error}
  12718.               {This instruction is part of an extension whose
  12719.                usage has not been enabled.}
  12720.               {The extension's name}
  12721. \errentry{1510}{invalid bit position}
  12722.               {error}
  12723.               {Either the number of bits specified is not allowed, or
  12724.                the command is not completely specified.}
  12725.               {none}
  12726. \errentry{1520}{only ON/OFF allowed}
  12727.               {error}
  12728.               {This pseudo command accepts as argument either \tty{ON} or
  12729.                \tty{OFF}}
  12730.               {none}
  12731. \errentry{1530}{stack is empty or undefined}
  12732.               {error}
  12733.               {It was tried to access a stack via a \tty{POPV} instruction
  12734.                that was either never defined or already emptied.}
  12735.               {the name of the stack in question}
  12736. \errentry{1540}{not exactly one bit set}
  12737.               {error}
  12738.               {Not exactly one bit was set in a mask passed to the
  12739.                \tty{BITPOS} function.}
  12740.               {none}
  12741. \errentry{1550}{ENDSTRUCT without STRUCT}
  12742.               {error}
  12743.               {An \tty{ENDSTRUCT} instruction was found though there is
  12744.                currently no structure definition in progress.}
  12745.               {none}
  12746. \errentry{1551}{open structure definition}
  12747.               {error}
  12748.               {After end of assembly, not all \tty{STRUCT} instructions
  12749.                have been closed with appropriate \tty{ENDSTRUCT}s.}
  12750.               {the innermost, unfinished structure definition}
  12751. \errentry{1552}{wrong ENDSTRUCT}
  12752.               {error}
  12753.               {the name parameter of an \tty{ENDSTRUCT} instruction does
  12754.                not correspond to the innermost open structure
  12755.                definition.}
  12756.               {none}
  12757. \errentry{1553}{phase definition not allowed in structure definition}
  12758.               {error}
  12759.               {What should I say about that?  \tty{PHASE} inside a record
  12760.                simply does not make sense and only leads to
  12761.                confusion...}
  12762.               {none}
  12763. \errentry{1554}{invalid \tty{STRUCT} directive}
  12764.               {error}
  12765.               {Only \tty{EXTNAMES}, \tty{NOEXTNAMES}, \tty{DOTS},
  12766.                and \tty{NODOTS} are allowed as directives of a
  12767.                \tty{STRUCT} statement.}
  12768.               {the unknown directive}
  12769. \errentry{1555}{structure re-defined}
  12770.               {error}
  12771.               {A structure of this name has already been defined.}
  12772.               {the name of the structure}
  12773. \errentry{1556}{unresolvable structure element reference}
  12774.               {error}
  12775.               {An element in a structure references to another
  12776.                element, however this referenced element was not
  12777.                defined or itself has an unresolvable reference.}
  12778.               {the name of the element itself and the referenced one}
  12779. \errentry{1557}{duplicate structure element}
  12780.               {error}
  12781.               {The structure already contains an element of this name.}
  12782.               {name of the element}
  12783. \errentry{1560}{instruction is not repeatable}
  12784.               {error}
  12785.               {This machine instruction cannot be repeated via a {\tt
  12786.                RPT} construct.}
  12787.               {none}
  12788. \errentry{1600}{unexpected end of file}
  12789.               {error}
  12790.               {It was tried to read past the end of a file with a
  12791.                \tty{BINCLUDE} statement.}
  12792.               {none}
  12793. \errentry{1700}{ROM-offset must be in range 0..63}
  12794.               {error}
  12795.               {The ROM table of the 680x0 coprocessor has only 64 entries.}
  12796.               {none}
  12797. \errentry{1710}{invalid function code}
  12798.               {error}
  12799.               {The only function code arguments allowed are SFC, DFC, a
  12800.                data register, or a constant in the interval of 0..15 (only
  12801.                for 680x0 MMU).}
  12802.               {none}
  12803. \errentry{1720}{invalid function code mask}
  12804.               {error}
  12805.               {Only a number in the interval 0..15 can be used as
  12806.                function code mask (only for 680x0 MMU)}
  12807.               {none}
  12808. \errentry{1730}{invalid MMU register}
  12809.               {error}
  12810.               {The MMU does not have a register with this name (only for
  12811.                680x0 MMU).}
  12812.               {none}
  12813. \errentry{1740}{level must be in range 0..7}
  12814.               {error}
  12815.               {The level for \tty{PTESTW} and \tty{PTESTR} must be a constant in the
  12816.                range of 0...7 (only for 680x0 MMU).}
  12817.               {none}
  12818. \errentry{1750}{invalid bit mask}
  12819.               {error}
  12820.               {The bit mask used for a bit field command has a wrong
  12821.                format (only for 680x0).}
  12822.               {none}
  12823. \errentry{1760}{invalid register pair}
  12824.               {error}
  12825.               {The register here defined cannot be used in this context,
  12826.                or there is a syntactic error (only for 680x0).}
  12827.               {none}
  12828. \errentry{1800}{open macro definition}
  12829.               {error}
  12830.               {An incomplete macro definition was found. Probably an
  12831.                \tty{ENDM} statement is missing.}
  12832.               {none}
  12833. \errentry{1801}{IRP without ENDM}
  12834.               {error}
  12835.               {An incomplete IRP block was found. Probably an
  12836.                \tty{ENDM} statement is missing.}
  12837.               {none}
  12838. \errentry{1802}{IRPC without ENDM}
  12839.               {error}
  12840.               {An incomplete IRPC block was found. Probably an
  12841.                \tty{ENDM} statement is missing.}
  12842.               {none}
  12843. \errentry{1803}{REPT without ENDM}
  12844.               {error}
  12845.               {An incomplete REPT block was found. Probably an
  12846.                \tty{ENDM} statement is missing.}
  12847.               {none}
  12848. \errentry{1804}{WHILE without ENDM}
  12849.               {error}
  12850.               {An incomplete WHILE block was found. Probably an
  12851.                \tty{ENDM} statement is missing.}
  12852.               {none}
  12853. \errentry{1805}{EXITM not called from within macro}
  12854.               {error}
  12855.               {\tty{EXITM} is designed to terminate a macro expansion.  This
  12856.                instruction only makes sense within macros and an attempt
  12857.                was made to call it in the absence of macros.}
  12858.               {none}
  12859. \errentry{1810}{more than 10 macro parameters}
  12860.               {error}
  12861.               {A macro cannot have more than 10 parameters}
  12862.               {none}
  12863. \errentry{1811}{keyword argument not defined in macro}
  12864.               {error}
  12865.               {a keyword argument referred to a parameter the
  12866.                called macro does not provide.}
  12867.               {used keyword resp. macro parameter}
  12868. \errentry{1812}{positional argument no longer allowed after keyword argument}
  12869.               {Fehler}
  12870.               {position and keyword arguments  may be mixed in
  12871.                one macro call, however only keyword arguments
  12872.                are allowed after the first keyword argument.}
  12873.               {none}
  12874. \errentry{1815}{macro double defined}
  12875.               {error}
  12876.               {A macro was defined more than once in a program section.}
  12877.               {the multiply defined macro name.}
  12878. \errentry{1820}{expression must be evaluatable in first pass}
  12879.               {error}
  12880.               {The command used has an influence on the length of the
  12881.                emitted code, so that forward references cannot be resolved
  12882.                here.}
  12883.               {none}
  12884. \errentry{1830}{too many nested IFs}
  12885.               {error}
  12886.               {(no more implemented)}
  12887.               {none}
  12888. \errentry{1840}{ELSEIF/ENDIF without IF}
  12889.               {error}
  12890.               {A \tty{ELSEIF}- or \tty{ENDIF}- command was found, that is not preceded
  12891.                by an \tty{IF}- command.}
  12892.               {none}
  12893. \errentry{1850}{nested / recursive macro call}
  12894.               {error}
  12895.               {(no more implemented)}
  12896.               {none}
  12897. \errentry{1860}{unknown function}
  12898.               {error}
  12899.               {The function invoked was not defined before.}
  12900.               {The name of the unknown function}
  12901. \errentry{1870}{function argument out of definition range}
  12902.               {error}
  12903.               {The argument does not belong to the allowed argument range
  12904.                associated to the referenced function.}
  12905.               {none}
  12906. \errentry{1880}{floating point overflow}
  12907.               {error}
  12908.               {Although the argument is within the range allowed to the
  12909.                function arguments, the result is not valid}
  12910.               {none}
  12911. \errentry{1890}{invalid value pair}
  12912.               {error}
  12913.               {The base-exponent pair used in the expression cannot be
  12914.                computed}
  12915.               {none}
  12916. \errentry{1900}{instruction must not start on this address}
  12917.               {error}
  12918.               {No jumps can be performed by the selected CPU from this
  12919.                address.}
  12920.               {none}
  12921. \errentry{1905}{invalid jump target}
  12922.               {error}
  12923.               {No jumps can be performed by the selected CPU to this
  12924.                address.}
  12925.               {none}
  12926. \errentry{1910}{jump target not on same page}
  12927.               {error}
  12928.               {Jump command and destination must be in the same memory
  12929.                page.}
  12930.               {none}
  12931. \errentry{1911}{jump target not in same section}
  12932.               {error}
  12933.               {Jump command and destination must be in the same (64K)
  12934.                memory section.}
  12935.               {none}
  12936. \errentry{1920}{code overflow}
  12937.               {error}
  12938.               {An attempt was made to generate more than 1024 code or
  12939.                data bytes in a single memory page.}
  12940.               {none}
  12941. \errentry{1925}{address overflow}
  12942.               {error}
  12943.               {The address space for the processor type actually used was
  12944.                filled beyond the maximum allowed limit.}
  12945.               {none}
  12946. \errentry{1930}{constants and placeholders cannot be mixed}
  12947.               {error}
  12948.               {Instructions that reserve memory, and instructions that define
  12949.                constants cannot be mixed in a single pseudo instruction.}
  12950.               {none}
  12951. \errentry{1940}{code must not be generated in structure definition}
  12952.               {error}
  12953.               {a \tty{STRUCT} construct is only designed to describe a
  12954.                data structure and not to create one; therefore, no
  12955.                instructions are allowed that generate code.}
  12956.               {none}
  12957. \errentry{1950}{parallel construct not possible here}
  12958.               {error}
  12959.               {Either these instructions cannot be executed in parallel,
  12960.                or they are not close enough each other, to do parallel
  12961.                execution.}
  12962.               {none}
  12963. \errentry{1960}{invalid segment}
  12964.               {error}
  12965.               {The referenced segment cannot be used here.}
  12966.               {The name of the segment used.}
  12967. \errentry{1961}{unknown segment}
  12968.               {error}
  12969.               {The segment referenced with a \tty{SEGMENT} command does not
  12970.                exist for the CPU used.}
  12971.               {The name of the segment used}
  12972. \errentry{1962}{unknown segment register}
  12973.               {error}
  12974.               {The segment referenced here does not exist (8086 only)}
  12975.               {none}
  12976. \errentry{1970}{invalid string}
  12977.               {error}
  12978.               {The string has an invalid format.}
  12979.               {none}
  12980. \errentry{1980}{invalid register name}
  12981.               {error}
  12982.               {The referenced register does not exist, or it cannot
  12983.                be used here.}
  12984.               {none}
  12985. \errentry{1985}{invalid argument}
  12986.               {error}
  12987.               {The command used cannot be performed with the \tty{REP}-prefix.}
  12988.               {none}
  12989. \errentry{1990}{indirect mode not allowed}
  12990.               {error}
  12991.               {Indirect addressing cannot be used in this way}
  12992.               {none}
  12993. \errentry{1995}{not allowed in current segment}
  12994.               {error}
  12995.               {(no more implemented)}
  12996.               {none}
  12997. \errentry{1996}{not allowed in maximum mode}
  12998.               {error}
  12999.               {This register can be used only in minimum mode}
  13000.               {none}
  13001. \errentry{1997}{not allowed in minimum mode}
  13002.               {error}
  13003.               {This register can be used only in maximum mode}
  13004.               {none}
  13005. \errentry{2000}{execution packet crosses address boundary}
  13006.               {error}
  13007.               {An execution packet must not cross a 32-byte address
  13008.                boundary}
  13009.               {none}
  13010. \errentry{2001}{multiple use of same execution unit}
  13011.               {error}
  13012.               {One of the CPU's execution units was used more than
  13013.                once in an execution packet}
  13014.               {the name of the execution unit}
  13015. \errentry{2002}{multiple long read operations}
  13016.               {error}
  13017.               {An execution packet contains more than one long read
  13018.                operation, which is not allowed}
  13019.               {one of the functional units executing a long read}
  13020. \errentry{2003}{multiple long write operations}
  13021.               {error}
  13022.               {An execution packet contains more than one long write
  13023.                operation, which is not allowed}
  13024.               {one of the functional units executing a long write}
  13025. \errentry{2004}{long read with write operation}
  13026.               {error}
  13027.               {An execution packet contains both a long read and a write
  13028.                operation, which is not allowed.}
  13029.               {one of the execution units executing the conflicting
  13030.                operations}
  13031. \errentry{2005}{too many reads of one register}
  13032.               {error}
  13033.               {The same register was referenced more than four times in
  13034.                the same execution packet.}
  13035.               {the name of the register referenced too often}
  13036. \errentry{2006}{overlapping destinations}
  13037.               {error}
  13038.               {The same register was written more than one time in the
  13039.                same instruction packet, which is not allowed.}
  13040.               {the name of the register in question}
  13041. \errentry{2008}{too many absolute branches in one execution packet}
  13042.               {error}
  13043.               {An execution packet contains more than one direct branch,
  13044.                which is not allowed.}
  13045.               {none}
  13046. \errentry{2009}{instruction cannot be executed on this unit}
  13047.               {error}
  13048.               {This instruction cannot be executed on this functional
  13049.                unit.}
  13050.               {none}
  13051. \errentry{2010}{invalid escape sequence}
  13052.               {error}
  13053.               {The special character defined using a backslash sequence
  13054.                is not defined}
  13055.               {none}
  13056. \errentry{2020}{invalid combination of prefixes}
  13057.               {error}
  13058.               {The prefix combination here defined is not allowed, or it
  13059.                cannot be translated into binary code}
  13060.               {none}
  13061. \errentry{2030}{constants cannot be redefined as variables}
  13062.               {error}
  13063.               {A symbol that has once been declared as constant with
  13064.                {\tt EQU} must not be modified afterwards with {\tt SET}.}
  13065.               {the name of the symbol in question}
  13066. \errentry{2035}{variables cannot be redefined as constants}
  13067.               {error}
  13068.               {A symbol that has once been declared as variable with
  13069.                {\tt SET} must not be redeclared afterwards as constant
  13070.                (e.g. with {\tt EQU}.}
  13071.               {the name of the symbol in question}
  13072. \errentry{2040}{structure name missing}
  13073.               {error}
  13074.               {A structure's definition lacks the identifier name for the
  13075.                new structure}
  13076.               {none}
  13077. \errentry{2050}{empty argument}
  13078.               {error}
  13079.               {Empty strings must not be used in the argument list for
  13080.                this statement}
  13081.               {none}
  13082. \errentry{2060}{unimplemented instruction}
  13083.               {error}
  13084.               {The used machinen instruction is principally known
  13085.                to the assembler, however, it is currently not
  13086.                implemented, du to lack of documentation from the
  13087.                processor manufacturer.}
  13088.               {the instruction that was used}
  13089. \errentry{2070}{unnamed structure is not part of another structure}
  13090.               {error}
  13091.               {An unnamed structure or union always must be part
  13092.                of another structure or union.}
  13093.               {none}
  13094. \errentry{2080}{STRUCT ended by ENDUNION}
  13095.               {error}
  13096.               {ENDUNION may only be used to finalize the definition
  13097.                of a union and not of a structure.}
  13098.               {name of the structure (if available)}
  13099. \errentry{2090}{Memory address mot on active memory page}
  13100.               {error}
  13101.               {The target address is not within the page
  13102.                that is currently addressable via the page
  13103.                register.}
  13104.               {none}
  13105. \errentry{2100}{unknown macro expansion argument}
  13106.               {error}
  13107.               {An argument to \tty{MACEXP} could not be
  13108.                interpreted.}
  13109.               {the unknown argument}
  13110. \errentry{2105}{too many macro expansion arguments}
  13111.               {error}
  13112.               {The number macro expansion arguments exceeds the allowed limit.}
  13113.               {the argument that busted the limit}
  13114. \errentry{2110}{contradicting macro expansion specifications}
  13115.               {error}
  13116.               {A specification about macro expansion and its
  13117.                precise opposite may not be used in the same
  13118.                \tty{MACEXP} instruction.}
  13119.               {none}
  13120. \errentry{2130}{erwarteter Fehler nicht eingetreten}
  13121.               {error}
  13122.               {An error or warning announced via {\tt EXPECT} did not occur in the
  13123.                instruction block terminated via {\tt ENDEXPECT}.}
  13124.               {The error that was expected}
  13125. \errentry{2140}{nesting of EXPECT/ENDEXPECT not allowed}
  13126.               {error}
  13127.               {Code blocks framed via {\tt EXPECT/ENDEXPECT} must not contain
  13128.                nested {\tt EXPECT/ENDEXPECT} blocks.}
  13129.               {none}
  13130. \errentry{2150}{missing ENDEXPECT}
  13131.               {error}
  13132.               {An instruction block opened via {\tt EXPECT} was not closed via
  13133.                {\tt ENDEXPECT}.}
  13134.               {none}
  13135. \errentry{2160}{ENDEXPECT without EXPECT}
  13136.               {error}
  13137.               {There is no matching previous {\tt EXPECT} to an {\tt ENDEXPECT}.}
  13138.               {none}
  13139. \errentry{2170}{no default checkpoint register defined}
  13140.               {error}
  13141.               {No checkpoint register was specified for a type 12 instruction
  13142.                and no default checkpoint register had previously been defined
  13143.                via the {\tt CKPT} statement.}
  13144.               {none}
  13145. \errentry{2180}{invalid bit field}
  13146.               {error}
  13147.               {The bit field is not in the required syntax {\tt (start,count)}.}
  13148.               {the argument in question}
  13149. \errentry{2190}{argument value missing}
  13150.               {error}
  13151.               {Arguments must have the form 'variable=value'.}
  13152.               {the argument in question}
  13153. \errentry{2200}{unknown argument}
  13154.               {error}
  13155.               {This variable is not supported by the selected target platform.}
  13156.               {the argument in question}
  13157. \errentry{2210}{index register must be 16 bit}
  13158.               {error}
  13159.               {Z8000 index registers must have a size of 16 bits (Rn).}
  13160.               {the argument in question}
  13161. \errentry{2211}{I/O address register must be 16 bit}
  13162.               {error}
  13163.               {Z8000 registers used to address I/O addresses must have a size of 16 bits (Rn).}
  13164.               {the argument in question}
  13165. \errentry{2212}{address register in segmented mode must be 32 bit}
  13166.               {error}
  13167.               {Z8000 registers to address memory in segmented mode must have a size of 32 bits (RRn).}
  13168.               {the argument in question}
  13169. \errentry{2213}{address register in non-segmented mode must be 16 bit}
  13170.               {error}
  13171.               {Z8000 registers to address memory in non-segmented mode must have a size of 16 bits (Rn).}
  13172.               {the argument in question}
  13173. \errentry{2220}{invalid structure argument}
  13174.               {error}
  13175.               {The argument does not match any pattern of allowed arguments
  13176.                when expanding a structure.}
  13177.               {the argument in question}
  13178. \errentry{2221}{too many array dimensions}
  13179.               {error}
  13180.               {Arrays of structures are limited to being three-dimensional.}
  13181.               {the dimension argument that was 'too much'}
  13182. \errentry{2230}{unknown integer notation}
  13183.               {error}
  13184.               {The given integer notation does not exist, or the leading plus resp.
  13185.                minus sign is missing.}
  13186.               {the argument in question}
  13187. \errentry{2231}{invalid list of integer notations}
  13188.               {error}
  13189.               {The requested changes to the list of usable integer notations cannot
  13190.                be applied, because they would result in a contradiction.  Currently,
  13191.                the only such case are 0hex und 0oct which cannot be used at the same
  13192.                time.}
  13193.               {none}
  13194. \errentry{2240}{invalid scale}
  13195.               {error}
  13196.               {The given argument cannot be used as scaling factor.}
  13197.               {the argument in question}
  13198. \errentry{2250}{conflicting string options}
  13199.               {error}
  13200.               {The string option is in contradiction to a previously given option.}
  13201.               {the option in question}
  13202. \errentry{2251}{unknown string option}
  13203.               {error}
  13204.               {The string option does not exist.}
  13205.               {the option in question}
  13206. \errentry{2252}{invalid cache invalidate mode}
  13207.               {error}
  13208.               {Only data, instruction, or both caches may be invalidated.}
  13209.               {the argument in question}
  13210. \errentry{2253}{invalid config list}
  13211.               {error}
  13212.               {The configuration list is either syntactically incorrect or
  13213.                contains invalid elements.}
  13214.               {The list in question or one of its elements}
  13215. \errentry{2254}{conflicting config options}
  13216.               {error}
  13217.               {The option is in contradiction to a previously given option or repeats a previous one.}
  13218.               {the option in question}
  13219. \errentry{2255}{unknown config option}
  13220.               {error}
  13221.               {The option does not exist.}
  13222.               {the option in question}
  13223. \errentry{2260}{invalid CBAR value}
  13224.               {error}
  13225.               {This value for CBAR is not allowed (CA must be larger than BA).}
  13226.               {none}
  13227. \errentry{2270}{page not accessible}
  13228.               {error}
  13229.               {The target address is located in a memory page that is currently
  13230.                inaccessible.}
  13231.               {none}
  13232. \errentry{2280}{field not accessible}
  13233.               {error}
  13234.               {The target address is located in a memory field that is currently
  13235.                inaccessible.}
  13236.               {none}
  13237. \errentry{2281}{target not in same field}
  13238.               {error}
  13239.               {Instruction and target address must be located in the
  13240.                same memory field.}
  13241.               {none}
  13242. \errentry{2290}{invalid instruction combination}
  13243.               {error}
  13244.               {These instructions may not be combined with each other.}
  13245.               {none}
  13246. \errentry{2300}{unmapped character}
  13247.               {error}
  13248.               {The character string contains a charater that cannot be mapped.}
  13249.               {The string in question}
  13250. \errentry{2310}{invalid length of multi character constant}
  13251.               {error}
  13252.               {multi character constants must be between one and four characters long.}
  13253.               {none}
  13254. \errentry{2320}{no target set (use 'CPU ...' or '-cpu ...' to set one)}
  13255.               {fatal}
  13256.               {No target has been set so far.  The assembler therefore does
  13257.                not know which target to generate code for.}
  13258.               {none}
  13259. \errentry{10001}{error in opening file}
  13260.               {fatal}
  13261.               {An error was detected while trying to open a file for input.}
  13262.               {description of the I/O error}
  13263. \errentry{10002}{error in writing listing}
  13264.               {fatal}
  13265.               {An error happened while \asname{} was writing the listing file.}
  13266.               {description of the I/O error}
  13267. \errentry{10003}{file read error}
  13268.               {fatal}
  13269.               {An error was detected while reading a source file.}
  13270.               {description of the I/O error}
  13271. \errentry{10004}{file write error}
  13272.               {fatal}
  13273.               {While \asname{} was writing a code or share file, an error happened.}
  13274.               {description of the I/O error}
  13275. \errentry{10006}{heap overflow}
  13276.               {fatal}
  13277.               {The memory available is not enough to store all the data
  13278.                needed by \asname{}. Try using the DPMI or OS/2 version of \asname{}.}
  13279.               {none}
  13280. \errentry{10007}{stack overflow}
  13281.               {fatal}
  13282.               {The program stack crashed, because too complex formulas, or
  13283.                a bad disposition of symbols and/or macros were used. Try
  13284.                again, using \asname{} with the option \tty{-A}.}
  13285.               {none}
  13286. \errentry{10008}{INCLUDE nested too deeply}
  13287.               {fatal}
  13288.               {The include nesting depth has exceeded the given limit (200
  13289.                by default). The limit may be raised via the {\tt -maxinclevel}
  13290.                command line argument, a wrong (recursive) inclusion is however
  13291.                the more probable cause.}
  13292.               {the INCLUDE statement that exceeded the limit}
  13293. \end{description}
  13294.  
  13295. %%===========================================================================
  13296.  
  13297. \cleardoublepage
  13298. \chapter{I/O Error Messages}
  13299.  
  13300. The following error messages are generated not only by \asname{}, but also by
  13301. the auxiliary programs, like PLIST, BIND, P2HEX, and P2BIN. Only the most
  13302. probable error messages are here explained. Should you meet an undocumented
  13303. error message, then you probably met a program bug! Please inform us
  13304. immediately about this!!
  13305.  
  13306. \begin{description}
  13307. \item[2]{file not found\\
  13308.         The file requested does not exist, or it is stored on another
  13309.         drive.}
  13310. \item[3]{path not found\\
  13311.         The path of a file does not exist, or it is on another drive.}
  13312. \item[4]{too much open files\\
  13313.         There are no more file handles available to DOS. Increase
  13314.         their number changing the value associated to \tty{FILES=} in the file
  13315.         \tty{CONFIG.SYS}.}
  13316. \item[5]{file access not allowed\\
  13317.         Either the network access rights do not allow the file access, or
  13318.         an attempt was done to rewrite or rename a protected file.}
  13319. \item[6]{invalid file handler}
  13320. \item[12]{invalid access mode}
  13321. \item[15]{invalid drive letter\\
  13322.         The required drive does not exist.}
  13323. \item[16]{The file cannot be deleted}
  13324. \item[17]{RENAME cannot be done on this drive}
  13325. \item[100]{Unexpected end of file\\
  13326.         A file access tried to go beyond the end of file, although according
  13327.         to its structure this should not happen. The file is probably
  13328.         corrupted.}
  13329. \item[101]{disk full\\
  13330.         This is self explaining! Please, clean up !}
  13331. \item[102]{ASSIGN failed}
  13332. \item[103]{file not open}
  13333. \item[104]{file not open for reading}
  13334. \item[105]{file not open for writing}
  13335. \item[106]{invalid numerical format}
  13336. \item[150]{the disk is write-protected\\
  13337.         When you don't use a hard disk as work medium storage, you should
  13338.         sometimes remove the protecting tab from your diskette!}
  13339. \item[151]{unknown device\\
  13340.         you tried to access a peripheral unit that is unknown to DOS. This
  13341.         should not usually happen, since the name should be automatically
  13342.         interpreted as a filename.}
  13343. \item[152]{drive not ready\\
  13344.         close the disk drive door.}
  13345. \item[153]{unknown DOS function}
  13346. \item[154]{invalid disk checksum\\
  13347.         A bad read error on the disk. Try again; if nothing changes,
  13348.         reformat the floppy disk resp. begin to take care of your hard
  13349.         disk!}
  13350. \item[155]{invalid FCB}
  13351. \item[156]{position error\\
  13352.         the diskette/hard disk controller has not found a disk track. See
  13353.         nr. 154 !}
  13354. \item[157]{format unknown\\
  13355.         DOS cannot read the diskette format}
  13356. \item[158]{sector not found\\
  13357.         As nr. 156, but the controller this time could not find a disk
  13358.         sector in the track.}
  13359. \item[159]{end of paper\\
  13360.         You probably redirected the output of \asname{} to a printer. Assembler
  13361.         printout can be veeery long...}
  13362. \item[160]{device read error\\
  13363.         The operating system detected an unclassificable read error}
  13364. \item[161]{device write error\\
  13365.         The operating system detected an unclassificable write error}
  13366. \item[162]{general failure error\\
  13367.         The operating system has absolutely no idea of what happened to the
  13368.         device.}
  13369. \end{description}
  13370.  
  13371. %%===========================================================================
  13372.  
  13373. \cleardoublepage
  13374. \chapter{Programmierbeispiele}
  13375.  
  13376. I often get questions about how to realize certain things. Some of those are
  13377. asked frequently, and it might be worth documenting the solutions in a 'Tips
  13378. and Tricks' corner.  This chapter is meant to collect and document them:
  13379.  
  13380. \section{16 Bit Instructions via Macros}
  13381.  
  13382. AMany 8 bit processors can only process eight bits at once (as the name already
  13383. implies...).  They however often contain enough registers to virtuall concatenate
  13384. two of them to a virtual '16 bit accumulator'.  If we define macros to operate
  13385. on this virtual accumulator, they ideally should provide the same addressing
  13386. modes as the 8 bit instructions implemented by the hardware.  To achieve this,
  13387. macros somehow have to 'parse' their arguments.  How can this be accomplished?
  13388.  
  13389. As an examplr, the Motorola 6800 contains two accumulators named A an B.  It
  13390. is straightforward to treat them also as a 16 bit accumulator.  Addressing modes
  13391. should be the same as for 8 bit arithmetic instructions, namely:
  13392. \begin{itemize}
  13393. \item{immediate}
  13394. \item{direct (address within first 256 bytes)}
  13395. \item{extended (arbitrary address)}
  13396. \item{indexed}
  13397. \end{itemize}
  13398. Therefore, a macro implementing a virtual 16 bit instruction has to analyze
  13399. the one or two arguments passsed to it:
  13400. \begin{enumerate}
  13401. \item{Indexed addressing is the only mode using two arguments.}
  13402. \item{Immediate addressing is recognized by the leading hash character.}
  13403. \item{Checking whether an address is within the first 256 bytes or not
  13404.      may be left to the assembler.}
  13405. \end{enumerate}
  13406. The (single) argument has to be transformed into a string to perform step 2.
  13407. This string can then also be used to strip the leading hash character, to evaluate
  13408. the actual immediate value.  The complete macro looks like this:
  13409. \begin{verbatim}
  13410. subd    macro   ARG1,ARG2
  13411.  if      "ARG2" != ""            ; indexed?
  13412.   suba    (ARG1)+1,ARG2
  13413.   sbcb    ARG1,ARG2
  13414.  elseif                          ; not indexed?
  13415. _SARG1   set     "ARG1"           ; convert to string
  13416.  if      substr(_SARG1,0,1)='#' ; immediate?
  13417. _SARG1    set     substr(_SARG1,1,strlen(_SARG1)-1) ; y->del #
  13418.   suba    #lo(VAL(_SARG1))      ; ...and subtract lo/hi bytes
  13419.   sbcb    #hi(VAL(_SARG1))
  13420.  elseif                         ; no immediate->ext. or direct
  13421.   suba    (ARG1)+1              ; and subtract lo/hi bytes
  13422.   sbcb    ARG1
  13423.  endif
  13424.  endif
  13425.  endm
  13426. \end{verbatim}
  13427. Macro arguments hav deliberately been written in all-uppercase.  This way,
  13428. the macro works both in case-sensitive and non-case-sensitive mode.  The
  13429. usage of the macro looks like this:
  13430. \begin{verbatim}
  13431.        subd    $0007                   ; direct
  13432.        subd    $1234                   ; absolute
  13433.        subd    #$55aa                  ; immediate
  13434.        subd    $12,x                   ; indexed
  13435. \end{verbatim}
  13436. Of course, we want to have more 16 bit operations than just subtraction.  One
  13437. could write a similar macro for every type of operation. However, there is a
  13438. more elegant method.  A macro may itself contain a macro definition.  So we
  13439. can define a sort of 'meta macro' which gets the instruction names as arguments:
  13440. \begin{verbatim}
  13441. def16   macro   NEWINST,LOINST,HIINST
  13442. NEWINST macro   ARG1,ARG2
  13443.  if      "ARG2" != ""            ; indexed?
  13444.   LOINST  (ARG1)+1,ARG2
  13445.   HIINST  ARG1,ARG2
  13446.  elseif                          ; not indexed?
  13447. _SARG1   set     "ARG1"                 ; convert to string
  13448.  if      substr(_SARG1,0,1)='#' ; immediate?
  13449. _SARG1    set     substr(_SARG1,1,strlen(_SARG1)-1) ; y->del #
  13450.   LOINST  #lo(VAL(_SARG1))      ; ...and subtract lo/hi bytes
  13451.   HIINST  #hi(VAL(_SARG1))
  13452.  elseif                         ; no immediate->ext. or direct
  13453.   LOINST  (ARG1)+1              ; ...and subtract lo/hi bytes
  13454.   HIINST  ARG1
  13455.  endif
  13456.  endif
  13457.  endm
  13458.  endm
  13459. \end{verbatim}
  13460. The remaining definitions now become one-liners:
  13461. \begin{verbatim}
  13462.        def16   addd,adda,adcb
  13463.        def16   subd,suba,sbcb
  13464.        def16   andd,anda,andb
  13465.        def16   ord,ora,orb
  13466.        def16   eord,eora,eorb
  13467. \end{verbatim}
  13468.  
  13469.  
  13470. %%===========================================================================
  13471.  
  13472. \cleardoublepage
  13473. \chapter{Frequently Asked Questions}
  13474.  
  13475. In this chapter, I tried to collect some questions that arise very often
  13476. together with their answers.  Answers to the problems presented in
  13477. this chapter might also be found at other places in this manual, but
  13478. one maybe does not find them immediately...
  13479.  
  13480. \begin{description}
  13481. \item[Q:]{I am fed up with DOS.  Are there versions of \asname{} for other
  13482.   operating systems ?}
  13483. \item[A:]{Apart from the protected mode version that offers more memory when
  13484.   working under DOS, ports exist for OS/2 and Unix systems like
  13485.   Linux (currently in test phase).  Versions that help operating
  13486.   system manufacturers located in Redmont to become even richer are
  13487.   currently not planned.  I will gladly make the sources of \asname{}
  13488.   available for someone else who wants to become active in this
  13489.   direction.  The C variant is probably the best way to start a
  13490.   port into this direction.  He should however not expect support
  13491.   from me that goes beyond the sources themselves...}
  13492. \vspace{0.3cm}
  13493. \item[Q:]{Is a support of the XYZ processor planned for \asname{}?}
  13494. \item[A:]{New processors are appearing all the time and I am trying to keep
  13495.   pace by extending \asname{}.  The stack on my desk labeled ''undone''
  13496.   however never goes below the 4 inch watermark... Wishes coming
  13497.   from users of course play an important role in the decision which
  13498.   candidates will be done first.  The internet and the rising amount
  13499.   of documentation published in electronic form make the acquisition
  13500.   of data books easier than it used to be, but it always becomes
  13501.   difficult when more exotic or older architectures are wanted.  If
  13502.   the processor family in question is not in the list of families
  13503.   that are planned (see chapter 1), adding a data book to a request
  13504.   will have a highly positive influence.  Borrowing books is also
  13505.   fine.}
  13506. \vspace{0.3cm}
  13507. \item[Q:]{Having a free assembler is really fine, but I now also had use for
  13508.   a disassembler...and a debugger...a simulator would also really be
  13509.   cool!}
  13510. \item[A:]{\asname{} is a project I work on in leisure time, the time I have when I
  13511.   do not have to care of how to make my living.  \asname{} already takes a
  13512.   significant portion of that time, and sometimes I make a time-out
  13513.   to use my soldering iron, enjoy a Tangerine Dream CD, watch TV, or
  13514.   simply to fulfill some basic human needs... I once started to
  13515.   write the concept of a disassembler that was designed to create
  13516.   source code that can be assembled and that automatically
  13517.   separates code and data areas.  I quickly stopped this project
  13518.   again when I realized that the remaining time simply did not
  13519.   suffice.  I prefer to work on one good program than to struggle for
  13520.   half a dozen of mediocre apps.  Regarded that way, the answer to
  13521.   the question is unfortunately ''no''...}
  13522. \vspace{0.3cm}
  13523. \item[Q:]{The screen output of \asname{} is messed up with strange characters, e.g.
  13524.   arrows and brackets.  Why?}
  13525. \item[A:]{\asname{} will by default use some ANSI control sequences for screen
  13526.   control.  These sequences will appear unfiltered on your screen
  13527.   if you did not install an ANSI driver.  Either install an ANSI
  13528.   driver or use the DOS command \tty{SET USEANSI=N} to turn the
  13529.   sequences off.}
  13530. \vspace{0.3cm}
  13531. \item[Q:]{\asname{} suddenly terminates with a stack overflow error while
  13532.   assembling my program.  Did my program become to large?}
  13533. \item[A:]{Yes and No.  Your program's symbol table has grown a bit
  13534.   unsymmetrically what lead to high recursion depths while accessing
  13535.   the table.  Errors of this type especially happen in the
  13536.   16-bit-OS/2 version of \asname{} which has a very limited stack area.
  13537.   Restart \asname{} with the \tty{-A} command line switch.  If this does not
  13538.   help, too complex formula expression are also a possible cause of
  13539.   stack overflows.  In such a case, try to split the formula into
  13540.   intermediate steps.}
  13541. \vspace{0.3cm}
  13542. \item[Q:]{It seems that \asname{} does not assemble my program up to the end.  It
  13543.   worked however with an older version of \asname{} (1.39).}
  13544. \item[A:]{Newer versions of \asname{} no longer ignore the \tty{END} statement; they
  13545.   actually terminate assembly when an \tty{END} is encountered.
  13546.   Especially older include files made by some users tended to
  13547.   contain an \tty{END} statement at their end.  Simply remove the
  13548.   superfluous \tty{END} statements.}
  13549. \vspace{0.3cm}
  13550. \item[Q:]{I made an assembly listing of my program because I had some more
  13551.   complicated assembly errors in my program.  Upon closer
  13552.   investigation of the listing, I found that some branches do not
  13553.   point to the desired target but instead to themselves!}
  13554. \item[A:]{This effect happens in case of forward jumps in the first pass.
  13555.   The formula parser does not yet have the target address in its symbol
  13556.   table, and as it is a completely independent module, it has to think of
  13557.   a value that even does not hurt relative branches with short displacement
  13558.   lengths.  This is the current program counter itself...in the
  13559.   second pass, the correct values would have appeared, but the second
  13560.   pass did not happen due to errors in the first one.  Correct the
  13561.   other errors first so that \asname{} gets into the second pass, and the
  13562.   listing should look more meaningful again.}
  13563. \vspace{0.3cm}
  13564. \item[Q:]{Assembly of my program works perfectly, however I get an empty
  13565.   file when I try to convert it with P2HEX or P2BIN.}
  13566. \item[A:]{You probably did not set the address filter correctly.  By
  13567.   default, the filter is disabled, i.e. all data is copied to the
  13568.   HEX or binary file.  It is however possible to create an empty file
  13569.   if a manually set range does not fit to the addresses used by your
  13570.   program.}
  13571. \vspace{0.3cm}
  13572. \item[Q:]{I cannot enter the dollar character when using P2BIN or P2HEX
  13573.   under Unix.  The automatic address range setting does not work, instead
  13574.   I get strange error messages.}
  13575. \item[A:]{Unix shells use the dollar character for expansion of shell
  13576.   variables.  If you want to pass a dollar character to an application,
  13577.   prefix it with a backslash (\verb!\!).  In the special case of the
  13578.   address range specification for P2HEX and P2BIN, you may also use
  13579.   \tty{0x} instead of the dollar character, which removes this prblen
  13580.   completely.}
  13581. \item[Q:]{I use \asname{} on a Linux system, the loader program for my target
  13582.          system however runs on a Windows machine. To simplify things,
  13583.          both systems access the same network drive.  Unfortunately, the
  13584.          Windows side refuses to read the hex files created by the Linux
  13585.          side :-(}
  13586. \item[A:]{Windows and Linux systems use slightly different formats for
  13587.          text files (hex files are a sort of text files).  Windows
  13588.          terminates every line with the characters CR (carriage return)
  13589.          and LF (linefeed), however Linux only uses the linefeed.  It
  13590.          depends on the Windows program's 'goodwill' whether it will
  13591.          accept text files in the Linux format or not.  If not, it is
  13592.          possible to transfer the files via FTP in ASCII mode instead
  13593.          of a network drive.  Alternatively, the hex files can be
  13594.          converted to the Windows format.  For example, the program
  13595.          {\em unix2dos} can be used to do this, or a small script under
  13596.          Linux:
  13597.          \begin{verbatim}
  13598.          awk '{print $0"\r"}' test.hex >test_cr.hex
  13599.          \end{verbatim}}
  13600. \item[Q:]{I have a 16 bit address in my program and have to load its
  13601.          upper and lower half into separate CUP registers. How do I
  13602.          extract the byte halves? Other assemblers have built-in
  13603.          functions to accomodate this.}
  13604. \item[A:]{This can be done ''by hand'' with the built-in logical and
  13605.          shift operators.  However, there is also a file {\tt bitfuncs.inc}
  13606.          that defines the functions {\tt lo()} respectively {\tt hi()}.}
  13607. \end{description}
  13608.  
  13609. %%===========================================================================
  13610.  
  13611. \cleardoublepage
  13612. \chapter{Pseudo-Instructions and Integer Syntax}
  13613. \label{SectPseudoInst}
  13614.  
  13615. This appendix is designed as a quick reference to look up all pseudo
  13616. instructions provided by \asname{}.  The list is ordered in two parts: The
  13617. first part lists the instructions that are always available, and this
  13618. list is followed by lists that enumerate the instructions
  13619. additionally available for a certain processor family.
  13620.  
  13621. \subsubsection{Instructions that are always available}
  13622. \input{../doc_COM/pscomm.tex}
  13623. Additionally, there are:
  13624. \begin{itemize}
  13625. \item{\tty{SET} as an alias to \tty{EVAL}, unless \tty{SET} is already a machine
  13626.      instruction.}
  13627. \item{\tty{SHIFT} resp. \tty{SHFT}, in case \tty{SHIFT} is already a machine
  13628.      instruction.}
  13629. \item{\tty{RESTORE} as an alias to \tty{RESTOREENV}, unless \tty{RESTORE} is already a machine
  13630.      instruction.}
  13631. \item{\tty{SAVE} as an alias to \tty{SAVEENV}, unless \tty{SAVE} is already a machine
  13632.      instruction.}
  13633. \item{\tty{PAGE} resp. \tty{PAGESIZE}, in case \tty{PAGE} is already a machine
  13634.      instruction.}
  13635. \item{\tty{SWITCH} resp. \tty{SELECT}, in case \tty{SWITCH} is already a machine
  13636.      instruction.}
  13637. \end{itemize}
  13638.  
  13639. \input{../doc_COM/pscpu.tex}
  13640.  
  13641. %%===========================================================================
  13642.  
  13643. \cleardoublepage
  13644. \chapter{Predefined Symbols}
  13645. \label{AppInternSyms}
  13646.  
  13647. \begin{center}\begin{longtable}{|l|l|l|l|}
  13648. \hline
  13649. Name          & Data Type & Definition & Meaning \\
  13650. \hline
  13651. \hline
  13652. \endhead
  13653. ARCHITECTURE  & string    & predef.    & target platform \asname{} was \\
  13654.              &           &            & compiled for, in the style \\
  13655.              &           &            & processor-manufacturer- \\
  13656.              &           &            & operating system \\
  13657. BIGENDIAN     & boolean   & dyn.(0)    & storage of constants MSB \\
  13658.              &           &            & first? \\
  13659. CASESENSITIVE & boolean   & normal     & case sensitivity in symbol \\
  13660.              &           &            & names? \\
  13661. CONSTPI       & float     & normal     & constant Pi (3.1415.....) \\
  13662. DATE          & string    & predef.    & date of begin of assembly \\
  13663. FALSE         & boolean   & predef.    & 0 = logically ''false'' \\
  13664. HASFPU        & boolean   & dyn.(0)    & coprocessor instructions \\
  13665.              &           &            & enabled? \\
  13666. HASPMMU       & boolean   & dyn.(0)    & MMU instructions \\
  13667.              &           &            & enabled? \\
  13668. INEXTMODE     & boolean   & dyn.(0)    & XM flag set for 4 Gbyte \\
  13669.              &           &            & address space? \\
  13670. INLWORDMODE   & boolean   & dyn.(0)    & LW flag set for 32 bit \\
  13671.              &           &            & instructions? \\
  13672. INMAXMODE     & boolean   & dyn.(0)    & processor in maximum \\
  13673.              &           &            & mode? \\
  13674. INSUPMODE     & boolean   & dyn.(0)    & processor in supervisor \\
  13675.              &           &            & mode? \\
  13676. INSRCMODE     & boolean   & dyn.(0)    & processor in source mode? \\
  13677. FULLPMMU      & boolean   & dyn.(0/1)  & full PMMU instruction set \\
  13678.              &           &            & allowed? \\
  13679. LISTON        & boolean   & dyn.(1)    & listing enabled? \\
  13680. MACEXP        & boolean   & dyn.(1)    & expansion of macro con- \\
  13681.              &           &            & structs in listing enabled? \\
  13682. MOMCPU        & integer   & dyn.       & number of target CPU \\
  13683.               &           & (68008)    & currently set \\
  13684. MOMCPUNAME    & string    & dyn.       & name of target CPU \\
  13685.              &           & (68008)    & currently set \\
  13686. MOMFILE       & string    & special    & current source file \\
  13687.              &           &            & (including include files) \\
  13688. MOMLINE       & integer   & special    & current line number in  \\
  13689.              &           &            & source file \\
  13690. MOMPASS       & integer   & special    & number of current pass \\
  13691. MOMSECTION    & string    & special    & name of current section or \\
  13692.               &           &            & empty string if out of any \\
  13693.              &           &            & section \\
  13694. MOMSEGMENT    & string    & special    & name of address space \\
  13695.              &           &            & currently selected \\
  13696.              &           &            & with \tty{SEGMENT} \\
  13697. NESTMAX       &  Integer  & dyn.(256)  & maximum nesting level \\
  13698.              &           &            & of macro expansions \\
  13699. PADDING       & Boolean   & dyn.(1)    & pad byte field to even \\
  13700.              &           &            & count? \\
  13701. RELAXED       & Boolean   & dyn.(0)    & any syntax allowed integer \\
  13702.              &           &            & constants? \\
  13703. PC            & Integer   & special    & current program counter \\
  13704.              &           &            & (Thomson) \\
  13705. TIME          & String    & predef.    & time of begin of assembly \\
  13706.              &           &            & (1st pass) \\
  13707. TRUE          & Integer   & predef.    & 1 = logically ''true'' \\
  13708. VERSION       & Integer   & predef.    & version of \asname{} in BCD \\
  13709.               &           &            & coding, e.g. 1331 hex for \\
  13710.              &           &            & version 1.33p1 \\
  13711. WRAPMODE      & Integer   & predef.    & shortened program \\
  13712.              &           &            & counter assumed? \\
  13713. \verb!*!      & Integer   & special    & current program counter \\
  13714.              &           &            & (Motorola, Rockwell, \\
  13715.              &           &            & Microchip, Hitachi) \\
  13716. .             & Integer   & special    & curr. program counter \\
  13717.              &           &            & (IM61x0) \\
  13718. \$            & Integer   & special    & current program counter \\
  13719.              &           &            & Intel, Zilog, Texas, \\
  13720.              &           &            & Toshiba, NEC, Siemens, \\
  13721.              &           &            & AMD) \\
  13722. \hline
  13723. \end{longtable}\end{center}
  13724.  
  13725. To be exact, boolean symbols are just ordinary integer symbols with the
  13726. difference that \asname{} will assign only two different values to them (0 or 1,
  13727. corresponding to False or True).  \asname{} does not store special symbols
  13728. in the symbol table.  For performance reasons, they are realized with
  13729. hardcoded comparisons directly in the parser.  They therefore do not
  13730. show up in the assembly listing's symbol table.  Predefined symbols
  13731. are only set once at the beginning of a pass.  The values of dynamic
  13732. symbols may in contrast change during assembly as they reflect
  13733. settings made with related pseudo instructions.  The values added in
  13734. parentheses give the value present at the beginning of a pass.
  13735.  
  13736. The names given in this table also reflect the valid way to reference
  13737. these symbols in case-sensitive mode.
  13738.  
  13739. The names listed here should be avoided for own symbols; either one
  13740. can define but not access them (special symbols), or one will receive
  13741. an error message due to a double-defined symbol.  The ugliest case is
  13742. when the redefinition of a symbol made by \asname{} at the beginning of a
  13743. pass leads to a phase error and an infinite loop...
  13744.  
  13745. %%===========================================================================
  13746.  
  13747. \cleardoublepage
  13748. \chapter{Shipped Include Files}
  13749.  
  13750. The distribution of \asname{} contains a couple of include files.  Apart from
  13751. include files that only refer to a specific processor family (and whose
  13752. function should be immediately clear to someone who works with this
  13753. family), there are a few processor-independent files which include useful
  13754. functions.  The functions defined in these files shall be explained
  13755. briefly in the following sections:
  13756.  
  13757. \section{BITFUNCS.INC}
  13758.  
  13759. This file defines a couple of bit-oriented functions that might be
  13760. hardwired for other assemblers.  In the case of \asname{} however, thaey are
  13761. implemented with the help of user-defined functions:
  13762.  
  13763. \begin{itemize}
  13764. \item{{\em mask(start,bits)} returns an integer with {\em bits} bits set
  13765.      starting at position {\em start};}
  13766. \item{{\em invmask(start,bits)} returns one's complement to {\em
  13767.      mask()};}
  13768. \item{{\em cutout(x,start,bits)} returns {\em bits} bits masked out from
  13769.      {\em x} starting at position {\em start} without shifting them to
  13770.      position 0;}
  13771. \item{{\em hi(x)} returns the second lowest byte (bits 8..15) of {\em
  13772.      x};}
  13773. \item{{\em lo(x)} returns the lowest byte (bits 8..15) of {\em x};}
  13774. \item{{\em hiword(x)} returns the second lowest word (bits 16..31) of
  13775.      {\em x};}
  13776. \item{{\em loword(x)} returns the lowest word (bits 0..15) of {\em x};}
  13777. \item{{\em odd(x)} returns TRUE if {\em x} is odd;}
  13778. \item{{\em even(x)} returns TRUE if {\em x} is even;}
  13779. \item{{\em getbit(x,n)} extracts bit {\em n} out of {\em x} and returns
  13780.      it as 0 or 1;}
  13781. \item{{\em shln(x,size,n)} shifts a word {\em x} of length {\em size} to
  13782.      the left by {\em n} places;}
  13783. \item{{\em shrn(x,size,n)} shifts a word {\em x} of length {\em size} to
  13784.      the right by {\em n} places;}
  13785. \item{{\em rotln(x,size,n)} rotates the lowest {\em size} bits of an
  13786.      integer {\em x} to the left by {\em n} places;}
  13787. \item{{\em rotrn(x,size,n)} rotates the lowest {\em size} bits of an
  13788.      integer {\em x} to the right by {\em n} places;}
  13789. \end{itemize}
  13790.  
  13791. \section{CTYPE.INC}
  13792.  
  13793. This include file is similar to the C include file {\tt ctype.h} which
  13794. offers functions to classify characters.  All functions deliver either
  13795. TRUE or FALSE:
  13796.  
  13797. \begin{itemize}
  13798. \item{{\em isdigit(ch)} becomes TRUE if {\em ch} is a valid decimal
  13799.      digit (0..9);}
  13800. \item{{\em isxdigit(ch)} becomes TRUE if {\em ch} is a valid hexadecimal
  13801.      digit (0..9, A..F, a..f);}
  13802. \item{{\em isupper(ch)} becomes TRUE if {\em ch} is an uppercase
  13803.      letter, excluding special national characters);}
  13804. \item{{\em islower(ch)} becomes TRUE if {\em ch} is a lowercase
  13805.      letter, excluding special national characters);}
  13806. \item{{\em isalpha(ch)} becomes TRUE if {\em ch} is a letter, excluding
  13807.      special national characters);}
  13808. \item{{\em isalnum(ch)} becomes TRUE if {\em ch} is either a letter or
  13809.      a valid decimal digit;}
  13810. \item{{\em isspace(ch)} becomes TRUE if {\em ch} is an 'empty' character
  13811.      (space, form feed, line feed, carriage return, tabulator);}
  13812. \item{{\em isprint(ch)} becomes TRUE if {\em ch} is a printable character,
  13813.      i.e. no control character up to code 31;}
  13814. \item{{\em iscntrl(ch)} is the opposite to {\em isprint()};}
  13815. \item{{\em isgraph(ch)} becomes TRUE if {\em ch} is a printable and
  13816.      visible character;}
  13817. \item{{\em ispunct(ch)} becomes TRUE if {\em ch} is a printable special
  13818.      character (i.e. neither space nor letter nor number);}
  13819. \end{itemize}
  13820.  
  13821. %%===========================================================================
  13822.  
  13823. \cleardoublepage
  13824. \chapter{Acknowledgments}
  13825.  
  13826. \begin{quote}\it
  13827. ''If I have seen farther than other men, \\
  13828. it is because I stood on the shoulders of giants.'' \\
  13829. \hspace{2cm} --Sir Isaac Newton
  13830. \rm\end{quote}
  13831. \begin{quote}\it
  13832. ''If I haven't seen farther than other men, \\
  13833. it is because I stood in the footsteps of giants.'' \\
  13834. \hspace{2cm} --unknown
  13835. \rm\end{quote}
  13836. \par
  13837. There is a commaon saying that programs you write are like children
  13838. you put into the world.  It is now more than 30 years that I have been
  13839. working on this assembler, and I have come to the conclusion that such
  13840. a project is rather a journey for its author.  The people you meet
  13841. and learn to know on this journey are at least as important as the perceived
  13842. target itself.  Your learn a lot on this trip and in the best case, one
  13843. also understands that things can also be seen from a completely different
  13844. perspective.  If the discussions are fruitful, it is a win for both sides.
  13845. \par
  13846. While making this journey, some people have kept a special place in my
  13847. memories, because of the way they contributed to this project and to the
  13848. state it has now achieved.  The following enumeration of these people is
  13849. naturally incomplete, since my memories are not any more as good as they used
  13850. to be.  So the first 'thank you' goes to all the people I (accidentally)
  13851. omit in the following paragraphs.  The journey goes on, and maybe our
  13852. ways will be crossing again!
  13853. \par
  13854. The concept of \asname{} as a universal cross assembler came from Bernhard
  13855. (C.) Zschocke who needed a ''student friendly'', i.e. free cross
  13856. assembler for his microprocessor course and talked me into extending
  13857. an already existing 68000 assembler.  The rest is history...
  13858. The microprocessor course held at RWTH Aachen also always provided the
  13859. most engaged users (and bug-searchers) of new \asname{} features and
  13860. therefore contributed a lot to today's quality of \asname{}.
  13861.  
  13862. The Internet and FTP have proved to be a big help for spreading \asname{} and
  13863. reporting of bugs.  My thanks therefore go to the FTP admins (Bernd
  13864. Casimir in Stuttgart, Norbert Breidor in Aachen, and J\"urgen Mei\ss\-burger
  13865. in J\"ulich).  Especially the last one personally engaged a lot to
  13866. establish a practicable way in J\"ulich.
  13867.  
  13868. As we are just talking about the ZAM: Though Wolfgang E. Nagel never
  13869. involved personally into \asname{}, he however was my tutor and
  13870. boss.  He always had at least four eyes on what I was doing.
  13871. Regarding \asname{}, there seemed to be at least one that smiled...
  13872.  
  13873. A program like \asname{} cannot be done without appropriate data books and
  13874. documentation.  I received information from an enormous amount of
  13875. people, ranging from tips up to complete data books.  An enumeration
  13876. follows (as stated before, this is very probably incomplete!):
  13877.  
  13878. Ernst Ahlers, Charles Altmann, Marco Awater, Len Bayles,
  13879. Andreas Bolsch, Rolf Buchholz, Bernd Casimir, Nils Eilers,
  13880. Gunther Ewald, Michael Haardt, Stephan Hruschka,  Fred van Kempen,
  13881. Peter Kliegelh\"ofer, Ulf Meinke, Udo M\"oller, Matthias Paul,
  13882. Norbert Rosch, Curt J. Sampson, Steffen Schmid, Leonhard Schneider,
  13883. Ernst Schwab, Michael Schwingen, Oliver Sellke, Christian Stelter,
  13884. Patrik Str\"omdahl, Tadashi G. Takaoka, Oliver Thamm, Thorsten Thiele,
  13885. Leszek Ulman, Rob Warmelink, Andreas Wassatsch, John Weinrich.
  13886.  
  13887. ...and a somewhat ironic ''thank you'' to Rolf-Dieter-Klein and Tobias
  13888. Thiel, who gave me the initial impulse with their ASM68K.  Several things
  13889. did not work the way I wanted them to have, so I thought I could do
  13890. better or at least different.
  13891.  
  13892. And of course, I did not entirely write \asname{} on my own.  The DOS
  13893. version of \asname{} contained the OverXMS routines from Wilbert van
  13894. Leijen which can move the overlay modules into the extended memory.
  13895. A really nice library, easy to use without problems!
  13896.  
  13897. The TMS320C2x/5x code generators and the file \tty{STDDEF2x.INC} come
  13898. from Thomas Sailer, ETH Zurich.  It's surprising, he only needed one
  13899. weekend to understand my coding and to implement the new code
  13900. generator.  Either that was a long nightshift or I am slowly getting
  13901. old...the same praise goes to Haruo Asano for providing the
  13902. MN1610/MN1613, IM6100, CP1600, Renesas RX and HP NanoProcessor code
  13903. generators.
  13904.  
  13905. %%===========================================================================
  13906.  
  13907. \cleardoublepage
  13908. \chapter{Changes since Version 1.3}
  13909.  
  13910. \begin{itemize}
  13911. \item{version 1.31:
  13912.      \begin{itemize}
  13913.      \item{additional MCS-51 processor type 80515.  The number
  13914.            is again only stored by the assembler.  The file
  13915.            \tty{STDDEF51.INC} was extended by the necessary SFRs.
  13916.            \bb{CAUTION!} Some of the 80515 SFRs have moved to other
  13917.            addresses!}
  13918.      \item{additional support for the Z80 processor;}
  13919.      \item{faster 680x0 code generator.}
  13920.      \end{itemize}}
  13921. \item{version 1.32:
  13922.      \begin{itemize}
  13923.      \item{syntax for zero page addresses for the 65xx family
  13924.            was changed from \tty{addr.z} to \tty{$<$addr} (similar to 68xx);}
  13925.      \item{additional support for the 6800, 6805, 6301, and
  13926.            6811 processors;}
  13927.      \item{the 8051 part now also understands \tty{DJNZ, PUSH}, and
  13928.            \tty{POP} (sorry);}
  13929.      \item{the assembly listing now not also list the symbols
  13930.            but also the macros that have been defined;}
  13931.      \item{additional instructions \tty{IFDEF/IFNDEF} for conditional
  13932.            assembly based on the existence of a symbol;}
  13933.      \item{additional instructions \tty{PHASE/DEPHASE} to support code
  13934.            that shall be moved at runtime to a different address;}
  13935.      \item{additional instructions \tty{WARNING, ERROR}, and \tty{FATAL} to print
  13936.            user-defined error messages;}
  13937.      \item{the file \tty{STDDEF51.INC} additionally contains the macro
  13938.            \tty{USING} to simplify working with the MCS-51's register
  13939.            banks;}
  13940.      \item{command line option \tty{u} to print segment usage;}
  13941.      \end{itemize}}
  13942. \item{version 1.33:
  13943.      \begin{itemize}
  13944.      \item{additionally supports the 6809 processor;}
  13945.      \item{added string variables;}
  13946.      \item{The instructions \tty{TITLE, PRTINIT, PRTEXIT, ERROR},
  13947.            \tty{WARNING}, and \tty{FATAL} now expect a string expression.
  13948.            Constants therefore now have to be enclosed in
  13949.            '' instead of ' characters.  This is also true
  13950.            for \tty{DB}, \tty{DC.B}, and \tty{BYT};}
  13951.      \item{additional instruction \tty{ALIGN} to align the program
  13952.            counter for Intel processors;}
  13953.      \item{additional instruction \tty{LISTING} to turn the generation
  13954.            of an assembly listing on or off;}
  13955.      \item{additional instruction \tty{CHARSET} for user-defined
  13956.            character sets.}
  13957.      \end{itemize}}
  13958. \item{version 1.34:
  13959.      \begin{itemize}
  13960.      \item{the second pass is now omitted if there were errors
  13961.            in the first pass;}
  13962.      \item{additional predefined symbol \tty{VERSION} that contains
  13963.            the version number of \asname{};}
  13964.      \item{additional instruction \tty{MESSAGE} to generate additional
  13965.            messages under program control;}
  13966.      \item{formula parser is now accessible via string constants;}
  13967.      \item{if an error in a macro occurs, additionally the line
  13968.            number in the macro itself is shown;}
  13969.      \item{additional function \tty{UPSTRING} to convert a string to
  13970.            all upper-case.}
  13971.      \end{itemize}}
  13972. \item{version 1.35:
  13973.      \begin{itemize}
  13974.      \item{additional function \tty{TOUPPER} to convert a single
  13975.            character to upper case;}
  13976.      \item{additional instruction \tty{FUNCTION} for user-defined
  13977.            functions;}
  13978.      \item{additional command line option \tty{D} to define symbols
  13979.            from outside;}
  13980.      \item{the environment variable \tty{ASCMD} for commonly used
  13981.            command line options was introduced;}
  13982.      \item{the program will additionally be checked for double
  13983.            usage of memory areas if the u option is enabled;}
  13984.      \item{additional command line option \tty{C} to generate a cross
  13985.            reference list.}
  13986.      \end{itemize}}
  13987. \item{version 1.36:
  13988.      \begin{itemize}
  13989.      \item{additionally supports the PIC16C5x and PIC17C4x
  13990.            processor families;}
  13991.      \item{the assembly listing additionally shows the nesting
  13992.            depth of include files;}
  13993.      \item{the cross reference list additionally shows the
  13994.            definition point of a symbol;}
  13995.      \item{additional command line option \tty{A} to force a more
  13996.            compact layout of the symbol table.}
  13997.      \end{itemize}}
  13998. \item{version 1.37:
  13999.      \begin{itemize}
  14000.      \item{additionally supports the processors 8086, 80186,
  14001.            V30, V35, 8087, and Z180;}
  14002.      \item{additional instructions \tty{SAVE} and \tty{RESTORE} for an
  14003.            easier switching of some flags;}
  14004.      \item{additional operators for logical shifts and bit
  14005.            mirroring;}
  14006.      \item{command line options may now be negated with a
  14007.            plus sign;}
  14008.      \item{additional filter AS2MSG for a more comfortable
  14009.            work with \asname{} under Turbo-Pascal 7.0;}
  14010.      \item{\tty{ELSEIF} now may have an argument for construction
  14011.            of \tty{IF\--THEN\--ELSE} ladders;}
  14012.      \item{additional \tty{CASE} construct for a more comfortable
  14013.            conditional assembly;}
  14014.      \item{user-defined functions now may have more than one
  14015.            argument;}
  14016.      \item{P2HEX can now additionally generate hex files in
  14017.            a format suitable for 65xx processors;}
  14018.      \item{BIND, P2HEX, and P2BIN now have the same scheme
  14019.            for command line processing like \asname{};}
  14020.      \item{additional switch \tty{i} for P2HEX to select one out
  14021.            three possibilities for the termination record;}
  14022.      \item{additional functions \tty{ABS} and \tty{SGN};}
  14023.      \item{additional predefined symbols \tty{MOMFILE} and \tty{MOMLINE};}
  14024.      \item{additional option to print extended error messages;}
  14025.      \item{additional instruction \tty{IFUSED} and \tty{IFNUSED} to check
  14026.            whether a symbol has been used so far;}
  14027.      \item{The environment variables \tty{ASCMD, BINDCMD} etc. now
  14028.            optionally may contain the name of a file that
  14029.            provides more space for options;}
  14030.      \item{P2HEX can now generate the hex formats specified
  14031.            by Microchip (p4);}
  14032.      \item{a page length specification of 0 now allows to
  14033.            suppress automatic formfeeds in the assembly listing
  14034.            completely (p4);}
  14035.      \item{symbols defined in the command line now may be
  14036.            assigned an arbitrary value (p5).}
  14037.      \end{itemize}}
  14038. \item{version 1.38:
  14039.      \begin{itemize}
  14040.      \item{changed operation to multipass mode.  This enables
  14041.            \asname{} to generate optimal code even in case of forward
  14042.            references;}
  14043.      \item{the 8051 part now also knows the generic \tty{JMP} and
  14044.            \tty{CALL} instructions;}
  14045.      \item{additionally supports the Toshiba TLCS-900 series
  14046.            (p1);}
  14047.      \item{additional instruction \tty{ASSUME} to inform the assembler
  14048.            about the 8086's segment register contents (p2);}
  14049.      \item{additionally supports the ST6 series from
  14050.            SGS-Thomson (p2);}
  14051.      \item{..and the 3201x signal processors from Texas
  14052.            Instruments (p2);}
  14053.      \item{additional option \tty{F} for P2HEX to override the
  14054.            automatic format selection (p2);}
  14055.      \item{P2BIN now can automatically set the start resp.
  14056.            stop address of the address window by specifying
  14057.            dollar signs (p2);}
  14058.      \item{the 8048 code generator now also knows the 8041/42
  14059.            instruction extensions (p2);}
  14060.      \item{additionally supports the Z8 microcontrollers (p3).}
  14061.      \end{itemize}}
  14062. \item{version 1.39:
  14063.      \begin{itemize}
  14064.      \item{additional opportunity to define sections and local
  14065.            symbols;}
  14066.      \item{additional command line switch \tty{h} to force hexadecimal
  14067.            numbers to use lowercase;}
  14068.      \item{additional predefined symbol \tty{MOMPASS} to read the
  14069.            number of the currently running pass;}
  14070.      \item{additional command line switch \tty{t} to disable
  14071.            individual parts of the assembly listing;}
  14072.      \item{additionally knows the L variant of the TLCS-900
  14073.            series and the MELPS-7700 series from Mitsubishi
  14074.            (p1);}
  14075.      \item{P2HEX now also accepts dollar signs as start resp.
  14076.            stop address (p2);}
  14077.      \item{additionally supports the TLCS-90 family from
  14078.            Toshiba (p2);}
  14079.      \item{P2HEX now also can output data in Tektronix and
  14080.            16 bit Intel Hex format (p2);}
  14081.      \item{P2HEX now prints warnings for address overflows
  14082.            (p2);}
  14083.      \item{additional include file \tty{STDDEF96.INC} with address
  14084.            definitions for the TLCS-900 series (p3);}
  14085.      \item{additional instruction \tty{READ} to allow interactive
  14086.            input of values during assembly (p3);}
  14087.      \item{error messages are written to the STDERR channel
  14088.            instead of standard output (p3);}
  14089.      \item{the \tty{STOP} instruction missing for the 6811 is now
  14090.            available (scusi, p3);}
  14091.      \item{additionally supports the $\mu$PD78(C)1x family from
  14092.            NEC (p3);}
  14093.      \item{additionally supports the PIC16C84 from NEC (p3);}
  14094.      \item{additional command line switch \tty{E} to redirect error
  14095.            messages to a file (p3);}
  14096.      \item{The MELPS-7700's 'idol' 65816 is now also available
  14097.            (p4);}
  14098.      \item{the ST6 pseudo instruction \tty{ROMWIN} has been removed
  14099.            was integrated into the \tty{ASSUME} instruction (p4);}
  14100.      \item{additionally supports the 6804 from SGS-Thomson (p4);}
  14101.      \item{via the \tty{NOEXPORT} option in a macro definition, it is
  14102.            now possible to define individually for every macro
  14103.            whether it shall appear in the \tty{MAC} file or not (p4);}
  14104.      \item{the meaning of \tty{MACEXP} regarding the expansion of
  14105.            macros has changed slightly due to the additional
  14106.            \tty{NOEXPAND} option in the macro definition (p4);}
  14107.      \item{The additional \tty{GLOBAL} option in the macro definition
  14108.            now additionally allows to define macros that are
  14109.            uniquely identified by their section name (p4).}
  14110.      \end{itemize}}
  14111. \item{version 1.40:
  14112.      \begin{itemize}
  14113.      \item{additionally supports the DSP56000 from Motorola;}
  14114.      \item{P2BIN can now also extract the lower resp. upper
  14115.            half of a 32-bit word;}
  14116.      \item{additionally supports the TLCS-870 and TLCS-47
  14117.            families from Toshiba (p1);}
  14118.      \item{a prefixed \tty{!} now allows to reach machine instructions
  14119.            hidden by a macro (p1);}
  14120.      \item{the \tty{GLOBAL} instruction now allows to export symbols
  14121.            in a qualified style (p1);}
  14122.      \item{the additional \tty{r} command line switch now allows to
  14123.            print a list of constructs that forced additional
  14124.            passes (p1);}
  14125.      \item{it is now possible to omit an argument to the \tty{E}
  14126.            command line option; \asname{} will then choose a fitting
  14127.            default (p1);}
  14128.      \item{the \tty{t} command line option now allows to suppress
  14129.            line numbering in the assembly listing (p1);}
  14130.      \item{escape sequences may now also be used in ASCII style
  14131.            integer constants (p1);}
  14132.      \item{the additional pseudo instruction \tty{PADDING} now allows
  14133.            to enable or disable the insertion of padding bytes
  14134.            in 680x0 mode (p2);}
  14135.      \item{\tty{ALIGN} is now a valid instruction for all targets
  14136.            (p2);}
  14137.      \item{additionally knows the PIC16C64's SFRs (p2);}
  14138.      \item{additionally supports the 8096 from Intel (p2);}
  14139.      \item{\tty{DC} additionally allows to specify a repetition factor
  14140.            (r3);}
  14141.      \item{additionally supports the TMS320C2x family from Texas
  14142.            Instruments (implementation done by Thomas Sailer, ETH
  14143.            Zurich, r3); P2HEX has been extended appropriately;}
  14144.      \item{an equation sign may be used instead of \tty{EQU} (r3);}
  14145.      \item{additional \tty{ENUM} instruction to define enumerations
  14146.            (r3);}
  14147.      \item{\tty{END} now has a real effect (r3);}
  14148.      \item{additional command line switch \tty{n} to get the internal
  14149.            error numbers in addition to the error messages (r3);}
  14150.      \item{additionally supports the TLCS-9000 series from
  14151.            Toshiba (r4);}
  14152.      \item{additionally supports the TMS370xxx series from Texas
  14153.            Instruments, including a new \tty{DBIT} pseudo instruction
  14154.            (r5);}
  14155.      \item{additionally knows the DS80C320's SFR's (r5);}
  14156.      \item{the macro processor is now also able to include files
  14157.            from within macros.  This required to modify the
  14158.            format of error messages slightly.  If you use
  14159.            AS2MSG, replace it with the new version! (r5)}
  14160.      \item{additionally supports the 80C166 from Siemens (r5);}
  14161.      \item{additional \tty{VAL} function to evaluate string
  14162.            expressions (r5);}
  14163.      \item{it is now possible to construct symbol names with the
  14164.            help of string expressions enclosed in braces (r5);}
  14165.      \item{additionally knows the 80C167's peculiarities (r6);}
  14166.      \item{the MELPS740's special page addressing mode is now
  14167.            supported (r6);}
  14168.      \item{it is now possible to explicitly reference a symbol
  14169.            from a certain section by appending its name enclosed
  14170.            in brackets.  The construction with an \tty{@} sign has
  14171.            been removed! (r6)}
  14172.      \item{additionally supports the MELPS-4500 series from
  14173.            Mitsubishi (r7);}
  14174.      \item{additionally supports H8/300 and H8/300H series from
  14175.            Hitachi (r7);}
  14176.      \item{settings made with \tty{LISTING} resp. \tty{MACEXP} may now be
  14177.            read back from predefined symbols with the same names
  14178.            (r7);}
  14179.      \item{additionally supports the TMS320C3x series from Texas
  14180.            Instruments (r8);}
  14181.      \item{additionally supports the SH7000 from Hitachi (r8);}
  14182.      \item{the Z80 part has been extended to also support the
  14183.            Z380 (r9);}
  14184.      \item{the 68K part has been extended to know the
  14185.            differences of the 683xx micro controllers (r9);}
  14186.      \item{a label not any more has to be placed in the first
  14187.            row if it is marked with a double dot (r9);}
  14188.      \item{additionally supports the 75K0 series from NEC (r9);}
  14189.      \item{the additional command line option o allows to set
  14190.            a user-defined name for the code file (r9);}
  14191.      \item{the \verb!~~! operator has been moved to a bit more senseful
  14192.            ranking (r9);}
  14193.      \item{\tty{ASSUME} now also knows the 6809's DPR register and its
  14194.            implications (pardon, r9);}
  14195.      \item{the 6809 part now also knows the 6309's secret
  14196.            extensions (r9);}
  14197.      \item{binary constants now also may be written in a C-like
  14198.            notation (r9);}
  14199.      \end{itemize}}
  14200. \item{version 1.41:
  14201.      \begin{itemize}
  14202.      \item{the new predefined symbol \tty{MOMSEGMENT} allows to
  14203.            inquire the currently active segment;}
  14204.      \item{\tty{:=} is now allowed as a short form for \tty{SET/EVAL};}
  14205.      \item{the new command line switch \tty{q} allows to force a
  14206.            ''silent'' assembly;}
  14207.      \item{the key word \tty{PARENT} to reference the parent section
  14208.            has been extended by \tty{PARENT0..PARENT9};}
  14209.      \item{the PowerPC part has been extended by the
  14210.            microcontroller versions MPC505 and PPC403;}
  14211.      \item{symbols defined with \tty{SET} or \tty{EQU} may now be assigned
  14212.            to a certain segment (r1);}
  14213.      \item{the SH7000 part now also knows the SH7600's
  14214.            extensions (and should compute correct
  14215.            displacements...) (r1);}
  14216.      \item{the 65XX part now differentiates between the 65C02
  14217.            and 65SC02 (r1);}
  14218.      \item{additionally to the symbol \tty{MOMCPU}, there is now also
  14219.            a string symbol \tty{MOMCPUNAME} that contains the
  14220.            processor's full name (r1);}
  14221.      \item{P2HEX now also knows the 32-bit variant of the Intel
  14222.            hex format (r1);}
  14223.      \item{additionally knows the 87C750's limitations (r2);}
  14224.      \item{the internal numbers for fatal errors have been moved
  14225.            to the area starting at 10000, making more space for
  14226.            normal error messages (r2);}
  14227.      \item{unused symbols are now marked with a star in the
  14228.            symbol table (r2);}
  14229.      \item{additionally supports the 29K family from AMD (r2);}
  14230.      \item{additionally supports the M16 family from Mitsubishi
  14231.            (r2);}
  14232.      \item{additionally supports the H8/500 family from Hitachi
  14233.            (r3);}
  14234.      \item{the number of data bytes printed per line by P2HEX
  14235.            can now be modified (r3);}
  14236.      \item{the number of the pass that starts to output warnings
  14237.            created by the \tty{r} command line switch is now variable
  14238.            (r3);}
  14239.      \item{the macro processor now knows a \tty{WHILE} statement that
  14240.            allows to repeat a piece of code a variable number of
  14241.            times (r3);}
  14242.      \item{the \tty{PAGE} instruction now also allows to set the line
  14243.            with of the assembly listing (r3);}
  14244.      \item{CPU aliases may now be defined to define new pseudo
  14245.            processor devices (r3);}
  14246.      \item{additionally supports the MCS/251 family from Intel
  14247.            (r3);}
  14248.      \item{if the cross reference list has been enabled, the
  14249.            place of the first definition is given for double
  14250.            definitions of symbols (r3);}
  14251.      \item{additionally supports the TMS320C5x family from Texas
  14252.            Instruments (implementation done by Thomas Sailer,
  14253.            ETH Zurich, r3);}
  14254.      \item{the OS/2 version should now also correctly work with
  14255.            long file names.  If one doesn't check every s**t
  14256.            personally... (r3);}
  14257.      \item{the new pseudo instruction \tty{BIGENDIAN} now allows to
  14258.            select in MCS-51/251 mode whether constants should
  14259.            be stored in big endian or little endian format (r3);}
  14260.      \item{the 680x0 part now differentiates between the full
  14261.            and reduced MMU instruction set; a manual toggle can
  14262.            be done via the \tty{FULLPMMU} instruction (r3);}
  14263.      \item{the new command line option \tty{I} allows to print a list
  14264.            of all include files paired with their nesting level
  14265.            (r3);}
  14266.      \item{additionally supports the 68HC16 family from Motorola
  14267.            (r3);}
  14268.      \item{the \tty{END} statement now optionally accepts an argument
  14269.            as entry point for the program (r3);}
  14270.      \item{P2BIN and P2HEX now allow to move the contents of a
  14271.            code file to a different address (r4);}
  14272.      \item{comments appended to a \tty{SHARED} instruction are now
  14273.            copied to the share file (r4);}
  14274.      \item{additionally supports the 68HC12 family from Motorola
  14275.            (r4);}
  14276.      \item{additionally supports the XA family from Philips
  14277.            (r4);}
  14278.      \item{additionally supports the 68HC08 family from Motorola
  14279.            (r4);}
  14280.      \item{additionally supports the AVR family from Atmel (r4);}
  14281.      \item{to achieve better compatibility to the AS11 from
  14282.            Motorola, the pseudo instructions \tty{FCB, FDB, FCC}, and
  14283.            \tty{RMB} were added (r5);}
  14284.      \item{additionally supports the M16C from Mitsubishi (r5);}
  14285.      \item{additionally supports the COP8 from National
  14286.            Semiconductor (r5);}
  14287.      \item{additional instructions \tty{IFB} and \tty{IFNB} for conditional
  14288.            assembly (r5);}
  14289.      \item{the new \tty{EXITM} instruction now allows to terminate a
  14290.            macro expansion (r5);}
  14291.      \item{additionally supports the MSP430 from Texas
  14292.            Instruments (r5);}
  14293.      \item{\tty{LISTING} now knows the additional variants
  14294.            \tty{NOSKIPPED} and \tty{PURECODE} to remove code that
  14295.            was not assembled from the listing (r5);}
  14296.      \item{additionally supports the 78K0 family from NEC (r5);}
  14297.      \item{\tty{BIGENDIAN} is now also available in PowerPC mode
  14298.            (r5);}
  14299.      \item{additional \tty{BINCLUDE} instruction to include binary
  14300.            files (r5);}
  14301.      \item{additional \tty{TOLOWER} and \tty{LOWSTRING} functions to convert
  14302.            characters to lower case (r5);}
  14303.      \item{it is now possible to store data in other segments
  14304.            than \tty{CODE}.  The file format has been extended
  14305.            appropriately (r5);}
  14306.      \item{the \tty{DS} instruction to reserve memory areas is now
  14307.            also available in Intel mode (r5);}
  14308.      \item{the \tty{U} command line switch now allows to switch \asname{}
  14309.            into a case sensitive mode that differentiates
  14310.            between upper and lower case in the names of symbols,
  14311.            user-defined functions, macros, macro parameters, and
  14312.            sections (r5);}
  14313.      \item{\tty{SFRB} now also knows the mapping rules for bit
  14314.            addresses in the RAM areas; warnings are generated
  14315.            for addresses that are not bit addressable (r5);}
  14316.      \item{additional instructions \tty{PUSHV} and \tty{POPV} to save symbol
  14317.            values temporarily (r5);}
  14318.      \item{additional functions \tty{BITCNT, FIRSTBIT, LASTBIT}, and
  14319.            \tty{BITPOS} for bit processing (r5);}
  14320.      \item{the 68360 is now also known as a member of the CPU32
  14321.            processors (r5);}
  14322.      \item{additionally supports the ST9 family from SGS-Thomson
  14323.            (r6);}
  14324.      \item{additionally supports the SC/MP from National
  14325.            Semiconductor (r6);}
  14326.      \item{additionally supports the TMS70Cxx family from Texas
  14327.            Instruments (r6);}
  14328.      \item{additionally supports the TMS9900 family from Texas
  14329.            Instruments (r6);}
  14330.      \item{additionally knows the 80296's instruction set
  14331.            extensions (r6);}
  14332.      \item{the supported number of Z8 derivatives has been
  14333.            extended (r6);}
  14334.      \item{additionally knows the 80C504's mask defects (r6);}
  14335.      \item{additional register definition file for Siemens' C50x
  14336.            processors (r6);}
  14337.      \item{additionally supports the ST7 family from SGS-Thomson
  14338.            (r6);}
  14339.      \item{the Tntel pseudo instructions for data disposal are
  14340.            now also valid for the 65816/MELPS-7700 (r6);}
  14341.      \item{for the 65816/MELPS-7700, the address length may now
  14342.            be set explicitly via prefixes (r6);}
  14343.      \item{additionally supports the 8X30x family from Signetics
  14344.            (r6);}
  14345.      \item{from now on, \tty{PADDING} is enabled by default only
  14346.            for the 680x0 family (r7);}
  14347.      \item{the new predefined symbol \tty{ARCHITECTURE} can now be
  14348.            used to query the platform \asname{} was compiled for (r7);}
  14349.      \item{additional statements \tty{STRUCT} and \tty{ENDSTRUCT}
  14350.            to define data structures (r7);}
  14351.      \item{hex and object files for the AVR tools may now be generated
  14352.            directly (r7);}
  14353.      \item{\tty{MOVEC} now also knows the 68040's control registers
  14354.            (r7);}
  14355.      \item{additional \tty{STRLEN} function to calculate the length
  14356.            of a string (r7);}
  14357.      \item{additional ability to define register symbols (r7 currently
  14358.            only Atmel AVR);}
  14359.      \item{additionally knows the 6502's undocumented instructions (r7);}
  14360.      \item{P2HEX and P2BIN now optionally can erase the input files
  14361.            automatically (r7);}
  14362.      \item{P2BIN can additionally prepend the entry address to the
  14363.            resulting image (r7);}
  14364.      \item{additionally supports the ColdFire family from Motorola as a
  14365.            variation of the 680x0 core (r7);}
  14366.      \item{\tty{BYT/FCB, ADR/FDB}, and \tty{FCC} now also allow the
  14367.            repetition factor known from DC (r7);}
  14368.      \item{additionally supports Motorola's M*Core (r7);}
  14369.      \item{the SH7000 part now also knows the SH7700's
  14370.            extensions (r7);}
  14371.      \item{the 680x0 part now also knows the 68040's additional
  14372.            instructions (r7);}
  14373.      \item{the 56K part now also knows the instruction set extensions
  14374.            up to the 56300 (r7).}
  14375.      \item{the new \tty{CODEPAGE} statement now allows to keep several
  14376.            character sets in parallel (r8);}
  14377.      \item{The argument variations for \tty{CHARSET} have been extended
  14378.            (r8);}
  14379.      \item{New string functions \tty{SUBSTR} and \tty{STRSTR} (r8);}
  14380.      \item{additional \tty{IRPC} statement in the macro processor (r8);}
  14381.      \item{additional \tty{RADIX} statement to set the default numbering
  14382.            system for integer constants (r8);}
  14383.      \item{instead of {\tt ELSEIF}, it is now valid to simply write {\tt
  14384.            ELSE} (r8);}
  14385.      \item{$==$ may be used as equality operator instead of $=$ (r8);}
  14386.      \item{\tty{BRANCHEXT} for the Philips XA now allows to automatically
  14387.            extend the reach of short branches (r8);}
  14388.      \item{debug output is now also possible in NoICE format (r8);}
  14389.      \item{additionally supports the i960 family from Intel (r8);}
  14390.      \item{additionally supports the $\mu$PD7720/7725 signal processors
  14391.            from NEC (r8);}
  14392.      \item{additionally supports the $\mu$PD77230 signal processor from
  14393.            NEC (r8);}
  14394.      \item{additionally supports the SYM53C8xx SCSI processors from
  14395.            Symbios Logic (r8);}
  14396.      \item{additionally supports the 4004 from Intel (r8);}
  14397.      \item{additionally supports the SC14xxx series of National (r8);}
  14398.      \item{additionally supports the instruction extensions of the PPC
  14399.            403GC (r8);}
  14400.      \item{additional command line option {\tt cpu} to set the default
  14401.            target processor (r8);}
  14402.      \item{key files now also may be referenced from the command line
  14403.            (r8);}
  14404.      \item{additional command line option {\tt shareout} to set the
  14405.            output file for SHARED definitions (r8);}
  14406.      \item{new statement {\tt WRAPMODE} to support AVR processors with
  14407.            a shortened program counter (r8);}
  14408.      \item{additionally supports the C20x instruction subset in the C5x
  14409.            part (r8);}
  14410.      \item{hexadecimal address specifications for the tools now may also
  14411.            be made in C notation (r8);}
  14412.      \item{the numbering system for integer results in \verb!\{...}!
  14413.            expressions is now configurable via \tty{OUTRADIX} (r8);}
  14414.      \item{the register syntax for 4004 register pairs has been corrected
  14415.            (r8);}
  14416.      \item{additionally supports the F$^{2}$MC8L family from Fujitsu
  14417.            (r8);}
  14418.      \item{P2HEX now allows to set the minimum address length for S
  14419.            record addresses (r8);}
  14420.      \item{additionally supports the ACE family from Fairchild (r8);}
  14421.      \item{{\tt REG} is now also allowed for PowerPCs (r8);}
  14422.      \item{additional switch in P2HEX to relocate all addresses (r8);}
  14423.      \item{The switch \tty{x} now additionally allows a second level
  14424.            of detailness to print the source line in question (r8).}
  14425.      \end{itemize}}
  14426. \item{version 1.42:
  14427.      \begin{itemize}
  14428.      \item{the default integer syntax for Atmel AVR is now the C Syntax;}
  14429.      \item{additional command line option {\tt olist} to set the
  14430.            list file's name and location;}
  14431.      \item{additionally supports the F$^{2}$MC16L family from Fujitsu;}
  14432.      \item{additional instruction {\tt PACKING} for the AVR family;}
  14433.      \item{additional implicit macro parameters {\tt ALLARGS} and
  14434.            {\tt ARGCOUNT};}
  14435.      \item{additional instruction {\tt SHIFT} to process variable macro
  14436.            argument lists;}
  14437.      \item{support for temporary symbols;}
  14438.      \item{additional instruction {\tt MAXNEST} to set the maximum
  14439.            nesting depth of macro expansions;}
  14440.      \item{additional command line argument {\tt noicemask} to control
  14441.            the amount of segments listed in a NoICE debug info file;}
  14442.      \item{additionally supports the 180x family from Intersil;}
  14443.      \item{additionally supports the 68HC11K4 address windowing;}
  14444.      \item{P2HEX now allows to vary the address field length of AVR HEX
  14445.            files;}
  14446.      \item{the new command line option {\tt -gnuerrors} allows to output
  14447.            error messages in a GNU C-style format;}
  14448.      \item{additionally supports the TMS320C54x family from Texas
  14449.            Instruments;}
  14450.      \item{new macro option {\tt INTLABEL};}
  14451.      \item{added Atmel MegaAVR 8/16 instructions and register
  14452.            definitions;}
  14453.      \item{{\tt ENDIF/ENDCASE} show the line number of the corresponding
  14454.            opening statement in the listing;}
  14455.      \item{the 8051 part now also supports the extended address space of
  14456.            the Dallas DS80C390;}
  14457.      \item{added nameless temporary smbols;}
  14458.      \item{additionally supports the undocumented 8085 instructions;}
  14459.      \item{improved structure handling;}
  14460.      \item{added EXPRTYPE() function;}
  14461.      \item{allow line continuation;}
  14462.      \item{integrated support for KCPSM/PicoBlaze provided by Andreas
  14463.            Wassatsch;}
  14464.      \item{additionally supports the 807x family from National
  14465.            Semiconductor;}
  14466.      \item{additionally supports the Intel 4040;}
  14467.      \item{additionally supports the Zilog eZ8;}
  14468.      \item{additionally supports the 78K2 family from NEC;}
  14469.      \item{additionally supports the KCPSM3 variant from Xilinx;}
  14470.      \item{additionally supports the LatticeMico8;}
  14471.      \item{additionally supports the 12X instruction extensions and the
  14472.            XGATE core of the 68HC12 family;}
  14473.      \item{additionally supports the Signetics 2650;}
  14474.      \item{additionally supports the COP4 family from National
  14475.            Semiconductor;}
  14476.      \item{additionally supports the HCS08 extensions by Freesacle;}
  14477.      \item{additionally supports the RS08 family by Freescale;}
  14478.      \item{additionally supports the Intel 8008;}
  14479.      \item{add another optional syntax for integer constants;}
  14480.      \item{added function \tty{CHARFROMSTR};}
  14481.      \item{additionally allow Q for octal constants in Intel mode;}
  14482.      \item{add another variant for temporary symbols;}
  14483.      \item{the PowerPC part has been extended by the MPC821
  14484.            (contribution by Marcin Cieslak);}
  14485.      \item{implicit macro parameters are always case-insensitive;}
  14486.      \item{add \tty{REG} statement to MSP430;}
  14487.      \item{additionally supports the XMOS XS1;}
  14488.      \item{additional parameters \tty{GLOBALSYMBOLS} and
  14489.            \tty{NOGLOBALSYMBOLS} to control whether labels in
  14490.            macros are local or not;}
  14491.      \item{additionally supports the NEC 75xx series;}
  14492.      \item{additionally supports the TMS1000 controllers from
  14493.            TI;}
  14494.      \item{additionally supports the 78K2 family from NEC;}
  14495.      \item{all newer changes are only documented in the separate
  14496.            changelog file.}
  14497.      \end{itemize}}
  14498. \end{itemize}
  14499.  
  14500. %%===========================================================================
  14501.  
  14502. \cleardoublepage
  14503. \chapter{Hints for the \asname{} Source Code}
  14504. \label{ChapSource}
  14505.  
  14506. As I already mentioned in the introduction, I release the source code of
  14507. \asname{} on request.  The following shall give a few hints to their usage.
  14508.  
  14509. %%---------------------------------------------------------------------------
  14510.  
  14511. \section{Language Preliminaries}
  14512.  
  14513. In the beginning, \asname{} was a program written in Turbo-Pascal.  This was
  14514. roughly at the end of the eighties, and there were a couple of reasons for
  14515. this choice: First, I was much more used to it than to any C compiler, and
  14516. compared to Turbo Pascal's IDE, all DOS-based C compilers were just
  14517. crawling along.  In the beginning of 1997 however, it became clear that
  14518. things had changed: One factor was that Borland had decided to let its
  14519. confident DOS developers down (once again, explicitly no 'thank you', you
  14520. boneheads from Borland!) and replaced version 7.0 of Borland Pascal with
  14521. something called 'Delphi', which is probably a wonderful tool to develop
  14522. Windows programs which consist of 90\% user interface and accidentaly a
  14523. little bit of content, however completely useless for command-line driven
  14524. programs like \asname{}.  Furthermore, my focus of operating systems had made a
  14525. clear move towards Unix, and I probably could have waited arbitrarily long
  14526. for a Borland Pascal for Linux (to all those remarking now that Borland
  14527. would be working on something like that: this is {\em Vapourware}, don\'t
  14528. believe them anything until you can go into a shop and actually buy it!).
  14529. It was therefore clear that C was the way to go.
  14530.  
  14531. After this eperience what results the usage of 'island systems' may have,
  14532. I put a big emphasize on portability while doing the translation to C;
  14533. however, since \asname{} for example deals with binary data in an exactly format
  14534. and uses operating systen-specific functions at some places which may need
  14535. adaptions when one compliles \asname{} the first time for a new platform.
  14536.  
  14537. \asname{} is tailored for a C compiler that conforms to the ANSI C standard; C++
  14538. is explicitly not required.  If you are still using a compiler conforming
  14539. to the outdated Kernighan\&Ritchie standard, you should consider getting a
  14540. newer compiler: The ANSI C standard has been fixed in 1989 and there
  14541. should be an ANSI C compiler for every contemporary platform, maybe by
  14542. using the old compiler to build GNU-C.  Though there are some switches in
  14543. the source code to bring it nearer to K\&R, this is not an officially
  14544. supported feature which I only use internally to support a quite antique
  14545. Unix.  Everything left to say about K\&R is located in the file {\tt
  14546. README.KR}.
  14547.  
  14548. The inclusion of some additional features not present in the Pascal
  14549. version (e.g. dynamically loadable message files, test suite, automatic
  14550. generation of the documentation from {\em one} source format) has made the
  14551. source tree substantially more complicated.  I will attempt to unwire
  14552. everything step by step:
  14553.  
  14554. %%---------------------------------------------------------------------------
  14555.  
  14556. \section{Capsuling System dependencies}
  14557.  
  14558. As I already mentioned, As has been tailored to provide maximum platform
  14559. independence and portability (at least I believe so...).  This means
  14560. packing all platform dependencies into as few files as possible.  I will
  14561. describe these files now, and this section is the first one because it is
  14562. probably one of the most important:
  14563.  
  14564. The Build of all components of \asname{} takes place via a central {\tt
  14565. Makefile}.  To make it work, it has to be accompanied by a fitting {\tt
  14566. Makefile.def} that gives the platform dependent settings like compiler
  14567. flags.  The subdirectory {\tt Makefile.def-samples} contains a couple of
  14568. includes that work for widespread platforms (but which need not be
  14569. optimal...).  In case your platform is not among them, you may take the
  14570. file {\tt Makefile.def.tmpl} as a starting point (and send me the
  14571. result!).
  14572.  
  14573. A further component to capure system dependencies is the file {\tt
  14574. sysdefs.h}.  Practically all compilers predefine a couple of preprocessor
  14575. symbols that describe the target processor and the used operating system.
  14576. For example, on a Sun Sparc under Solaris equipped with the GNU compiler,
  14577. the symbols \verb!__sparc! and \verb!__SVR4!.  {\tt sysdefs.h} exploits
  14578. these symbols to provide a homogeneous environment for the remaining,
  14579. system-independent files.  Especially, this covers integer datatypes of a
  14580. specific length, but it may also include the (re)definition of C functions
  14581. which are not present or non-standard-like on a specific platform.  It's
  14582. best to read this files yourself if you like to know which things may
  14583. occur...  Generally, the \verb!#ifdef! statement are ordered in two
  14584. levels: First, a specific processor platform is selected, the the
  14585. operating systems are sorted out in such a section.
  14586.  
  14587. If you port \asname{} to a new platform, you have to find two symbols typical for
  14588. this platform and extend {\tt sysdefs.h} accordingly.  Once again, I'm
  14589. interested in the result...
  14590.  
  14591. %%---------------------------------------------------------------------------
  14592.  
  14593. \section{System-Independent Files}
  14594.  
  14595. ...represent the largest part of all modules.  Describing all functions in
  14596. detail is beyond the scope of this description (those who want to know
  14597. more probably start studying the sources, my programming style isn't that
  14598. horrible either...), which is why I can only give a short list at this
  14599. place with all modules their function:
  14600.  
  14601. \subsection{Modules Used by \asname{}}
  14602.  
  14603. \subsubsection{as.c}
  14604.  
  14605. This file is \asname{}'s root: it contains the {\em main()} function of \asname{}, the
  14606. processing of all command line options, the overall control of all passes
  14607. and parts of the macro processor.
  14608.  
  14609. \subsubsection{asmallg.c}
  14610.  
  14611. This module processes all statements defined for all processor targets,
  14612. e.g. \tty{EQU} and \tty{ORG}.  The \tty{CPU} pseudo-op used to switch
  14613. among different processor targets is also located here.
  14614.  
  14615. \subsubsection{asmcode.c}
  14616.  
  14617. This module contains the bookkeping needed for the code output file.  It
  14618. exports an interface that allows to open and close a code file and offers
  14619. functions to write code to (or take it back from) the file.  An important
  14620. job of this module is to buffer the write process, which speeds up
  14621. execution by writing the code in larger blocks.
  14622.  
  14623. \subsubsection{asmdebug.c}
  14624.  
  14625. \asname{} can optionally generate debug information for other tools like
  14626. simulators or debuggers, allowing a backward reference to the source code.
  14627. They get collected in this module and can be output after assembly in one
  14628. of several formats.
  14629.  
  14630. \subsubsection{asmdef.c}
  14631.  
  14632. This modules only contains declarations of constants used in different
  14633. places and global variables.
  14634.  
  14635. \subsubsection{asmfnums.c}
  14636.  
  14637. \asname{} assigns internally assigns incrementing numbers for each used source
  14638. file.  These numbers are used for quick referencing.  Assignment of
  14639. numbers and the conversion between names and numbers takes place here.
  14640.  
  14641. \subsubsection{asmif.c}
  14642.  
  14643. Here ara ll routines located controlling conditional assembly.  The most
  14644. important exported variable is a flag called \tty{IfAsm} which controls
  14645. whether code generation is currently turned on or off.
  14646.  
  14647. \subsubsection{asminclist.c}
  14648.  
  14649. This module holds the definition of the list stucture that allows \asname{} to
  14650. print the nesting of include files to the assembly list file.
  14651.  
  14652. \subsubsection{asmitree.c}
  14653.  
  14654. When searching for the mnemonic used in a line of code, a simple linear
  14655. comparison with all available machine instructions (as it is still done in
  14656. most code generators, for reasons of simplicity and laziness) is not
  14657. necessary the most effective method.  This module defines two improved
  14658. structures (binary tree and hash table) which provide a more efficient
  14659. search and are destined to replace the simple linear search on a
  14660. step-by-step basis...priorities as needed...
  14661.  
  14662. \subsubsection{asmmac.c}
  14663.  
  14664. Routines to store and execute macro constructs are located in this module.
  14665. The real macro processor is (as already mentioned) in {\tt as.c}.
  14666.  
  14667. \subsubsection{asmpars.c}
  14668.  
  14669. Here we really go into the innards: This module stores the symbol tables
  14670. (global and local) in two binary trees.  Further more, there is a quite
  14671. large procedure {\tt EvalExpression} which analyzes and evaluates a (formula)
  14672. expression.  The procedure returns the result (integer, floating point, or
  14673. string) in a varaint record.  However, to evaluate expressions during code
  14674. generation, one should better use the functions  \tty{EvalIntExpression,
  14675. EvalFloatExpression}, and \tty{EvalStringExpression}.  Modifications for
  14676. tha esake of adding new target processors are unnecessary in this modules
  14677. and should be done with extreme care, since you are touching something
  14678. like '\asname{}'s roots'.
  14679.  
  14680. \subsubsection{asmsub.c}
  14681.  
  14682. This module collects a couple of commonly used subroutines which primarily
  14683. deal with error handling and 'advanced' string processing.
  14684.  
  14685. \subsubsection{bpemu.c}
  14686.  
  14687. As already mentioned at the beginning, \asname{} originally was a program written
  14688. in Borland Pascal.  For some intrinsic functions of the compiler, it was
  14689. simpler to emulate those than to touch all places in the source code where
  14690. they are used.  Well...
  14691.  
  14692. \subsubsection{chunks.c}
  14693.  
  14694. This module defines a data type to deal with a list of address ranges.
  14695. This functionality is needed by \asname{} for allocation lists; furthermore,
  14696. P2BIN and P2HEX use such lists to warn about overlaps.
  14697.  
  14698. \subsubsection{cmdarg.c}
  14699.  
  14700. This module implements the overall mechanism of command line arguments.
  14701. It needs a specification of allowed arguments, splits the command line and
  14702. triggers the appropriate callbacks.   In detail, the mechanism includes
  14703. the following:
  14704. \begin{itemize}
  14705. \item{Processing of arguments located in an environment variable or
  14706.      a corresponding file;}
  14707. \item{Return of a set describing which command line arguments have not
  14708.      been processed;}
  14709. \item{A backdoor for situations when an overlaying IDE converts the passed
  14710.      command line completely into upper or lower case.}
  14711. \end{itemize}
  14712.  
  14713. \subsubsection{codepseudo.c}
  14714.  
  14715. You will find at this place pseudo instructions that are used by
  14716. a subset of code generators.  On the one hand, this is the Intel group of
  14717. \tty{DB..DT}, and on the other hand their counterparts for 8/16 bit CPUs
  14718. from Motorola or Rockwell.  Someone who wants to extend \asname{} by a
  14719. processor fitting into one of these groups can get the biggest part
  14720. of the necessary pseudo instructions with one call to this module.
  14721.  
  14722. \subsubsection{codevars.c}
  14723.  
  14724. For reasons of memory efficiency, some variables commonly used by diverse
  14725. code generators.
  14726.  
  14727. \subsubsection{endian.c}
  14728.  
  14729. Yet another bit of machine dependence, however one you do not have to
  14730. spend attention on: This module automatically checks at startup whether
  14731. a host machine is little or big endian.  Furthermore, checks are made if
  14732. the type definitions made for integer variables in {\tt sysdefs.h} really
  14733. result in the correct lengths.
  14734.  
  14735. \subsubsection{headids.c}
  14736.  
  14737. At this place, all processor families supported by \asname{} are collected with
  14738. their header IDs (see chapter \ref{SectCodeFormat}) and the output format
  14739. to be used by default by P2HEX.  The target of this table is to centralize
  14740. the addition of a new processor as most as possible, i.e. in contrast to
  14741. earlier versions of \asname{}, no further modifications of tool sources are
  14742. necessary.
  14743.  
  14744. \subsubsection{ioerrs.c}
  14745.  
  14746. The conversion from error numbers to clear text messages is located here.
  14747. I hope I'll never hit a system that does not define the numbers as macros,
  14748. because I would have to rewrite this module completely...
  14749.  
  14750. \subsubsection{nlmessages.c}
  14751.  
  14752. The C version of \asname{} reads all messages from files at runtime after the
  14753. language to be used is clear.  The format of message files is not a simple
  14754. one, but instead a special compact and preindexed format that is generated
  14755. at runtime by a program called 'rescomp' (we will talk about it later).
  14756. This module is the counterpart to rescomp that reads the correct language
  14757. part into a character field and offers functions to access the messages.
  14758.  
  14759. \subsubsection{nls.c}
  14760.  
  14761. This module checks which country-dependent settings (date and time format,
  14762. country code) are present at runtime.  Unfortunately, this is a highly
  14763. operating system-dependend task, and currently, there are only three
  14764. methods defines: The MS-DOS method, the OS/2 method and the typical Unix
  14765. method via {\em locale} functions.  For all other systems, there is
  14766. unfortunately currently only \verb!NO_NLS! available...
  14767.  
  14768. \subsubsection{stdhandl.c}
  14769.  
  14770. On the one hand, here is a special open function located knowing the
  14771. special strings {\tt !0...!2} as file names and creating duplicates of the
  14772. standard file handles {\em stdin, stdout,} and {\em stderr}.  On the other
  14773. hand, investiagations are done whether the standard output has been
  14774. redirected to a device or a file.  On no-Unix systems, this unfortunately
  14775. also incorporates some special operations.
  14776.  
  14777. \subsubsection{stringlists.c}
  14778.  
  14779. This is just a little 'hack' that defines routines to deal with linear
  14780. lists of strings, which are needed e.g. in the macro processor of \asname{}.
  14781.  
  14782. \subsubsection{strutil.c}
  14783.  
  14784. Some commonly needed string operations have found their home here.
  14785.  
  14786. \subsubsection{version.c}
  14787.  
  14788. The currently valid version is centrally stored here for \asname{} and all other
  14789. tools.
  14790.  
  14791. \subsubsection{code????.c}
  14792.  
  14793. These modules form the main part of \asname{}: each module contains the code
  14794. generator for a specific processor family.
  14795.  
  14796. \subsection{Additional Modules for the Tools}
  14797.  
  14798. \subsubsection{hex.c}
  14799.  
  14800. A small module to convert integer numbers to hexadecimal strings.  It's
  14801. not absolutely needed in C any more (except for the conversion of {\em
  14802. long long} variables, which unfortunately not all {\tt printf()}'s
  14803. support), but it somehow survived the porting from Pascal to C.
  14804.  
  14805. \subsubsection{p2bin.c}
  14806.  
  14807. The sources of P2BIN.
  14808.  
  14809. \subsubsection{p2hex.c}
  14810.  
  14811. The sources of P2HEX.
  14812.  
  14813. \subsubsection{pbind.c}
  14814.  
  14815. The sources of BIND.
  14816.  
  14817. \subsubsection{plist.c}
  14818.  
  14819. The sources of PLIST.
  14820.  
  14821. \subsubsection{toolutils.c}
  14822.  
  14823. All subroutines needed by several tools are collected here, e.g. for
  14824. reading of code files.
  14825.  
  14826. \section{Modules Needed During the Build of \asname{}}
  14827.  
  14828. \subsubsection{a2k.c}
  14829.  
  14830. This is a minimal filter converting ANSI C source files to
  14831. Kernighan-Ritchie style.  To be exact: only function heads are converted,
  14832. even this only when they are roughly formatted like my programming style.
  14833. Noone should therefore think this were a universal C parser!
  14834.  
  14835. \subsubsection{addcr.c}
  14836.  
  14837. A small filter needed during installation on DOS- or OS/2-systems.  Since
  14838. DOS and OS/2 use a CR/LF for a newline, inc ontrast to the single LF of
  14839. Unix systems, all assembly include files provided with \asname{} are sent through
  14840. this filter during assembly.
  14841.  
  14842. \subsubsection{bincmp.c}
  14843.  
  14844. For DOS and OS/2, this module takes the task of the {\em cmp} command,
  14845. i.e. the binary comparison of files during the test run.  While this would
  14846. principally be possible with the {\em comp} command provided with the OS,
  14847. {\em bincmp} does not have any nasty interactive questions (which seem to
  14848. be an adventure to get rid of...)
  14849.  
  14850. \subsubsection{findhyphen.c}
  14851.  
  14852. This is the submodule in {\em tex2doc} providing hyphenation of words.
  14853. The algorithm used for this is shamelessly stolen from TeX.
  14854.  
  14855. \subsubsection{grhyph.c}
  14856.  
  14857. The definition of hyphenation rules for the german language.
  14858.  
  14859. \subsubsection{rescomp.c}
  14860.  
  14861. This is \asname{}'s 'resource compiler', i.e. the tool that converts a readable
  14862. file with string resources into a fast, indexed format.
  14863.  
  14864. \subsubsection{tex2doc.c}
  14865.  
  14866. A tool that converts the LaTeX documentation of \asname{} into an ASCII format.
  14867.  
  14868. \subsubsection{tex2html.c}
  14869.  
  14870. A tool that converts the LaTeX documentation of \asname{} into an HTML document.
  14871.  
  14872. \subsubsection{umlaut.c and unumlaut.c}
  14873.  
  14874. These tiny programs convert national special characters between their
  14875. coding in ISO8859-1 (all \asname{} files use this format upon delivery) and their
  14876. system-specific coding.  Apart from a plain ASCII7 variant, there are
  14877. currently the IBM character sets 437 and 850.
  14878.  
  14879. \subsubsection{ushyph.c}
  14880.  
  14881. The definition of hyphenation rules for the english language.
  14882.  
  14883. %%---------------------------------------------------------------------------
  14884.  
  14885. \section{Generation of Message Files}
  14886.  
  14887. As already mentioned, the C source tree of \asname{} uses a dynamic load
  14888. principle for all (error) messages.  In contrast to the Pasacl sources
  14889. where all messages were bundled in an include file and compiled into the
  14890. programs, this method eliminates the need to provide \asname{} in multiple
  14891. language variants; there is only one version which checks for the
  14892. langugage to be used upon runtime and loads the corresponding component
  14893. from the message files.  Just to remind: Under DOS and OS/2, the {\tt
  14894. COUNTRY} setting is queried, while under Unix, the environment variables
  14895. {\tt LC\_MESSAGES, LC\_ALL,} and {\tt LANG} are checked.
  14896.  
  14897. \subsection{Format of the Source Files}
  14898.  
  14899. A source file for the message compiler {\em rescomp} usually has the
  14900. suffix {\tt .res}.  The message compiler generates one or two files from a
  14901. source:
  14902. \begin{itemize}
  14903. \item{a binary file which is read at runtime by \asname{} resp. its tools}
  14904. \item{optionally one further C header file assigning an index number to
  14905.      all messages. These index numbers in combination with an index
  14906.      table in the binary file allow a fast access to to individual
  14907.      messages at runtime.}
  14908. \end{itemize}
  14909.  
  14910. The source file for the message compiler is a pure ASCII file and can
  14911. therefore be modified with any editor.  It consists of a sequence of
  14912. control commands with parameters.  Empty lines and lines beginning with a
  14913. semicolon are ignored.  Inclusion of other files is possible via the {\tt
  14914. Include} statement:
  14915. \begin{verbatim}
  14916. Include <Datei>
  14917. \end{verbatim}
  14918.  
  14919. The first two statements in every source file must be two statements
  14920. describing the languages defined in the following.  The more important one
  14921. is {\tt Langs}, e.g.:
  14922. \begin{verbatim}
  14923. Langs DE(049) EN(001,061)
  14924. \end{verbatim}
  14925. describes that two languages will be defined in the rest of the file.  The
  14926. first one shall be used under Unix when the language has been set to {\tt
  14927. DE} via environment variable.  Similarly, It shall be used under DOS and
  14928. OS/2 when the country code was set to 049.  Similarly, the second set
  14929. shall be used for the settings {\tt DE} resp. 061 or 001.  While multiple
  14930. 'telephone numbers' may point to a single language, the assignment to a
  14931. Unix language code is a one-to-one correspondence.  This is no problem in
  14932. practice since the {\tt LANG} variables Unix uses describe subversions via
  14933. appendices, e.g.:
  14934. \begin{verbatim}
  14935. de.de
  14936. de.ch
  14937. en.us
  14938. \end{verbatim}
  14939. \asname{} only compares the beginning of the strings and therefore still comes to
  14940. the right decision.
  14941. The {\tt Default} statement defines the language that shall be used if
  14942. either no language has been set at all or a language is used that is not
  14943. mentioned in the asrgument list of {\tt Langs}.  This is typically the
  14944. english language:
  14945. \begin{verbatim}
  14946. Default EN
  14947. \end{verbatim}
  14948. These definitions are followed by an arbitrary number of {\tt Message}
  14949. statements, i.e. definitions of messages:
  14950. \begin{verbatim}
  14951. Message ErrName
  14952. ": Fehler "
  14953. ": error "
  14954. \end{verbatim}
  14955. In case {\em n} languages were announced via the {\tt Langs} statement,
  14956. the message compiler takes {\bf exactly} the following {\em n} as the
  14957. strings to be stored.  It is therefore impossible to leave out certain
  14958. languages for individual messages, and an empty line following the strings
  14959. should in no way be misunderstood as an end marker for the list; inserted
  14960. lines between statements only serve purposes of better readability.  It is
  14961. however allowed to split individual messages across multiple lines in the
  14962. source file; all lines except for the last one have to be ended with a
  14963. backslash as continuation character:
  14964. \begin{verbatim}
  14965. Message TestMessage2
  14966. "Dies ist eine" \
  14967. "zweizeilige Nachricht"
  14968. "This is a" \
  14969. "two-line message"
  14970. \end{verbatim}
  14971. As already mentioned, source files are pure ASCII files; national special
  14972. characters may be placed in message texts (and the compiler will correctly
  14973. pass them to the resulting file), a big disadvantage however is that such
  14974. a file is not fully portable any more: in case it is ported to another
  14975. system using a different coding for national special characters, the user
  14976. will probably be confronted with funny characters at runtime...special
  14977. characters should therefore always be written via special sequences
  14978. borrowed from HTML resp. SGML (see table \ref{TabSpecChars}).  Linefeeds
  14979. can be inserted into a line via \verb!\n!, similar to C.
  14980. \begin{table*}[htb]
  14981. \begin{center}\begin{tabular}{|l|l|}
  14982. \hline
  14983. Sequence... & results in... \\
  14984. \hline
  14985. \hline
  14986. \verb!&auml; &ouml; &uuml;! & "a "o "u (Umlauts)\\
  14987. \verb!&Auml; &Ouml; &Uuml;! & "A "O "U \\
  14988. \verb!&szlig;!              & "s (sharp s) \\
  14989. \verb!&agrave; &egrave; &igrave; &ograve;! & \'a \'e \'i \'o \\
  14990. \verb!&ugrave;! & \'u \\
  14991. \verb!&Agrave; &Egrave; &Igrave; &Ograve;! & \'A \'E \'I \'O \\
  14992. \verb!&Ugrave;! & \'U (Accent grave) \\
  14993. \verb!&aacute; &eacute; &iacute; &oacute;! & \`a \`e \`i \`o \\
  14994. \verb!&uacute;! & \`u \\
  14995. \verb!&Aacute; &Eacute; &Iacute; &Oacute;! & \`A \`E \`I \`O \\
  14996. \verb!&Uacute;! & \`U (Accent agiu) \\
  14997. \verb!&acirc; &ecirc; &icirc; &ocirc;! & \^a \^e \^i \^o \\
  14998. \verb!&ucirc;! & \^u \\
  14999. \verb!&Acirc; &Ecirc; &Icirc; &Ocirc;! & \^A \^E \^I \^O \\
  15000. \verb!&Ucirc;! & \^U (Accent circonflex) \\
  15001. \verb!&ccedil; &Ccedil;! & \c{c} \c{C}(Cedilla) \\
  15002. \verb!&ntilde; &Ntilde;! & \~n \~N \\
  15003. \verb!&aring; &Aring;! & \aa  \AA \\
  15004. \verb!&aelig; &Aelig;! & \ae  \AE \\
  15005. \verb!&iquest; &iexcl;! & inverted ! or ? \\
  15006. \hline
  15007. \end{tabular}\end{center}
  15008. \caption{Syntax for special character in {\em rescomp}\label{TabSpecChars}}
  15009. \end{table*}
  15010.  
  15011. %%---------------------------------------------------------------------------
  15012.  
  15013. \section{Creation of Documentation}
  15014.  
  15015. A source distribution of \asname{} contains this documentation in LaTeX format
  15016. only.  Other formats are created from this one automatically  via tools
  15017. provided with \asname{}.  One reason is to reduce the size of the source
  15018. distribution, another reason is that changes in the documentation only
  15019. have to be made once, avoiding inconsistencies.
  15020.  
  15021. LaTex was chosen as the master format because...because...because it's
  15022. been there all the time before.  Additionally, TeX is almost arbitrarily
  15023. portable and fits quite well to the demands of \asname{}.  A standard
  15024. distribution therefore allows a nice printout on about any printer; for a
  15025. conversion to an ASCII file that used to be part of earlier distributions,
  15026. the converter {\em tex2doc} is included, additionally the converter {\em
  15027. tex2html} allowing to put the manual into the Web.
  15028.  
  15029. Generation of the documentation is started via a simple
  15030. \begin{verbatim}
  15031. make docs
  15032. \end{verbatim}
  15033. The two converters mentioned are be built first, then applied to the TeX
  15034. documentation and finally, LaTeX itself is called.  All this of course for
  15035. all languages...
  15036.  
  15037. %%---------------------------------------------------------------------------
  15038.  
  15039. \section{Test Suite}
  15040.  
  15041. Since \asname{} deals with binary data of a precisely defined structure, it is
  15042. naturally sensitive for system and compiler dependencies.  To reach at
  15043. least a minimum amount of secureness that everything went right during
  15044. compilation, a set of test sources is provided in the subdirectory {\tt
  15045. tests} that allows to test the freshly built assembler.  These programs
  15046. are primarily trimmed to find faults in the translation of the machine
  15047. instruction set, which are commonplace when integer lenghts vary.
  15048. Target-independent features like the macro processors or conditional
  15049. assembly are only casually tested, since I assume that they work
  15050. everywhere when they work for me...
  15051.  
  15052. The test run is started via a simple {\em make test}.  Each test program
  15053. is assembled, converted to a binary file, and compared to a reference
  15054. image.  A test is considered to be passed if and only if the reference
  15055. image and the newly generated one are identical on a bit-by-bit basis.  At
  15056. the end of the test, the assembly time for every test is printed (those
  15057. who want may extend the file BENCHES with these results), accompanied with
  15058. a success or failure message.  Track down every error that occurs, even if
  15059. it occurs in a processor target you are never going to use!  It is always
  15060. possible that this points to an error that may also come up for other
  15061. targets, but by coincidence not in the test cases.
  15062.  
  15063. %%---------------------------------------------------------------------------
  15064.  
  15065. \section{Adding a New Target Processor}
  15066.  
  15067. The probably most common reason to modify the source code of \asname{} is to add
  15068. a new target processor.   Apart from adding the new module to the
  15069. Makefile, there are few places in other modules that need a modification.
  15070. The new module will do the rest by registering itself in the list of code
  15071. generators.  I will describe the needed steps in a cookbook style in the
  15072. following sections:
  15073.  
  15074. \subsubsection{Choosing the Processor's Name}
  15075.  
  15076. The name chosen for the new processor has to fulfill two criterias:
  15077. \begin{enumerate}
  15078. \item{The name must not be already in use by another processor.  If one
  15079.      starts \asname{} without any parameters, a list of the names already in
  15080.      use will be printed.}
  15081. \item{If the name shall appear completely in the symbol \tty{MOMCPU}, it may
  15082.      not contain other letters than A..F (except right at the
  15083.      beginning).  The variable \tty{MOMCPUNAME} however will always report
  15084.      the full name during assembly.  Special characters are generally
  15085.      disallowed, lowercase letters will be converted by the \tty{CPU}
  15086.      command to uppercase letters and are therefore senseless in the
  15087.      processor name.}
  15088. \end{enumerate}
  15089.  
  15090. The first step for registration is making an entry for the new processor
  15091. (family) in the file {\tt headids.c}.  As already mentioned, this file is
  15092. also used by the tools and specifies the code ID assigned to a processor
  15093. family, along with the default hex file format to be used.  I would like
  15094. to have some coordination before choosing the ID...
  15095.  
  15096. \subsubsection{Definition of the Code Generator Module}
  15097.  
  15098. The unit's name that shall be responsible for the new processor
  15099. should bear at least some similarity to the processor's name (just
  15100. for the sake of uniformity) and should be named in the style of
  15101. \tty{code....}.  The head with include statements is best taken from
  15102. another existing code generator.
  15103.  
  15104. Except for an initialization function that has to be called at the
  15105. begginning of the {\tt main()} function in module {\tt as.c}, the new
  15106. module neither has to export variables nor functions as the complete
  15107. communication is done at runtime via indirect calls.  They are simply done
  15108. by a call to the function
  15109. \tty{AddCPU} for each processor type that shall be treated by this unit:
  15110. \begin{verbatim}
  15111.   CPUxxxx:=AddCPU('XXXX',SwitchTo_xxxx);
  15112. \end{verbatim}
  15113. \tty{'XXXX'} is the name chosen for the processor which later must be used
  15114. in assembler programs to switch \asname{} to this target processor.
  15115. \tty{SwitchTo\_xxxx} (abbreviated as the ''switcher'' in the following) is
  15116. a procedure without parameters that is called by \asname{} when the switch to the
  15117. new processor actually takes place.  \tty{AddCPU} delivers an integer
  15118. value as result that serves as an internal ''handle'' for the new
  15119. processor.  The global variable \tty{MomCPU} always contains the handle of
  15120. the target processor that is currently set.  The value returned by
  15121. \tty{AddCPU} should be stored in a private variable of type \tty{CPUVar}
  15122. (called \tty{CPUxxxx} in the example above).  In case a code generator
  15123. module implements more than one processor (e.g. several processors of a
  15124. family), the module can find out which instruction subset is currently
  15125. allowed by comparing \tty{MomCPU} against the stored handles.
  15126.  
  15127. The switcher's task is to ''reorganize'' \asname{} for the new target
  15128. processor.  This is done by changing the values of several global
  15129. variables:
  15130. \begin{itemize}
  15131. \item{\tty{ValidSegs}: Not all processors have all address spaces defined
  15132.      by \asname{}.  This set defines which subset the \tty{SEGMENT} instruction
  15133.      will enable for the currently active target processor.  At least the
  15134.      \tty{CODE} segment has to be enabled.  The complete set of allowed
  15135.      segments can be looked up the file \tty{fileformat.h} (\tty{Seg....}
  15136.      constants).}
  15137. \item{\tty{SegInits}: This array stores the initial program counter values
  15138.      for the individual segments (i.e. the values the program counters
  15139.      will initially take when there is no \tty{ORG} statement).  There are
  15140.      only a few exceptions (like logically separated address spaces
  15141.      that physically overlap) which justify other initial values than
  15142.      0.}
  15143. \item{\tty{Grans}: This array specifies the size of the smallest addressable
  15144.      element in bytes for each segment, i.e. the size of an element
  15145.      that increases an address by 1.  Most processors need a value of
  15146.      1, even if they are 16- or 32-bit processors, but the PICs and
  15147.      signal processors are cases where higher values are required.}
  15148. \item{\tty{ListGrans}: This array specifies the size of byte groups that shall
  15149.      be shown in the assembly listing.  For example, instruction words
  15150.      of the 68000 are always 2 bytes long though the code segment's
  15151.      granularity is 1.  The \tty{ListGran} entry therefore has to be set to
  15152.      2.}
  15153. \item{\tty{SegLimits}: This array stores the highest possible address for
  15154.      each segment, e.g. 65535 for a 16-bit address space.  This array
  15155.      need not be filled in case the code generator takes over the
  15156.      {\tt ChkPC} method.}
  15157. \item{\tty{ConstMode}: This variable may take the values
  15158.      \tty{ConstModeIntel}, \tty{ConstModeMoto}, or \tty{ConstModeC}
  15159.      and rules which syntax has to be used to specify the base of
  15160.      integer constants.}
  15161. \item{\tty{PCSymbol}: This variable contains the string an assembler program
  15162.      may use to to get the current value of the program counter.
  15163.      Intel processors for example usually use a dollar sign.}
  15164. \item{\tty{TurnWords}: If the target processor uses big-endian addressing and
  15165.      one of the fields in \tty{ListGran} is larger than one, set this flag
  15166.      to true to get the correct byte order in the code output file.}
  15167. \item{\tty{SetIsOccupied}: Some processors have a \tty{SET} machine instruction.
  15168.      If this callback is set to a non-NULL value, the code generator
  15169.      may report back whether \tty{SET} shall not be interpreted as
  15170.      pseudo instruction.  The return value may be constant \tty{True} or
  15171.      or e.g. depend on the number of argument if a differentiation is
  15172.      possible.}
  15173. \item{\tty{HeaderID}: This variable contains the ID that is used to mark the
  15174.      current processor family in the the code output file (see the
  15175.      description of the code format described by \asname{}).  I urge to
  15176.      contact me before selecting the value to avoid ambiguities.
  15177.      Values outside the range of \$01..\$7f should be avoided as they
  15178.      are reserved for special purposes (like a future extension to
  15179.      allow linkable code). Even though this value is still hard-coded
  15180.      in most code generators, the preferred method is now to fetch this
  15181.      value from {\tt headids.h} via {\tt FindFamilyByName}.}
  15182. \item{\tty{NOPCode}: There are some situations where \asname{} has to fill unused
  15183.      code areas with NOP statements.  This variable contains the
  15184.      machine code of the NOP statement.}
  15185. \item{\tty{DivideChars}: This string contains the characters that are valid
  15186.      separation characters for instruction parameters.  Only extreme
  15187.      exotics like the DSP56 require something else than a single comma
  15188.      in this string.}
  15189. \item{\tty{HasAttrs}: Some processors like the 68k series additionally split
  15190.      an instruction into mnemonic and attribute.  If the new processor
  15191.      also does something like that, set this flag to true and \asname{} will
  15192.      deliver the instructions' components readily split in the string
  15193.      variables \tty{OpPart} and \tty{AttrPart}.  If this flag is however set to
  15194.      false, no splitting will take place and the instruction will be
  15195.      delivered as a single piece in \tty{OpPart}.  \tty{AttrPart} will stay empty
  15196.      in this case.  One really should set this flag to false if the
  15197.      target processor does not have attributes as one otherwise looses
  15198.      the opportunity to use macros with a name containing dots (e.g.
  15199.      to emulate other assemblers).}
  15200. \item{\tty{AttrChars}: In case \tty{HasAttrs} is true, this string has to contain
  15201.      all characters that can separate mnemonic and attribute.  In most
  15202.      cases, this string only contains a single dot.}
  15203. \end{itemize}
  15204. Do not assume that any of these variables has a predefined value; set
  15205. them \bb{all}!!
  15206.  
  15207. Apart from these variables, some function pointers have to be set that
  15208. form the link form \asname{} to the ''active'' parts of the code
  15209. generator:
  15210. \begin{itemize}
  15211. \item{\tty{MakeCode}: This routine is called after a source line has been
  15212.      split into mnemonic and parameters.  The mnemonic is stored into
  15213.      the variable \tty{OpPart}, and the parameters can be looked up in the
  15214.      array \tty{ArgStr}.  The number of arguments may be read from
  15215.      \tty{ArgCnt}.
  15216.      The binary code has to be stored into the array \tty{BAsmCode}, its
  15217.      length into \tty{CodeLen}.  In case the processor is word oriented
  15218.      like the 68000 (i.e. the \tty{ListGran} element corresponding to the
  15219.      currently active segment is 2), the field may be addressed
  15220.      wordwise via \tty{WAsmCode}.  There is also \tty{DAsmCode} for extreme
  15221.      cases... The code length has to be given in units corresponding
  15222.      to the current segment's granularity.}
  15223. \item{\tty{SwitchFrom}: This parameter-less procedure enables the code generator
  15224.      module to do ''cleanups'' when \asname{} switches to another target processor.
  15225.      This hook allows e.g. to free memory that has been allocated in the
  15226.      generator and that is not needed as long as the generator is not
  15227.      active.  It may point to an empty procedure in the simplest case.
  15228.      One example for the usage of this hook is the module \tty{CODE370} that
  15229.      builds its instruction tables dynamically and frees them again after
  15230.      usage.}
  15231. \item{\tty{IsDef}: Some processors know additional instructions that impose
  15232.      a special meaning on a label in the first row like \tty{EQU} does.  One
  15233.      example is the \tty{BIT} instruction found in an 8051 environment.  This
  15234.      function has to return TRUE if such a special instruction is
  15235.      present.  In the simplest case (no such instructions), the routine
  15236.      may return a constant FALSE.}
  15237. \end{itemize}
  15238.  
  15239. Optionally, the code generator may additionally set the following function
  15240. pointers:
  15241. \begin{itemize}
  15242. \item{\tty{ChkPC} : Though \asname{} internally treats all program counters as
  15243.      either 32 or 64 bits, most processors use an address space that is
  15244.      much smaller.  This function informs \asname{} whether the current program
  15245.      counter has exceeded its allowed range.  This routine may of course
  15246.      be much more complicated in case the target processor has more than
  15247.      one address space.  One example is in module \tty{code16c8x.c}.  In
  15248.      case everything is fine, the function has to return TRUE, otherwise
  15249.      FALSE.  The code generator only has to implement this function if
  15250.      it did not set up the array {\tt SegLimits}.  This may e.g. become
  15251.      necessary when the allowed range of addresses in a segment is
  15252.      non-continuous.}
  15253. \item{\tty{InternSymbol} : Some processorcs, e.g. such with a register
  15254.      bank in their internal RAM, predefine such 'registers' as symbols,
  15255.      and it wouldn't make much sense to define them in a separate include
  15256.      file with 256 or maybe more {\tt EQU}s.  This hook allows access to
  15257.      the code generator of \asname{}: It obtains an expression as an ASCII
  15258.      string and sets up the passed structure of type {\em TempResult}
  15259.      accordingly when one of these 'built-in' symbols is detected.  The
  15260.      element {\tt Typ} has to be set to {\tt TempNone} in case the check
  15261.      failed.  Errors messages from this routine should be avoided as
  15262.      unidentified names could signify ordinary symbols (the parser will
  15263.      check this afterwards).  Be extreme careful with this routine as
  15264.      it allows you to intervene into the parser's heart!}
  15265. \item{\tty{DissectBit} : In case the target platform supports bit objects,
  15266.      i.e. objects that pack both a register or memory address and a bit
  15267.      position into one integer number, this is the callback to dissect
  15268.      such a packed representation and transform it back into a source-code
  15269.      like, human-readable form.  This provides better readability of the
  15270.      listing.}
  15271. \item{\tty{DissectReg} : In case the target platform supports register
  15272.      symbols, this is the callback that translates register number and size
  15273.      back to a source-code like, human-readable form.  Again, this function
  15274.      is used for the listing.}
  15275. \item{\tty{QualifyQuote} : This optional callback allows to define on a
  15276.      per-platform base situations when a single quotation character does
  15277.      {\em not} lead in a character string.  An example for this is the
  15278.      Z80's alternate register bank, which is written as \tty{AF'}, or
  15279.      the hexadecimal constant syntax \tty{H'...} used on some Hitachi
  15280.      processors.}
  15281. \end{itemize}
  15282.  
  15283. By the way: People who want to become immortal may add a copyright
  15284. string.  This is done by adding a call to the procedure \tty{AddCopyright}
  15285. in the module's initialization part (right next to the \tty{AddCPU} calls):
  15286. \begin{verbatim}
  15287.   AddCopyright(
  15288.      "Intel 80986 code generator (C) 2010 Jim Bonehead");
  15289. \end{verbatim}
  15290. The string passed to \tty{AddCopyright} will be printed upon program start
  15291. in addition to the standard message.
  15292.  
  15293. If needed, the unit may also use its initialization part to hook into
  15294. a list of procedures that are called prior to each pass of assembly.
  15295. Such a need for example arises when the module's code generation
  15296. depends on certain flags that can be modified via pseudo
  15297. instructions.  An example is a processor that can operate in either
  15298. user or supervisor mode.  In user mode, some instructions are
  15299. disabled.  The flag that tells \asname{} whether the following code executes
  15300. in user or supervisor mode might be set via a special pseudo
  15301. instruction.  But there must also be an initialization that assures
  15302. that all passes start with the same state.  The hook offered via
  15303. \tty{AddInitPassProc} offers a chance to do such initializations.  The
  15304. callback function passed to it is called before a new pass is
  15305. started.
  15306.  
  15307. The function chain built up via calls to \tty{AddCleanUpProc}
  15308. operates similar to \tty{AddInitPassProc}: It enables code
  15309. generators to do clean-ups after assembly (e.g.  freeing of
  15310. literal tables).  This makes sense when multiple files are
  15311. assembled with a single call of \asname{}.  Otherwise, one would risk to
  15312. have 'junk' in tables from the previous run.  No module currently
  15313. uses this feature.
  15314.  
  15315. \subsubsection{Writing the Code Generator itself}
  15316.  
  15317. Now we finally reached the point where your creativity is challenged:
  15318. It is up to you how you manage to translate mnemonic and parameters
  15319. into a sequence of machine code.  The symbol tables are of course
  15320. accessible (via the formula parser) just like everything exported
  15321. from \tty{ASMSUB}.  Some general rules (take them as advises and not as
  15322. laws...):
  15323. \begin{itemize}
  15324. \item{Try to split the instruction set into groups of instructions that
  15325.      have the same operand syntax and that differ only in a few bits
  15326.      of their machine code.  For example, one can do all instructions
  15327.      without parameters in a single table this way.}
  15328. \item{Most processors have a fixed spectrum of addressing modes.  Place
  15329.      the parsing of an address expression in a separate routine so you
  15330.      an reuse the code.}
  15331. \item{The subroutine \tty{WrError} defines a lot of possible error codes and
  15332.      can be easily extended.  Use this!  It is no good to simply issue
  15333.      a ''syntax error'' on all error conditions!}
  15334. \end{itemize}
  15335. Studying other existing code generators should also prove to be
  15336. helpful.
  15337.  
  15338. \subsubsection{Modifications of Tools}
  15339.  
  15340. A microscopic change to the tolls' sources is still necessary, namely to
  15341. the routine {\tt Granularity()} in {\tt toolutils.c}: in case one of the
  15342. processor's address spaces has a granularity different to 1, the swich
  15343. statement in this place has to be adapted accordingly, otherwise PLIST,
  15344. P2BIN, and P2HEX start counting wrong...
  15345.  
  15346. \section{Localization to a New Language}
  15347.  
  15348. You are interested in this topic?  Wonderful!  This is an issue that is
  15349. often neglected by other programmers, especially when they come from the
  15350. country on the other side of the big lake...
  15351.  
  15352. The localization to a new language can be split into two parts: the
  15353. adaption of program messages and the translation of the manual.  The
  15354. latter one is definitely a work of gigantic size, however, the adaption of
  15355. program messages should be a work doable on two or three weekends, given
  15356. that one knows both the new and one of the already present messages.
  15357. Unfortunately, this translation cannot be done on a step-by-step basis
  15358. because the resource compiler currently cannot deal with a variable amount
  15359. of languages for different messages, so the slogan is 'all or nothing'.
  15360.  
  15361. The first oeration is to add the new language to {\tt header.res}.  The
  15362. two-letter-abbreviation used for this language is best fetched from the
  15363. nearest Unix system (in case you don't work on one anyway...), the
  15364. international telephone prefix from a DOS manual.
  15365.  
  15366. When this is complete, one can rebuild all necessary parts with a simple
  15367. {\em make} and obtains an assembler that supports one more language.  Do
  15368. not forget to forward the results to me.  This way, all users will benefit
  15369. from this with the next release :-)
  15370.  
  15371. %%===========================================================================
  15372.  
  15373. \cleardoublepage
  15374. \begin{thebibliography}{99}
  15375.  
  15376. \input{../doc_COM/biblio.tex}
  15377.  
  15378. \end{thebibliography}
  15379.  
  15380. \cleardoublepage
  15381.  
  15382. \printindex
  15383.  
  15384. \end{document}
  15385.