ttl assist09 - mc6809 monitor * Modification date: March 4, 1985 ************************************* * copyright (c) motorola, inc. 1979 * ************************************* ************************************* * This version of assist09 contains modifications * which allow a mc68681 duart to be used in place * of the mc6850 acia and mc6840 ptm, while also * providing software controlled baud rate. * several options (opt) are used to generate * printouts of the modified sections only. ************************************* ********************************************* * global module equates ******************************************** rombeg equ $f800 rom start assembly address ramofs equ -$3800 rom offset to ram work page romsiz equ 2048 rom size rom2of equ rombeg-romsiz start of extension rom duart equ $8010 default acia address ptm equ $8020 default dumb address * refer to table below in miscellaneous equates * section for modificatiuons of baud rate mbaud equ $02bb byte1 is mode byte2 is baud rate dftchp equ 0 default character pad count dftnlp equ 5 default new line pad count prompt equ '> prompt character numbkp equ 8 number of breakpoints ********************************************* * miscelaneous equates ********************************************* eot equ $04 end of transmission bell equ $07 bell character lf equ $0a line feed cr equ $0d carriage return dle equ $10 data link escape can equ $18 cancel (ctl-x) * duart access definitions mr1a equ $00 mode register 1 port a mr2a equ $00 mode register 2 port a csra equ $01 clock select register trans equ $03 transmit buffer reciv equ $03 receiver buffer acr equ $04 auxillery control cra equ $02 command register a stat equ $01 status register a scc equ $0e start counter command stop equ duart+$0f imr equ $05 ctur equ $06 * * baud rate select table for * some common selections for * baud rate set #2 on mc68681 * * 300 baud = $44 * 1200 baud = $66 * 2400 baud = $88 * 4800 baud = $99 * 9600 baud = $bb * 19.2k baud = $cc skip2 equ $8c "cmpx #" opcode - skips two byte ******************************************* * assist09 monitor swi functions * the following equates define functions provided * by the assist09 monitor via the swi instruction. ****************************************** inchnp equ 0 input char in a reg - no parity outch equ 1 output char from a reg pdata1 equ 2 output string pdata equ 3 output cr/lf then string out2hs equ 4 output two hex and space out4hs equ 5 output four hex and space pcrlf equ 6 output cr/lf space equ 7 output a space monitr equ 8 enter assist09 monitor vctrsw equ 9 vector examine/switch brkpt equ 10 user program breakpoint pause equ 11 task pause function numfun equ 11 number of available functions * next sub-codes for accessing the vector table. * they are equivalent to offsets in the table. * relative positioning must be maintained. .avtbl equ 0 address of vector table .cmdl1 equ 2 first command list .rsvd equ 4 reserved hardware vector .swi3 equ 6 swi3 routine .swi2 equ 8 swi2 routine .firq equ 10 firq routine .irq equ 12 irq routine .swi equ 14 swi routine .nmi equ 16 nmi routine .reset equ 18 reset routine .cion equ 20 console on .cidta equ 22 console input data .cioff equ 24 console input off .coon equ 26 console output on .codta equ 28 console output data .cooff equ 30 console output off .hsdta equ 32 high speed printdata .bson equ 34 punch/load on .bsdta equ 36 punch/load data .bsoff equ 38 punch/load off .pause equ 40 task pause routine .expan equ 42 expression analyzer .cmdl2 equ 44 second command list .duart equ 46 duart address .pad equ 48 character pad and new line pad .echo equ 50 echo/load and null bkpt flag .ptm equ 52 ptm not really used * ptm equate was deleted due to implementation * of trace by the timer/counter on the mc68681 numvtr equ 52/2+1 number of vectors hivtr equ 52 highest vector offset ****************************************** * work area * This work area is assigned to the page addressed by * -$800, pcr from the base address of the assist09 * rom. the direct page register during most routine * operations will point to this work area. the Stack * initially starts under the reserved work areas as * defined herein. ****************************************** workpg equ rombeg+ramofs setup direct page address * setdp workpg!>8 notify assembler org workpg+256 ready page definitions * the following thru bkptop must reside in this order * for proper initialization org *-4 pauser equ * pause routine org *-1 swibfl equ * bypass swi as breakpoint flag org *-1 bkptct equ * breakpoint count org *-2 slevel equ * stack trace level org *-$36 vectab equ * vector table org *-$10 bkptbl equ * breakpoint table org *-$10 bkptop equ * breakpoint opcode table org *-2 window equ * window org *-2 addr equ * address pointer value org *-1 basepg equ * base page value org *-2 number equ * binary build area org *-2 lastop equ * last opcode traced org *-2 rstack equ * reset stack pointer org *-2 pstack equ * command recovery stack org *-2 pcnter equ * last program counter org *-2 tracec equ * trace count org *-1 swicnt equ * trace "swi" nest level count org *-1 (misflg must follow swicnt) misflg equ * load cmd/thru breakpoint flag org *-1 delim equ * expression delimiter/work byte org *-40 rom2wk equ * extension rom reserved area org *-21 tstack equ * temporary stack hold stack equ * start of initial stack ****************************************** * default the rom beginning address to 'rombeg' * assist09 is position address independent, however * we assemble assuming control of the hardware vectors. * note that the work ram page must be 'ramofs' * from the rom beginning address. ******************************************** org rombeg rom assembly/default address ***************************************************** * bldvtr - build assist09 vector table * hardware reset calls this subroutine to build the * assist09 vector table. this subroutine resides at * the first byte of the assist09 rom, and can be * called via external control code for remote * assist09 execution. * input: s->valid stack ram * output: u->vector table address * dpr->assist09 work area page * the vector table and defaults are initialized * all registers volatile ************************************************* bldvtr leax vectab,pcr address vector table tfr x,d obtain base page address tfr a,dp setup dpr sta work area page * d,y,u=unreliable x=as called from user * s=as from swi interrupt ********************************************* ************************************************** * [swi function 8] * monitor entry * fireup the assist09 monitor. * the stack with its values for the direct page * register and condition code flags are used as is. * 1) initialize console i/o * 2) optionally print signon * 3) initialize ptm for single stepping * 4) enter command processor * input: a=0 init console and print startup message * a#0 omit console init and startup message ************************************************* signon fcc /assist09/ signon eye-catcher fcb eot zmontr sts =0 valid)/compare cnt * u-3=carriage return flag (0=cr has been done) * u-4=start of command store * s+0=end of command store *********************************************** cmd swi to new line fcb pcrlf function * disarm the breakpoints cmdnep lbsr cbkldr obtain breakpoint pointers bpl cmdnol branch if not armed or none negb make positive stb assist09 direct page work area ** z=1 carriage return entered ** z=0 non carriage return delimiter ** s=normal return address ** the label "cmdbad" may be entered to issue an ** an error flag (*). ************************************************** * assist09 command tables * these are the default command tables. external * tables of the same format may extend/replace * these by using the vector swap function. * * entry format: * +0...total size of entry (including this byte) * +1...command string * +n...two byte offset to command (entryaddr-*) * * the tables terminate with a one byte -1 or -2. * the -1 continues the command search with the * second command table. * the -2 terminates command searches. ***************************************************** * this is the default list for the second command * list entry. cmdtb2 fcb -2 stop command searches * this is the default list for the first command * list entry. cmdtbl equ * monitor command table fcb 4 fcc /B/ 'breakpoint' command fdb cbkpt-* fcb 4 fcc /C/ 'call' command fdb ccall-* fcb 4 fcc /D/ 'display' command fdb cdi -* fcb 4 fcc /E/ 'encode' command fdb cencde-* fcb 4 fcc /G/ 'go' command fdb cgo-* fcb 4 fcc /L/ 'load' command fdb cload-* fcb 4 fcc /M/ 'memory' command fdb cmem-* fcb 4 fcc /N/ 'nulls' command fdb cnulls-* fcb 4 fcc /O/ 'offset' command fdb coffs-* fcb 4 fcc /P/ 'punch' command fdb cpunch-* fcb 4 fcc /R/ 'registers' command fdb creg-* fcb 4 fcc /S/ 'stlevel' command fdb cstlev-* fcb 4 fcc /T/ 'trace' command fdb ctrace-* fcb 4 fcc /V/ 'verify' command fdb cver-* fcb 4 fcc /W/ 'window' command fdb cwindo-* fcb -1 end, continue with the second ************************************************* * [swi functions 4 and 5] * 4 - out2hs - decode byte to hex and add space * 5 - out4hs - decode word to hex and add space * input: x->byte or word to decode * output: characters sent to output handler * x->next byte or word ************************************************** zout2h lda ,x+ load next byte pshs d save - do not reread ldb #16 shift by 4 bits mul with multiply bsr zouthx send out as hex puls d restore bytes anda #$0f isolate right hex zouthx adda #$90 prepare a-f adjust daa adjust adca #$40 prepare character bits daa adjust send jmp [vectab+.codta,pcr] send to out handler zot4hs bsr zout2h convert first byte zot2hs bsr zout2h convert byte to hex stx 4,s update users x register * fall into space routine ************************************************* * [swi function 7] * ace - send blank to output handler * input: none * output: blank send to console handler ************************************************* zspace lda #' load blank bra zotch2 send and return *********************************************** * [swi function 9] * swap vector table entry * input: a=vector table code (offset) * x=0 or replacement value * output: x=previous value *********************************************** zvswth lda 1,s load requesters a cmpa #hivtr ? sub-code too high bhi zotch3 ignore call if so ldy string * output: cr/lf and string sent to output console * handler. * c=0 no ctl-x, c=1 ctl-x recieved * note: line feed must follow carriage return for * proper punch data. ************************************************** zpdata lda #cr load carriage return bsr send send it lda #lf load line feed * fall into pdata1 ************************************************* * [swi function 2] * pdata1 - output string till eot ($04) * this routine pauses if an input byte becomes * available during output transmission until a * second is recieved. * input: x->string * output: string sent to output console driver * c=0 no ctl-x, c=1 ctl-x recieved ************************************************* zpdtlp bsr send send character to driver zpdta1 lda ,x+ load next character cmpa #eot ? eot bne zpdtlp loop if not * fall into pause check function ******************************************** * [swi function 12] * pause - return to task dispatching and check * for freeze condition or ctl-x break * this function enters the task pause handler so * optionally other 6809 processes may gain control. * upon return, check for a 'freeze' condition * with a resulting wait loop, or condition code * return if a control-x is entered from the input * handler. * output: c=1 if ctl-x has entered, c=0 otherwise ****************************************** zpause bsr xqpaus release control at every line bsr chkabt check for freeze or abort tfr cc,b prepare to replace cc stb ,s overlay old one on stack bra zotch3 return from "swi" * chkabt - scan for input pause/abort during output * output: c=0 ok, c=1 abort (ctl-x issued) * volatile: u,x,d chkabt bsr xqcidt attempt input bcc chkrtn branch no to return cmpa #can ? ctl-x for abort bne chkwt branch no to pause chksec comb set carry chkrtn rts return to caller with cc set chkwt bsr xqpaus pause for a moment bsr xqcidt ? key for start bcc chkwt loop until recieved cmpa #can ? abort signaled from wait beq chksec branch yes clra set c=0 for no abort rts and return * save memory with jumps xqpaus jmp [vectab+.pause,pcr] to pause routine xqcidt jsr [vectab+.cidta,pcr] to input routine anda #$7f strip parity rts return to caller ******************************************** * nmi default interrupt handler * the nmi handler is used for tracing instructions. * trace printouts occur only as long as the stack * trace level is not breached by falling below it. * tracing continues until the count turns zero or * a ctl-x is entered from the input console device. ********************************************* mshowp fcb 'O,'P,'-,eot opcode prep * * one instruction was added to the nmi handler * this instruction stops the counter on the * mc68681 duart which also negates the signal * which caused the interrupt (nmi) * nmir tst stop * * bsr lddp load page and verify stack tst register to print tst ,s ? change option bne regcng branch yes tst -1,y ? one or two bytes beq regp3 branch zero means one swi perform word hex fcb out4hs function fcb skip2 skip byte print regp3 swi perform byte hex fcb out2hs function reg4 ldd ,y+ to front of next entry tstb ? end of entries bne regp1 loop if more swi force new line fcb pcrlf function regrtn puls pc,y,x,a restore stack and return regcng bsr bldnnb input binary number beq regnxc if change then jump cmpa #cr ? no more desired beq regagn branch nope ldb -1,y load size flag decb minus one negb make positive aslb times two (=2 or =4) regskp swi perform spaces fcb space function decb bne regskp loop if more bra reg4 continue with next register regnxc sta ,s save delimiter in option * (always > 0) ldd