SBUG monitor
In this section there is a look at SBUG monitor and sample code implementation using the monitor.
Sbug pld code
Name 6809 max board,SBUGmON;
Partno 0001;
Revision Ver 1;
Date 11/10/17;
Designer mc;
Company mcoz;
Location oz;
Assembly manual;
Device g22v10;
/** Inputs **/
pin [3..11] = [a7..15] ;
pin 14 = a6;
pin 15 = a5;
pin 16 = a4;
pin 1 = eout;
pin 2 = rnw;
pin 17= naIRQ;
/** Outputs **/
pin 22 = !rd;
pin 23 = !wr;
pin 19 = !piaCS;
pin 21 = !acaCS;
pin 20 = !memCS;
pin 13 = !exCS;
pin 18 = sRTS;
/** Declarations and Intermediate Variable Definitions **/
field ioaddr= [a15..4];
acaCS_eqn = ioaddr:[E000..E0FF];
piaCS_eqn = ioaddr:[E1XX..E1FF];
sRTS_eqn = !naIRQ;
memCS_eqn = (ioaddr:[00XX..DFXX])#(ioaddr:[E2XX..F7XX])#((ioaddr:[F8XX..FFXX])& rnw & eout);
/** Logic Equations **/
rd = eout & rnw ;
wr = !rnw & eout ;
piaCS = piaCS_eqn ;
acaCS = acaCS_eqn;
memCS = memCS_eqn;
sRTS = sRTS_eqn;
Note:
ACIA address @ E000 and
PIA address @ E100
To access the comms port via SBUG you can use subroutine calls for characters In or Out. You can also do your own control of the port via following two assembly examples.
Receive a character (via ACIA Port)
The following sample code is examined in Leventhal's book, in 'Using a 6850', ch 14.5 .
Basically the aim is to:
set the control register of the comms port ($E000) ,
read the status register , and
if the IRQ (bit7) is set, save the character in Address $7060
Note this address range is used not to interfere with the Basic code.
Now because the ACIA is already reset and operating (within SBUG) we do not have to reset the control register. So then just read the status register and wait till IRQ flag is set ..then save the character data in $7060 memory location.
The listing of the code would be something like this:
0000 ACIACR: EQU $E000
0000 ACIASR: EQU $E000
0000 ACIADR: EQU $E001
7000 .ORG $7000
7000 B6 E0 00 WAITD: LDA ACIASR
7003 44 LSRA
7004 24 FA BCC WAITD
7006 B6 E0 01 LDA ACIADR
7009 B7 70 60 STA $7060
700C 3F SWI
This can be entered manually using the M command .. Here is a snapshot of the terminal screen.
As you can see the code data is entered $7000-$700C. The location $7060 is zeroed. After that the PC is set to $7000 and Go command issued to run the program.
Capital letter "A" was typed on the terminal and the program returned to SBUG.. with listing of the registers including register A which has $42..equivalent to letter "A"
This was repeated again and letter "B" was typed ..with return value of $42 in register A.
Just to make sure it all worked OK memory location $7060 was also looked at and it has the value of $42.
So there you are easy way of capturing entered value via the ACIA chip.
Transmit a character (via ACIA port)
In a similar way we can transmit a single character with the following example. For more detail see Leventhal 14.6 .
The listing of the code would go something like this:
0000 ACIACR: EQU $E000
0000 ACIASR: EQU $E000
0000 ACIADR: EQU $E001
0000 MASK: EQU 00000010B
7000 .ORG $7000
7000 86 02 LDA #MASK
7002 B5 E0 00 WAITR: BITA ACIASR
7005 27 FB BEQ WAITR
7007 B6 70 60 LDA $7060
700A B7 E0 01 STA ACIADR
700D 3F SWI
Load the above code and place $43 value in $7060 memory location (which when fetched will printout letter "C").
You can see from the above when the program loaded and run...it displays letter "C" after G .. and the value of reg A is $43 ... which is the code put out on the port. Nice ...
Links
AS80 - Online assembler/IDE (via browser). Can be used for 6809 code ..save assembly files as ... name.a09 ...i.e with a09 extension.
PLD Code
Name 6809 max board,SBUGmON;
Partno 0001;Revision Ver 1;
Date 11/10/17;
Designer mc;
Company mcoz;
Location oz;
Assembly manual;
Device g22v10;
/** Inputs **/
pin [3..11] = [a7..15] ;
pin 14 = a6;
pin 15 = a5;
pin 16 = a4;
pin 1 = eout;
pin 2 = rnw;
pin 17= naIRQ;
/** Outputs **/
pin 22 = !rd;
pin 23 = !wr;
pin 19 = !piaCS;
pin 21 = !acaCS;
pin 20 = !memCS;
pin 13 = !exCS;
pin 18 = sRTS;
/** Declarations and Intermediate Variable Definitions **/
field ioaddr= [a15..4];
acaCS_eqn = ioaddr:[E000..E0FF];
piaCS_eqn = ioaddr:[E1XX..E1FF];
sRTS_eqn = !naIRQ;
memCS_eqn = (ioaddr:[00XX..DFXX])#(ioaddr:[E2XX..F7XX])#((ioaddr:[F8XX..FFXX])& rnw & eout);
/** Logic Equations **/
rd = eout & rnw ;
wr = !rnw & eout ;
piaCS = piaCS_eqn ;
acaCS = acaCS_eqn;
memCS = memCS_eqn;
sRTS = sRTS_eqn;