IASM12 USERS MANUAL LICENSE, LIABILITY, and ACKNOWLEDGEMENTS ............ 1 IASM12 - The Integrated Assembler ................... 2 INSTALLATION ........................................ 4 HOTKEYS ............................................. 6 MENU ................................................ 7 HELP ................................................ 9 EDITOR .............................................. 10 Entering and Editing Test ......................... 10 The Editing Screen ................................ 10 Tabs .............................................. 11 Windows ........................................... 12 Cursor Movement Commands .......................... 13 Insert and Delete Commands ........................ 15 Block Commands .................................... 16 Miscellaneous Commands ............................ 18 ASSEMBLER ........................................... 20 Labels ............................................ 21 Assembler Directives .............................. 21 Conditional Assembly .............................. 23 Includes .......................................... 24 Macros ............................................ 25 Constants ......................................... 26 Opcodes ........................................... 26 Operands .......................................... 27 Comments .......................................... 27 Pseudo-Ops ........................................ 28 Listing Directives ................................ 29 Listing File ...................................... 30 Object files ...................................... 30 Map files ......................................... 31 Errors ............................................ 32 COMMUNICATIONS ...................................... 34 INSTRUCTION SET ..................................... 36 INSTRUCTION FORMATS ................................. 40 ADDRESSING MODES .................................... 43 Inherent Addressing ............................... 43 Immediate Mode (IMM) .............................. 43 Direct Mode (DIR) ................................. 43 Extended Addressing (EXT) ......................... 43 Indexed 5-BIT Constant Offset (IDX) ............... 44 Indexed Auto Pre/Post Decrement/Increment (IDX) ... 44 Indexed Accumulator Offest (IDX) .................. 44 Indexed 9-Bit Constant Offset (IDX1) .............. 44 Indexed 16-Bit Constant Offset (IDX2) ............. 45 Indexed 16-Bit Constant Indirect ([IDX2]) ......... 45 Indexed Auto Pre/Post Decrement/Increment (IDX) ... 45 Indexed Accumulator Offest (IDX) .................. 46 Indexed D-Indirect ([D,IDX]) ...................... 46 Multiple Addressing Modes ......................... 46 IASM12.DOC Copyright P&E Microcomputer (1997) Page - Index LICENSE LICENSE, LIABILITY, and ACKNOWLEDGEMENTS P&E Microcomputer Systems License Agreement: The IASM12 license is a "single user" license. You may: 1. Personally use the program on any machine; 2. Copy the program into any machine-readable or printed form for your personal use as backup only. You may not: 1. Use, copy, modify, or transfer the program, in whole or in part, except as noted above; 2. De-compile or disassemble the code for the program; 3. Use or place the program on any time sharing or other interactive system including but not restricted to workstation networks, bulletin boards or multi-user systems; 4. Rent or lease this program. This program may only be used on one computer at any one time. LIABILITY P&E Microcomputer System does not assume any liability for the use of IASM12 beyond the original purchase price of the software. In no event will P&E Microcomputer Systems be liable to you for additional damages, including any lost profits, lost savings or other incidental or consequential damages arising out of the use of or inability to use this program, even if P&E Microcomputer Systems, Inc. has been advised of the possibility of such damages. ACKNOWLEDGEMENTS Portions of the software are: copyright 1987 by Borland International copyright 1988 by TurboPower Software Manufacture's specifications offered in the HELP screens are reprinted with the manufacture's permission. See "MANUFACTURER" within the HELP system. IASM12.DOC Copyright P&E Microcomputer (1997) Page - 1 IASM12 IASM12 - The Integrated Assembler IASM12 is an editor, cross assembler, and communications package. All three applications have been blended into a single environment to greatly simplify your job of writing and debugging source code. With IASM12 you will be able to easily correct any syntactical errors in your source code without leaving the environment. IASM12's integrated editor is a standard source file editor. The integrated cross assembler is similar to P&E Microcomputer's past cross assemblers but has been optimized for the new environment. The built in communication environment enables you to work with any development system attached to your PC. Assembled files may be downloaded and tested while the original source code is edited and assembled. System Requirements IASM12 runs under MS-DOS or PC-DOS on an IBM PC, XT, AT or compatible. It is greatly recommended to have at least 512 Kilobytes of system memory. The communications uses COM1 or COM2. If you intend to print from within IASM12, the standard DOS printer port is used. System Overview IASM12 lets you generate standard assembly language source code or read it in from a disk file. Three output files may be generated. One is the object file, machine language for the target processor. The second is a listing file: a copy of the input text with various annotations such as the machine code, cycle timing, etc. The third is a map file. This is used by other P&E Microcomputer software such as simulators and user interfaces. These files may or may not be generated, depending on the options the user chooses. If an error is found during assembly of a file, the line in question is highlighted on the screen, the cursor is placed near the error, and the user is told of the problem. The communications window may be opened at anytime and the code tested on a development board. Getting Started Two files must reside in your working directory or on your DOS path (see your DOS manual) for the environment to work properly. One is the main file IASM12.EXE. The other file is the on-screen help file, IASM12.HLP. This file is only needed if you plan on using the built-in help system. To start the environment all you need to type is the command line : IASM12 where is an optional file name that will immediately be loaded into the editor. Note that the editor will, as a default, name all files with the extension .ASM. If a filename is not specified, the editor will start with a blank file entitled "NONAME.ASM". You will be prompted to change it's name upon saving the file. IASM12.DOC Copyright P&E Microcomputer (1997) Page - 2 NOTE: Any source code used as examples in this manual may or may not use mnemonics that are acceptable for your version of the assembler. If you are using source code that has been written for another assembler, see the Appendix at the end of this manual. IASM12.DOC Copyright P&E Microcomputer (1997) Page - 3 INSTALLATION Installation You may choose to run the installation program at any time and as many times as you wish. The program has four basic functions. First, it allows you to change any of the editor commands. Second, it enables you to choose any color scheme you like. Third, you set up various parameters concerning the assembler. Fourth, you set up the parameters concerning the communications. To invoke the installation program, at the DOS prompt type: IASMINST IASM12 You will first have the opportunity to modify certain parameters for the editor. In most cases, hitting Enter will accept the default value shown. You will be asked for a DOS string to be executed when F6 is hit during an editing session. This is a dedicated shell to DOS and may be left blank if desired. Next you can modify several assembler choices. You will be prompted for default settings of all the items in the ASSEMBLE sub-menu. See that section for a full explanation. Next you can modify the communications parameters. You will be prompted for default settings of all the items in the COMM sub-menu. See that section for a full explanation. At this point you will be prompted for color choices. The screen shows all possible colors or shades for the current monitor. Choose whichever colors suit your taste. Use the up and down arrow keys to choose the attribute you want to set and hit Enter. Now use the arrow keys to choose a color and select it with the Enter key. When finished, hit Esc. You will now be asked if you want fast entry mode for keyboard configuration. The default entry is NO for random access entry. These are ways of reconfiguring the editor commands. Fast Entry If you choose fast entry, you will receive on line instructions. Basically, you are shown each command one at a time and can either leave it the way it is (press Enter), change it using the Bksp key, clear it by hitting C or restore it by hitting R. If you specify a new command, terminate it by hitting Enter. If you wish Enter to be part of the command, first press the Scroll-Lock key to accept keys literally. Hit it again to go back to the normal mode. Pressing Esc takes you out of the fast entry mode and puts you into the random access mode. Random Access This mode lets you alter any or all commands in any order. Instructions are shown at the top of the screen. Use the cursor keys to move the cursor to the entry you want to change. The editing functions are the same as described in fast entry, above. IASM12.DOC Copyright P&E Microcomputer (1997) Page - 4 Moving on ... When you are done making changes you can hit the Esc followed by either Q or W. W W will bring up the message "Checking for conflicts ..." If you have assigned the same sequence to two commands, you will be given an error message. You can correct the mistake by looking for highlighted items. You will also get an error message if the new list of keystrokes is too long. If so, just eliminate some of the secondary key sequences, or any you will not be using. Q Q will cause the installation program to move on and not change any commands. NOTE: Whenever you assemble a program and a listing file is generated, the assembly time will be increased. It is recommended that you set this default to OFF and only turn it on when you want to generate a listing file. The same is true of the object file. IASM12.DOC Copyright P&E Microcomputer (1997) Page - 5 HOTKEYS Hotkeys You will notice that several hotkeys are shown on the bottom of the screen display. They are : F1 : Help This key will bring up the help; system. F2 : Save Hitting F2 will cause the file currently in the editor to be saved, a backup file to be made and the cursor returned to the point just before F2 was selected. F3 : Load Hitting F3 will allow the user to load in a new file. You will be prompted, if any changes have been made to the current file, to save the current file and then asked for the name of the new file. Hitting ^ F3 (Cntrl F3) will do the same but the file loaded will be the file specified on the command line when IASM12 was entered. F4 : Assemble Hitting F4 will start the assembly of the file currently in the editor. Any options chosen from the main menu system will be in effect. Note that only one window may be open during assembly. F5 : Exit Hitting F5 will cause an end to the editing-assembling session. If any changes have been made to the current file, you will be given an opportunity to save them before returning to DOS. If you are in a secondary window, F5 will close that window. F6 : DOS String Hitting F6 causes a shell to DOS with the string specified in the installation program. F7 : Comm Hitting F7 will either open the communications window or, if it is already open, will make the communications window the active window. F9 : DOS shell Hitting F9 will put you into DOS. Typing EXIT at the DOS prompt will return you into IASM12. F10 : Menu Hitting F10 will cause the main menu system to appear. IASM12.DOC Copyright P&E Microcomputer (1997) Page - 6 MENU Menu The Menu system contains a highlighted bar along the bottom of the screen. You can choose a menu ;item by highlighting it with the cursor keys or entering the highlighted letter within your choice ('E' in Edit, for example). Hitting Esc; will go back to the previous menu (if you are within a submenu) or return you to the editor. Edit: This choice will put you back into the editor. There are no submenus. File: This choice will open a submenu with the following choices : Save: The file currently in the editor is saved, a backup file is made and the cursor returned to the point just before the selection. Load: Loads in a new file. You will be prompted, if any changes have been made to the current file, to save the current file and then asked for the name of the new file. Dir: Shows a directory listing using the mask prompted for. The default mask is *.asm, thus showing all files in the current directory having an extension of .ASM. If the cursor is placed on a filename and Enter is pressed, that file will be loaded into the editor. Assemble: This choice will open a submenu with the following choices: Assemble: Performs the assembly of the file currently in the editor. Any options chosen from this submenu will be in effect. Note that only one window may be open during assembly. Listing: This choice toggles between on and off indicating whether or not a listing file (.LST) will be created at assembly time. Note that assembly time is increased when listing is turned on. Object: This choice toggles between off, hex and s19 indicating whether or not an object file will be created at assembly time and what type it will be. Choose the type needed by your development system or PROM programmer. Note that assembly time is increased when an object file is created. Cycle Cntr: This choice toggles between on and off indicating whether or not instruction cycle counts will be included in the listing file. Debug Map: This choice toggles between on and off indicating whether or not a map file (.MAP) will be created at assembly time. Note that assembly time is increased when a map file is created. Map files are used with P&E Microcomputer simulators and interface software. Macro: This choice toggles between view and IASM12.DOC Copyright P&E Microcomputer (1997) Page - 7 hide. View means that the source code for macros will be printed in the .LST file at every macro call. Hide suppresses this printing. Include: This choice toggles between view and hide. View means that the source code within the INCLUDE files will be printed in the .LST file. Hide suppresses this printing. Communicate: This choice will open a submenu with the following choices: Comm: This choice toggles between COM1 and COM2, the hardware ports recognized by the operating system. Baud: This choice toggles through the list of possible baud rates from 110 to 9600. Parity: This choice toggles between N for none, E for even and O for odd. Length: This choice toggles between 7 and 8 indicating the number of bits per word to use. Stop: This choice toggles between 1 and 2 indicating the number of stop bits per word to use. Help: Brings up the help menu. IASM12.DOC Copyright P&E Microcomputer (1997) Page - 8 HELP Help Hitting F1 from within the editor brings up the menu driven help system. The initial window displays a list of topics from which to choose. Using the cursor keys, move the highlight bar over the topic desired. Note that when there are more topics than the window shows, the window will scroll with the up and down arrow keys. Once an item is chosen, hitting Enter will display the first help page for that item. PgDn and PgUp keys will show the next or previous pages. Hitting Esc at any time will exit the current help window going to the previous one, exiting the help system from the first window. The help system covers three main areas. The first is the editor itself and all of the commands are given. If any commands have been changed via IASMINST, the changes will not be reflected here. The second area is the assembler. Most assembler commands, options and structures are explained. Finally there are microcontroller - microprocessor specific topics. In most cases this information is from the manufacturer and reprinted with their permission. P&E Microcomputer has made every effort to assure the accuracy of this information but assumes no responsibility for it. See the help topic "MANUFACTURER" for more information. Also note that the chip information is generally for the entire family of chips that this specific IASM12 covers, hence not all of the information may be applicable to your application. IASM12.DOC Copyright P&E Microcomputer (1997) Page - 9 EDITOR Editor Entering and Editing Text Text is entered into the editor much like it is on a typewriter and most of the keys act the same way. However, there are several important differences. 1. The cursor is always positioned at the spot where new text will be entered. 2. There are several delete commands to correct mistakes quickly and easily. 3. There are several block commands for moving and copying text. 4. There are Find and Find-and-replace commands. 5. In many cases you can "undo' your last several commands with the Restore option. All of the commands are described in the text that follows. For a quick reference, refer the back cover of this manual. The Editing Screen The top line of the screen is set aside as a prompt line. Messages and instructions are displayed here as are responses to prompts (see the section "Prompt Editor"). When the first key of a two key command is entered, it is echoed at the left edge of the prompt line. The top line of any editing window is a status line with the following information: FILENAME.EXT Shows the name and extension of the file being edited. You may specify full path names to the editor but they will not show up here. Line n This is the line number, starting from the start of the file, that the cursor is currently on. Col n The number of the column containing the cursor. Byte n The position of the cursor relative to the first character in the file. Insert Shows that the editor is in insert mode (as opposed to overwrite). Indent Shows that the editor is in auto-indent mode. Tab Shows that the editor is using fixed tab stops. Save This indicates that the file has been modified since IASM12.DOC Copyright P&E Microcomputer (1997) Page - 10 it was last saved. Prompt Editor When IASM12 prompts you for a response to a question, you are generally presented with a default answer which may be accepted by hitting Enter. You may cancel the operation by hitting Esc. When you are entering text at the prompt line, you are using the prompt editor, a line editor with its own set of commands. Most are the same as the full editor in IASM12 with the following additions: Function Key Command Accept entry Enter or ^M Abort Esc Insert control character ^P ================================================================== TABS Tabs There are two tab settings, smart tabs and fixed tabs. Smart tabs: When smart tabs is enabled, the tab stops are determined by the previous line. The start of any non-space sequence (the first letter in a word, for instance) acts as a tab stop. This is generally the easiest mode to use when entering source code. Fixed tabs: Tab stops start at column 9 and then every 8 columns. This can be changed in the installation program to any number desired. Note that the first tab stop is always in column (tab size + 1). With either setting, tabs are translated to spaces automatically. When a file is read into the editor, all tabs are expanded to the default tab settings. When a file is written, spaces will be encoded into tabs if this option is enabled via IASMINST, the installation program. This will save disk space but cause the writing of files to be slower. IASM12.DOC Copyright P&E Microcomputer (1997) Page - 11 WINDOWS Window Commands You may have up to 5 windows open at any one time. Note that when you assemble, only one window may be open and that is to contain the file to be assembled. All window commands are accessed with the Alt key. When this key is held down, the help line at the bottom of the display will show you the available key combinations. Add a window Alt-F3 Opens another text window. You will be prompted for a file to edit; if none is specified, NONAME.ASM will be created. You may later save it as a named file. If too many windows are open or if the active window is too small to divide in half (to make room for the new window), you will get an error message. Close a window Alt-X Closes the current window. If there is only one window active, this will close the window and leave IASM12. Resize current window Alt-F4 Changes the size of the current window. You may adjust the size by pressing the up and down arrow keys. When you are done, press Enter or Esc to return to the editor. Next window Alt-F1 Makes the next text window the current window. Previous window Alt-F2 Makes the previous text window the current window. IASM12.DOC Copyright P&E Microcomputer (1997) Page - 12 CURSOR COMMANDS Cursor Commands There are typically two ways of moving the cursor on screen. One way is with the cursor control keys on the cursor pad, and the other is via control characters. Either method can be defined or changed by running the installation program. The symbol ^ means hold down the Ctrl key while pressing the following letter. Character left left arrow or ^S Moves the cursor one character to the left. Character right Right arrow or ^D Moves the cursor one character to the right. This command may cause the display to scroll horizontally but it will not cause the cursor to change lines. Word left ^Left arrow or ^A Moves the cursor to the beginning of the word to the left. The cursor may move across a line break. Word right ^Right arrow or ^F Moves the cursor to the beginning of the word to the right. The cursor may move across a line break. Line up Up arrow or ^E Moves the cursor up a line and may scroll the screen. Line down Down arrow or ^X Moves the cursor down a line and may scroll the screen. Scroll up ^W Scrolls the screen up one line. The cursor does not change lines until it hits the bottom of the screen. Scroll down ^Z Scrolls the screen down one line. The cursor does not change lines until it hits the top of the screen. Page up PgUp or ^R Moves the cursor up one page with a single line of overlap. Page down PgDn or ^C Moves the cursor down one page with a single line of overlap. Beginning of file ^PgUp or ^QR Moves the cursor to the file's first character. End of file ^PgDn or ^QC Moves the cursor just beyond the end of the file. Beginning of line Home or ^QS Moves the cursor to column 1 of the current line. End of line End or ^QD Moves the cursor to the end of the current line. Trailing blanks are always removed from lines. Top of screen ^Home or ^QE Moves the cursor to the top line on the screen. IASM12.DOC Copyright P&E Microcomputer (1997) Page - 13 Bottom of screen ^End or ^QX Moves the cursor to the last line on the screen. Go to line ^JL Prompts for a line number and moves the cursor to the specified line. Any integer from 1 to 32,767 is valid. If the value is preceded by a plus (+) or a minus (-), the target line number will be an offset from the current line. Go to column ^JC Prompts for a column number and moves the cursor to the specified column of the current line. Any positive integer from 1 to 120 is valid. If the value is preceded by a plus (+) or a minus (-), the target column will be an offset from the current column. Top of block ^QB Moves the cursor to the position of the block-begin marker set with ^KB. Works even if there is no block-end marker or the block is hidden. Bottom of block ^QK Moves the cursor to the position of the block-end marker set with ^KK. Works even if there is no block-begin marker or the block is hidden. Previous cursor position ^QP Moves to the last cursor position. Very useful after a Save, Find or Find-and-Replace command. Jump to marker 0..9 ^Q0..^Q9 Moves the cursor to one of four previously set invisible markers. Set marker 0..9 ^K0..^K9 Sets one of four invisible markers at the current cursor position. IASM12.DOC Copyright P&E Microcomputer (1997) Page - 14 INSERT AND DELETE Insert And Delete Commands These commands let you insert and delete characters, words, and lines. New line Enter or ^M In insert mode a line break is created at the cursor position. If autoindent is on, the cursor moves to the next line and to the same column as the first non blank character in the previous line, otherwise it moves to column 1. In overwrite mode, the cursor is moved to column 1 of the next line without inserting a new line. Insert line ^N Inserts a line break at the cursor position. The cursor does not change position. Insert control character ^P This allows control characters to be entered into the text. For example, ^P followed by ^ G will insert a ^ G (the bell character) into the text stream. Control characters are displayed as uppercase highlighted letters. Note that the assembler does not accept control characters, only the editor. Tab Tab or ^I Moves the cursor right to the next tab stop. In insert mode, any text to the right of the cursor on the current line is also moved. In overwrite mode, only the cursor moves. The amount of cursor movement depends on whether fixed tabs or smart tabs are enabled. See the section on tabs. Delete current character Del or ^G Deletes the character at the cursor position. Characters to the right on the same line are moved one position left. The command does not cross line breaks. Delete character left Bksp or ^H Moves the cursor to the left one and deletes the character at that position. Characters on the same line are moved one position left. If the cursor starts in column one, the current line is joined to the line above it. Delete word ^T Deletes the word to the right of the cursor. This command works across line breaks and may be used to remove line breaks. Delete to end of line ^QY Deletes all characters from the current cursor position to the end of the line. Delete line ^Y Deletes the line containing the cursor and moves any lines below it up one line. The cursor moves to column one of the next line. A line deleted this way cannot be restored. IASM12.DOC Copyright P&E Microcomputer (1997) Page - 15 BLOCK COMMANDS Block Commands A block is any defined, contiguous stream of text. It may be a single character or many lines. In fact, the entire file can be specified to be a block. A block is defined by placing a begin-block marker at the first character in the desired block and an end-block marker after the last character. Once a block is so marked, it may be moved, copied, deleted or written to a file. Once a block is defined, it is typically shown highlighted. This may be changed with the hide-block command. All of the block manipulation commands work only with a non-hidden fully defined block. Begin block ^KB This is the marker for the beginning of a block. The marker itself is not visible on the screen. If an end-block command has been given, the block will now be highlighted. Whether or not an end-block exists, you can jump to the begin-block marker at any time with the Top of block command, ^QB. End block ^KK or F8 This is the marker for the end of a block. The marker itself is not visible on the screen. If a begin-block command has been given, the block will now be highlighted. Whether or not an begin-block exists, you can jump to the end-block marker at any time with the Bottom of block command, ^QK. Copy block ^KC A copy of the previously marked and displayed block is placed at the current cursor position. The original block is not effected and the markers are moved to the new copy. Move block ^KV The previously marked and displayed block is moved to the current cursor position. The block markers remain around the block as it is moved. Delete block ^KY Deletes a previously marked and displayed block. Although the Undo last deletion command (^QU) can usually restore portions of an accidentally deleted block, there is no command to restore a deleted block in its entirety, so use this command with care. Hide block ^KH Turns on and off the highlighting of a block. The block commands only work on displayed blocks. This command does not effect the markers. Print block ^KP Prints the block currently selected. Make sure the printer is connected and turned on. The command is canceled with Esc. Mark single word ^KT Marks an entire word as a block (places the begin-block and IASM12.DOC Copyright P&E Microcomputer (1997) Page - 16 end-block markers around the word) in one command. If the cursor is within a word, that word is marked. If the cursor is not within a word, then the word to the left is marked. Read block from file ^KR Reads an entire file into the text stream at the current cursor position as if it were a marked block within the text. The file is read in and marked as a block. The editor will prompt you for the name of the file. If the command has previously been used, the last file name requested will be displayed. You may either enter a new name, change the one displayed by using the Bksp key, or accept it by pressing Enter. The file name specified may be any legal file name, including a drive and/or path identifier. The command is canceled with Esc. Write block to file ^KW Copies the previously marked and displayed block to a file. The block itself is not changed and the markers are left in place. The editor will prompt you for the name of the file. You should not use names with the extension .BAK since this is the extension used when the editor creates a backup file. If the file name specified is found to exist, you are asked if you want to overwrite it. If you type N (for No), you can enter a new file name, change the one displayed by using the Bksp key, or cancel the command using Esc. If no block has been specified, this command is ignored. IASM12.DOC Copyright P&E Microcomputer (1997) Page - 17 MISCELLANEOUS Miscellaneous Commands Abort Esc Halts an operation in progress. The keyboard buffer is checked regularly to see if the Abort command has been issued; if it has, the buffer is emptied and the operation is stopped. Toggle insert mode Ins or ^V Selects either insert or overwrite mode. In insert mode, the text to the right of the cursor is moved to the right as new text is entered. In overwrite mode, the new text replaces any old text. The status line says "Insert" when in insert mode. Toggle autoindent ^QI When autoindent is enabled, the cursor will go to the next row and to the same column as the first non-blank character on the previous line in response to a ^M or Enter. The status line says "Indent" when this is enabled. Toggle fixed tabs ^QT When fixed tabs are enabled, the first tab stop is at column 9 and then there is one every 8 columns thereafter. The default is not fixed tabs but rather smart tabs. Smart tabs are located at the first character of each word on the previous line. This makes for very clean looking source code. When fixed tabs are enabled, the status line says "Tab" and the editor uses spaces in the text stream. Smart tabs are also implemented with a series of blanks. Restore line ^QL This command will undo any changes to the current line as long as the cursor has not left the line. The line will be restored regardless of any changes made to it. Undo last deletion ^QU Restores lines deleted with the Delete line command or the Delete command. It does not restore single characters or words. To undo your most recent changes to the current line, use the Restore line command. The size of the "undo buffer" (used to save deleted lines) is specified with the Set undo limit command. Set undo limit ^JU Sets the size of the "undo buffer" which stores deleted lines. The default value is 40 lines unless you have changed it with the installation program. Show version ^JV Display the current version of IASM12. Show available memory ^JR Shows the amount of RAM available to IASM12. Find ^QF Find lets you search for a character string up to 67 characters in length. The status line will clear and you will be prompted for a search string. If the command has been used previously, the last search string will be IASM12.DOC Copyright P&E Microcomputer (1997) Page - 18 displayed. You can select it again by pressing Enter, edit it, or enter an entire new string. When editing a string you may use Bksp, ^ R (restores previous string), ^S (move cursor left), and ^D (move cursor right). Esc will cancel the command. To enter a control character into the search string, precede it with ^P (for example, to find a period '.' at the end of a line you would enter the search string : . ^P ^M ). After the search string is entered you may specify search options. If any options were used in a previous search, they are offered and may be edited. The following options are available: B Searches from the current cursor position towards the beginning of the file (Backwards). G Searches globally. The entire file is scanned for the search string, regardless of the current position of the cursor. The search starts at the beginning of the file if searching forwards; at the end if searching backwards. L Limits the search to the currently marked block. U Ignore case; treats all alphabetic characters as if they were uppercase. The cursor is placed at the end of the matching pattern if one is found. Find and Replace ^QA This command works almost exactly as the previous one. The difference is that after the search string is prompted for, you are asked for the replacement string. This new string may be up to 67 characters long. The previous replacement string (if there is one) will be displayed and it may be accepted, edited, or replaced. Finally, you are prompted for options. Any previously used options are shown and may be edited as before. The same options are available as are for the Find command with the addition of : N Replaces without a prompt. Normally the user is prompted as to whether or not to make the change (No prompt). If a match with the search string is found in the text, the cursor is placed at the end of the target. You are then asked if you want the replacement to occur. Press Y to replace, or N to skip, or A to replace it and all subsequent matches without asking. The operation can be aborted by hitting Q or Esc. If the N option was selected, this question will not be asked. You can speed up a global search and replace operation by selecting the N option and then pressing Esc. The screen will not be updated until all updates are completed. Find next ^L This command will repeat the last search operation, either a Find or Find and Replace. Exit editor ^KD Saves the current file and exits the editor. The original file (if one exists) is renamed FILENAME.BAK. Exit editor Alt-X IASM12.DOC Copyright P&E Microcomputer (1997) Page - 19 If the file in the editor has been modified, a prompt asks if the file should be saved. If yes, the file is saved and IASM12 exits to DOS, else IASM12 simply exits. Save to file ^KN Prompts you for a file name, then saves the file in the current window to the specified name. This becomes the new file in the current window. This is especially useful for NONAME.ASM files. ================================================================== ASSEMBLER Assembler The assembler takes the file currently in the editor and assembles it. Depending upon the options chosen, the assembler may produce an object file, map file, and/or a listing file. The source file uses factory standard mnemonics. The list of acceptable mnemonics may be seen using the environment's help screens. Statements - Each line of the source file contains a single assembly language statement. A statement may contain up to four fields: label, operation, operands, and comment fields, as follows : label operation operand ;comment IASM12.DOC Copyright P&E Microcomputer (1997) Page - 20 LABELS Labels Labels, if present, must start in column one. They may be up to 16 characters long and must start with an alphabetic character. The assembler does not differentiate between upper and lower case letters when searching for labels. The label itself may contain any alphanumeric character, underscore, or dash. An optional colon may be added at the end of a label but a space will suffice. Note that labels within macros must be no longer than 10 characters. Examples: Label: ThisIsALabel: Loop_1 This_label_is_much_too_long: The label in the last example would be truncated to 16 characters and, to the assembler, would be the same as: This_label_is_much_longer_than_needed ================================================================== DIRECTIVES Assembler Directives These are keywords which control the progress and the modes of the assembler itself. They are invoked by placing a /, #, or $ as the first character of a line followed by the following directive words and parameters: BASE ^ Change default input base to ^ (2,8,10, or 16 decimal). CYCLE_ADDER_ON Start accumulating instruction cycles. CYCLE_ADDER_OFF Stop accumulating instruction cycles and print total. ELSEIF Alternate code for conditional assembly. ENDIF End of conditional assembly. IF ^ Conditional assembly if condition "^" is true. IFNOT ^ Conditional assembly if condition "^" is false. INCLUDE '^ ' Include file named "^ " in source code. MACRO ^ MacroCreates a macro with the name "^ ". MACROEND Ends a macro definition. SET ^ Set condition named "^ " to true. SETNOT ^ Set condition named "^ " to false. Each directive is fully explained on the following pages. IASM12.DOC Copyright P&E Microcomputer (1997) Page - 21 BASE Base The BASE assembler directive changes the default base of the current file. The parameter specified must be in the current base or have a base qualifier on it. The new base will be in effect until either the end of the file or until another BASE directive is encountered. The default base is hexadecimal. You may set the base to either 2, 8, 10 or 16 decimal. It is a good idea to specify an explicit base (see the section on constants) since you may not be sure what base is currently in use. Examples: $BASE 10T ;changes default base to decimal $BASE 0AH ;changes default base to decimal ================================================================== CYCLE_ADDER Cycle_adder The CYCLE_ADDER_ON and CYCLE_ADDER_OFF assembler directives control a counter that is internal to the assembler. When the CYCLE_ADDER_ON directive is encountered, this internal counter is cleared. It is then incremented by the number of instruction cycles associated with each instruction subsequently assembled. When the CYCLE_ADDER_OFF directive is reached, the counter is disabled and the total number of cycles counted is displayed in the .LST file. Some instructions have various cycle counts, depending on the actual execution of the instruction (test and branch, etc.). The smaller number of cycles will be used by IASM12. NOTE: The Listing and Cycle Cntr options in the Assemble submenu must be on for this directive to work. IASM12.DOC Copyright P&E Microcomputer (1997) Page - 22 CONDITIONALS Conditional Assembly Conditional assembly allows you to specify blocks of code that should assemble only on certain conditions. These conditions are specified with the SET and SETNOT directives. The SET directive sets the parameter to a "true" value. The SETNOT directive sets it to "false". Any code following an IF directive (up to either an ENDIF or an ELSEIF) will be assembled if the given parameter has been set true. Any code following an IFNOT directive (up to either an ENDIF or an ELSEIF) will be assembled if the given parameter has been set false. An ELSEIF directive may come between an IF or IFNOT directive and an ENDIF. The code between the ELSEIF and the ENDIF will be assembled only if the code between the IF (or IFNOT) and ELSEIF was not assembled. Likewise, if the code between the IF (or IFNOT) and the ELSEIF was not assembled, the code between the ELSEIF and ENDIF will be. An example is definitely called for .... EXAMPLE: $SET debug ;set debug = true $SETNOT test ;set test = false nop ;always assembles nop ;always assembles $IF debug ;if debug = true jmp start ;will assemble $ELSEIF ;if debug = false jmp end ;will not assemble $ENDIF ; nop ;always assembles nop ;always assembles $IF test ;if test = true jmp test ;will not assemble $ENDIF ; IASM12.DOC Copyright P&E Microcomputer (1997) Page - 23 INCLUDE Include The INCLUDE directive tells the assembler where to look for source code. Once an include directive is encountered the assembler starts taking source code from the specified file until either another INCLUDE is encountered or the end of file is found. If the end of file is found, the assembler continues with the source code immediately following the INCLUDE directive. Includes may be nested up to a maximum depth of ten. The file specified should contain a full path name if it does not reside in the current directory. You can choose whether or not to show the source code from INCLUDE files within the .LST file. This is controlled via a choice in the Assemble submenu. Note that the file name must be in quotes (single or double). EXAMPLES: $INCLUDE 'init.asm' $INCLUDE "c:\project\init.asm" IASM12.DOC Copyright P&E Microcomputer (1997) Page - 24 MACROS Macros The basic idea of a macro is simple. You assign a name to a block of text and whenever that name is encountered during assembly, the block of text is inserted. The macro can be thought of as expanding into the text when it is referred to. A macro is very similar to an INCLUDE file but it is more flexible. If the same file is INCLUDEd more than once, any labels in it will cause errors. A macro, on the other hand, may have labels and may also be passed parameters. Macros are defined with the MACRO directive. All source code between a MACRO and MACROEND directive is part of the macro. No directives are allowed within a macro. The macro definition itself does not contain any parameters. Within the macro, any place a parameter is needed, the parameter is specified with %n where n is the nth parameter at the macro call. If parameters are specified on the macro definition line, they are ignored, hence they may be helpful for documentation. Note that macros cannot be forward referenced. Example 1: $MACRO divide_by_4 asr a ; acc / 2 asr a ; acc /4 $MACROEND In this example, the accumulator is divided by four. Example 2: $MACRO delay count mov a,%1 loop: nop djnz loop $MACROEND This example creates a time delay. The parameter count does nothing except help with documentation showing that the first parameter is a count. The parameter sent to the routine will be substituted for the %1 wherever it occurs. The first time this macro is called, the label loop will be changed by the assembler to loop:0001 as will the operand on the last line. If this macro is invoked with : delay 100t then the loop will occur 100 (base ten) times. Extra parameters sent to a macro will be ignored but an error will occur if not enough are sent. Labels will automatically be changed each time they are used. Labels within macros cannot be longer than 10 characters. The assembler will append :nnnn to the label where nnnn is a four digit hexadecimal number. This will ensure that labels are always unique. Note that you may not have any code jump into a macro but you may jump out of a macro. IASM12.DOC Copyright P&E Microcomputer (1997) Page - 25 You have the choice as to whether the code generated during a macro is printed in the listing file or not. The setting in the ASSEMBLE sub-menu handles this. If the setting is "MACROS hide" then you will only see the macro call. If the setting is "MACRO view" then the code will be shown. The code shown will not look exactly like that entered into the macro definition. No comments will appear and the code will be all upper case. Note that these settings do not affect the macro definition itself, it always appears in the listing file. ================================================================== CONSTANTS Constants Constants are specific numbers entered into assembly language instructions. The default base for all constants in the assembler is hexadecimal. The default may be changed with the base assembler directive. Temporary override of the default is possible as follows: Base Prefix Suffix 2 % Q 10 ! T 16 $ H Either a prefix or a suffix is used, not both. Additionally, a $ or a * by itself is used to mean "the current program counter". Examples : 10010111Q = %10010111 = 97H = $97 JMP $ ; jump to myself JMP * ; jump to myself An ASCII constant may be specified by placing it in single or double quotes such as 'A' which is the same as 41H. Strings consist of characters enclosed in quotes as in : db 'this is a string' ================================================================== OPCODES Opcodes All factory mnemonics are supported. The full list of supported mnemonics for the assembler can be seen in the on-line help system by looking under "INSTRUCTION SET". Opcodes cannot start in column one and there must be at least one space or a colon between the label (if one exists on the line) and the opcode. IASM12.DOC Copyright P&E Microcomputer (1997) Page - 26 OPERANDS Operands An operand may be an address, label, or a constant as defined by the opcode. Arithmetic may be performed within parameters, at assembly time. The allowed operators are: * multiplication / division \ special division + addition - subtraction < left shift > right shift % remainder after division & bitwise and | bitwise or ^ bitwise xor Special division is an operator that allows a divide by zero. If there is a divide by zero anywhere in the expression, the entire expression equates to zero. Operator precedence follows the rules of algebra and may be altered by the use of parentheses. If more then one operator, parenthesis, or imbedded spaces are used, the entire expression must be put inside curly brackets {}. Examples: jmp start ;start is a previously defined label. jmp start+3 ;jump to location start + 3 jmp {start > 2} ;jump to location start divided by 4 ================================================================== COMMENTS Comments Comments are delineated by a semicolon. They may start in any column and go until the end of the line. Additionally, any line with an * or a ; in column 1 is considered to be a comment. Examples: nop ;this is a comment * this entire line is a comment. IASM12.DOC Copyright P&E Microcomputer (1997) Page - 27 PSEUDO-OPS Pseudo-Ops The following list of pseudo operations are allowed in place of opcodes: ds n or rmb n Define storage, n = number or label, reserves n bytes. Forward references of n are not allowed. db m or fcb m Define byte storage, m = label, number or string. Strings generate ASCII codes for multiple bytes. Numbers and labels define only a single byte per parameter. Multiple parameters are allowed and are separated by commas. dw n or fdb n Define word storage, n=label, number or string. Two bytes are generated for each number or label. Multiple parameters are allowed and are separated by commas. lab: equ n Assigns the value of the number or label n to the label lab. Forward references to n are not allowed. org n Sets the origin to the value of the number or label n. Forward references to n are not allowed. align_long Aligns the program counter to a long address aling_word Aligns the program counter to a word address IASM12.DOC Copyright P&E Microcomputer (1997) Page - 28 LISTING DIRECTIVES Listing Directives These are keywords entered into the source code that control the output to the listing file. They are purely for viewing the source code output and have no effect on the actual code assembled. A listing directive is invoked by placing a period '.' in column one of the source code immediately followed by the directive. Note that the directive itself will not appear in the listing file. If you want it to, then invoke it as you would any assembler directive, with a /, #, or $. eject or page Begins a new page. header '^' The string specified will be a header on the listing pages. The string must be in quotes and can only be defined once. Default : header ' ' list Turns on the .lst file output if the list choice in the assemble sub-menu is on and the .lst file output has been turned off with a nolist directive. The list choice in the assemble sub-menu MUST be on for this optional directive to work. nolist Turns off the .lst file output if it has been turned on. This directive effects the listing of the symbol table. pagelength ^ Sets the length of the page in lines. Default: pagelength 66t pagewidth ^ Sets the width of the output. Any additional text will be wordwrapped. Default : pagewidth 80t subheader '^' The string specified will be a subheader on the listing pages. The string must be in quotes and will take effect on the next page. IASM12.DOC Copyright P&E Microcomputer (1997) Page - 29 LISTING FILE Listing File When a listing file is requested via the menu system, it is created during assembly. The listing file is given the same name as the file being assembled with the extension .LST. Note that any existing file with this name will be overwritten. The listing file has the following format : AAAA VVVVVVVV [CC] LLLL Source Code ..... The first four hexadecimal digits (AAAA) are the address of the instruction in the target processor's memory. The next group of hexadecimal digits (VVVVVVVV) are the values put into that memory address and possibly the next several addresses. The size of this field depends on the actual opcode. If Cycle Cntr was turned on prior to assembly, the number of machine cycles (CC) used by the opcode is displayed in decimal within square brackets. In instances where an instruction has several possible cycle counts (whether or not a branch happens, for instance) and the assembler cannot determine the correct number, the best case (lowest number) is given. The next decimal digits (LLLL _ up to four places) comprise the line count. Finally, the actual source code is presented. The end of the listing file contains the symbol table with every label used and it's value presented. This file is affected by the listing directives list and nolist. A nolist directive at the end of the source code file will suppress the symbol table. ================================================================== OBJECT FILES Object files: When an object file is requested via the menu system, it is created during assembly. The object file is given the same name as the file being assembled with the extension .HEX or .S19. The choice of name depends on the choice made in the Assemble sub-menu. Note that any existing file with the same name will be overwritten. HEX is Intel 8-bit object code format. S19 is Motorola 8-bit object code format. IASM12.DOC Copyright P&E Microcomputer (1997) Page - 30 MAP FILES Map files: When requested via the menu system, map files are generated during assembly. The file is used by other P&E Microcomputer products to aid in symbolic debugging. IASM12.DOC Copyright P&E Microcomputer (1997) Page - 31 ERRORS Errors If the assembler finds an error during assembly, the error is highlighted and an error message appears on the prompt line. The possible errors and their meanings follow. error 1 Parameter : invalid, too large, missing, or out of range. There is an error in the operand field of the highlighted line. It may be an invalid number or representation of a number, or the parameter evaluates to a number that does not fit in the memory space allocated to the instruction. error 2 Too many conditional assembly variables. You may have up to a maximum of 25 conditional variables. error 3 Conditional assembly variable not found. The variable in the IF or IFNOT statement has not been declared with a SET of SETNOT. error 4 Include directives nested too deep. Includes may only be nested 10 levels. error 5 Invalid base value. The base parameter may be set to 2, 8, 10 or 16 decimal. Since you may not know the current base, it is always a good idea to use a value with an explicit base identifier such as 10T or 0AH. error 6 Undefined label. The label used as a parameter in the highlighted line has not been declared. error 7 Too many labels. See error 16. error 8 MACRO parameter error. The macro is expecting a different number of parameters than it received. error 9 MACRO label too long. Macro labels may be up to 10 characters, no more. error 10 INCLUDE file not found. The file specified in the INCLUDE directive was not found. Specify the full path name if necessary. There is no default extension, it must be specified if it exists. Be sure that the file name is enclosed in quotes. error 11 Unrecognized operation. The highlighted opcode is unknown. This may be caused by a wrong number or type of parameters. error 12 Duplicate label. The label on the highlighted line has already been used. IASM12.DOC Copyright P&E Microcomputer (1997) Page - 32 error 13 Invalid opcode, too long. The opcode on the highlighted line is wrong. error 14 Error writing .LST or .MAP file - check disk space. For some reason a .lst or .map file cannot be created. Check disk space and make sure that your CONFIG.SYS file allows multiple files to be open at once (see your DOS manual). error 15 Error writing object file - check disk space. See error 14. error 16 Out of memory. The assembler ran out of system memory. Try creating a file that consists of an INCLUDE directive only. This should specify your primary file. Assembling this file will leave the maximum amount of memory available to the assembler. error 17 '}' not found. A mathematical expression that started with '{' did not end with '}'. IASM12.DOC Copyright P&E Microcomputer (1997) Page - 33 COMMUNICATIONS Communications Comm Hitting F7 opens the communications window. The parameters used (port, baud, parity, word length, number of stop bits) are based on the options in the COMM sub-menu. If you are unsure of what these settings should be, consult the manual that came with the development board in use. Once the communications window is opened, you can toggle between communicating and editing with the F7 key. Note that if you change the communication parameters while the communication window is open, the parameters will not take effect until the window is closed and then reopened. The speed of the download command is determined by the baud rate chosen and the inter character delays set in the installation program. Once inside the communications window, the following hot keys are available : F1 : Help This key will bring up the help system. F2 : View This key will cause a prompt for a file name. Entering a valid file name will cause that file to be loaded into memory for viewing. The file may be up to the size of available memory. When the communications window is left, the viewer will close and be replaced by the editor. F6 : Download Hitting F6 causes a prompt for a file name. Entering a valid file name will cause that file to be transferred out the appropriate serial port. No special protocol is used, the file is simply transferred as is. F7 : Edit Hitting F7 will put you into the editor window, closing an open view file. F8,F9 : Resize By using F8 and F9 the communications window is made larger and smaller. F10 : Close Hitting F10 will close the communications window and return control, and the full screen, back to the editor. ================================================================== IASM12.DOC Copyright P&E Microcomputer (1997) Page - 34 Some technical data in the help system is used by permission of Motorola Semiconductor. IASM12.DOC Copyright P&E Microcomputer (1997) Page - 35 INSTRUCTION SET Instruction Set ABA add accumulator B to accumulator A ABX add accumulator B to index reg. X ABY add accumulator B to index reg. Y ADCA add with carry to A ADCB add with carry to B ADDA add without carry to A ADDB add without carry to B ADDD add double accumulator ANDA logical and A ANDB logical and B ANDCC logical and CCR with mask ASL arithmetic shift left memory ASLA arithmetic shift left A ASLB arithmetic shift left B ASLD arithmetic shift left double acc. ASR arithmetic shift right memory ASRA arithmetic shift right A ASRB arithmetic shift right B BCC branch if carry clear BCLR clear bit(s) in memory BCS branch if carry set BEQ branch if equal BGE branch if >= zero BGND enter background debug mode BGT branch if > zero BHI branch if higher BHS branch if higher or same BITA bit test A BITB bit test B BLE branch if <= zero BLO branch if lower BLS branch if lower or same BLT branch if < zero BMI branch if minus BNE branch if not equal to zero BPL branch if plus BRA branch always BRCLR branch if bit(s) clear BRN branch never BRSET branch if bit(s) set BSET set bit(s) in memory BSR branch to subroutine BVC branch if overflow clear BVS branch if overflow set CALL call subroutine in extended memory CBA compare accumulators CLC clear carry CLI clear interrupt mask CLR clear memory CLRA clear A CLRB clear B CLV clear two's complement overflow bit CMPA compare A CMPB compare B COM complement memory COMA complement A COMB complement B CPD compare accumulator D CPS compare stack pointer IASM12.DOC Copyright P&E Microcomputer (1997) Page - 36 CPX compare index reg. X CPY compare index reg. Y DAA decimal adjust A DBEQ decrement and branch if equal to zero DBNE decrement and branch if not equal to zero DEC decrement memory DECA decrement A DECB decrement B DES decrement stack pointer DEX decrement index register X DEY decrement index register Y EDIV extended divide 32-bit by 16-bit (unsigned) EDIVS extended divide 32-bit by 16-bit (signed) EMACS extended multiply and accumulate (signed) EMAXD max of 2 unsigned 16-bit values (result in D) EMAXM max of 2 unsigned 16-bit values (result in mem) EMIND min of 2 unsigned 16-bit values (result in D) EMINM min of 2 unsigned 16-bit values (result in mem) EMUL extended multiply 16-bit by 16-bit (unsigned) EMULS extended multiply 16-bit by 16-bit (signed) EORA exclusive or A EORB exclusive or B ETBL extended table lookup and interpolate EXG exchange register contents FDIV fractional divide IBEQ increment and branch if equal to zero IBNE increment and branch if not equal to zero IDIV integer divide IDIVS integer divide (signed) INC increment memory INCA increment A INCB increment B INS increment stack pointer INX increment index register X INY increment index register Y JMP jump JSR jump to subroutine LBCC long branch if carry clear LBCS long branch if carry set LBEQ long branch if equal LBGE long branch if greater than or equal to zero LBGT long branch if greater than zero LBHI long branch if higher LBHS long branch if higher or same LBLE long branch if less than or equal to zero LBLO long branch if lower LBLS long branch if lower or same LBLT long branch if less than zero LBMI long branch if minus LBNE long branch if not equal to zero LBPL long branch if plus LBRA long branch always LBRN long branch never LBVC long branch if overflow clear LBVS long branch if overflow set LDAA load accumulator A LDAB load accumulator B LDD load double accumulator LDS load stack pointer LDX load index register X LDY load index register Y LEAS load stack pointer with effective address IASM12.DOC Copyright P&E Microcomputer (1997) Page - 37 LEAX load X with effective address LEAY load Y with effective address LSL logical shift left memory LSLA logical shift left A LSLB logocal shift left B LSLD logical shift left double LSR logical shift right memory LSRA logical shift right A LSRB logical shift right B LSRD logical shift right double accumulator MAXA max of 2 unsigned 8-bit values (result in A) MAXM max of 2 unsigned 8-bit values (result in mem) MEM determine grade of membership MINA min of 2 unsigned 8-bit values (result in A) MINM min of 2 unsigned 8-bit values (result in mem) MOVB move data from one memory byte to another MOVW move data from one memory word to another MUL multiply unsigned NEG negate memory NEGA negate A NEGB negate B NOP no operation ORAA inclusive or A ORAB inclusive or B ORCC logical or CCR with mask PSHA push A onto stack PSHB push B onto stack PSHC push CCR onto stack PSHD push double accumulator onto stack PSHX push index reg. X onto stack PSHY push index reg. Y onto stack PULA pull A from stack PULB pull B from stack PULC pull CCR from stack PULD pull double accumulator from stack PULX pull index reg. X from stack PULY pull index reg. Y from stack REV fuzzy logic rule evaluation REVW fuzzy logic rule evaluation (weighted) ROL rotate left memory ROLA rotate left A ROLB rotate left B ROR rotate right memory RORA rotate right A RORB rotate right B RTC return from call RTI return from interrupt RTS return from subroutine SBA subtract accumulators SBCA subtract with carry from A SBCB subtract with carry from B SEC set carry SEI set interrupt mask SEV set two's complement overflow bit SEX sign extend into 16-bit register STAA store accumulator A STAB store accumulator B STD store double accumulator STOP stop processing STS store stack pointer STX store index register X STY store index register Y IASM12.DOC Copyright P&E Microcomputer (1997) Page - 38 SUBA subtract A SUBB subtract B SUBD subtract double accumulator SWI software interrupt TAB transfer from acc. A to acc. B TAP transfer from acc. A to CCR TBA transfer from acc. B to acc. A TBEQ test and branch if equal to zero TBL table lookup and interpolate TBNE test and branch if not equal to zero TFR transfer register content to another register TPA transfer from CCR to accumulator A TRAP unimplemented opcode trap TST test memory TSTA test A TSTB test B TSX transfer from SP to index reg. X TSY transfer from SP to index reg. Y TXS transfer from index reg. X to SP TYS transfer from index reg. Y to SP WAI wait for interrupts WAV weighted average XGDX exchange double acc. and index reg. X XGDY exchange double acc. and index reg. Y IASM12.DOC Copyright P&E Microcomputer (1997) Page - 39 INSTRUCTION FORMATS Note that the symbol ^ reflects a numeric parameter and the symbol ! represents an addressing mode.. ABA ABX ABY ADCA !,! ADCA #^ ADCA ,! ADCA @^ ADCA [!,!] ADCA [^,!] ADCA ^ ADCA ^,! ADCB !,! ADCB #^ ADCB ,! ADCB @^ ADCB [!,!] ADCB [^,!] ADCB ^ ADCB ^,! ADDA !,! ADDA #^ ADDA ,! ADDA @^ ADDA [!,!] ADDA [^,!] ADDA ^ ADDA ^,! ADDB !,! ADDB #^ ADDB ,! ADDB @^ ADDB [!,!] ADDB [^,!] ADDB ^ ADDB ^,! ADDD !,! ADDD #^ ADDD ,! ADDD @^ ADDD [!,!] ADDD [^,!] ADDD ^ ADDD ^,! ANDA !,! ANDA #^ ANDA ,! ANDA @^ ANDA [!,!] ANDA [^,!] ANDA ^ ANDA ^,! ANDB !,! ANDB #^ ANDB ,! ANDB @^ ANDB [!,!] ANDB [^,!] ANDB ^ ANDB ^,! ANDCC #^ ASL !,! ASL ,! ASL [!,!] ASL [^,!] ASL ^ ASL ^,! ASLA ASLB ASLD ASR !,! ASR ,! ASR [!,!] ASR [^,!] ASR ^ ASR ^,! ASRA ASRB BCC ^ BCLR !,!,^ BCLR ,!,^ BCLR @^,^ BCLR ^,!,^ BCLR ^,^ BCS ^ BEQ ^ BGE ^ BGND BGT ^ BHI ^ BHS ^ BITA !,! BITA #^ BITA ,! BITA @^ BITA [!,!] BITA [^,!] BITA ^ BITA ^,! BITB !,! BITB #^ BITB ,! BITB @^ BITB [!,!] BITB [^,!] BITB ^ BITB ^,! BLE ^ BLO ^ BLS ^ BLT ^ BMI ^ BNE ^ BPL ^ BRA ^ BRCLR !,!,^,^ BRCLR ,!,^,^ BRCLR @^,^,^ BRCLR ^,!,^,^ BRCLR ^,^,^ BRN ^ BRSET !,!,^,^ BRSET ,!,^,^ BRSET @^,^,^ BRSET ^,!,^,^ BRSET ^,^,^ BSET !,!,^ BSET ,!,^ BSET @^,^ BSET ^,!,^ BSET ^,^ BSR ^ BVC ^ BVS ^ CALL !,!,^ CALL ,!,^ CALL [!,!] CALL [^,!] CALL ^,!,^ CALL ^,^ CBA CLC CLI CLR !,! CLR ,! CLR [!,!] CLR [^,!] CLR ^ CLR ^,! CLRA CLRB CLV CMPA !,! CMPA #^ CMPA ,! CMPA @^ CMPA [!,!] CMPA [^,!] CMPA ^ CMPA ^,! CMPB !,! CMPB #^ CMPB ,! CMPB @^ CMPB [!,!] CMPB [^,!] CMPB ^ CMPB ^,! COM !,! COM ,! COM [!,!] COM [^,!] COM ^ COM ^,! COMA COMB CPD !,! CPD #^ CPD ,! CPD @^ CPD [!,!] CPD [^,!] CPD ^ CPD ^,! CPS !,! CPS #^ CPS ,! CPS @^ CPS [!,!] CPS [^,!] CPS ^ CPS ^,! CPX !,! CPX #^ CPX ,! CPX @^ CPX [!,!] CPX [^,!] CPX ^ CPX ^,! CPY !,! CPY #^ CPY ,! CPY @^ CPY [!,!] CPY [^,!] CPY ^ CPY ^,! DAA DBEQ !,^ DBNE !,^ DEC !,! DEC ,! DEC [!,!] DEC [^,!] DEC ^ DEC ^,! DECA DECB DES DEX DEY EDIV EDIVS EMACS ^ IASM12.DOC Copyright P&E Microcomputer (1997) Page - 40 EMAXD !,! EMAXD ,! EMAXD [!,!] EMAXD [^,!] EMAXD ^,! EMAXM !,! EMAXM ,! EMAXM [!,!] EMAXM [^,!] EMAXM ^,! EMIND !,! EMIND ,! EMIND [!,!] EMIND [^,!] EMIND ^,! EMINM !,! EMINM ,! EMINM [!,!] EMINM [^,!] EMINM ^,! EMUL EMULS EORA !,! EORA #^ EORA ,! EORA @^ EORA [!,!] EORA [^,!] EORA ^ EORA ^,! EORB !,! EORB #^ EORB ,! EORB @^ EORB [!,!] EORB [^,!] EORB ^ EORB ^,! ETBL !,! ETBL ,! ETBL ^,! EXG !,! FDIV IBEQ !,^ IBNE !,^ IDIV IDIVS INC !,! INC ,! INC [!,!] INC [^,!] INC ^ INC ^,! INCA INCB INS INX INY JMP !,! JMP ,! JMP [!,!] JMP [^,!] JMP ^ JMP ^,! JSR !,! JSR ,! JSR @^ JSR [!,!] JSR [^,!] JSR ^ JSR ^,! LBCC ^ LBCS ^ LBEQ ^ LBGE ^ LBGT ^ LBHI ^ LBHS ^ LBLE ^ LBLO ^ LBLS ^ LBLT ^ LBMI ^ LBNE ^ LBPL ^ LBRA ^ LBRN ^ LBVC ^ LBVS ^ LDAA !,! LDAA #^ LDAA ,! LDAA @^ LDAA [!,!] LDAA [^,!] LDAA ^ LDAA ^,! LDAB !,! LDAB #^ LDAB ,! LDAB @^ LDAB [!,!] LDAB [^,!] LDAB ^ LDAB ^,! LDD !,! LDD #^ LDD ,! LDD @^ LDD [!,!] LDD [^,!] LDD ^ LDD ^,! LDS !,! LDS #^ LDS ,! LDS @^ LDS [!,!] LDS [^,!] LDS ^ LDS ^,! LDX !,! LDX #^ LDX ,! LDX @^ LDX [!,!] LDX [^,!] LDX ^ LDX ^,! LDY !,! LDY #^ LDY ,! LDY @^ LDY [!,!] LDY [^,!] LDY ^ LDY ^,! LEAS !,! LEAS ,! LEAS ^,! LEAX !,! LEAX ,! LEAX ^,! LEAY !,! LEAY ,! LEAY ^,! LSL !,! LSL ,! LSL [!,!] LSL [^,!] LSL ^ LSL ^,! LSLA LSLB LSLD LSR !,! LSR ,! LSR [!,!] LSR [^,!] LSR ^ LSR ^,! LSRA LSRB LSRD MAXA !,! MAXA ,! MAXA [!,!] MAXA [^,!] MAXA ^,! MAXM !,! MAXM ,! MAXM [!,!] MAXM [^,!] MAXM ^,! MEM MINA !,! MINA ,! MINA [!,!] MINA [^,!] MINA ^,! MINM !,! MINM ,! MINM [!,!] MINM [^,!] MINM ^,! MOVB #^,^ MOVB #^,,! MOVB #^,^,! MOVB #^,!,! MOVB ^,^ MOVB ^,,! MOVB ^,^,! MOVB ^,!,! MOVB ,!,^ MOVB ^,!,^ MOVB !,!,^ MOVB ,!,,! MOVB ,!,^,! MOVB ,!,!,! MOVB ^,!,,! MOVB ^,!,^,! MOVB ^,!,!,! MOVB !,!,,! MOVB !,!,^,! MOVB !,!,!,! MOVW #^,^ MOVW #^,,! MOVW #^,^,! MOVW #^,!,! MOVW ^,^ MOVW ^,,! MOVW ^,^,! MOVW ^,!,! MOVW ,!,^ MOVW ^,!,^ MOVW !,!,^ MOVW ,!,,! MOVW ,!,^,! MOVW ,!,!,! MOVW ^,!,,! MOVW ^,!,^,! MOVW ^,!,!,! MOVW !,!,,! MOVW !,!,^,! MOVW !,!,!,! MUL NEG !,! NEG ,! NEG [!,!] NEG [^,!] NEG ^ NEG ^,! NEGA NEGB NOP ORAA !,! ORAA #^ ORAA ,! ORAA @^ ORAA [!,!] ORAA [^,!] ORAA ^ ORAA ^,! ORAB !,! ORAB #^ ORAB ,! ORAB @^ ORAB [!,!] IASM12.DOC Copyright P&E Microcomputer (1997) Page - 41 ORAB [^,!] ORAB ^ ORAB ^,! ORCC #^ PSHA PSHB PSHC PSHD PSHX PSHY PULA PULB PULC PULD PULX PULY REV REVW ROL !,! ROL ,! ROL [!,!] ROL [^,!] ROL ^ ROL ^,! ROLA ROLB ROR !,! ROR ,! ROR [!,!] ROR [^,!] ROR ^ ROR ^,! RORA RORB RTC RTI RTS SBA SBCA !,! SBCA #^ SBCA ,! SBCA @^ SBCA [!,!] SBCA [^,!] SBCA ^ SBCA ^,! SBCB !,! SBCB #^ SBCB ,! SBCB @^ SBCB [!,!] SBCB [^,!] SBCB ^ SBCB ^,! SEC SEI SEV SEX !,! STAA !,! STAA ,! STAA @^ STAA [!,!] STAA [^,!] STAA ^ STAA ^,! STAB !,! STAB ,! STAB @^ STAB [!,!] STAB [^,!] STAB ^ STAB ^,! STD !,! STD ,! STD @^ STD [!,!] STD [^,!] STD ^ STD ^,! STOP STS !,! STS ,! STS @^ STS [!,!] STS [^,!] STS ^ STS ^,! STX !,! STX ,! STX @^ STX [!,!] STX [^,!] STX ^ STX ^,! STY !,! STY ,! STY @^ STY [!,!] STY [^,!] STY ^ STY ^,! SUBA !,! SUBA #^ SUBA ,! SUBA @^ SUBA [!,!] SUBA [^,!] SUBA ^ SUBA ^,! SUBB !,! SUBB #^ SUBB ,! SUBB @^ SUBB [!,!] SUBB [^,!] SUBB ^ SUBB ^,! SUBD !,! SUBD #^ SUBD ,! SUBD @^ SUBD [!,!] SUBD [^,!] SUBD ^ SUBD ^,! SWI TAB TAP TBA TBEQ !,^ TBL !,! TBL ,! TBL ^,! TBNE !,^ TFR !,! TPA TRAP ^ TST !,! TST ,! TST [!,!] TST [^,!] TST ^ TST ^,! TSTA TSTB TSX TSY TXS TYS WAI WAV WAVR XGDX XGDY IASM12.DOC Copyright P&E Microcomputer (1997) Page - 42 ADDRESSING MODES INHERENT ADDRESSING These instructions do not have operands and do not need access to any memory locations. Examples: ABA NOP IMMEDIATE MODE (IMM) These instructions have a single operand following the # symbol. The operand is not a memory address. The operand is the value to be used by the instruction. Omitting the # symbol will cause the operand to be mistaken as direct mode. Examples: ADCA #$c5 ;IMM8 ADDD #$FDEA ;IMM16 DIRECT MODE (DIR) This mode can only access addresses in the range from $0000 to $00FF. The operand given is assumed to be a memory address. If the instruction requires an 8 bit value, the instruction reads in the byte at the memory address given. If the instruction requires a 16-bit value, the instruction reads in the byte at the address given and stores it in the high order half. The next memory address incrementally is read as the low order half. Examples: ADCA $c8 CMPB $45 EXTENDED ADDRESSING (EXT) This addressing mode is used to access the full 64 kilobyte memory. The operand of this instruction is a 16-bit memory address. Examples: ADCA $510a EORA $eb2c INDEXED 5-BIT CONSTANT OFFSET (IDX) IASM12.DOC Copyright P&E Microcomputer (1997) Page - 43 In this addressing mode, two operands are given. The first is a signed 4-bit number and the second is an index register. The signed 4-bit number must have a value between -$10 and $0f. The operation will proceed by reading the value in memory pointed to by the index register offset with the first operand. The index register can be either X, Y, PC, or SP. The index register is not altered in this mode. Examples: EORA -8,X ETBL 2,X INDEXED AUTO PRE/POST DECREMENT/INCREMENT (IDX) This indexing mode allows the index register to be altered before or after indexing takes place. There are two operands: a signed value from 1 to 8, and the index register with a plus or minus sign before or after it. If the sign is before the index register, the first operand will be added or subtracted, depending on its sign, from the index register. This new value will be stored in the index register and used as the indexing address. If the sign comes after the index register, the initial value of the register will be used for indexing and the increment/decrement will occur afterward. Only the X, Y, and SP index registers can be used. Examples: LDAB $8,x+ ; post increment x by 8 LDAB $4,-x ; pre decrement x by 4 INDEXED ACCUMULATOR OFFSET (IDX) In this addressing mode, the contents of an accumulator are added to the index register to determine the effective address. The index register can be X, Y, SP, and PC and the accumulator can be A, B, or D. The index register is not altered in this mode. Examples: LDAB D,PC LDS B,SP INDEXED 9-BIT CONSTANT OFFSET (IDX1) Similar to 5-bit except it uses a full signed byte offset. The first operand is a signed 8-bit number, with a value between -$100 and $ff, and the second operand is an index register. The operation will be carried out by reading in the value pointed to be the index register offset by the first operand. The index IASM12.DOC Copyright P&E Microcomputer (1997) Page - 44 register can be either X, Y, PC, or SP. The index register is not altered in this mode. Examples: EORA -$10,X INC $c7,PC INDEXED 16-BIT CONSTANT OFFSET (IDX2) In this mode, a 16-bit offset is added to the index register, to determine the proper memory address to access. This index mode can access any address in memory offset from the index register. It does not matter if the value is considered to be signed or unsigned. The index register can be X, Y, PC, or SP. The index register is not altered in this mode. Examples: INC $6d17,SP JSR $CCFA,X INDEXED 16-BIT CONSTANT INDIRECT ([IDX2]) In this addressing mode, there are two operands surrounded by brackets. The first operand is the offset and the second is the index register. The index register offset by the first operand is the memory address of a pointer to the effective address. The index register can be X, Y, SP, or PC. The index register is not altered in this mode. Examples: JSR [$d486,x] LDAA [$6e41,y] INDEXED AUTO PRE/POST DECREMENT/INCREMENT (IDX) This indexing mode allows the index register to be altered before or after indexing takes place. There are two operands: a signed value from 1 to 8, and the index register with a plus or minus sign before or after it. If the sign is before the index register, the first operand will be added or subtracted, depending on its sign, from the index register. This new value will be stored in the index register and used as the indexing address. If the sign comes after the index register, the initial value of the register will be used for indexing and the increment/decrement will occur afterward. Only the X, Y, and SP index registers can be used. Examples: LDAB $8,x+ ; post increment x by 8 IASM12.DOC Copyright P&E Microcomputer (1997) Page - 45 LDAB $4,-x ; pre decrement x by 4 INDEXED ACCUMULATOR OFFSET (IDX) In this addressing mode, the contents of an accumulator are added to the index register to determine the effective address. The index register can be X, Y, SP, and PC and the accumulator can be A, B, or D. The index register is not altered in this mode. Examples: LDAB D,PC LDS B,SP INDEXED D-INDIRECT ([D,IDX]) In this addressing mode, the contents of D are added to the index register. This is the address of a pointer to a memory location. There are two operands surrounded by brackets in this mode. The first operand must always be D and the second is an index register X, Y, SP, or PC. The index register is not altered in this mode. Examples: LDS [D,X] LSR [D,PC] MULTIPLE ADDRESSING MODES There are cases when multiple addressing modes can be used. With the MOVE instruction both the source and the destination can have different addressing modes. Bit manipulation instructions need several operands, for the memory location, bits set, and address to branch to. The second operand must be immediate, but the first can be one of several addressing modes. Examples: MOVB #$DF,$C600 ;IMM8-EXT MOVW $8EFA,D0,Y ;EXT-IDX BRCLR $01,SP+,$6F,$ ;IDX BRSET -$10,X,$8A,$ ;IDX IASM12.DOC Copyright P&E Microcomputer (1997) Page - 46