;C:\Users\Dave\OneDrive\Documents\_6809\asm6809-2.12-w64\asm6809.exe -B -l nanocomp_6809_v2_doc.txt nanocomp_6809_v2_doc.asm -o nanocomp_6809_v2_doc.bin ; Condition Code Register ; CC 7 6 5 4 3 2 1 0 ; E F HC I N Z O C ; ; 0 C Carry/Borrow ; 1 O Overflow ; 2 Zero ; 3 N Negative ; 4 I IRQ Mask ; 5 HC Half Carry ; 6 F FIRQ Mask ; 7 E Entire State on Stack ; ; Nanocomp 6809 Monitor V2 with MC6850 ACIA and Motorola SREC Load and Save ; ;- After power up, display - wait for command ;RST Reset Is hard reset bringing /RST line low via switch debounce circuit ;AB Abort Is Non Maskable Interupt (NMI), vector at 13F2 ;G Go Displays G to acknowledge command, enter 4 digit hex address and will run on 4th digit ;CN Continue After SWI or Abort (NMI) press CN to continue, values on the stack will be pulled including program counter ;M Memory Display M in far right display (upside down U), ; 4 digit Hex entered in left 4 digits, ; displays memory contents in right two digits ; change by typing in new digits enter in from right shift to left ; Press I to save and move to next ; No changes press I to advance or AB to abort ; Invalid address or hex bytes will return to monitor - prompt ;S Save SAVE range to serial port in V2+ in S19/SREC format 7DCB ; Display S to prompt for Start address ; Display F to prompt for for finish address ; Displays F when finished ;L Load LOAD from serial port in V2+ 7DC4 ; When finished Display F Finished or E for Hex error or C for Checksum error ;AB Abort Return to monitor start via NMI if not changed NMI vector ;R Register Display register values via the pushed values on the stack (automatic after SWI) ; Right digits show ; C Condition Code register ; A ACC A ; b ACC B ; d direct page register ; H X Register ; Y Y Register ; U User Stack Pointer ; P Program Counter ; S Hardware Stack Pointer ; Press I between values ; After SP displayed returns to Monitor, AB to Abort to monitor ; Example programs ; 7800 Hex to decimal converter ; G 7800 Type L then decimal No then I to display Hex, press I to start again ; Press P for hex to decimal then I ; 7A00 Calculate offsets ; G 7A00 Displays S enter start address then I ; Displays d then enter destination then twos complement offset displayed ; If outside range displays --, press I for next ; 7A80 Mastermind ; I displayed after thinking of 4 digit number 4 digits 0-7 ; Press I enter guess 2 digits display Correct digits and correct numbers in wrong places (Bulls and Cows) ; Press I for next number, after 4 bulls press I and displays number of tries ; 7940 Duckshoot ; G 7940 Store 0020 at memory 0000 and 0001 (1000 and 1001 for 6809) ; Press number 1-6 for duck until none are left. ; Common Subroutines ; 7C7B DISPRESH Displays 6 digits from 13FA (left) to 13FF (right) ; Bit Segments, note that A-G seqments in 1981 design are different from modern LED displays (E&F swapped) ; b3 A ; ------- ; b5 E| | b1 B ; | b0 G| ; ------- ; b6 F| | b2 C ; | | ; ------- ; b4 D ; 7 Segment display values (see segxx EQU definitions below) ; 0 1 2 3 4 5 6 7 8 9 A B C D E F - G M P S U X Y ; 7E 06 5B 1F 27 3D 7D 0E 7F 3F 6F 75 78 57 79 69 01 7C 6E 6B 3D 76 67 37 ; 7C20 GETKEY Scans for key and refreshes display until key pressed. Then waits to be released and returns key in A ; Key Codes in Hex (see keyxx EQU definitions below) ; 0 1 2 3 4 5 6 7 8 9 A B C D E F L SP CN G M R I ; 22 24 02 12 14 00 10 04 01 11 03 13 23 33 21 20 05 15 25 35 31 30 32 ; 7CE7 HEXCON converts key code in A into Hex equivelent for the key and returns in A. If non Hex command key entered returns to monitor ; 7CE4 KEYHEX Combines GETKEY and HEXCON ; 7CB5 BADDR Build 4 digit hex address from keyboard refreshing display and return address in X index register ; 7CFF L7SEG converts left hex digit of A into 7 segment code for display and returns in A ; 7D03 R7SEG converts right hex digit of A into 7 segment code for display and returns in A ; 7D15 SVNHEX Converts 7 segment hex code in A to hex value returned in A, default to monitor if code not hex ; 7CCC HEXIN Use KEYHEX to accept two hex key entries and combines two hex digits in one byte in A ; 6809 Memory Map ;EPROM Monitor 7FFF ; 7C00 ; User 7BFF ; 7000 ;Serial Port ; Control W 5000 ; Status R 5000 ; Data R/W 5001 ; Note the PIA RS0 and RS1 Pins are reversed and connected to RS0=A1 and RS1=A0 ; Register order does not match the 6821 datasheet ;PIA Out/Dir A 4000 ; Out/Dir B 4001 ; Control A 4002 ; Control B 4003 ;RAM 13FF ; 1000 ;Monitor RAM ; Display buffer right 13FF ; left 13FA ; Working Storage 13E0 ; Monitor stack 13D0 (MONSTACK) ; 13B0 ; User Stack 1390 (USERSTACK) ; Interupt vector Address ; SWI3 13E5/6 ; SWI2 13E7/8 ; FIRQ 13E9/AB ; NMI 13F2/3 ; IRQ 13F4/5 ; Reset Vector FFFE 7D ; FFFF 89 PORTA EQU $4000 PORTB EQU $4001 CTRLA EQU $4002 CTRLB EQU $4003 ;Keys Hex 0 1 2 3 4 5 6 7 8 9 A B C D E F L S CN G M R I ;Current 22 24 02 12 14 00 10 04 01 11 03 13 23 33 21 20 05 15 25 35 31 30 32 keyCN EQU $25 keyG EQU $35 keyI EQU $32 keyL EQU $05 keyM EQU $31 keyP EQU $15 ; P Punch replaced with S Save keyS EQU $15 keyR EQU $30 key0 EQU $22 key1 EQU $24 key2 EQU $02 key3 EQU $12 key4 EQU $14 key5 EQU $00 key6 EQU $10 key7 EQU $04 key8 EQU $01 key9 EQU $11 keyA EQU $03 keyB EQU $13 keyC EQU $23 keyD EQU $33 keyE EQU $21 keyF EQU $20 seg0 EQU $7E seg1 EQU $06 seg2 EQU $5B seg3 EQU $1F seg4 EQU $27 seg5 EQU $3D seg6 EQU $7D seg7 EQU $0E seg8 EQU $7F seg9 EQU $3F segA EQU $6F segB EQU $75 segC EQU $78 segD EQU $57 segE EQU $79 segF EQU $69 segG EQU $7C segM EQU $6E ; (upside down U) segP EQU $6B segS EQU $3D ; (Same as 5) segU EQU $76 segX EQU $67 segY EQU $37 segDash EQU $01 asciiNull EQU $00 asciiLF EQU $0A asciiCR EQU $0D ascii0 EQU $30 ascii1 EQU $31 ascii3 EQU $33 ascii9 EQU $39 asciiA EQU $41 asciiC EQU $43 asciiF EQU $46 asciiS EQU $53 ; Used by HEXTODEC for conversion between decimal and Hex DEC10K EQU $2710 DEC1K EQU $03E8 ; Starting values for Monitor/System and User Stack pointers MONSTACK EQU $13D0 USERSTACK EQU $1390 ; Direct page values used to initialise Direct Page Register dpRam EQU $13 dpPIA EQU $40 ;REGDISPCHAR2 EQU $7DEF ; Label for where Register Display characters go from 8 bit to 16 bit ;chksum EQU $13ED ; ?? Used for Send and Receive Checksum calculation allzeros EQU $0000 ; Used to initialise some registers with $0000 ; Serial Port Constants SERIALCTRL EQU $5000 ; Use DP $50 $5000 SERIALSTATUS EQU $5000 ; Use DP $50 $5000 SERIALDATA EQU $5001 ; Use DP $50 $5001 CTRLRESET EQU %00000011 ; CR1, CR0 1,1 for Master Reset CTRLDIVIDE16 EQU %00000001 ; CR1, CR0 0,1 for divide by 16 CTRLDIVIDE64 EQU %00000010 ; CR1, CR0 1,0 for divide by 64 CTRLWORD8N1S EQU %00010100 ; CR4, CR3, CR2 1, 0, 1 for 8 Bits, 1 Stop No Parity CTRLRTSLOW EQU %00000000 ; CR6, CR5, 0,0 RTS low IRQ disabled, requests data CTRLRTSHIGH EQU %01000000 ; CR6, CR5, 1,0 RTS high IRQ disabled, prevents receiving data CTRLIRQENABLED EQU %10000000 ; CR7, 1 IRQ enabled STATUSRDRF EQU %00000001 ; Receive Data Register Full Bit 0 STATUSTDRE EQU %00000010 ; Transmit Data Register Empty Bit 1 STATUSDCD EQU %00000100 ; Data Carrier Detect Bit 2 STATUSCTS EQU %00001000 ; Clear To Send Bit 3 STATUSFE EQU %00010000 ; Framing Error Bit 4 STATUSOVRN EQU %00100000 ; Receiver Overrun Bit 5 STATUSPE EQU %01000000 ; Parity Error Bit 6 STATUSIRQREQ EQU %10000000 ; Interupt Request /IRQ Bit 7 EOS EQU $00 ; end of string ;chksum EQU $13ED ORG $13D0 usrsp RMB 1 ; ORG $13E3 ;org needs to be 13E4 to have separate chksum, when key input uses chksum messes up debug of save and load bytecount RMB 1 ; new variable for srec byte count as using tmp2 got used by key input chksum RMB 1 ; SWI3VEC RMB 2 ; SWI2VEC RMB 2 ; FIRQVEC RMB 2 ; count RMB 1 ; tmp2 RMB 1 ; tmp3 RMB 1 ; ptr RMB 2 ; addr RMB 2 ; NMIVEC RMB 2 ; IRQVEC RMB 2 ; tmpX RMB 2 ; Used by Load to parse target address for X STACKSTART RMB 2 ; ; 4 5 6 7 8 9 (Port B) ; 13FA 13FB 13FC 13FD 13FE 13FF dbuf RMB 6 ; Display Buffer LSB is Left, MSB is Right ORG $7800 ; 7800 Hex to decimal converter ; G 7800 Type L then decimal No then I to display Hex, press I to start again ; Press P for hex to decimal then I HEXTODEC lds #USERSTACK HEXTODEC1 jsr CLEARDISP lda #dpRam tfr a,dp clra clrb sta <$07 std <$08 std <$0A std <$0C std <$0E HEXTODEC2 jsr GETKEY ; P pressed for Hex to Decimal cmpa #keyP lbeq HEXTODEC141 ; L pressed for Decimal to Hex cmpa #keyL bne HEXTODEC2 ldx #$1309 HEXTODEC3 jsr GETKEY ; I pressed to display Hex cmpa #keyI beq HEXTODEC4 leax $01,x jsr HEXCON cmpa #$09 bhi HEXTODEC1 sta ,x jsr R7SEG sta $F0,x bra HEXTODEC3 HEXTODEC4 lda ,x sta <$09 bsr HEXTODEC13 HEXTODEC5 ldb #$0A cmpa #$00 beq HEXTODEC6 addb <$09 stb <$09 deca bra HEXTODEC5 HEXTODEC6 bsr HEXTODEC13 HEXTODEC7 cmpa #$00 beq HEXTODEC8 pshs a ldd #$64 addd <$08 std <$08 puls a deca bra HEXTODEC7 HEXTODEC8 bsr HEXTODEC13 HEXTODEC9 cmpa #$00 beq HEXTODEC10 pshs a ldd #DEC1K addd <$08 std <$08 puls a deca bra HEXTODEC9 HEXTODEC10 bsr HEXTODEC13 HEXTODEC11 cmpa #$00 beq HEXTODEC12 pshs a ldd #DEC10K addd <$08 std <$08 puls a deca bra HEXTODEC11 HEXTODEC12 jsr CLEARDISP lda <$07 jsr R7SEG sta FDB SWI2INTR ; SWI2 $7F, $D0 ; <$7FF4> FDB FIRQINTR ; FIRQ $7F, $DA ; <$7FF6> FDB INTRQ ; IRQ $7F, $DF ; <$7FF8> SWINTR FDB REGDISPSWI ; SWI $7D, $F4 ; <$7FFA> FDB NMINTR ; NMI $7F, $E4 ; <$7FFC> RESETBOOT FDB RESET ; RESET $7D, $89 ; <$7FFE>