;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 4000 PORTA EQU $4000 4001 PORTB EQU $4001 4002 CTRLA EQU $4002 4003 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 0025 keyCN EQU $25 0035 keyG EQU $35 0032 keyI EQU $32 0005 keyL EQU $05 0031 keyM EQU $31 0015 keyP EQU $15 ; P Punch replaced with S Save 0015 keyS EQU $15 0030 keyR EQU $30 0022 key0 EQU $22 0024 key1 EQU $24 0002 key2 EQU $02 0012 key3 EQU $12 0014 key4 EQU $14 0000 key5 EQU $00 0010 key6 EQU $10 0004 key7 EQU $04 0001 key8 EQU $01 0011 key9 EQU $11 0003 keyA EQU $03 0013 keyB EQU $13 0023 keyC EQU $23 0033 keyD EQU $33 0021 keyE EQU $21 0020 keyF EQU $20 007E seg0 EQU $7E 0006 seg1 EQU $06 005B seg2 EQU $5B 001F seg3 EQU $1F 0027 seg4 EQU $27 003D seg5 EQU $3D 007D seg6 EQU $7D 000E seg7 EQU $0E 007F seg8 EQU $7F 003F seg9 EQU $3F 006F segA EQU $6F 0075 segB EQU $75 0078 segC EQU $78 0057 segD EQU $57 0079 segE EQU $79 0069 segF EQU $69 007C segG EQU $7C 006E segM EQU $6E ; (upside down U) 006B segP EQU $6B 003D segS EQU $3D ; (Same as 5) 0076 segU EQU $76 0067 segX EQU $67 0037 segY EQU $37 0001 segDash EQU $01 0000 asciiNull EQU $00 000A asciiLF EQU $0A 000D asciiCR EQU $0D 0030 ascii0 EQU $30 0031 ascii1 EQU $31 0033 ascii3 EQU $33 0039 ascii9 EQU $39 0041 asciiA EQU $41 0043 asciiC EQU $43 0046 asciiF EQU $46 0053 asciiS EQU $53 ; Used by HEXTODEC for conversion between decimal and Hex 2710 DEC10K EQU $2710 03E8 DEC1K EQU $03E8 ; Starting values for Monitor/System and User Stack pointers 13D0 MONSTACK EQU $13D0 1390 USERSTACK EQU $1390 ; Direct page values used to initialise Direct Page Register 0013 dpRam EQU $13 0040 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 0000 allzeros EQU $0000 ; Used to initialise some registers with $0000 ; Serial Port Constants 5000 SERIALCTRL EQU $5000 ; Use DP $50 $5000 5000 SERIALSTATUS EQU $5000 ; Use DP $50 $5000 5001 SERIALDATA EQU $5001 ; Use DP $50 $5001 0003 CTRLRESET EQU %00000011 ; CR1, CR0 1,1 for Master Reset 0001 CTRLDIVIDE16 EQU %00000001 ; CR1, CR0 0,1 for divide by 16 0002 CTRLDIVIDE64 EQU %00000010 ; CR1, CR0 1,0 for divide by 64 0014 CTRLWORD8N1S EQU %00010100 ; CR4, CR3, CR2 1, 0, 1 for 8 Bits, 1 Stop No Parity 0000 CTRLRTSLOW EQU %00000000 ; CR6, CR5, 0,0 RTS low IRQ disabled, requests data 0040 CTRLRTSHIGH EQU %01000000 ; CR6, CR5, 1,0 RTS high IRQ disabled, prevents receiving data 0080 CTRLIRQENABLED EQU %10000000 ; CR7, 1 IRQ enabled 0001 STATUSRDRF EQU %00000001 ; Receive Data Register Full Bit 0 0002 STATUSTDRE EQU %00000010 ; Transmit Data Register Empty Bit 1 0004 STATUSDCD EQU %00000100 ; Data Carrier Detect Bit 2 0008 STATUSCTS EQU %00001000 ; Clear To Send Bit 3 0010 STATUSFE EQU %00010000 ; Framing Error Bit 4 0020 STATUSOVRN EQU %00100000 ; Receiver Overrun Bit 5 0040 STATUSPE EQU %01000000 ; Parity Error Bit 6 0080 STATUSIRQREQ EQU %10000000 ; Interupt Request /IRQ Bit 7 0000 EOS EQU $00 ; end of string ;chksum EQU $13ED 13D0 ORG $13D0 13D0 usrsp RMB 1 ; 13E3 ORG $13E3 ;org needs to be 13E4 to have separate chksum, when key input uses chksum messes up debug of save and load 13E3 bytecount RMB 1 ; new variable for srec byte count as using tmp2 got used by key input 13E4 chksum RMB 1 ; 13E5 SWI3VEC RMB 2 ; 13E7 SWI2VEC RMB 2 ; 13E9 FIRQVEC RMB 2 ; 13EB count RMB 1 ; 13EC tmp2 RMB 1 ; 13ED tmp3 RMB 1 ; 13EE ptr RMB 2 ; 13F0 addr RMB 2 ; 13F2 NMIVEC RMB 2 ; 13F4 IRQVEC RMB 2 ; 13F6 tmpX RMB 2 ; Used by Load to parse target address for X 13F8 STACKSTART RMB 2 ; ; 4 5 6 7 8 9 (Port B) ; 13FA 13FB 13FC 13FD 13FE 13FF 13FA dbuf RMB 6 ; Display Buffer LSB is Left, MSB is Right 7800 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 7800 10CE1390 HEXTODEC lds #USERSTACK 7804 BD7DDC HEXTODEC1 jsr CLEARDISP 7807 8613 lda #dpRam 7809 1F8B tfr a,dp 780B 4F clra 780C 5F clrb 780D 9707 sta <$07 780F DD08 std <$08 7811 DD0A std <$0A 7813 DD0C std <$0C 7815 DD0E std <$0E 7817 BD7C20 HEXTODEC2 jsr GETKEY ; P pressed for Hex to Decimal 781A 8115 cmpa #keyP 781C 102700AB lbeq HEXTODEC141 ; L pressed for Decimal to Hex 7820 8105 cmpa #keyL 7822 26F3 bne HEXTODEC2 7824 8E1309 ldx #$1309 7827 BD7C20 HEXTODEC3 jsr GETKEY ; I pressed to display Hex 782A 8132 cmpa #keyI 782C 2714 beq HEXTODEC4 782E 3001 leax $01,x 7830 BD7CE7 jsr HEXCON 7833 8109 cmpa #$09 7835 22CD bhi HEXTODEC1 7837 A784 sta ,x 7839 BD7D03 jsr R7SEG 783C A78900F0 sta $F0,x 7840 20E5 bra HEXTODEC3 7842 A684 HEXTODEC4 lda ,x 7844 9709 sta <$09 7846 8D75 bsr HEXTODEC13 7848 C60A HEXTODEC5 ldb #$0A 784A 8100 cmpa #$00 784C 2707 beq HEXTODEC6 784E DB09 addb <$09 7850 D709 stb <$09 7852 4A deca 7853 20F3 bra HEXTODEC5 7855 8D66 HEXTODEC6 bsr HEXTODEC13 7857 8100 HEXTODEC7 cmpa #$00 7859 270E beq HEXTODEC8 785B 3402 pshs a 785D CC0064 ldd #$64 7860 D308 addd <$08 7862 DD08 std <$08 7864 3502 puls a 7866 4A deca 7867 20EE bra HEXTODEC7 7869 8D52 HEXTODEC8 bsr HEXTODEC13 786B 8100 HEXTODEC9 cmpa #$00 786D 270E beq HEXTODEC10 786F 3402 pshs a 7871 CC03E8 ldd #DEC1K 7874 D308 addd <$08 7876 DD08 std <$08 7878 3502 puls a 787A 4A deca 787B 20EE bra HEXTODEC9 787D 8D3E HEXTODEC10 bsr HEXTODEC13 787F 8100 HEXTODEC11 cmpa #$00 7881 270E beq HEXTODEC12 7883 3402 pshs a 7885 CC2710 ldd #DEC10K 7888 D308 addd <$08 788A DD08 std <$08 788C 3502 puls a 788E 4A deca 788F 20EE bra HEXTODEC11 7891 BD7DDC HEXTODEC12 jsr CLEARDISP 7894 9607 lda <$07 7896 BD7D03 jsr R7SEG 7899 97FA sta 7FF4 7FD0 FDB SWI2INTR ; SWI2 $7F, $D0 ; <$7FF4> 7FF6 7FDA FDB FIRQINTR ; FIRQ $7F, $DA ; <$7FF6> 7FF8 7FDF FDB INTRQ ; IRQ $7F, $DF ; <$7FF8> 7FFA 7DF4 SWINTR FDB REGDISPSWI ; SWI $7D, $F4 ; <$7FFA> 7FFC 7FE4 FDB NMINTR ; NMI $7F, $E4 ; <$7FFC> 7FFE 7D89 RESETBOOT FDB RESET ; RESET $7D, $89 ; <$7FFE>