==== ==== ================================================================ DR 6502 AER 201S Engineering Design 6502 Execution Simulator ================================================================ Supplementary Notes M.J.Malone By: Use of Simulator ==================== Quick/Kick Start ================ using Some of dos and don'ts and reasons for m in DR6502 program will be given first. that default drive, not using card real be your used 2 use. be certain to 1) DO put all of DR6502 in on one drive and execute it from drive. It saves hassles later since it is easier to to current drive on all DR6502 files. 2) DO put your.bin file to be simulated on that same same reason. 3) Try not to use pathnames with DR6502. DR6502 does recognize pathnames. 4) DON'T expect to see any actual input or output when DR6502 without hardware simulator card. Without DR6502 is a software simulator only that is incapable of input/output though such operations can and should simulated through user intervention. 5) DON'T assume re is an error in DR6502 just because program did not work as expected. Many students have DR6502 in past and it has proven to work well, though small bugs were discovered in most recent YEAR of It is very common for students to make errors in logic or mistaken about operation of flags for instructions. If a genuine error is encountered, following should be provided: a) A listing of minimum assembly program required
produce error. IE 4-10 lines long where every line is required to induce error. b) The precise keystrokes/commands required to show error. Such documented errors will be repaired as expeditiously as possible. Starting ======== 1) System Requirements ---------------------- To run DR6502, a machine must be XT or AT compatible and have at least 640K of memory. Of that 640K at least 373K must be free after all memory resident programs and ram disks etc are installed. If re is not enough free memory in your computer, n some of memory resident programs must be removed or ram disk must be downsized. page 2 not 2) Code Requirements -------------------- Produce a pure text file containing your assembly code. Do use any text editor that encodes file in any way. If you are using project computer n remember that your final (target) computer code must start with following instructions:.org $E000 SEI LDX #$FF TXS ; LDX #$00 LDY #$00 InitDelay DEX BNE InitDelay DEY BNE InitDelay ; to Your code n follows. The first three statements are used
initialize microprocessor stack and se are also required when producing a code for DR6502. The next six instructions are a delay necessary to EVERY program used on project computer. These are required because project board uses a non-debounced reset switch circuit. Simple debouncing would violate rise time requirements of RST signal and more complex methods would require more chips on project computer board. A small addition to beginning of every student's program was not considered a problem. At end of your code you must have:.org $FFFC.WORD $E000.END This sets reset vector. When RST (reset) line is used to signal to processor to begin executing, processor is 'hardwired' to look in memory location $FFFC to find a vector pointing to beginning of user program. DR6502 expects to find reset vector in same place so se three directives are also required in programs to be simulated. 3) Assembling -------------- Any assembler capable of converting 6502 assembly language statements to a binary file of 6502 machine opcodes and operands would be acceptable. The TASM (Table oriented ASseMbler) is user supported package available to AER 201S students. TASM is a converter of ASC II assembly code files to binary executable files. It is capable of assembling for 6502 as well as several or processors. It is a common mistake to believe that re is some problem with fact that TASM program executes on an IBM type computer but produces code for a 6502 machine. Once again TASM is a
page 3 converter program. The machine it executes on does not determine what type of files it produces. TASM could be programmed to run on a Cray but it would still produce code for execution on a 6502 machine. The proper command line for assembling program 'myfile.asm' in current directory is: tasm -65 -b -l -fff myfile.asm myfile.bin myfile.lst Note on Options: -65 : Assemble for 6502 -b : Binary file output -l : List symbol table -fff: Fill unassigned spaces of EPROM with $FF any This produces a binary file named myfile.bin ready for DR6502 or EPROM programmer. The files myfile.lst can be used to look at errors that TASM may have found. 4) Eprom Burning ---------------- This is actually easier than simulating code so it will be dealt with first. The PC's in lab that are equipped with EPROM burners have software installed to copy.bin files onto EPROMs. The EPROM burner itself is a card for PC computers with a cable that leads to EPROM ZIF (Zero Insertion Force) socket module. You place your EPROM in socket in orientation suggested and press locking lever. Place disk with your software in floppy drive and type 'EPROM'. The EPROM burner menu has several options. You should check that EPROM type and programming voltage match EPROM you have. Load file from disk into EPROM program's buffer memory starting at address 0000. Check EPROM is blank by selecting 'blank check' function from menu. If EPROM checks out as blank, select 'program' or 'copy' from buffer to EPROM' function to program EPROM. Remove EPROM and place it in target computer. If you would like to change program in EPROM or if
EPROM did not check out as blank before programming n place EPROM in EPROM eraser unit. The EPROM eraser unit clears program from EPROM using ultraviolet light on memory gates. Erasing requires twenty minutes under ultraviolet light. 5) Writing an EEPROM -------------------- A routine has been written utilizing hardware simulator interface card, to write data to an EEPROM plugged into a project board RAM socket. EEPROMS must be of XL2864A type or equivalent. Simulating a Program with DR6502 ================================ page 4 Getting to Status Screen ---------------------------- To simulate program DR6502 needs code and memory configuration for target computer. To give this information to simulator re are two options. 1) Run CONFIG.EXE program by typing CONFIG, 2) Run DR6502.EXE by typing DR6502 and when it asks if it is configured for memory of target type 'n' for no. In this case DR6502 will call CONFIG program automatically. In CONFIG program user will be asked for type of memory elements and ir addresses. When EPROM is specified, user will be asked for name of.bin file that will be in memory of target computer. DR6502 expects to find this.bin file in current directory.
Once configuration is input, CONFIG will automatically call DR6502. This time since you have just finished running CONFIG program you can answer that 'y' "Yes, DR6502 is configured for memory of target". Provided you do not change name of binary file in subsequent revisions of your software, re is no need to run CONFIG program again. DR6502 will next ask if this will be a hardware simulator session. To use DR6502 in hardware mode, hardware simulator card and simulator software (DR6502) must be present in PC. The.BIN and all auxiliary files must be available. The simulator cable must be plugged into 6502 socket on target and target must be supplied with power from a power supply. DR6502 will read several files for information necessary for its operation and n will begin reading EPROM files. If hardware simulator is being used program will ask if EPROM corresponding to file is present or not. If EPROM is not present on target, simulator will use PC's memory to emulate it. The simulator will also ask if re is a symbol file that goes with.bin file (a.sym file produced with DRSYM.EXE and your.lst file) to be loaded into simulator. It is not necessary to have a symbol file but it does enhance performance of certain of simulator's functions. The simulator will next ask what type of processor you are using. The options are 0) - NMOS 6502, 1) Standard CMOS 65C02 and 2) Rockwell CMOS 65C02. The differences between each of se processors is instruction set. In newer revisions of processor, some new instructions were added. Choose selection that corresponds to processor that will be in your target computer.
page 5 look Interpreting Status Screen ------------------------------ The 'stopped' status screen will n appear and it should as shown below: --------------------------top of screen----------------------------- (Errors and Warnings Area) ================================================================ ==== ACC=00 XREG=00 YREG=00 SP=00 PC=E001 Status Register N V u B D I Z C 0 0 1 0 0 1 0 0 ================================================================ ==== E000 78 SEI (2) Fetch Address =FFFF E001 Next OpCode Vector Address=FFFF Elapsed Cycles (millions):000000.000002 ================================================================ ==== (Commands area) ---------------------------bottom of screen------------------------- The area at top of screen warns of error conditions detected by DR6502 and warns if opcode stream is becoming unusual. The next area down on screen shows current status of processor registers and flag register. The next area down on screen displays information about current program step. The opcode and operands are shown and n assembly mnemonic and addressing mode. If addressing mode involves a memory fetch n effective fetch address is shown. If address mode involves vector indirection n vector address
is was area also shown. The number of machine cycles since processor reset is also shown. Below lowest bar is commands where user commands are input. From status screen several commands are possible to view or manipulate memory or to start processor executing in one of several modes: shown processor Modes of Execution: (From slowest to fastest) --------------------------------------------- 'Single' Step Mode - While at 'Stopped' status screen (as above) user can press 's' key to cause to advance one machine instruction or STEP and return to 'Stopped' status screen. 'Go' Mode - While at 'Stopped' Status screen (as shown above) user can press 'g' key (for GO) to cause processor to execute a machine instruction, output all status information and continue on to next instruction. The 's' key will STOP execution and return simulator to 'Stopped' status screen. through mode status fast program page 6 'Go Fast' Mode - Since screen output takes most of time in execution loop, to speed processor's progress uninteresting parts of code a limited output 'fast' is available. By pressing '`' key in stopped screen, user can cause processor to enter execution where screen is cleared and only counter is displayed on screen. By pressing '`' again
user can make processor slow to full output 'go' mode. 'Go Really Fast' Mode - Since even printing program counter slows execution incredibly, a second fast mode was devised. Often user knows exactly to what point in code y would like processor to run. A 'breakpoint' could be used to halt processor at that point and user would need no screen output until that time. As a result when user has selected a breakpoint and enters '`' 'Go Fast' mode, processor will clear screen and enter a completely silent 'Really Fast' mode. There is about an order of magnitude speed difference between 'Go' and 'Go fast' and nearly anor order of magnitude between that and 'Go Really Fast'. The following are SOME of options are available in stopped menu. Influencing Execution --------------------- 'b' - 'set a Breakpoint' This allows user to set a point in memory as a breakpoint for execution. If processor encounters this memory location any time during execution, eir as a program location or a data access, execution in 'go' and 'go really fast' will stop and full stopped status screen is displayed. 'r' - 'change Registers' The user can modify contents of any of 6502 registers including flags, processor status register and program counter. Manipulating Memory ------------------- 'v' - 'View memory' This option performs a hexidecimal display of data space memory so that variables or arrays can be viewed. 'p' - 'Poke memory' This allows user to input hexidecimal
values into memory. page 7 Manipulating Programs --------------------- 'P' - '(re)program code' This option disassembles one page (256 bytes) of code and displays several lines on screen. The user can n edit code with a number of sub-options in 'P' program option. Changes made to code are not permanent unless 's'ave sub-option is selected before 'q'uit. Display Control --------------- 'm' - 'Monitor a variable' This option allows user to monitor on main output screen contents of a memory location that is an important variable to program. Summary ======= The previous explanations tried to address some of common concerns when students approach producing a piece of project software for AER201S. Complete information can only be gained by consulting: TASM documentation DR6502 documentation Project Computer Board Notes There is however no substitute for actually DOING. The sooner a student is completely familiar with process of moving a
code from concept to testing and implementation, faster it will go when design iterations become necessary. Design iterations result when software never works at all on first five tries, and doesn't work completely right until twentieth or fiftieth revision.