805x Monitor Documentation J. Zbiciak, 1996 =========================================================================== Foreward The monitor on the 805x board implements a number of basic features that are common to all of the modular computer systems. It also includes some minor enhancements that may be useful for program development. Finally, there are some definate conventions and restrictions that are unique to this particular board. This document will attempt to highlight all of these aspects of the 805x board and its monitor in detail. The appendix contains a monitor quick-reference. Table of Contents I. Basic Features of the 805x Monitor A. Basic Monitor Conventions 1. One and two letter commands 2. Up to two four-digit hex arguments (argv1 and argv2) 3. Aborting commands (ESC) B. Terminal Mode 1. Entering and leaving terminal mode (T and ^C) 2. Logging into the Unix system 3. Compiling and downloading programs (^A) 4. Logging out of the Unix system C. Accessing Memory and Registers 1. Dumping memory with DX, DI, DB 2. Editing memory with EX, EI, EB 3. Viewing/editing registers with R D. Running Code 1. Jumpstarting code with "G"oto 2. Setting/resuming/clearing "B"reakpoints E. Miscellaneous: "Q"uiet mode toggle II. 805x Monitor Internals A. Memory Map 1. Modular computer memory map 2. Monitor memory requirements B. Limitations of Monitor Breakpoints 1. Stack usage on entering breakpoint 2. Breakpoints in a loop 3. Saving P2 -- shadowing convention 4. Interrupt masking C. User Accessible Routines: Terminal and Unix I/O Appendix. 805x Monitor Quick Reference 805x Monitor Documentation J. Zbiciak, 1996 =========================================================================== Section I: Basic Features of the 805x Monitor Part A -- Basic Monitor Conventions Communication with the monitor takes place by typing a series of commands at the monitor's "> " prompt. Each command consists of a one or two letter mnemonic optionally followed by up to two 4-digit hexadecimal arguments. Excess whitespace in the command is ignored, and whitespace may generally be omitted between the mnemonic and the first argument, unless the resulting command would be ambiguous. Borrowing from C notation, the command arguments are referred to as "argv1" and "argv2" throughout this document. When omitted, "argv1" generally defaults to the saved program-counter value after a breakpoint (otherwise it's undefined), and "argv2" defaults to the value 0x0010. Finally, most "long duration" monitor commands may be aborted by pressed [ESC]. Part B -- Terminal Mode The monitor's "T" command invokes "Terminal Mode." This allows the user to communicate with the Xyplex terminal server, and ultimately, the Unix system. The monitor's other activies are suspended while in Terminal Mode. To return to Monitor Mode, press "^C" (which means [Ctrl]-[C]). To log into the Unix system, perform the following: 1. Enter Terminal Mode. 2. Log into the Xyplex terminal server by typing your login name at the "Enter Username>" prompt. 3. Next, type "c ee1 [enter]" at the subsequent "eeterm1>" prompt. 4. Finally, log in at the familiar Unix "login:" prompt. Once logged in, the user can compile and download programs. The compiler for the 805x board is named "as31". To assemble an 805x source file, type "as31 -l file.asm", where "file.asm" is the name of the source file. (Note: one must have the ".asm" extension for as31 to properly recognize the file.) This command will generate an object-code file, ending in ".obj", and a compiled code listing, ending in ".lst". The ".obj" file is in Intel IHEX format, and is suitable for downloading. The ".lst" file includes the original source, along with opcode and program offset information which is useful for determining breakpoint locations and other addresses. Pressing "^A" in Terminal Mode initiates a download. The user will be prompted for the file to download. Pressing [enter] without specifying a file aborts the download. The user should specify the ".obj" file created by "as31". The downloader will then request the file from the Unix system, and display a counter indicating the memory region currently being downloaded. If an error occurs, such as the file not being found, or being corrupted, the download will abort with a diagnostic message. The monitor returns to Terminal Mode once the download is complete. It is important to note that the user is not logged off the Unix system when leaving Terminal Mode to return to Monitor Mode. This feature is useful during a developing session, as the logging in process can be quite tedious. The user must remember to log off his/her Unix account when finished with the modular computer, by typing "exit" at the Unix prompt. 805x Monitor Documentation J. Zbiciak, 1996 =========================================================================== Section I: Basic Features of the 805x Monitor (cont) Part C -- Accessing Memory and Registers The 805x monitor permits two modes of access to RAM: Read only, and read/write. The former, read-only, is useful for dumping large amounts of external, internal, or bitwise addressable RAM. The latter is useful for viewing, and possibly tweaking, small numbers of memory locations. Further, the monitor allows the user to view and edit a number of 805x registers. Note: There is no mechanism for properly viewing or editing the SFRs. To display large blocks of memory use the "D" commands: "DX", "DI", and "DB", which display eXternal, Internal, and Bit-addressed memory, respectively. Using "D" alone is the same as using "DX". The "D" commands accept two arguments. Argv1 is the address to begin displaying at, and argv2 is the count of addresses to display. The value in argv1 is rounded down to the next lowest multiple of 0x0010, while the value in argv2 is rounded up, in order to limit memory displays to full, 16-byte lines. For the "DI" and "DB" commands, an argv2 of 0 is equivalent to 0x100. Examples: > DX 1234 15 1230: 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 0123456789ABCDEF 1240: 61 62 63 64 65 66 67 68 69 6A 6A 6B 6C 6D 6E 6F abcdefghijklmnop > DI 20 10 I 20: 00 99 22 33 44 55 66 77 88 99 AA BB CC DD EE FF .."3DUfw........ > DB 00 10 B 00: 0 0 0 0 0 0 0 0 1 0 0 1 1 0 0 1 To edit memory, use the "E" commands: "EX", "EI", and "EB", which edit eXternal, Internal, and Bit-addressed memory, respectively. Using "E" alone is the same as using "EX". The "E" commands accept one argument, the address at which to start editing/viewing memory. For these commands, the monitor displays an address and its contents, and allows the user to type hexidecimal digits. The value shown is shifted left one nibble (4-bits) and the new digit is inserted at the right. (In the case of entering Bit data, the least-significant bit of the key pressed is used, and only 1 bit is displayed.) Pressing [Enter] moves to the next location, and pressing [ESC] or [Space] returns to the monitor prompt. 805x Monitor Documentation J. Zbiciak, 1996 =========================================================================== Section I: Basic Features of the 805x Monitor (cont) Part C -- Accessing Memory and Registers (cont) To view and edit the contents of the 805x registers, use the "R" command. Its output format is similar to the "E" commands, except a register name is shown rather than a memory address. This command allows the user to edit the following: SP, PSW, DPL, DPH, A, B, and R0-R7 of the current register bank. (Note: Editing PSW can change the current register bank. The monitor is aware of this and adjusts appropriately.) Again, pressing [Enter] moves to the next location, and pressing [ESC] or [Space] returns to the monitor prompt. Part D -- Running Code Most importantly, the monitor allows you to execute your code. The monitor also supports setting and resuming from breakpoints. The "G", as in Goto, command is used for jumpstarting a program. It accepts one argument, the address to jump to in your code. Also, this command is used for resuming after a breakpoint. For this reason, argv1 defaults to the Program Counter value when we are stopped at a breakpoint. Prior to executing user code, the monitor PUSHes its entry point on the stack so that a RET from the user's code will return to the monitor. The PUSH is suppressed when resuming the user's code after a breakpoint. The "B" command is used for setting breakpoints and the "C" command is used for clearing them. When a breakpoint is reached, the breakpoint address is cleared, and the current program counter is saved for use as the default argv1. Also, a flag is set indicating that the monitor is stopped at a breakpoint, so the next "G"oto command will assume that the user is *resuming* rather than *executing afresh*, even if the user specifies a new address to "G"oto. This flag can be cleared by issuing the "C" command to explicitly clear the breakpoint state. Part E -- Miscellaneous: "Q"uiet mode toggle The monitor includes support for a "Quiet" mode, which filters all ASCII "BEL" characters from reaching the Viewpoint terminal. The "Q" command toggles this filter on and off. The filter applies to all output from either Monitor Mode or Terminal Mode. This option can be used to reduce the user's aspirin intake during projects week. 805x Monitor Documentation J. Zbiciak, 1996 =========================================================================== Section II. 805x Monitor Internals Part A -- Memory Map There are two memory maps which are relevant to the 805x modular computer setup: the modular computer itself, and the 805x module memory map. The user must also be familiar with the 805x Monitor's memory requirements and demands. Figure 1. Modular Computer Memory Map, with 805x Module Address Range Description ============= =========== 0x0000-0x0FFF 805x Module address space 0x1000-0x1FFF 4K RAM 0x4000-0xFEFF 48K Static RAM (optional) 0xFF00-0xFFFF I/O Page Figure 2. 805x Module Memory Map, with Monitor Requirements Address Range Address Map Description ============= =========== =========== 0x0000-0x0FFF External On-board 4K RAM (Data only) *0x0F00-0x0FFF External Reserved for Monitor Usage 0x0000-0x0FFF Code On-board EPROM 0x00-0xFF Internal 8052 internal RAM * 0x30 Internal Port 2 (P2 SFR) shadowing (P2SAVE) 0x1000-0xFFFF External Modular computer address space *0x1003-0x1032 External Mirror of interrupt vector space *Indicates locations reserved for monitor usage Part B -- Limitations of Monitor Breakpoints Registers and other state info are saved when not executing user code, and restored prior to executing the user's code. This is true whether reaching the monitor from a breakpoint, or by "RET"urning from user code to the monitor. These actions are mostly transparent to the user. Unfortunately, one SFR cannot be saved: Port 2 (P2). User code must shadow any value written to P2 to the P2SAVE location, 0x30. P2 will then be initialized from P2SAVE before entering user code. (Likewise, editing P2SAVE from the monitor effectively edits the user's code's P2.) The monitor also requires 5 bytes of stack space when implementing a breakpoint trap, or 1 byte when "RET"urning to the monitor. Therefore, that amount of data (1 or 5 bytes) past the top-of-stack will be lost upon re-entering the monitor. Aside from this and the P2SAVE behavior, all internal RAM usage is transparent to the user program. 805x Monitor Documentation J. Zbiciak, 1996 =========================================================================== Section II. 805x Monitor Internals (cont) Part B -- Limitations of Monitor Breakpoints (cont) Setting breakpoints within a loop is minorly annoying. Breakpoints are implemented by exchanging 3 bytes of user code with a 3-byte LCALL to the monitor entry point. Upon reaching the entry point, the monitor POPs off the return address of the LCALL, which corresponds to the PC value of the LCALL. This is then compared against the breakpoint location, and if it matches, the monitor assumes a breakpoint is reached, and it *clears the breakpoint*. If not, it PUSHes back the PC value it had grabbed, since it was actual data, rather than a breakpoint return address. This PUSH returns the stack to the correct state. In the case of a breakpoint in a loop (or other recurring breakpoint), it is not possible to re-set the breakpoint at the same location each iteration, if the user resumes at the exact location of the break. If the user does put the breakpoint at the location being resumed, no new code gets executed when resuming--the user resumes into an immediate breakpoint! The workaround is to insert 3 bytes of NOPs into the loop at the intended breakpoint, and then manually resume the code 3 bytes after the breakpoint location. This allows the breakpoint to be re-set in the same location for each iteration, and no actual code is skipped. Finally, all interrupts are masked while within the monitor. No effort is made to suspend the timer or otherwise preserve timer or interrupt information, aside from saving/restoring the IE and IP masks. Part C -- User Accessible Routines: Terminal and Unix I/O Due to their large perceived demand, the monitor's terminal and Unix serial I/O routines have been made readily available for use by user code. A jump table exists from 0x0FE0-0x0FEE, and is set as follows: Figure 3. Jump Table for Monitor I/O Routines Location Routine Description ======== =================== 0x0FE0 Send byte to terminal 0x0FE3 Send byte to terminal with filtering 0x0FE6 Receive byte from terminal (non-blocking) 0x0FE9 Send byte to Unix/terminal server 0x0FEC Receive byte from Unix/terminal server (non-blocking) The send byte routines accept a byte to be sent in A. The routines will "block" until the device is ready to accept the character being sent. The "Send...with filtering" routine will filter out characters that match the value in internal memory location 0x10. (This, in part, is how the monitor implements "Quiet mode".) The receive-byte routines are "non-blocking", meaning they return whether or not a character is ready. If a character was ready, the character is placed in A, and the carry bit is set. Otherwise, the previously read character is placed in A, and the carry bit is cleared. Note: It's up to the user to use appropriate delays, etc. for proper output when writing to the Viewpoint terminal. (The Viewpoint requires delays primarily when scrolling.) 805x Monitor Documentation J. Zbiciak, 1996 =========================================================================== Quick reference: D[XIB] addr len Display locations starting at (X -- eXternal I -- Internal B -- Bit-addressed) E[XIB] addr Examine/modify memory locations starting at R Examine/modify registers (SP,PSW,DPL,DPH,A,B,R0-R7) B addr Set breakpoint C Clear breakpoint G addr Execute code at (aka, 'G'oto) Q Toggle 'Q'uiet mode T Enter terminal mode ^C Return to monitor mode ^A Download a .HEX file Important memory locations: Location Description ======== =========== C 0x0FE0 Send byte to terminal C 0x0FE3 Send byte to terminal with filtering C 0x0FE6 Receive byte from terminal (non-blocking) C 0x0FE9 Send byte to Unix/terminal server C 0x0FEC Receive byte from Unix/terminal server (non-blocking) I 0x10 Filter character for "send byte with filtering" I 0x30 P2SAVE (Port 2 shadow location) X 0x0F00-0x0FFF Monitor reserved RAM X 0x1003-0x1032 Revectored interrupt vector locations Legend for location types: C == Code Space I == Internal X== External