On Tue, Oct 02, 2018 at 12:24:47PM -0700, tim lindner via cctalk wrote: > Does anyone have source to a 6809 monitor program? > > I'm looking for something I can make work in a CoCo. > > Functionality I'm looking for is something that will let me read and > write to memory.
I have a copy of psymon.s if you want it. > > -- > -- > tim lindner > > "Proper User Policy apparently means Simon Says." -- - d...@freebsd.org d...@db.net http://artemis.db.net/~db
************************************************* * psymon version 1.00 * * copyright (c) 1979 percom data company, inc. * percom data company, inc. grants unrestricted * royalty-free license for the use of this * program provided the user clearly acknowledges * its origin. * * while this monitor is very simple, its true * power lies in its extensibility and in the * tools that it provides for other software * to use. This operating system is dedicated * to harold mauch and his legendary 512 byte * operating system. * * psymon Much modified version 4.00 * * commands: * m <address> - memory examine/change * o <address> - memory change (output to I/O port no read) * g <address> - go to address * r <register> - register examine/change * l <address> - load program from tape, optional load address * s <start> <end> - save program to tape * b <address> - set/list breakpoints * u <address> - unset breakpoints * e start end dest - Burn EEPROM at dest with data from start, end * * other comments to be added here later * * Extensive modifications for GPE * - acia changed to 68681 DUART, I know strange to use a 68k part on 6809 * - removed 'z' command * - moved I/O,ram,rom addresses as needed * - removed special code for special dcb's for punch since * debug port will be used for all uploads/downloads and need the bytes. * (There is lots of ROM on target system, but I am unwilling to attempt * relocating monitor since that would entail working out padding, * see my next note) * - Original programmer did not make use of 'lbra' and 'lbsr' instructions * for reaching code ie. used 'stepping stone' technique, makes me wonder * if this was originally a 6800 monitor? * - Added 'o' command * - DCB is obviously "Device Control Block" but no reference to that * in "FLEX" or "OS9" so I have no idea where this came from. * * DB. Feb 19 1990 * DB. Feb 25 1990 ************************************************* * system address constants (GPE version) RUNSYS equ 1 ; if bottom bit is set on INPORT, Run 2nd ROM rom1 equ 0F800H ; base add of psymon rom rom2 equ 0C000H ; base add of extension rom ram equ 0000 ; base add of ram termnl equ 8000H ; system terminal acia * ascii character constants cr equ 0dH ; carriage return lf equ 0AH ; line feed sp equ 20H ; space * acia control configurations MREG equ 0 ; Mode register (MR1,MR2) SREG equ 1 ; Status register CSREG equ 1 ; Clock select register CREG equ 2 ; Command register RHR equ 3 ; Receiver holding register THR equ 3 ; Transmitter holding register OPCR equ 0DH ; Output port conf reg. INPORT equ 0DH ; Same as above, read input port SETOP equ 0EH RESETOP equ 0FH * yes, THR is the same as RHR * * Bit masks for SREG (status register) * RXRDY equ 01H ; RXRDY equ %00000001 TXRDY equ 04H ; TXRDY equ %00000100 RXBRK equ 80H ; RXBRK equ %10000000 FRAME equ 40H ; FRAME equ %01000000 PARER equ 20H ; PARER equ %00100000 OVRUN equ 10H ; OVRUN equ %00010000 * * Commands for CREG * RESETRX equ 20H ; RESETRX equ %00100000 RESETTX equ 30H ; RESETTX equ %00110000 RESETMR equ 10H ; RESETMR equ %00010000 ENBTX equ 04H ; ENBTX equ %00000100 Enable Transmitter ENBRX equ 01H ; ENBRX equ %00000001 Enable Receiver DISTX equ 08H ; DISTX equ %00001000 Disable Transmitter DISRX equ 02H ; DISRX equ %00000010 Disable Receiver ENABLE equ 05H ; ENABLE equ %00000101 Enable both RX and TX * * Commands for MR * Whenever MR is pointing to MR1 and then is written to, MR flips to MR2. * RXRTSNO equ 0 RXRTSYES equ 80H ; RXRTSYES equ %10000000 RXINTRDY equ 0 RXINTFUL equ 40H ; RXINTFUL equ %01000000 * * MR1 equ RXRTSNO|RXINTRDY|ERRORCHAR|NOPARITY|BITS8 MR1 equ 13H ; MR1 equ %00010011 *MR2 equ NORMAL|TXRTSNO|CTSCTLNO|STOP1 MR2 equ 07H ; MR2 equ %00000111 * * Commands for CSREG * B9600 equ 0BBH ; B9600 equ %10111011 * BURNRAM equ 1400H ; where EEPROM routine goes * * psymon dcb offsets dcblnk equ 0 ; ptr to next dcb in chain dcbdid equ 2 ; ascii 2 char device id dcbdvr equ 4 ; device driver address dcbioa equ 6 ; device io address dcberr equ 8 ; error status code dcbext equ 9 ; dcb extension byte count dcbapp equ 10 ; driver dcb appendage * psymon dcb function codes readfn equ 01H ; read writfn equ 02H ; write statfn equ 04H ; read status initfn equ 08H ; init the 68681 baudfn equ 10H ; set baud rate (for 68681 only) * psymon ram definitions (mp-a2 version) org ram * psymon internal stack (& register) space rmb 800H ; stack space stack: regc: rmb 1 ; condition code register rega: rmb 1 ; a register regb: rmb 1 ; b register regd: rmb 1 ; dp register regx: rmb 2 ; x register regy: rmb 2 ; y register regu: rmb 2 ; u register regp: rmb 2 ; pc * psymon breakpoint table bptabl: rmb 30 ; space for 10 breakpoints bptend: * psymon work areas memptr: rmb 2 ; pointer for M command usrtbl: rmb 2 ; address of user command table comand: rmb 1 ; command char storage cksum: rmb 1 ; load & save checksum begadd: rmb 2 ; begin address for save endadd: rmb 2 ; end address for save offsetflg: rmb 1 offset: rmb 2 stkptr: rmb 2 ; contents of stack pointer * the psymon console dcb condcb: rmb 10 ; no extensions * psymon dcb pointers dcbchn: rmb 2 ; base of dcb chain cidcb: rmb 2 ; console input dcb cedcb: rmb 2 ; console echo dcb codcb: rmb 2 ; console output dcb tpdcb: rmb 2 ; cassette tape dcb * psymon vectors swi3v: rmb 2 ; software interrupt 3 swi2v: rmb 2 ; software interrupt 2 firqv: rmb 2 ; fast interrupt request irqv: rmb 2 ; interrupt request swiv: rmb 2 ; software interrupt nmiv: rmb 2 ; non-maskable interrupt restrt: rmb 2 ; re-entry into psymon * psymon rom coding org 0F800H ; rom1 ************************************************* * psymon initialization ************************************************* init: ld s #stack ; set up stack pointer tfr s x ; point x at stack init1: clr ,x+ ; clear a byte cmp x #condcb+2 ; all fields clear? bne init1 ; loop if not lea y ramint,pcr ; point to ram data init2: ld d ,y++ ; move 2 bytes st d ,x++ cmp x #restrt+2 ; end of ram? bne init2 ; loop if not ld x #condcb ; point to dcb ld b #initfn lbsr reqio ; reset acia ld x #termnl ld a INPORT,x bit a #RUNSYS ; Run the system ROM? bne monent ld a rom2 ; check for second rom cmp a #'V' ; is there a version code there? bne monent ; branch if not jmp rom2+4 ; else call second rom ************************************************* * psymon user entry ************************************************* monent: ld s #stack ; set stack pointer st s stkptr ************************************************* * get command ************************************************* getcmd: lea x prompt,pcr ; display prompt lbsr pstrng lbsr inchr ; input command character cmp a #'a' blo getupper and a #0DFH ; convert to upper getupper: bsr lookup ; look it up bne getcmd ; loop if not found lbsr outsp ; output a space jsr [0,x] ; call command routine bra getcmd ; go back for more prompt: fcb cr,lf str "cmd" fcb '?'+80H ; end of string ************************************************* * look up command in table ************************************************* lookup: ld y #comand ; point y at command st a ,y ; save command character ld x usrtbl ; get user table address beq look1 ; branch if none bsr search ; else search user table beq serchx ; go if found look1: lea x cmdtbl,pcr ; search internal table ************************************************* * general table search * * entry requirements: x - points to table * y - points to item * first byte of table must * contain item length * last byte must be ff * * exit conditions: c - z set if found, clear * if not found * x - points to address of routine * for match * a,b - changed * ************************************************* search: ld b ,x+ ; get item length serch1: bsr compar ; compare current item abx ; advance to next item beq serchx ; exit if match lea x 2,x ; step over address tst ,x ; end of table? bpl serch1 ; loop if not serchx: rts ************************************************* * general string compare * * entry requirements: x - address of string 1 * y - address of string 2 * b - length of strings * * exit conditions: c - set per compare 1:2 * b,x,y - unchanged * a - changed * ************************************************* compar: pshs b x y ; save registers comp1: ld a ,x+ ; get next char cmp a ,y+ ; compare it bne comp2 ; exit if unmatched dec b ; decrement loop count bne comp1 comp2: puls b x y pc ; restore registers & return ************************************************* * load program from tape, with optional load address ************************************************* tload: clr offsetflg lbsr gethex ; get optional offset value beq tload0 st x offset ld a #1 st a offsetflg tload0: ld x cedcb ; save default echo mode pshs x clr a ; set d to 0 clr b st d cedcb ; set no echo bsr load ; load the tape puls x ; restore echo mode st x cedcb tst cksum ; any errors? beq loadx ; branch if not ************************************************* * display error indicator of '?' ************************************************* error: ld a #'?' ; display error indicator lbra outchr ************************************************* * load program in hex format * * entry requirements: none * * exit conditions: all registers changed * cksum non-zero if error * ************************************************* load: tfr s y ; mark stack for error recovery load1: lbsr inchr ; get a character load2: cmp a #'S' ; start of record? bne load1 ; loop if not lbsr inchr ; get another character cmp a #'9' ; end of load? beq loadx ; branch if yes cmp a #'1' ; start of record? bne load2 ; loop if not clr cksum ; init checksum bsr inbyte ; read length sub a #2 ; adjust it tfr a b ; save in b bsr inbyte ; get address hi st a ,--s ; save on stack bsr inbyte ; get address lo st a 1,s ; put on stack puls x ; address now in x tst offsetflg beq load3 exg d x sub d offset ; subtract from given load address exg d x load3: bsr inbyte ; read a byte dec b ; decrement count beq load4 ; branch if done st a ,x ; store byte cmp a ,x+ ; verify good store bne load5 ; branch if error bra load3 load4: inc cksum ; check checksum beq load1 ; loop if good load5: ld a #0ffH ; set error flag st a cksum tfr y s ; restore stack loadx: rts ************************************************* * input a byte ************************************************* inbyte: bsr inhex ; get hex digit beq load4 ; branch if error asl a ; shift to ms half asl a asl a asl a pshs a ; save digit bsr inhex ; get another digit beq load4 ; branch if error add a ,s ; combine halves st a ,s ; save on stack add a cksum ; add to checksum st a cksum puls a pc ; get result & return ************************************************* * get hex number from console * * entry requirements: none * * exit conditions: a - last char input * b - hex digit count * x - hex number * c - set according to b * ************************************************* gethex: clr b ; init digit count & result ld x #0 gethx1: bsr inhex ; get a digit beq gethx2 ; go if not hex exg d x ; old result to a,b asl b ; shift left 1 digit rol a asl b rol a asl b rol a asl b rol a exg d x ; replace result lea x a,x ; add in new digit inc b ; add to digit count bra gethx1 ; loop for more gethx2: tst b ; set/reset z flag rts ************************************************* * get hex digit from console * * entry requirements: none * * exit conditions: a - hex digit or non-hex * c - z flag set if a not hex * all other regs preserved * ************************************************* inhex: bsr inchr ; get a character cmp a #'a' blo inhexupper and a #0DFH ; convert to upper inhexupper: pshs a ; save it sub a #30H ; convert to binary bmi inhex2 ; branch if not numeric cmp a #09H ; greater than 9? bls inhex1 ; branch if not sub a #07H ; else convert letter inhex1: cmp a #0fH ; greater than 15? bls inhex3 ; branch if not inhex2: ld a ,s ; get original char back inhex3: cmp a ,s+ ; set/reset z flag rts ************************************************* * console input routine * * entry requirements: none * * exit conditions: a - character with parity removed * all other regs except c preserved * ************************************************* inchr: pshs b x ; save registers ld x cidcb ; point to input dcb ld b #readfn ; set up for read bsr reqio ; read a character and a #7fH ; remove parity ld x cedcb ; point to echo dcb pshs a ; save character bne outch1 ; branch if echo puls a b x pc ; else restore regs & return ************************************************* * console output routine * * entry requirements: a - character to be output * * exit conditions: all registers preserved except c * ************************************************* outchr: pshs a b x ; save registers ld x codcb ; point to output dcb outch1: ld b #writfn ; set function bsr reqio ; output the character puls a b x pc ; restore regs & return ************************************************* * perform io requests * * entry requirements: a - driver parameter * b - function code * x - dcb address * * exit conditions: a - driver result * all other regs except c preserved * ************************************************* reqio: pshs b x y ; save registers jsr [dcbdvr,x] ; call driver puls b x y pc ; restore regs & return ************************************************* * display double byte * * entry requirements: a,b - double byte to print * * exit conditions: all regs preserved but c * ************************************************* dspdby: bsr outhex ; display a as 2 hex digits exg a b bsr dspsby ; display b as 2 hex digits exg a b ; restore a & b rts ************************************************* * display a byte and space * * entry requirements: a - byte to be displayed * * exit conditions: all regs but c preserved * ************************************************* dspsby: bsr outhex ; display byte in a ************************************************* * output a space to the console * * * * entry requirements: none * * * * exit conditions: all registers reserved * * except c * * * ************************************************* outsp: pshs a ; save a register ld a #sp ; output a space ************************************************* * output character, restore a, & return * ************************************************* outchx: bsr outchr ; display character puls a pc ; restore & exit ************************************************* * display a register as 2 hex digits * * * * entry requirements: a - byte to display * * * * exit conditions: all registers preserved * * except c * * * ************************************************* outhex: pshs a ; save the byte lsr a ; get ms byte lsr a lsr a lsr a bsr outdig ; display it ld a ,s ; get ls digit bsr outdig ; display it puls a pc ; restore a & return ************************************************* * display a hex digit * ************************************************* outdig: and a #0fH ; mask off digit add a #30H ; convert to ascii cmp a #39H ; bigger than 9? bls outchr ; go if not add a #07H ; convert to letter bra outchr ; print and exit ************************************************* * print a string to the console * * * * entry conditions: x - points to string * * last byte has bit 7 on * * * * exit conditions: x - points 1 byte past end * * a,c - changed * * * ************************************************* pstrng: ld a ,x ; get a character and a #7fH ; mask off bsr outchr ; display it tst ,x+ ; was it last? bpl pstrng ; loop if not rts ************************************************* * print cr/lf on console * * * * entry requirements: none * * * * exit conditions: all registers preserved * * except c * * * ************************************************** crlf: pshs a ; save a register ld a #cr ; output cr bsr outchr ld a #lf ; output lf & exit bra outchx ************************************************** * save program on tape * ************************************************** tsave: lbsr gethex ; get start address beq tsave2 ; go if none st x begadd ; save start lbsr gethex ; get end address bne tsave1 ; go if entered ld x begadd ; duplicate address inc b ; set address indicator tsave1: st x endadd ; save end tsave2: pshs a ; save terminator tst b ; any address entered? beq tsave3 ; go if not bsr save ; save the program tsave3: puls a ; get terminator cmp a #cr ; was it return? bne tsave4 ; go if not ld b #'9' ; output s9 record bsr outsn tsave4: rts ************************************************* * save a program in hex * * * * entry requirements: save addresses are in * * begaddr & endaddr * * * * exit conditions: all registers change * * * ************************************************* save: ld x begadd ; point at first byte save1: ld b #'1' ; begin new s1 record bsr outsn clr cksum ; init checksum ld d endadd ; calculate bytes to save pshs x sub d ,s++ tst a ; greater than 255? bne save2 ; go if yes cmp b #16 ; less than full record? blo save3 ; go if yes save2: ld b #15 ; set full record size save3: inc b ; correct record size tfr b a ; output record size add a #3 ; adjust for address,count bsr outbyt pshs x ; address to stack puls a ; output address high bsr outbyt puls a ; output address low bsr outbyt save4: ld a ,x+ ; save a data byte bsr outbyt dec b ; loop until 0 bne save4 ld a cksum ; get checksum com a ; compliment it because it was good bsr outbyt ; output it lea y -1,x ; cmp y endadd bne save1 ; loop if not rts ************************************************ * output byte as hex and add to checksum * ************************************************ outbyt: lbsr outhex ; output byte as hex add a cksum ; add to checksum st a cksum rts ************************************************ * output 'S' tape record headers * ************************************************ outsn: lbsr crlf ; begin new line ld a #'S' ; output 'S' header lbsr outchr tfr b a ; record type to a lbra outchr ************************************************ * memory examine and change * ************************************************ memec: lbsr gethex ; get address bne memec1 ; go if good ld x memptr ; use previous memec1: st x memptr ; update ram pointer lbsr crlf ; begin new line tfr x d ; display address lbsr dspdby ld a ,x+ ; get contents lbsr dspsby ; display them tfr x y ; save address in y lbsr gethex ; get change data exg d x ; save delim, get new beq memec2 ; go if no change st b -1,y ; update memory cmp b -1,y ; verify good store beq memec2 ; go if good store lbsr error ; display error memec2: tfr x d ; get delimiter in a tfr y x ; get next address in x cmp a #cr ; end of update? beq memec3 ; go if yes cmp a #':' ; backing up? bne memec1 ; loop if not lea x ,--x ; back up 2 bra memec1 ; continue memec3: rts ************************************************ * memory change * ************************************************ change: lbsr gethex ; get address bne change1 ; go if good ld x memptr ; use previous change1: st x memptr ; update ram pointer lbsr crlf ; begin new line tfr x d ; display address lbsr dspdby lea x 1,x tfr x y ; save address in y lbsr gethex ; get change data exg d x ; save delim, get new beq change2 ; go if no change st b -1,y ; update memory change2: tfr x d ; get delimiter in a tfr y x ; get next address in x cmp a #cr ; end of update? beq change3 ; go if yes cmp a #':' ; backing up? bne change1 ; loop if not lea x ,--x ; back up 2 bra change1 ; continue change3: rts **** * eeprom * Rather specialized code to burn EEPROMs * **** eeprom: lea x burnrom,pcr ; Copy ROM EEPROM code to RAM ld y #BURNRAM ; Where RAM portion will be ld b #2AH ; endburnrom-burnrom+1 prom0: ld a ,x+ ; copy code to ram st a ,y+ dec b bne prom0 * lbsr gethex ; read hex # for Source object beq promerror ; if none given this is error st x begadd lbsr gethex ; get second hex # tfr x d sub d begadd ; ensure is above start address blo promerror tfr d y ; save # bytes to copy lea y 1,y ; bump # bytes to copy lbsr gethex ; get destination address beq promerror ; none given, give up. tfr x u ld x begadd jsr BURNRAM promerror: rts * * This code is copied into RAM * it is called with * x -> source address of data to be written to eprom * u -> destination eprom address * y -> number of bytes to write * burnrom: pshs x ld x #termnl ld a #0 st a OPCR,x ; set all bits for output ld a #18H ; %11000 ; clear bits 3 + 4 to enable ROM for writes st a SETOP,x puls x burnnext: ld b ,x+ st b ,u burnpoll: ld a ,u ; keep looping pshs b ; until dest byte = source byte cmp a ,s+ bne burnpoll lea u 1,u ; bump dest. lea y -1,y ; bump down byte counter bne burnnext ld x #termnl ld a #18H ; %11000 ; reset bits 3 + 4 to disable ROM for writes st a RESETOP,x rts endburnrom: ************************************************ * go to address * ************************************************ go: ld s stkptr ; set up stack lbsr gethex ; get target address beq go1 ; go if none st x regp go1: ld x regp st x 10,s ; store in pc on stack ld a regc or a #80H ; set 'e' flag in cc st a ,s ld a rega ; set 'a' reg st a 1,s ld a regb st a 2,s ld a regd st a 3,s ld d regx st d 4,s ld d regy st d 6,s ld d regu st d 8,s intret: rti ; load registers and go *********************************************** * breakpoint (software interrupt) trap * ************************************************ brkpnt: ld x 10,s ; get program counter lea x -1,x ; decrement by 1 st x 10,s ; replace on stack ld b #0FFH ; $ff flag for single removal lbsr rembk ; remove breakpoint ************************************************ * interrupt (hardware/software) trap * ************************************************ trap: st s stkptr ; save stack pointer lbsr crlf ; begin new line bsr regdmp ; dump registers lbra getcmd ; get next command ************************************************ * register examine and change * ************************************************ regec: lbsr inchr ; get register to examine cmp a #'a' blo regupper and a #0DFH ; convert to upper regupper: lbsr crlf ; begin new line clr b ; clear offset count lea x regids,pcr ; point to register id string regec1: cmp a b,x ; check register name beq regec2 ; go if found inc b ; advance count cmp b #11 ; end of list? bls regec1 ; loop if not bra regdmp ; bad id - dump all regec2: pshs b ; save offset bsr rdump ; display the reg & contents lbsr gethex ; get new value puls b ; restore offset beq regecx ; go if no change lea y b,y ; point to reg on stack cmp b #3 ; single byte reg? tfr x d ; get new data in a,b bls regec3 ; go if single st a ,y+ ; store ms byte regec3: st b ,y ; store ls byte regecx: rts regids: str "CABDXXYYUUPP" ************************************************ * complete register dump * ************************************************ regdmp: lea x regids,pcr ; point to id string clr b ; clear offset counter rgdmp1: ld a b,x ; get reg name bsr rdump ; display it inc b ; bump to next reg cmp b #11 ; all printed? bls rgdmp1 ; loop if not ld a #'S' ; display stack id bsr dspid ld y #stkptr-12 ; y+b=>stkptr bra rdump1 ************************************************ * display register contents * ************************************************ rdump: bsr dspid ; display register id ld y stkptr ; point y at stack cmp b #3 ; single byte reg? bls rdump2 ; go if yes rdump1: ld a b,y ; display ms byte lbsr outhex inc b ; advance offset rdump2: ld a b,y ; display a byte lbra dspsby ************************************************ * display register id * ************************************************ dspid: lbsr outchr ; display reg name ld a #'=' ; display '=' lbra outchr ************************************************ * set a breakpoint * ************************************************ setbk: lbsr gethex ; get address beq dspbk ; go if none entered bsr initbp ; point y at bp table setbk1: ld d ,y ; empty slot? beq setbk2 ; go if yes bsr nextbp ; advance to next slot bne setbk1 ; loop if not end bra dspbk ; exit setbk2: st x ,y ; save address beq dspbk ; go if address = 0 ld a ,x ; get contents st a 2,y ; save in table ld a #3fH ; swi op code st a ,x ; set break ************************************************ * display all breakpoints * ************************************************ dspbk: lbsr crlf ; begin new line bsr initbp ; point y at bp table dspbk1: ld d ,y ; get address of bp beq dspbk2 ; go if inactive lbsr dspdby ; display address dspbk2: bsr nextbp ; advance pointer bne dspbk1 ; loop if not end rts ************************************************ * initialize breakpoint table pointer * ************************************************ initbp: ld y #bptabl ; point y at bp table rts ************************************************ * advance breakpoint table pointer * ************************************************ nextbp: lea y 3,y ; advance to next entry cmp y #bptend ; check for end of table rts ************************************************ * unset a breakpoint * ************************************************ unsbk: lbsr gethex ; get address ************************************************ * remove one or more breakpoints * ************************************************ rembk: bsr initbp ; point y at bp table rembk1: tst b ; remove all? beq rembk2 ; go if yes cmp x ,y ; find address? beq unset ; go if yes bra rembk3 ; loop if no rembk2: bsr unset ; unset it rembk3: bsr nextbp ; advance pointer bne rembk1 ; loop if not end rts ************************************************* * remove a breakpoint * ************************************************* unset: ld x ,y ; get address of bp beq unset1 ; go if inactive ld a 2,y ; get contents st a ,x ; replace bp clr 0,y ; mark bp inactive clr 1,y unset1: rts ************************************************* * terminal driver (acia) * ************************************************* termdr: clr dcberr,x ; no errors possible ld x dcbioa,x ; get i/o address lsr b ; read function? bcs termrd ; go if yes lsr b ; write functions? bcs termwt ; go if yes lsr b ; status function? bcs termst ; go if yes lsr b ; init function? bcc term1 ; go if not ld b #RESETRX st b CREG,x ld b #RESETTX st b CREG,x ld b #RESETMR st b CREG,x ld b #MR1 st b MREG,x ; This store flips MREG to MR2 ld b #MR2 st b MREG,x ld b #B9600 st b CSREG,x ld b #ENABLE ; enable RX and TX st b CREG,x term1: rts termrd: ld b SREG,x ; get status bit b #RXRDY beq termrd ; loop if no input ld a RHR,x ; get character rts termwt: ld b SREG,x ; get status bit b #TXRDY ; ready for output? beq termwt ; loop if not st a THR,x ; output character rts termst: ld a SREG,x ; get status and a #0FH ; $F mask off ready bits rts ************************************************ * psymon command table * ************************************************ cmdtbl: fcb 1 ; item length fcb 'M' ; memory examine/change fdb memec fcb 'O' ; memory change fdb change fcb 'E' ; EEPROM burn! fdb eeprom fcb 'G' ; goto address fdb go fcb 'L' ; program load fdb tload fcb 'S' ; program save fdb tsave fcb 'R' ; register examine/change fdb regec fcb 'B' ; set/print breakpoints fdb setbk fcb 'U' ; unset breakpoints fdb unsbk fcb 0ffH ; end sentinel ************************************************ * ram initialization data * ************************************************ ramint: str "cn" ; console dcb id fdb termdr ; console driver fdb termnl ; console I/O address fdb 0 ; error status, ext fdb condcb ; dcb chain pointer fdb condcb ; dcb pointers fdb condcb fdb condcb fdb condcb fdb trap ; interrupt vectors fdb trap fdb intret fdb trap fdb brkpnt fdb trap fdb monent ************************************************ * interrupt handlers * ************************************************ hwswi3: jmp [swi3v] ; software interrupt 3 hwswi2: jmp [swi2v] ; software interrupt 2 firq: jmp [firqv] ; fast interrupt request hwirq: jmp [irqv] ; interrupt request hwswi: jmp [swiv] ; software interrupt nmi: jmp [nmiv] ; non-maskable interrupt ************************************************ * software vectors * ************************************************ org 0FFE0H ; $ffe0 fdb dspsby ; display single byte fdb dspdby ; display double byte fdb gethex ; get hex number from console fdb pstrng ; print string to console fdb inchr ; input character fdb outchr ; output character fdb reqio ; perform I/O request fdb monent ; monitor re-entry ************************************************ * hardware vectors * ************************************************ fdb init ; reserved by motorola fdb hwswi3 ; software interrupt 3 fdb hwswi2 ; software interrupt 2 fdb firq ; fast interruupt request fdb hwirq ; interrupt request fdb hwswi ; software interrupt fdb nmi ; non-maskable interrupt fdb init ; restart end