
Добавил:
korayakov
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз:
Предмет:
Файл:motorola - ПиП МПС / motorola / MC68000 / Distribs / Emulator / 68K
.DOCX68000: version for use on IBM PC PREFACE This document describes the use of X68K and E68K on the IBM Personal Computer. X68K is a cross-assembler based on the assembler provided by Motorola, and E68K is a program which emulates the instructions and architecture of the Motorola MC68000 chip. X68000: version for use on IBM PC 1 X68K Motorola M68000 cross assembler The X68K assembler is based upon the assembler provided by Motorola. It will assemble all the valid instruction mnemonics as described in Motorola publications, and accepts some of the directives. The current release of X68K will only generate absolute code and does not include facilities for structured assembly. Of the directives supported by the Motorola assembler the following are accepted by X68K. DC, DCB, DS, END, ENDC, ENDM, EQU, FAIL, FORMAT, NOFORMAT, IFxx, INCLUDE, LIST, NOLIST, MACRO, MEXIT, PAGE, REG, SET, SPC, TTL. OPT (A, BRL, BRS, CEX, NOCEX, CL, NOCL, CRE, FRL, FRS, MC, NOMC, MD, NOMD, MEX, NOMEX, PCO, NOPCO) The usage of all the above is documented in the official Motorola assembler manual. However, there are some minor points to be made: i) By default X68K generates no symbol table information in the listing file. OPT CRE causes symbol table and cross reference information to be displayed, instead of just cross reference information. ii) OPT NOCL is used to stop conditional "IFxx" directives being displayed in the listing file. This has been extended to include instructions that are skipped as a result if an "IFxx" directive being false. iii) The text string that follows the "TTL" directive MUST be enclosed in single quotes. Only the last "TTL" directive will be used as a title in the listing file. Similarly the pathname ised in the "INLCUDE" directive must be enclosed in single quotes. iv) The "END" directive must have a label, as this defines the start address of the assembled program. If OPT MEX is used and a listing file produced there may be more lines in the listing file than there were in the original source file. This will be due to macro expansions. In order to make it easier to relate a listing file to the original source file, X68K will place two sets of line numbers in the listing file if macros have been called. The first column of line numbers is used by X68K for cross referencing purposes. The second set of line numbers relate to source lines in the original file, and are displayed in parenthesis. Any error messages displayed on the screen during assembly will be of the form: Line NN, error message OR Line NN.XX, error message In both cases the NN part refers to a line number in the original source file being assembled. The XX part will be used when an error is detected in a macro expansion which started at line NN. Page 1 X68000: version for use on IBM PC To call X68K the command is: X68K filename or X68K filename/L (if a listing file is wanted) where the full name of the file is filename.X68 If the assembly is error-free, a binary output file will be produced with the name "filename.BIN". The assembler was written primarily to be used with E68K the Motorola M68000 system emulator. Because of this the following points should be noted. The assembler initializes the program counter "PC" to zero before any code is produced and will only allow PC to be altered to addresses higher than PC through the use of ORG directives. This will stop users from causing code overlays. However, all user programs will normally have as their first non-comment statement an ORG $400 directive. This is because the 68000 holds exception vectors from $0 to $3FF. The PC is set to zero initially to allow users to use ORG to place the addresses of exception handlers in the vector table before generating code. Expressions within the assembler are broken into three types, string, arithmetic and logical. All non-string expressions are taken to be arithmetic expressions unless they contain any of: (!,&,<<,>>) or non-base-ten numbers. An expression may contain a string e.g. 'A'!$80 results in logical hex C1 where 65+128 results in arithmetic hex C1. This has the effect that statements such as: AND.B #$FF,D0 are legal since $FF is an eight bit quantity. But statements such as: AND.B #255,D0 are not legal since the arithmetic range for byte operations is -128 to 127. Any forward reference to a label defined by a SET directive will cause the value of the last SET directive in the program to be returned. For information on M68000 instructions and assembler conventions see the following books: M68000 16/32-BIT MICROPROCESSOR PROGRAMMERS REFERENCE MANUAL, ISBN 0-13-566795-X (Prentice-Hall) M68000 RESIDENT STRUCTURED ASSEMBLER REFERENCE MANUAL Page 2 X68000: version for use on IBM PC 2 E68K Motorola M68000 system emulator E68K is a program which emulates the instructions and architecture of the M68000. The emulator supports an addressing range of 10240 kbytes, memory being allocated when first written to. To call E68K the command is E68K [filename] where the full name of the input file is filename.BIN. The binary file may be one produced by X68K or a memory dump by E68K. Memory is allocated in 1KB chunks from addr 0. The user need not use memory in a contiguous fashion. If the user tries to exceed the memory available on the computer, an error message is printed and a Bus_error exception is generated. The emulator initializes the vector table to zeros before any programs are loaded. If, when an exception occurs, the vector is zero the emulator will take a default action. Otherwise normal exception processing takes place. The emulator is always in one of two modes. It is either executing a program or it is processing commands. Below is a list of the available commands and their meaning. 2.1 HELP The HELP command will respond with the following display. .PC .SR .US .SS .D0 .D1 .D2 .D3 .D4 .D5 .D6 .D7 .A0 .A1 .A2 .A3 .A4 .A5 .A6 .A7 .C .N .V .X .Z BF - Block fill, GT - Go with temp brkpt. BM - Block move, HE - Help. BR - Set/display brkpts, LO - Load binary file. BS - Block search, MD - Memory dump. DC - Data conversion, MM - Memory modify. DF - Display registers, MS - Memory set. DU - Dump memory to file, NOBR - Remove brkpts. GD - Go direct, TR - Trace program. GO - Execute program with brkpts, QUIT - Return to MS-DOS. For more detailed information type: HE command-name HE INFO HE EXCEPTIONS HE TRAP#15 Page 3 X68000: version for use on IBM PC The first three lines which specify register names indicate that the contents of any register can be displayed by entering .Rn as a command. The contents of registers can be altered in a similar fashion e.g. entering .PC $1000 assigns the value hex 1000 to PC. This feature is also available for the status register flags e.g. .Z 1 would set the ZERO flag to true. The emulator supports full expression processing using the same operators and operator priorities as the assembler. The only difference is that the default base of the emulator is hex, and decimal numbers must be preceeded by a "^". The register names may also be used in expressions e.g. .PC .PC+2 increments PC by 2. The remainder of the help display lists the valid command names, which are explained below. 2.2 BF - Block fill Format: BF <addr_1> <addr_2> <data> The BF command is used to fill a block of memory starting at ADDR_1 and ending at ADDR_2 with DATA. All arguments to this command are integers. The command uses word operations only. 2.3 BM - Block move Format: BM <addr_1> <addr_2> <addr_3> The BM command is used to move a block of memory starting at ADDR_1 and ending at ADDR_2 to a new location staring at ADDR_3. This operation is byte oriented. The two areas of memory must not overlap. Page 4 X68000: version for use on IBM PC 2.4 BR - Set and display breakpoints Format: BR <brkpt_1> ... <brkpt_7> -<count> The BR command allows a user to insert or remove breakpoints in memory. Associated with each breakpoint is a count. This count specifies how many times the breakpointed location can be referenced before a break is taken. If no count is specified the default value is zero. Upto seven breakpoints can be inserted with the BR command in one go if a count is specified, eight otherwise. If BR is used with no options the existing breakpoint table is printed. Upto sixteen breakpoints can be in force at once. Breakpoints should only be inserted in the first word of an instruction. Placing them in the middle of instructions will probably cause an illegal instruction exception when the instruction is executed. The breakpoint count is reset when any of the following commands are executed "GO", "GT", "TR n". Breakpoints for the "TR" command are ignored when N is one. 2.5 BS - Block search Format: BS <addr_1> <addr_2> 'string' BS <addr_1> <addr_2> <data> [<mask>] [-B] [-W] [-L] The BS command is used to search a block of memory starting at ADDR_1 and ending at ADDR_2. The first format searches for character strings. The second searches for DATA. The location being tested may be optionally anded with MASK before testing. The block search for non-strings may be byte, word or long_word based. The default is byte. If any matches are found the start address of the match is printed. 2.6 DC - Data conversion Format: DC expression This command evaluates an expression and prints it in hex, decimal, octal and binary. As with the assembler, expressions must not contain embedded blanks. Page 5 X68000: version for use on IBM PC 2.7 DF - Display formatted registers The DF command displays all the current register values and the various elements of the condition code register separately. The instruction pointed to by the current value of PC is also disassembled and displayed. 2.8 DU - Dump memory and registers to file Format: DU <addr_1> <addr_2> dumpfilename The DU command dumps a block of memory starting at ADDR_1 and ending at ADDR_2 to a disk file specified by dumpfilename. The full name of the file produced will be dumpfilename.BIN. The current register values are also dumped. The dumping is by word as is the loading. See LO. 2.9 GO - Execute program Format: GO <addr> The GO command causes execution to begin at address ADDR. The program will execute until a trap, exception or breakpoint is reached. 2.10 GD - Go direct (execute program without breakpoints) Format: GD <addr> The GD command causes execution to begin at address ADDR. The program will execute until a trap or exception is reached. Breakpoints are ignored. Page 6 X68000: version for use on IBM PC 2.11 GT - Execute program with temporary breakpoint Format: GT <addr> The GT command inserts a temporary breakpoint at address ADDR and then begins execution at the address in PC. The program will execute until a trap, exception or any breakpoint is reached. The temporary breakpoint is removed when execution terminates. 2.12 LO - Load binary file Format: LO filename This command loads a file specified by filename into memory. The full name of the file must be filename.BIN, and will either be an E68K DUmp file or one produced by X68K. The loading is done by word not byte. If the binary file is an E68K Dump file then the saved register contents will replace the current settings. 2.13 MD - Memory dump Format: MD <addr> <count> [-DI] The MD command dumps COUNT bytes of memory (or disassembles COUNT instructions if "-DI" is used) starting at address ADDR. Once the first section has been dumped entering carriage returns will cause the MD command to repeat with the next section. The default value of COUNT is sixteen. To stop the command enter any character before the carriage return. Page 7 X68000: version for use on IBM PC 2.14 MM - Memory modify Format: MM <addr> [-B] [-W] [-L] [-O] [-E] [-HEX] [-OCT] [-DEC] [-BIN] The MM command is used to display and change memory locations. The options determine the operation size and type. The defaults are -B and -HEX. -O selects odd bytes while -E selects only even bytes. The other options -B,-W and -L are obvious. The MM command starts at address ADDR and displays it's contents. The user may then specify new data for the location. The new data (if any) is followed by a symbol which determines the next location to be displayed. An "^" means step backwards to the previous location while "=" means don't move. The default is to step forward to the next memory location. Specifying a "." terminates the MM command. 2.15 MS - Memory set Format: MS <addr> 'string' MS <addr> n1 n2 ... n7 This command enables the user to set memory locations starting at ADDR to the values contained in the arguments. Successive bytes are used until the data is exhausted. The data may be a string value or numbers no greater than a 32 bit integer. 'FRED' would take 4 bytes, and $123 would take 2 bytes. 2.16 NOBR - Remove breakpoint Format: NOBR <brkpt_1> ... <brkpt_8> The NOBR command simply removes the breakpoints specified by the breakpoint address arguments (BRKPT_n) from the table. NOBR also prints the remaining breakpoint table. Page 8 X68000: version for use on IBM PC 2.17 TR - Trace program execution Format: TR <count> The TR command causes COUNT instructions to be executed starting at the current value of PC. The program will execute until the count expires or a trap, exception or breakpoint is reached. After COUNT instructions have completed the registers are printed and a trace prompt will appear. Typing a newline causes the next instruction to be executed and the registers are dumped again. Since the trace facility does not use the M68000 Trace_mode facility exceptions may also be traced. The default value of COUNT is 1. Breakpoints are only in effect when the value of COUNT is greater than one. 2.18 I/O and other facilities The emulator provides a mechanism to allow users to perform i/o on numbers and characters. This is achieved by using a TRAP #15 instruction. Should a user alter the default vector for TRAP #15 to a non-zero value this feature will cease to work and normal exception processing will take place for this instruction. The task number is in D0.B. See E68K : HELP TRAP#15 for information on the functions available. General The emulator has a built in disassembler which is available through the MD and DF commands. Should it encounter an illegal instruction pattern it will be disassembled as a DC.W $nnnn statement. A read in an unallocated area of memory causes zeros to be returned as the result. To keep the scheme consistent, newly allocated memory is always initialized to zero. It is possible for a user to write an assembler program which when executed enters an infinite loop. Pressing the ESC key during program execution will cause the emulator to return to command mode. Page 9