7 MADMAC Version 1.07 release notes, January, 1990.
10 Using .cargs used to cause subsequent global symbols to disappear from
11 the symbol table. Now it doesn't.
14 A movem instruction with no register list (i.e. "movem.l (sp)+,")
15 assembled without error; it now reports "missing regsiter list."
28 MADMAC Version 1.05 release notes, August, 1988.
31 This version of MadMac replaces version 1.00 and fixes some small bugs:
34 Symbols beginning with a capital L were not included in the
35 object file output. They should have been (and now are) excluded only
36 in AS68 compatibility mode, to avoid cluttering the output with
38 compiler-generated symbols.
41 Forward branches declared "short" (such as bras, dbra.s, bsr.$)
42 but whose targets were too far away did not cause an assembly-time
43 error; incorrect machine code was silently generated. They now cause
47 Symbols appeared in the object file symbol table in the order •
48 they were referenced in the source, not the order they were declared.
49 Now the order more nearly matches the order of declaration (but not
53 The disp(And(n.$) addressing mode produced correct machine code,
54 but incorrect output in the listing file. Now the output is correct.
96 NOTE: Every effort has been made to ensure the accuracy and robustness of this
97 manual and the associated software. However, because Atari Corporation is con-
98 stantly improving and updating its computer software, it is unable to guarantee
99 the accuracy of printed or duplicated material after the date of publication and
100 disclaims liability for changes, errors or omissions.
113 ATARI, the Atari logo, MEGA, and ST are trademarks or registered trademarks of
115 Mark Williams is a trademark of Mark Williams Company.
116 Motorola is a trademark of Motorola Inc.
128 Copyright ® 1986, 1987, Atari Corporation
131 Reproduction of this document or the associated software is not allowed without
132 the specific written consent of Atari Corporation.
136 Atari Document number C300341-001 Rev. A.
165 Example Command Lines 7
167 Things You Should Be Aware Of . 8
169 Notes for AS68 users . . 9
170 Notes for Mark Williams C Users . . . . . 9
171 Using MADMAC as a Back-End to the Alcyon C Compiler . 10
172 Text File Format . 10
182 Order of Evaluation 15
185 Binary Operators . 16
187 Example Expressions . 17
191 Macro Declaration . . 24
192 Parameter Substitution 24
193 Macro Invocation . . 25
196 6502 Support . . . 28
197 6502 Addressing Modes . . 28
198 6502 Directives . . 28
199 6502 Object Code Format . 29
207 MADMAC Reference Manual 1
219 This document describes MADMAC, a fast macro assembler for the 68000. MAD-
220 MAC currently runs on the Atari ST and under 4.2 BSD VAX UNIX. It was written
221 at Atari Corporation by programmers who needed a high performance assembler
223 MADMAC is intended to be used by programmers who write mostly in as-
224 sembly language. It was not originally a back-end to a C compiler, therefore it
225 has creature comfort that are usually neglected in such back-end assemblers. It
226 supports include files, macros, symbols with limited scope, some limited control
227 structures, and other features. MADMAC is also blindingly fast, another feature
228 often sadly and obviously missing in today's assemblers.1
229 MADMAC is not entirely compatible with the AS68 assembler provided with
230 the original Atari ST Developer's Kit, but most changes are minor and a few minutes
231 with an editor should allow you to assemble your current source files. If you are an
232 AS68 user, before you leap into the unknown please read the section on Notes for
234 This manual was typeset with TEX and the Computer Modern fonts, and it
235 was printed on the Atari SLM-804 laser printer with a MEGA ST. Except for 200
236 lines of assembly language, the assembler is written entirely in C.
238 =>Write protect your distribution disk and make a backup of it now. Put the
239 original disk in a safe place.
240 o The distribution disk contains a file called README that you should read.
241 This file contains important nays about the contents of the distribution disk
242 and summarizes the most recent changes to the tools.
243 o Hard disk users can simply copy the executable files to their work or binary
244 directories. People with floppy disks can copy the executables to ramdisks,
245 install the assembler with the -q option, or even work right off of the floppies.
246 o You will need an editor that can produce "normal" format text files. Micro
247 Emacs will work well, as will most other commercial program editors, but not
248 most word processors (such as First Word or Microsoft Write).
249 o You will probably want to examine or get a listing of the file "ATARI.S". It
250 contains lots of definitions for the Atari ST, including BIOS variables, most
251 BIOS, XBIOS and GEMDOS traps, and line-A equates. We (or you) could
252 split the file up into pieces (a file for line-A equates, a file for hardware and
254 1 It processes 30,000 lines a minute on a lightly loaded VAX 11/780; maybe
255 40,000 on a 520-ST with an SH-204 hard disk. Yet it could be sped up even more
256 with some effort and without resorting to assembly language; C doesn't have to be
259 2 MADMAC Reference Manual
263 BIOS variables and so on), but MADMAC is so fast that it doesn't matter
265 o Read the rest of the manual, especially the first two chapters on The Com-
266 mand Line and Using MADMAC. The distribution disk contains example
267 programs that you can look at, assemble and modify.
328 MADMAC Reference Manual 3
341 The assembler is called "mac.prg". The command line takes the form:
343 mac [switches] [files ...]
345 A command line consists of any number of switches followed by the names of files
346 to assemble. A switch is specified with a dash (-) followed immediately by a key
347 character. Key characters are not case-sensitive, so "-d" is the same as "-D". Some
348 switches accept (or require) arguments to immediately follow the key character,
349 with no spaces in between.
350 Switch order is important. Command lines are processed from left to right in
351 one pass, and switches usually take effect when they are encountered. In general it
352 is best to specify all switches before the names of any input files.
353 If the command line is entirely empty then MADMAC prints a copyright mes-
354 sage and enters an "interactive" mode, prompting for successive command lines
355 with a star (*). An empty command line will exit (See the examples in the chapter
356 on Using MADMAC). After each assembly in interactive mode, the assembler
357 will print a summary of the amount of memory used, the amount of memory left,
358 the number of lines processed, and the number of seconds the assembly took.
360 Input files are assumed to have the extension ".s"; if a filename has no extension
361 (i.e. no dot) then ".s" will be appended to it. More than one source filename may be
362 specified: the files are assembled into one object file, as if they were concatenated.
363 MADMAC normally produces object code in "file.o" if "file.s" is the first
364 input filename. If the first input file is a special character device, the output name
365 is noname.o. The -o switch (see below) can be used change the output file name.
369 -dname[=value] Define symbol, with optional value.
370 -e[file[.err]] Direct error messages to the specified file.
371 -fm Produce Mark Williams format object file.
372 -fmu Like "-fm" , but move underscores to end of symbol names.
373 -ipath Set include-file directory search path.
374 -l[file[prn]] Construct and direct assembly listing to the specified file.
375 -ofile[.o] Direct object code output to the specified file.
376 -p Produce an executable (.prg) output file.
377 -ps Produce an executable (.prg) output file with symbols.
378 -q Make MADMAC resident in memory (Atari ST only).
379 -s Warn about unoptimized long branches.
380 -u Assume that all undefined symbols are external.
381 -v Verbose mode (print running dialogue).
382 -yn Set listing page size to n lines.
383 -6 "Back end" mode for Alcyon C68.
384 file[s] Assemble the specified file.
387 4 MADMAC Reference Manual
391 The switches are described below. A summary of all the switches is given in
394 The -d switch permits symbols to be defined on the command line. The name
395 of the symbol to be defined immediately follows the switch (no spaces). The
396 symbol name may optionally be followed by an equals sign (=) and a decimal
397 number. If no value is specified the symbol's value is zero. The symbol at-
398 tributes are "defined, not referenced, and absolute". This switch is most useful
399 for enabling conditionally-assembled debugging code on the command line; for
401 -dDEBUG -dLoopCount=999 -dDebugLevel=55
403 The -e switch causes MADMAC to send error messages to a file, instead of the
404 console. If a filename immediately follows the switch character, error messages
405 are written to the specified file. If no filename is specified, a file is created with
406 the default extension ".err" and with the root name taken from the first input
407 file name (e.g. error messages are written to "file.err" if "file" or "file.s" is
408 the first input file name). If no errors are encountered, then no error listing
409 file is created. Beware! If an assembly produces no errors, any error file from
410 a previous assembly is not removed.
413 The -fm and -fmu switches cause MADMAC to generate Mark Williams style
414 object files instead of Alcyon object files. These files may be linked with the
415 Mark Williams linker. The -fmu switch causes underscores on the first char-
416 acter of a global symbol name to be moved to the end of the name, as per the
417 Mark Williams C compiler naming convention. That is, "_main" will become
418 "main_" and "__main" will become "_main_".
420 The -i switch allows automatic directory searching for include files. A list of
421 semi-colon seperated directory search paths may be mentioned immediately
422 following the switch (with no spaces anywhere). For example:
423 -im:;c:include;c:include\sys
424 will cause the assembler to search the current directory of device M, and the
425 directories include and include\sys on drive C. If -1 is not specified, and the
426 enviroment variable "MACPATH" exists, its value is used in the same manner.
427 For example, users of the Mark Williams shell could put the following line in
428 their profile script to achieve the same result as the -i example above:
429 setenv MACPATH="m:;c:include;c:include\sys"
431 The -l switch causes MADMAC to generate an assembly listing file. If a file-
432 name immediately follows the switch character, the listing is written to the
433 specified file. If no filename is specified, then a listing file is created with the
434 default extension ".prn" and with the root name taken from the first input file
435 name (e.g. the listing is written to "file.prn" if "file" or "file.s" is the first
438 The -o switch causes MADMAC to write object code on the specified file. No
439 default extension is applied to the filename. For historical reasons the filename
440 can also be seperated from the switch with a space (e.g. "-o file").
442 MADMAC Reference Manual 5
451 The -p and -ps switches cause MADMAC to produce an Atari ST executable
452 file with the default extension of ".prg". If there are any external references
453 at the end of the assembly, an error message is emitted and no executable file
454 is generated. The -p switch does not write symbols to the executable file. The
455 -ps switch includes symbols (Alcyon format) in the executable file.
459 The -q switch is aimed primarily at users of floppy-disk-only systems. It causes
460 MADMAC to install itself in memory, like a RAMdisk. Then the program
461 m.prg (which is very short - less than a sector) can be used instead of
462 mac.prg, which can take ten or twelve seconds to load.
465 The -s switch causes MADMAC to generate a list of unoptimized forward
466 branches as warning messages. This is used to point out branches that could
467 have been short (e.g. "bra" could be "bra.s").
470 The -u switch takes effect at the end of the assembly. It forces all referenced
471 and undefined symbols to be global, exactly as if they had been made global
472 with a .extern or .globl directive. This can be used if you have a lot of
473 external symbols, and you don't feel like declaring them all external.
476 The -v switch turns on a "verbose" mode in which MADMAC prints out (for
477 example) the names of the files it is currently processing. Verbose mode is
478 automatically entered when MADMAC prompts for input with a star.
482 The -y switch, followed immediately by a decimal number (with no intervening
483 space), sets the number of lines in a page. MADMAC will produce N lines
484 before emitting a form-feed. If N is missing or less than 10 an error message is
488 The -6 switch takes effect when it is mentioned. It allows MADMAC to be
489 used as a back end to the Alcyon C compiler.1 Note: the assembler will
490 produce code that is typically ten percent larger and ten percent slower than
491 the output of the Alcyon assembler, therefore use of this switch for production
518 1 The -6 switch is not a compatibility mode for AS68 - it has been carefully
519 tailored to accept the output of the Alcyon C compiler.
522 6 MADMAC Reference Manual
532 Let's assemble and link some example programs. These programs are included
533 on the distribution disk in the "EXAMPLES" directory - you should copy them to
534 your work area before continuing. In the following examples we adopt the conven-
535 tions that the shell prompt is a percent sign (%) and that your input (the stuff you
536 type) is presented in bold face.
537 If you have been reading carefully, you know that MADMAC can generate
538 an executable file without linking. This is useful for making small, stand alone
539 programs that don't require externals or library routines. For example, the following
543 could be replaced by the single command:
545 since you don't need the linker for stand-alone object files.
546 Successive source files named in the command line are are concatenated, as in
547 this example, which assembles three files into a single executable, as if they were
549 % mac -p bugs shift images
550 Of course you can get the same effect by using the .include directive, but sometimes
551 it is convenient to do the concatenation from the command line.
552 Here we have an unbelievably complex command line:
553 % mac -lzorf -y95 -o tmp -ehack -Ddebug=123 -ps example
554 This produces a listing on the file called "zorf.pni" with 95 lines per page, writes
555 the executable code (with symbols) to a file called "tmp.prg," writes an error list-
556 ing to the file "hack.err," specifies an include-file path that includes the current
557 directory on the drive "K:," defines the symbol "debug" to have the value 123, and
558 assembles the file "example.s". (Take a deep breath - you got all that?)
559 One last thing. If there are any assembly errors, MADMAC will terminate
560 with an exit code of 1. If the assembly succeeds (no errors, although there may be
561 warnings) the exit code will be 0. This is primarily for use with "make" utilities.
564 If you invoke MADMAC with an empty command line it will print a copyright
565 message and prompt you for more commands with a star (*). This is useful if you
566 are used to working directly from the desktop, or if you want to assemble several files
567 in succession without having to reload the assembler from disk for each assembly.
568 In interactive mode, the assembler is also in verbose mode (just as if you had
569 specified -v on each command line):
571 MADMAC Reference Manual 7
578 MADMAC Atari Macro Assembler
579 Copyright 1987 Atari Corporation
580 Beta version 0.12 Jun 1987 lmd
583 [Including: example.s]
586 [Leaving; example. a]
587 [Writing executable tile: example.prg
588 36K used, 3868K left, 850 lines, 2.0 seconds
591 You can see that the assembler gave a "blow-by-blow" account of the files it pro-
592 cessed, as well as a summary of the assembly's memory usage, the number of lines
593 processed (including macro and repeat-block expansion), and how long the assembly
595 The assembler prompts for another command with the star. At this point you
596 can either type a new command line for the assembler to process, or you can exit
597 by typing control-C or an empty line.
599 Things You Should Be Aware Of
600 MADMAC is a one pass assembler. This means that it gets all of its work done by
601 reading each source file exactly once and then "back-patching" to fix up forward
602 references. This one-pass nature is usually transparent to the programmer, with
603 the following important exceptions:-
604 o in listings, the object code for forward references is not shown. Instead, lower-
605 case "xx"s are displayed for each undefined byte, as in the following example:
606 60xx 1: bra.s.2 ;forward branch
607 xxxxxxxx dc.l .2 ;forward reference
608 60FE .2: bra.s.2 ;backward reference
610 o Forward branches (including BSRs) are never optimized to their short forms.
611 To get a short forward branch it is necessary to explicitly use the ".s" suffix in
613 o Error messages may appear at the end of the assembly, refering to earlier source
614 lines that contained undefined symbols.
615 o All object code generated must fit in memory. Running out of memory is a
616 fatal error that you must deal with by splitting up your source files, re-sizing
617 or eliminating memory-using programs such as ramdisks and desk accessories,
621 MADMAC does not optimize forward branches for you, but it will tell you about
622 them if you use the -s (short branch) option:
624 "example.s", line 20: warning: unoptimized short branch
625 With the -e option you can redirect the error output to a file, and determine by
626 hand (or editor macros) which forward branches are safe to explicitly declare short.
628 8 MADMAC Reference Manual
633 MADMAC is not entirely compatible with the Alcyon assembler, AS68. This section
634 outlines the major differences. In practice, we have found that very few changes are
635 necessary to make AS68 source code assemble.
636 o A semicolon (;) must be used to introduce a comment, except that a star (*)
637 may be used in the first column. AS68 treated anything following the operand
638 field, preceeded by whitespace, as a comment. (MADMAC treats a star that
639 is not in column 1 as a multiplication operator).
640 o Labels require colons (even labels that begin in column 1).
641 o Conditional assembly directives are called if, else and endif. AS68 called these
642 ifne, ifeq (etc.), and endc.
643 o The tilde (~) character is an operator, and back-quote (`) is an illegal character.
644 AS68 permitted the tilde and back-quote characters in symbols.
645 o There are no equivalents to AS68's org or section directives. AS68's page
646 directive has become eject. The AS68 .xdef and .xref directives are not imple-
647 mented, but .globl makes these unnecessary anyway. The directives .comline,
648 mask2, idnt and opt, which were unimplemented and ignored in AS68, are
650 o The location counter cannot be manipulated with a statement of the form:
652 o The ds directive is not permitted in the text or data segments (except in -6
653 mode); an error message is issued. Use dcb instead to reserve large blocks of
655 o Back-slashes in strings are "electric" characters that are used to escape C-like
656 character codes. Watch out for GEMDOS path names in ASCII constants -
657 you will have to convert them to double-backslashes.
659 Notes for Mark Williams C Users
660 MADMAC will generate object code that the Mark Williams C linker, ld, will
661 accept. This has been tested only with version 2.0 of the Mark Williams package.
662 Some notable differences between MADMAC and the Mark Williams assembler, as,
664 o MWC permits 16-character symbol names in the object file, and MADMAC
666 o MWC object files can contain more code and data sections than the MADMAC
667 (Alcyon) object code format. MADMAC maps its code sections as follows:
668 MWC Space MADMAC Space
669 shui (shared instruction) text
670 prvi (private instruction) unsupported
671 bssi (uninitialized instruction) unsupported
672 shrd (shared data) data
673 prvd (private data) unsupported
674 bssd (uninitialized data) bss
675 debug information unsupported
677 absolute abs, equates, etc.
679 MADMAC Reference Man real 9
685 It is not possible for MADMAC to generate code in the Mark Williams private
686 instruction, private data or uninitialized instruction spaces.
687 o None of the Mark Williams assembler directives (e.g. ".long" and ". odd") are
688 supported. None of the MWC non-standard addressing modes are supported.
689 o The Mark Williams debugger, db, does not support the Alcyon-format symbols
690 produced with the -ps switch; it complains about the format of the executable
692 o MADMAC does not support the method by which the Mark Williams shell
693 passes long command lines to programs. Command lines are truncated to 127
696 Using MADMAC as a Back-End to the Alcyon C Compiler
697 MADMAC can be used in place of the AS68 assembler as a back-end for the Alcyon
698 version 4.14 C compiler. The "-6" switch turns on a mode that warps and perverts
699 MADMAC's ordinary syntax into accepting what the Alcyon compiler dishes out.
700 This can be used in a batch file (for instance) with a line that looks like:
702 (Assuming that device "M:" is where the source was put by compiler phase c168).
703 You should be aware that AS68 generally produces better and faster code than
704 MADMAC, although it is slower to assemble.
707 For those using editors other than the "Emacs" style ones (Micro-Emacs, Mince,
708 etc.) this section documents the source file format that MADMAC expects.
709 o Files must contain characters with ASCII values less than 128; it is not per-
710 missable to have characters with their high bits set unless those characters are
711 contained in strings (i.e. between single or double quotes) or in comments.
712 o Lines of text are terminated with carriage-return/line-feed, linefeed alone, or
713 carriage-return alone.
714 o The file is assumed to end with the last terminated line. If there is text beyond
715 the last line terminator (e.g. control-Z) it is ignored.
736 10 MADMAC Reference Manual
748 A statement may contain up to four fields which are identified by order of ap-
749 pearance and terminating characters. The general form of an assembler statement
751 label: operator operand(s) ; comment
752 The label and comment fields are optional. An operand field may not appear
753 without an operator field. Operands are seperated with commas. Blank lines are
754 legal. If the first character on a line is an asterisk (*) or semicolon (;) then the
755 entire line is a comment. A semicolon anywhere on the line (except in a string)
756 begins a comment field which extends to the end of the line.
757 The label, if it appears, must be terminated with a single or double colon. If
758 it is terminated with a double colon it is automatically declared global. It is illegal
759 to declare a confined symbol global (see: Symbols and Scope).
761 A statement may also take one of these special forms:
762 symbol equ expression
765 symbol set expression
766 symbol reg register list
767 The first two forms are identical; they equate the symbol to the value of an
768 expression, which must be defined (no forward references). The third form, double-
769 equals (==), is just like an equate except that it also makes the symbol global. (As
770 with labels, it is illegal to make a confined equate global.) The fourth form allows
771 a symbol to be set to a value any number of times, like a variable. The last form
772 equates the symbol to a 16-bit register mask specified by a register list. It is possible
773 to equate confined symbols (see: Symbols and Scope). For example:
774 cr equ 13 carriage-return
776 DEBUG == 1 global debug flag
778 count set count + 1 increment variable
779 .rags reg d3-d7/a3-a6 register list
780 .cr 13 confined equate
782 Symbols may start with an uppercase or lowercase letter (A-Z a-z), an underscore
783 (_), a question mark (7) or a period ( ). Each remaining character may be an
784 upper or lowercase letter, a digit (0-9), an underscore, a dollar sign ($), or a ques-
785 tion mark. (Periods can only begin a symbol, they cannot appear as a symbol
787 MADMAC Reference Manual 11
792 continuation character). Symbols are terminated with a character that is not a
793 symbol continuation character (e.g. a period or comma, whitespace, etc.). Case is
794 significant for user-defined symbols, but not for 68000 mnemonics, assembler direc-
795 tives and register names. Symbols are limited to 100 characters. When symbols
796 are written to the object file they are silently truncated to eight (or sixteen) char-
797 acters (depending on the object file format) with no check for (or warnings about)
799 For example, all of the following symbols are legal and unique:
800 reallyLougSymbolliame .reallyLongConfinadSymbollame
801 al0 ret move dc frog aae a9 ????
802 .al .ret .move .dc .frog .a9 .9 ????
803 .0 .00 .000 .1 .11. .111 . ._
804 _frog ?zippo? sys$syetem atari Atari ATARI aTaRi
805 while all of the following symbols are illegal:
806 12days dc.10 dc.z 'quote .right.here
807 @work hi.there $money$ ~tilde
808 Symbols beginning with a period (.) are confined; their scope is between two
809 normal (unconfined) labels. Confined symbols may be labels or equates. It is illegal
810 to make a confined symbol global (with the ".globl" directive, a double colon, or a
811 double equals). Only unconfined labels delimit a confined symbol's scope; equates
812 (of any kind) do not count. For example, all symbols are unique and have unique
813 values in the following:
821 .loop: move.w -1,(a0)+
824 Confined symbols are useful since the programmer has to be much less inventive
825 about finding small, unique names that also have meaning.
826 It is legal to define symbols that have the same names as processor mnemonics
827 (such as "move" or "rts") or assembler directives (such as ".even"). Indeed, one
828 should be careful to avoid typographical errors, such as this classic (in 6502 mode):
831 which equates a confined symbol to a hexadecimal value, rather than setting the
832 location counter, which the .org directive does (without the equals sign).
834 The following names, in all combinations of uppercase and lowercase, are keywords
835 and may not be used as symbols (e.g. labels, equates, or the names of macros):
838 dO di d2 d3 d4 d5 d6 d7
839 a0 al a2 a3 a4 a5 a6 aT
840 r0 ri r2 r3 r4 r5 r6 r7
841 r8 r9 r10 1'11 r12 rl3 ri4 ri5
843 12 MADMAC Reference Manual
849 Numbers may be decimal, hexadecimal, octal, binary or concatenated ASCII. The
850 default radix is decimal, and it may not be changed. Decimal numbers are specified
851 with a string of digits (0-9). Hexadecimal numbers are specified with a leading
852 dollar sign ($) followed by a string of digits and uppercase or lowercase letters (A-F
853 a-f). Octal numbers are specified with a leading at-sign (@) followed by a string
854 of octal digits (0-7). Binary numbers are specified with a leading percent sign
855 (%) followed by a string of binary digits (0-1). Concatenated ASCII constants are
856 specified by enclosing from one to four characters in single or double quotes. For
866 Negative numbers Are specified with a unary minus (-). For example:
872 Strings are contained between double (") or single ( ') quote marks. Strings may
873 contain non-printable characters by specifying "backslash" escapes, similar to the
874 ones used in the C programming language. MADMAC will generate a warning if a
875 backslash is followed by a character not appearing below:
878 \n $0a line-feed (newline)
881 \r $0c1 carriage-return
887 It is possible for strings (but not symbols) to contain characters with their high
888 bits set (i.e. character codes 128...255).
889 You should be aware that backslash characters are popular in GEMDOS path
890 names, and that you may have to escape backslash characters in your existing source
891 code. For example, to get the file "c:\euto\andi.s" you would specify the string
895 Register lists are special forms used with the movem mnemonic and the .reg
896 directive. They are 16-bit values, with bits 0 through 15 corresponding to registers
897 D0 through A7. A register list consists of a series of register names or register
898 ranges seperated by slashes. A register range consists of two register names, Rm
899 and Rn,m<n, seperated by a dash. For example:
901 MADMAC Reference Manual 13
911 dO/d1/a0-a3/d7/a6-a7 $CF83
914 Register lists and register equates may be used in conjunction with the movem
915 mnemonic, as in this example:
916 temps reg d0-d2/a0-a2 ; temp registers
917 keeps reg d3-d7/d3-a6 ; registers to preserve
918 allregs reg d0-d7/a0-a7 ; all registers
919 movem.l #temps, -(sp) ; these two lines ...
920 aovea.l dO -d2/a0 -a2, -(sp) ; are identical
921 movea.l #keeps, -(sp) ; save "keep" registers
922 noven.1 (sp)+,#keeps ; restore "keep" registers
970 14 MADMAC Reference Manual
981 All values are computed with 32-bit 2's complement arithmetic. For boolean op-
982 erations (such as if or assert) zero is considered false, and non-zero is considered
984 Expressions are evaluated strictly left-to-right, with no
985 regard for operator precedence.
986 Thus the expression "1+2*3" evaluates to 9, not 7. However, precedence may be
987 forced with parenthesis (()) or square-brackets ([]).
990 Expressions belong to one of three classes: undefined, absolute or relocatable. An
991 expression is undefined if it involves an undefined symbol (e.g. an undeclared sym-
992 bol, or a forward reference). An expression is absolute if its value will not change
993 when the program is relocated (for instance, the number 0, all labels declared in
994 an abs section, and all Atari ST hardware register locations are absolute values).
995 An expression is relocatable if it involves exactly one symbol that is contained in a
996 text, data or BSS section.
997 Only absolute values may be used with operators other than addition (+) or
998 subtraction (-). It is illegal, for instance, to multiply or divide by a relocatable or
999 undefined value. Subtracting a relocatable value from another relocatable value in
1000 the same section results in an absolute value (the distance between them, positive
1001 or negative). Adding (or subtracting) an absolute value to or from a relocatable
1002 value yeilds a relocatable value (an offset from the relocatable address).
1003 It is important to realize that relocatable values belong to the sections they
1004 are defined in (e.g. text, data or BSS), and it is not permissible to mix and match
1005 sections. For example, in this code:
1006 linel: dc.l line2, linel+8
1007 line2: dc.l linel, line2-8
1008 line3: dc.l line2-linel, 8
1009 error: dc.l linel+line2, line2 >> 1, line3/4
1010 Line 1 deposits two longwords that point to line 2. Line 2 deposits two longwords
1011 that point to line 1. Line 3 deposits two longwords that have the absolute value
1012 eight. The fourth line will result in an assembly error, since the expressions (re-
1013 spectively) attempt to add two relocatable values, shift a relocatable value right by
1014 one, and divide a relocatable value by four.
1015 The pseudo-symbol "*" (star) has the value that the current section's location
1016 counter had at the beginning of the current source line. For example, these two
1017 statements deposit three pointers to the label "bar":
1021 Similarly, the pseudo-symbol "$" has the value that the current section's loca-
1022 tion counter has, and it is kept up to date as the assembler deposits information
1024 MADMAC Reference Manual 15
1031 "across" a line of source code. For example, these two statements deposit four
1032 pointers to the label "zip":
1041 Operator Description
1042 - Unary minus (2's complement).
1043 ! Logical (boolean) NOT.
1044 ~ Tilde: bitwise not (l's complement).
1045 ^^defined symbol True if symbol has a value.
1046 ^^referenced symbol True if symbol has been referenced.
1047 ^^streq stringl,string2 True if the strings are equal.
1048 ^^macdef macroName True if the macro is defined.
1050 o The boolean operators generate the value 1 if the expression is true, and 0 if
1053 o A symbol is referenced if it is involved in an expression. A symbol may have
1054 any combination of attributes: undefined and unreferenced, defined and unref-
1055 erenced (i.e. declared but never used), undefined and referenced (in the case
1056 of a forward or external reference), or defined and referenced.
1062 Operator Description
1063 + - * / The usual arithmetic operators.
1065 & | ^ Bit-wise AND, OR and Exclusive-OR.
1066 << >> Bit-wise shift left and shift right.
1067 < <= >= > Boolean magnitude comparisons.
1069 <> != Boolean inequality.
1071 o All binary operators have the same precedence: expressions are evaluated
1072 strictly left to right.
1074 o Division or modulo by zero yields an assembly error
1076 o The "<>" and "!=" operators are synonyms.
1078 o Note that the modulo operator (%) is also used to introduce binary constants
1079 (see: Constants). A percent sign should be followed by at least one space if
1080 it is meant to be a modulo operator, and is followed by a '0' or '1'.
1084 Special Form Description
1085 ^^date The current system date (Gemdos format).
1086 ^^time The current system time (Gemdos format).
1088 o The "^^date" special form expands to the current system date, in Gemdos
1089 format. The format is a 16-bit word with bits 0 ...4 indicating the day of the
1090 month (1...31), bits 5...8 indicating the month (1...12), and bits 9...15
1091 indicating the year since 1980, in the range 0...119.
1093 16 MADMAC Reference Manual
1098 o The "^^time" special form expands to the current system time, in Gemdos
1099 format. The format is a 16-bit word with bits 0...4 indicating the current
1100 second divided by 2, bits 5...10 indicating the current minute 0...59. and
1101 bits 11...15 indicating the current hour 0...23.
1105 line address contents source code
1106 ---- ------- -------- -------------------------------
1107 1 00000000 4480 lab1: neg.l d0
1108 2 00000002 427900000000 lab2: clr.w lab1
1109 3 =00000064 equ1 = 100
1110 4 =00000096 equ2 = equ1 + 50
1111 5 00000008 00000064 dc.l lab1 + equ1
1112 6 0000000C 7FFFFFE6 dc.l (equl + ~equ2) >> 1
1113 7 00000010 0001 dc.w ^^defined equl
1114 8 00000012 0000 dc.w ^^referenced lab2
1115 9 00000014 00000002 dc.l lab2
1116 10 00000018 0001 dc.w ^^referenced lab2
1117 11 0000001A 0001 dc.w lab1 = (lab2 - 6)
1118 Lines 1 through four here are used to set up the rest of the example. Line 5 deposits
1119 a relocatable pointer to the location 100 bytes beyond the label "lab1." Line 6 is
1120 a nonsensical expression that uses the and right-shift operators. Line 7 deposits
1121 a word of 1 because the symbol "equ1" is defined (in line 3).
1122 Line 8 deposits a word of 0 because the symbol "lab2," defined in line 2, has
1123 not been referenced. But the expression in line 9 references the symbol "lab2," so
1124 line 10 (which is a copy of line-8) deposits a word of 1. Finally, line 11 deposits a
1125 word of 1 because the Boolean equality operator evaluates to true.
1126 The operators "^^defined" and "^^referenced" are particularly useful in
1127 conditional assembly. For instance, it is possible to automatically include debugging
1128 code if the debugging code is referenced, as in:
1129 lea string,a0 ; AO -> message
1130 jsr debug ; print a message
1132 string: dc.b "Help me, Spock!",0 ; (the message)
1134 .iif ^^defined debug, .include "debug.s"
1135 The jsr statement references the symbol debug. Near the end of the source file, the
1136 ".iif' statement includes the file "debug.s" if the symbol debug was referenced.
1137 In production code, presumably all references to the debug symbol will be removed,
1138 and the debug source file will not be included. (We could have as easily made the
1139 symbol debug external, instead of including another source file).
1152 MADMAC Reference Manual 17
1165 Assembler directives may be any mix of upper- or lowercase. The leading periods
1166 are optional, though they are shown here and their use is encouraged. Directives
1167 may be preceeded by a label; the label is defined before the directive is executed.
1168 Some directives accept size suffixes (.b, .s, .w or .1); the default is word (.w) if no
1169 size is specified. The .s suffix is identical to .b. Directives relating to the 6502 are
1170 described in the chapter on 6502 Support.
1176 If the location counter for the current section is odd, make it even by adding
1177 one to it. In text and data sections a zero byte is deposited if necessary.
1178 .assert expression [,expression...]
1179 Assert that the conditions are true (non-zero). If any of the comma-seperated
1180 expressions evaluates to zero an assembler warning is issued. For example:
1181 .assert *-start = $76
1182 .assert stacksize >= $400
1186 Switch to the BSS, data or text segments. Instructions and data may not
1187 be assembled into the BSS-segment, but symbols may be defined and storage
1188 may be reserved with the As directive. Each assembly starts out in the text
1191 Start an absolute section, beginning with the specified location (or zero, if
1192 no location is specified). An absolute section is much like BSS, except that
1193 locations declared with .ds are based absolute. This directive is useful for
1194 declaring structures or hardware locations.
1195 For example, the following equates:
1201 could be as easily defined as:
1209 • 18 MADMAC Reference Manual
1213 .comm symbol, expression
1214 Specifies a label and the size of a common region. The label is made global,
1215 thus confined symbols cannot be made common. The linker groups all com-
1216 mon regions of the same name; the largest size determines the real size of the
1217 common region when the file is linked.
1219 .dc[.size] expression [,expression...]
1220 Deposit initialized storage in the current section. If the specified size is word
1221 or long, the assembler will execute a .even before depositing data. If the size
1222 is .b, then strings that are not part of arithmetic expressions are deposited
1223 byte-by-byte. If no size is specified, the default is .w. This directive cannot be
1224 used in the BSS section.
1226 .dcb[.size] expression 1, expression2
1227 Generate an initialized block of expression) bytes, words or longwords of the
1228 value expression2. If the specified size is word or long, the assembler will
1229 execute .even before generating data. If no size is specified, the default is .w.
1230 This directive cannot be used in the BSS section.
1232 .ds[.size] expression
1233 Reserve space in the current segment for the appropriate number of bytes,
1234 words or longwords. If no size is specified, the default size is .w. If the size
1235 is word or long, the assembler will execute .even before reserving space. This
1236 directive can only be used in the BSS or ABS sections (in text or data, use
1237 .dcb to reserve large chunks of initialized storage.)
1239 .init[.size] [#expression,]expression[.size] [,...]
1240 Generalized initialization directive. The size specified on the directive becomes
1241 the default size for the rest of the line. (The "default" default size is .w.) A
1242 comma-seperated list of expressions follows the directive; an expression may be
1243 followed by a size to override the default size. An expression may be preceeded
1244 by a sharp sign, an expression and a comma, which specifies a repeat count to
1245 be applied to the next expression. For example:
1246 .init.l -1, 0.w, #16,'z'.b, #3,0, 11.b
1248 will deposit a longword of -1, a word of zero, sixteen bytes of lower-case 'z',
1249 three longwords of zero, and a byte of 11.
1250 No auto-alignment is performed within the line, but a .even is done once
1251 (before the first value is deposited) if the default size is word or long.
1253 .cargs [#expression dsymboi[.size] [, symbol[.size].. .]
1254 Compute stack offsets to C (and other language) arguments. Each symbol is
1255 assigned an absolute value (like equ) which starts at expression and increases
1256 by the size of each symbol, for each symbol. If the expression is not supplied,
1257 the default starting value is 4. For example:
1258 .cargs #8, .fileliams.1, .openMode, .butPointer.l
1260 could be used to declare offsets from A6 to a pointer to a filename, a word
1261 containing an open mode, and a pointer to a buffer. (Note that the symbols
1262 used here are confined). Another example, a C-style "string-length" function,
1263 could be written as.
1265 MADMAC Reference Manual 19
1269 _strlen:: .cargs .string ; declare arg
1270 move.l .string(sp),a0 ; a0 -> string
1271 moveq #-1,d0 ; initial size = -1
1272 .1: addq.1 #1,d0 ; bump size
1273 tst.b (a0)+ ; at end of string?
1274 bne .1 ; (no -- try again)
1275 rts ; return string length
1277 End the assembly. In an include file, end the include file and resume assembling
1278 the superior file. This statement is not required, nor are warning messages
1279 generated if it is missing at the end of a file. This directive may be used inside
1280 conditional assembly, macros or .rept blocks.
1284 Start a block of conditional assembly. If the expression is true (non-zero) then
1285 assemble the statements between the .if and the matching .endif or .else.
1286 If the expression is false, ignore the statements unless a matching .else is
1287 encountered. Conditional assembly may be nested to any depth.
1288 It is possible to exit a conditional assembly block early from within an include
1289 file (with end) or a macro (with endni).
1290 .iif expression, statement
1291 Immediate version of if. If the expression is true (non-zero) then the state-
1292 ment, which may be an instruction, a directive or a macro, is executed. If
1293 the expression is false, the statement is ignored. No .endif is required. For
1295 .iif age < 21, canDrink = 0
1296 .iif weight > 500, dangerFlag = 1
1297 .iif !(^^defined DEBUG), .include dbsrc
1298 .macro name [formal, formal,...]
1301 Define a macro called name with the specified formal arguments. The macro
1302 definition is terminated with a .endm statement. A macro may be exited early
1303 with the .exitm directive. See the chapter on Macros for more information.
1304 .undefmac macroName [, macroNarne. .]
1305 Remove the macro-definition for the specified macro names. If reference is
1306 made to a macro that is not defined, no error message is printed and the name
1310 The statements between the .rept and .endr directives will be repeated ex-
1311 pression times. If the expression is zero or negative, no statements will be
1312 assembled. No label may appear on a line containing either of these directives.
1313 .globl symbol [, symbol...]
1314 .extern symbol [, symbol...]
1315 Each symbol is made global. None of the symbols may be confined symbols
1316 (those starting with a period). If the symbol is defined in the assembly, the
1317 symbol is exported in the object file. If the symbol is undefined at the end
1318 of the assembly, and it was referenced (i.e. used in an expression), then the
1320 20 MADMAC Reference Manual
1326 symbol value is imported as an external reference that must be resolved by the
1327 linker. The .extern directive is merely a. synonym for
1330 Include a file. If the filename is not enclosed in quotes, then a default extension
1331 of ".s" is applied to it. If the filename is quoted, then the name is not changed
1334 Note: If the filename is not a valid symbol, then the assembler will generate an
1335 error message. You should enclose filenames such as "atari.s" in quotes,
1336 because such names are not symbols.
1338 If the include file cannot be found in the current directory, then the direc-
1339 tory search path, as specified by -i on the commandline, or' by the NACPLTH
1340 enviroment string, is traversed
1343 Issue a page eject in the listing file.
1346 .subttl [-] "string"
1347 Set the title or subtitle on the listing page. The title should be specified on
1348 the the first line of the source program in order to take effect on the first page.
1349 The second and subsequent uses of .title will cause page ejects. The second
1350 and subsequent uses of .subttl will cause page ejects unless the subtitle string
1351 is preceeded by a dash (-).
1355 Enable or disable source code listing. These directives increment and decrement
1356 an internal counter, so they may be appropriately nested. They have no effect
1357 if the -l switch is not specified on the commandline.
1360 This directive provides unstructured flow of control within a macro definition.
1361 It will transfer control to the line of the macro containing the specified goto
1362 label. A goto label is a symbol preceeded by a colon that appears in the first
1363 column of a source line within a macro definition:
1367 where the label itself can be any valid symbol name, followed immediately by
1368 whitespace and a valid source line (or end of line). The colon must appear in
1370 The goto-label is removed from the source line prior to macro expansion -
1371 to all intents and purposes the label is invisible except to the .goto directive
1372 Macro expansion does not take place within the label.
1373 For example, here is a silly way to count from 1 to 10 without using .rept:
1379 iif count <= 10, goto loop
1389 MADMAC Reference Manual 21
1405 All of the standard Motorola 68000 mnemonics and addressing modes are supported;
1406 you should refer to The Motorola M68000 Programmer's Reference Manual
1407 for a description of the instruction set and the allowable addressing modes for each
1408 instruction. With one major exception (forward branches) the assembler performs
1409 all the reasonable optimizations of instructions to their short or address register
1411 Register names may be in upper or lower case. The alternate forms R0 through
1412 R15 may be used to specify D0 through A7. All register names are keywords, and
1413 may not be used as labels or symbols. None of the 68010 or 68020 register names
1414 are keywords (but they may become keywords in the future).
1417 Assembler Syntax Description
1418 Dn Data register direct
1419 An Address register direct
1420 (An) Address register indirect
1421 (An)+ Address register indirect postincrement
1422 -(An) Address register indirect predecrement
1423 disp(An) Address register indirect with displacement
1424 bdisp(An, Xi[.size]) Address register indirect indexed
1425 abs.w Absolute short
1426 abs Absolute (long or short)
1427 abs.l Forced absolute long
1428 disp(PC) Program counter with displacement
1429 bdisp(PC, Xi) Program counter indexed
1434 Since MADMAC is a one pass assembler, forward branches cannot be automatically
1435 optimized to their short form. Instead, unsized forward branches are assumed to
1436 be long. Backward branches are always optimized to the short form if possible.
1437 A table that lists "extra" branch mnemonics (common synonyms for the Mo-
1438 torola defined mnemonics) appears below.
1441 It is not possible to make an external reference that will fix up a byte. For example:
1444 move.l frog(pc,d0),d1
1446 22 MADMAC Reference Manual
1450 Alternate name Becomes:
1460 is illegal (and generates an assembly error) when frog is external, because the
1461 displacement occupies a byte field in the 68000 offset word, which the object file
1463 Optimizations and Translations
1464 The assembler provides "creature comforts" when it processes 68000 mnemonics:
1466 o CLR.x An will really generate SUB.x An,An.
1467 o ADD, SUB and CMP with an address register will really generate ADDA,
1469 o The ADD, AND, CMP, EOR, OR and SUB mnemonics with immediate
1470 first operands will generate the "I" forms of their instructions (ADDI, etc.) if
1471 the second operand is not register direct.
1472 o All shift instructions with no count value assume a count of one.
1473 o MOVE.L is optimized to MOVEQ if the immediate operand is defined and
1474 in the range -128...127. However, ADD and SUB are never translated to
1475 their quick forms; ADDQ and SUBQ must be explicit.
1476 MADMAC Reference Manual 23
1487 A macro definition is a series of statements of the form:
1488 .macro name [ formal-arg, ...]
1490 statements making up the macro body
1494 The name of the macro may be any valid symbol that is not also a 68000 instruction
1495 or an assembler directive. (The name may begin with a period - macros cannot
1496 be made confined the way labels or equated symbols can be). The formal argument
1497 list is optional; it is specified with a comma-seperated list of valid symbol names.
1498 Note that there is no comma between the name of the macro and the name of the
1499 first formal argument
1500 A macro body begins on the line after the .macro directive. All instructions
1501 and directives, except other macro definitions, are legal inside the body.
1502 The macro ends with the .endm statement. If a label appears on the line with
1503 this directive, the label is ignored and a warning is generated.
1505 Parameter Substitution
1506 Within the body, formal parameters may be expanded with the special forms:
1510 The second form (enclosed in braces) can be used in situations where the characters
1511 following the formal parameter name are valid symbol continuation characters. This
1512 is usually used to force concatentation, as in:
1514 \(godzilla}vs\{reagan}
1516 The formal parameter name is terminated with a character that is not valid in
1517 a symbol (e.g. whitespace or puncuation); optionally, the name may be enclosed in
1518 curly-braces. The names must be symbols appearing on the formal argument list,
1519 or a single decimal digit (\1 corresponds to the first argument, \2 to the second,
1520 \9 to the ninth, and \0 to the tenth). It is possible for a macro to have more than
1521 ten formal arguments, but arguments 11 and on must be referenced by name, not
1523 Other special forms are:
1525 24 MADMAC Reference Manual
1530 Special Form Description
1532 \~ a unique label of the form "Mn"
1533 \# the number of arguments actually specified
1534 \! the "dot-size" specified on the macro invocation
1535 \?name conditional expansion
1536 \?{name} conditional expansion
1538 The last two forms are identical: if the argument is specified and is non-empty, the
1539 form expands to a "1", otherwise (if the argument is missing or empty) the form
1541 The form "\!" expands to the "dot-size" that was specified when the macro
1542 was invoked. This can be used to write macros that behave differently depending
1543 on the size suffix they are given, as in this macro which provides a synonym for the
1545 .macro deposit value
1548 deposit.b 1 ; byte of 1
1549 deposit.w 2 ; word of 2
1550 deposit.l 3 ; longvord of 3
1551 deposit 4 ; word of 4 (no explicit size)
1554 A previously-defined macro is called when its name appears in the operation field of
1555 a statement. Arguments may be specified following the macro name; each argument
1556 is seperated by a comma. Arguments may be empty. Arguments are stored for
1557 substitution in the macro body in the following manner:
1558 o Numbers are converted to hexadecimal.
1559 o All spaces outside strings are removed.
1560 o Keywords (such as register names, dot sizes and "^^" operators) are converted
1562 o Strings are enclosed in double-quote marks (").
1563 For example, a hypothetical call to the macro "mymacro", of the form:
1564 mymacro A0, , 'Zorch' / 32, "^^DEFINED foo, , , tick tock
1565 will result in the translations:
1566 Argument Expansion Comment
1567 \1 a0 "A0" converted to lower-case
1569 \3 "Zorch"/$20 "Zorch" in double-quotes, 32 in hexadecimal
1570 \4 "^^defined foo" "^^DEFINED" converted to lower-case
1573 \7 ticktock spaces removed (note concatenation)
1575 The .exitm directive will cause an immediate exit from a macro body. Thus
1576 the macro definition:
1578 MADMAC Reference Manual 25
1583 .iif !\?source, .exitm ; exit if source is empty
1584 move \source,d0 ; otherwise, deposit source
1587 will not generate the move instruction if the argument "source" is missing from
1588 the macro invocation.
1589 The .end, .endif and .exitm directives all pop-out of their include levels
1590 appropriately. That is, if a macro performs a include to include a source file, an
1591 executed .exitm directive within the include-file will pop out of both the include-file
1593 Macros may be recursive or mutually recursive to any level, subject only to
1594 the availability of memory. When writing recursive macros, take care in the coding
1595 of the termination condition(s). A macro that repeatedly calls itself will cause the
1596 assembler to exhaust its memory and abort the assembly.
1601 The Gemdos macro is used to make file system calls. It has two parameters, a
1602 function number and the number of bytes to clean off the stack after the call. The
1603 macro pushes the function number onto the stack and does the trap to the file
1604 system. After the trap returns, conditional assembly is used to choose an addq or
1605 an add.w to remove the arguments that were pushed.
1606 .macro Gemdos trpno, clean
1607 move.w #\trpno,-(sp) ; push trap number
1608 trap #1 ; do GEMDOS trap
1610 addq Aclean,sp ; clean-up up to 8 bytes
1612 add.w $\clean,sp ; clean-up more than 8 bytes
1616 The Fopen macro is supplied two arguments; the address of a filename, and
1617 the open mode. Note that plain move instructions are used, and that the caller of
1618 the macro must supply an appropriate addressing mode (e.g. immediate) for each
1620 .macro Fopen file, mode
1621 movs.w \mode,-(sp) ;push open mode
1622 move.1 \file,-(sp) ;push address of tile name
1623 Gemdos $3d,8 ;do the GEMDOS call
1626 The String macro is used to allocate storage for a string, and to place the
1627 string's address somewhere. The first argument should be a string or other expres-
1628 sion acceptable in a dc.b directive. The second argument is optional; it specifies
1629 where the address of the string should be placed. If the second argument is omitted,
1630 the string's address is pushed onto the stack. The string data itself is kept in the
1633 26 MADMAC Reference Manual
1638 .macro String str,loc
1639 .if \?loc ; if lac is defined
1640 move.l #.\~,\loc ; put the string's address there
1642 pea .\~ ; push the string's address
1644 .data ; put the string data
1645 .\~: dc.b \str,0 ; in the data segment
1646 .text ; and switch back to the text segment
1649 The construction ".\~" will expand to a label of the form ".Mn" (where n is
1650 a unique number for every macro invocation), which is used to tag the location of
1651 the string. The label should be confined because the macro may be used along with
1652 other confined symbols.
1653 Unique symbol generation plays an important part in the art of writing fine
1654 macros. For instance, if we needed three unique symbols, we might write ".a\~",
1658 Repeat-blocks provide a simple iteration capability. A repeat block allows a range
1659 of statements to be repeated a specified number of times. For instance, to generate
1660 a table consisting of the numbers 255 through 0 (counting backwards) you could
1663 .count set 255 ; initialize counter
1664 .rept 256 ; repeat 256 times:
1665 dc.b .count ; deposit counter
1666 .count set .count - 1 ; and decrement it
1667 .endr ; (end of repeat block)
1669 Repeat blocks can also be used to duplicate identical pieces of code (which are
1670 common in bitmap-graphics routines). For example:
1672 .rept 16 ; clear 16 words
1673 clr.w (a0)+ ; starting at AO
1702 MADMAC Reference Manual 27
1715 MADMAC will generate code for the Motorola 6502 microprocessor. This chapter
1716 describes extra addressing modes and directives used to support the 6502.
1717 As the 6502 object code is not linkable (currently there is no linker) external
1718 references may not be made. (Nevertheless, MADMAC may reasonably be used for
1719 large assemblies because of its blinding speed.)
1720 All standard 6502 addressing modes are supported, with the exception of the
1721 accumulator addressing form, which must be omitted (e.g. "ror a" becomes "ror").
1722 Five extra modes, synonyms for existing ones, are included for compatibility with
1723 the Atari Coinop assembler.
1724 empty implied or accumulator (e.g. tsx or ror)
1725 expr absolute or zeropage
1733 x,expr(y) indirect Y
1737 While MADMAC lacks "high" and "low" operators, high bytes of words may
1738 be extracted with the shift (>>) or divide (/) operators, and low bytes may be
1739 extracted with the bitwise AND (&) operator.
1741 This directive enters the 6502 section. The location counter is undefined, and
1742 must be set with ".org" before any code can be generated.
1743 The "dc.w" directive will produce 6502-format words (low byte first). The
1744 68000's reserved keywords (d0-d7/a0-a7/ssp/usp and so on) remain reserved
1745 (and thus unusable) while in the 6502 section. The directives globl, dc.l,
1746 dcb.l, text, data, bas, abs, even and comm are illegal in the 6502 section.
1747 It is permitted, though probably not useful, to generate both 6502 and 68000
1748 code in the same object file.
1750 This directive leaves the 6502 segment and returns to the 68000's text segment.
1751 68000 instructions may be assembled as normal.
1753 This directive is only legal in the 6502 section. It sets the value of the location
1754 counter (or pc) to location, an expression that must be defined, absolute, and
1757 28 MADMAC Reference Manual
1763 It is possible to assemble "beyond" the microprocessor's 64K address space, but
1764 attempting to do so will probably screw up the assembler. DO NOT attempt
1765 to generate code like this:
1770 the third NOP in this example, at location $10000, may cause the assembler
1771 to crash or exhibit spectacular schizophrenia. In any case, MADMAC will give
1772 no warning before flaking out.
1775 This is a little bit of a kludge. An object file consists of a page map, followed by
1776 one or more page images, followed by a normal Alcyon 68000 object file. If the page
1777 map is all zero, it is not written.
1778 The page map contains a byte for each of the 256 256-byte pages in the 6502's
1779 64K address space. The byte is zero ($00) if the page contained only zero bytes, or
1780 one ($01) if the page contained any non-zero bytes. If a page is flagged with a one,
1781 then it is written (in order) following the page map.
1791 will generate a page map that looks (to a programmer) something like:
1794 <$7c more bytes of zero, for $100 total>
1798 Following the last page image is an Alcyon-format object file, starting with
1799 the magic number $601a. It may contain 68000 code (although that is probably
1800 useless), but the symbol table is valid and available for debugging purposes. 6502
1801 symbols will be absolute (not in text, data or bss).
1814 MADMAC Reference Manual 29
1826 When Things Go Wrong
1827 Most of MADMAC's error messages are self-explanatory. They fall into four classes:
1828 warnings about situations that you (or the assembler) may not be happy about,
1829 errors that cause the assembler to not generate object files, fatal errors that cause
1830 the assembler to abort immediately, and internal errors that should never happen.1
1831 You can write editor macros (or sed or awk scripts) to parse the error messages
1832 MADMAC generates. When a message is printed, it is of the form:
1833 "filename" , line line-number: message
1834 The first element, a filename enclosed in double quotes, indicates the file that gen-
1835 erated the error. The filename is followed by a comma, the word "line", and a line
1836 number, and finally a colon and the text of the message. The filename "(*top*)"
1837 indicates that the assembler could not determine which file had the problem.
1838 The following sections list warnings, errors and fatal errors in alphabetical
1839 order, along with a short description of what may have caused the problem.
1842 bad backslash code in string
1843 You tried to follow a backslash in a string with a character that the assembler
1844 didn't recognize. Remember that MADMAC uses a C-style escape system in
1847 You specified a label before a macro, rept or endm directive. The assembler
1848 is warning you that the label will not be defined in the assembly.
1849 unoptimized short branch
1850 This warning is only generated if the -s switch is specified on the command
1851 line. The message refers to a forward, unsized long branch that you could have
1856 As a result of previous errors, the assembler cannot continue processing. The
1857 assembly is aborted.
1858 line too long as a result of macro expansion
1859 When a source line within a macro was expanded, the resultant line was too
1860 long for MADMAC (longer than 200 characters or so).
1863 1 If you come across an internal error, we would appreciate it if you would contact
1864 Atari Technical Support and let us know about the problem.
1866 30 MADMAC Reference Manual
1872 The assembler ran out of memory. You should (1) split up your source files
1873 and assemble them seperately, or (2) if you have any ramdisks or RAM-resident
1874 programs (like desk accessories) decrease their size so that the assembler has
1875 more RAM to work with. As a rule of thumb, pure 68000 code will use up to
1876 twice the number of bytes contained in the source files, whereas 6502 code will
1877 use 64K of ram right away, plus the size of the source files. The assembler itself
1878 uses about 80K bytes. Get out your calculator...
1882 The assembler ran across an endm directive when it wasn't expecting to see
1883 one. The assembly is aborted. Check the nesting of your macro definitions -
1884 you probably have an extra endm.
1891 Syntax error in .cargs directive.
1893 .comm symbol already defined
1894 You tried to .comm a symbol that was already defined.
1896 .ds permitted only in BSS
1897 You tried to use .ds in the text or data section.
1899 .init not permitted in BSS or ABS
1901 You tried to use .init in the BSS or ABS section.
1903 .org permitted only in .6502 section
1904 You tried to use .org in a 68000 section.
1906 Cannot create: filename
1907 The assembler could not create the indicated filename.
1909 External quick reference
1910 You tried to make the immediate operand of a moveq, subq or addq instruc-
1914 PC-relative expr across sections
1915 You tried to make a PC-relative reference to a location contained in another
1918 [bwsl] must follow '.' in symbol
1920 You tried to follow a dot in a symbol name with something other than one of
1921 the four characters 'B', 'W', 'S' or 'L'.
1923 addressing mode syntax
1925 You made a syntax error in an addressing mode.
1928 One of your .assert directives failed!
1930 bad (section) expression
1931 You tried to mix and match sections in an expression
1933 bad 6502 addressing mode
1934 The 6502 mnemonic will not work with the addressing mode you specified.
1937 There's a syntax error in the expression you typed.
1942 MADMAC Reference Manual 31
1947 You tried to use an inappropriate size suffix for the instruction. Check your
1948 68000 manual for allowable sizes.
1950 You can't use .b (byte) mode with the movem instruction.
1951 cannot .globl local symbol
1952 You tried to make a confined symbol global or common.
1953 cannot initialize non-storage (BSS) section
1954 You tried to generate instructions (or data, with dc) in the BSS or ABS section.
1955 cannot use '.b' with an address register
1956 You tried to use a byte-size suffix with an address register. The 68000 does not
1957 perform byte-sized address register operations.
1958 directive illegal in .6502 section
1959 You tried to use a 68000-oriented directive in the 6502 section.
1961 The expression you typed involves a division by zero.
1962 expression out of range
1963 The expression you typed is out of range for its application.
1964 external byte reference
1965 You tried to make a byte-sized reference to an external symbol, which the
1966 object file format will not allow
1967 external short branch
1968 You tried to make a short branch to an external symbol, which the linker cannot
1970 extra (unexpected) text found after addressing mode
1971 MADMAC thought it was done processing a line, but it ran up against "extra"
1972 stuff. Be sure that any comment on the line begins with a semicolon, and check
1973 for dangling commas, etc.
1974 forward or undefined .assert
1975 The expression you typed after a .assert directive had an undefined value.
1976 Remember that MADMAC is one-pass.
1977 hit EOF without finding matching .endif
1978 The assembler fell off the end of last input file without finding a . endif to
1979 match an . it. You probably forgot a . endif somewhere.
1980 illegal 6502 addressing mode
1981 The 6502 instruction you typed doesn't work with the addressing mode you
1983 illegal absolute expression
1984 You can't use an absolute-valued expression here.
1985 illegal bra.s with zero offset
1986 You can't do a short branch to the very next instruction (read your 68000
1988 illegal byte-sized relative reference
1989 The object file format does not permit bytes contain relocatable values; you
1990 tried to use a byte-sized relocatable expression in an immediate addressing
1993 32 MADMAC Reference Manual
1999 Your source file contains a character that MADMAC doesn't allow. (most
2000 control characters fall into this category).
2001 illegal initialization of section
2002 You tried to use .dc or .dcb in the BSS or ABS sections.
2003 illegal relative address
2004 The relative address you specified is illegal because it belongs to a different
2006 illegal word relocatable (in .PRG mode)
2007 You can't have anything other than long relocatable values when you're gener-
2009 inappropriate addressing mode
2010 The mnemonic you typed doesn't work with the addressing modes you specified.
2011 Check your 68000 manual for allowable combinations.
2012 invalid addressing mode
2013 The combination of addressing modes you picked for the movem instruction
2014 are not implemehydd by the 68000. Check your 68000 reference manual for
2016 invalid symbol following ^^
2017 What followed the ^^ wasn't a valid symbol at all.
2019 The assembler found a .endr directive when it wasn't prepared to find one.
2020 Check your repeat-block nesting.
2022 The assembler found a .else directive when it wasn't prepared to find one.
2023 Check your conditional assembly nesting.
2025 The assembler found a .endif directive when it wasn't prepared to find one.
2026 Check your conditional assembly nesting.
2029 missing argument name
2030 missing close parenthesis ')'
2031 missing close parenthesis ']'
2036 missing symbol or string
2037 The assembler expected to see a symbol/filename/string (etc...), but found
2038 something else instead. In most cases the problem should be obvious.
2039 misuse of '.', not allowed in symbols
2040 You tried to use a dot (.) in the middle of a symbol name.
2042 The expression you typed involves a modulo by zero.
2047 MADMAC Reference Man ual 33
2052 multiple formal argument definition
2053 The list of formal parameter names you supplied for a macro definition includes
2054 two identical names.
2055 multiple macro definition
2056 You tried to define a macro which already had a definition.
2057 non-absolute byte reference
2058 You tried to make a byte reference to a relocatable value, which the object file
2059 format does not allow.
2060 non-absolute byte value
2061 You tried to dc.b or dcb.b a relocatable value. Byte relocatable values are
2062 not permitted by the object file format.
2064 You tried to specify a register list like D7-D0, which is illegal. Remember
2065 that the first register number must be less than or equal to the second register
2067 register list syntax
2068 You made an error in specifying a register list for a .reg directive or a .movem
2071 You probably forgot a comma between the names of two symbols in a symbol
2072 list, or you left a comma dangling on the end of the line.
2074 This is a "catch-all" error.
2075 undefined expression
2076 The expression has an undefined value because of a forward reference, or an
2077 undefined or external symbol.
2078 unimplemented addressing mode
2079 You tried to use 68020 "square-bracket" notation for a 68020 addressing mode.
2080 MADMAC does not support 68020 addressing modes.
2081 unimplemented directive
2082 You have found a directive that didn't appear in the documentation. It doesn't
2084 unimplemented mnemonic
2085 You've found an assembler for documentation) bug.
2086 unknown symbol following ^^
2087 You followed a ^^ with something other than one of the names defined, ref-
2089 unsupported 68020 addressing mode
2090 The assembler saw a 68020-type addressing mode. MADMAC does not assem-
2091 ble code for the 68020 or 68010.
2093 You specified a string starting with a single or double quote, but forgot to type
2096 The assembler had a problem writing an object file. This is usually caused by
2097 a full disk, or a bad sector on the media.
2099 34 MADMAC Reference Manual