;Gettting Data from DIP swiches of PTH and send it to PORTB in Assembly Language for Dragon12 Plus Trainer Board ;with D-Bug12 Program installed. This code is for AsmIde or MiniIde Assemblers (NOT the CodeWarrior) ;In Dragon12+ DIP switches are connected to PORTH and LEDs are to PORTB ;In Dragon12+ RAM address is from $1000-3FFF ;Use $2000-3BFF for code since $3C00-3FFF are used by the D-Bug12 for Interrupts ;We use RAM addresses starting at $1000 for scratch pad (variables) and $1FFF for Stack ;Make sure SW7=LOAD (SW7 is 2-bit red DIP Switch on bottom right side of the board and must be 00, or LOAD) #include "C:\Reg9s12.H" ;----------------------USE $1000-$2FFF for Scratch Pad and stack R1 EQU $1001 R2 EQU $1002 R3 EQU $1003 ;code section ORG $2000 ;RAM address for Code LDS #$2000 ;Stack LDAA #$FF STAA DDRB ;Make PORTB output LDAA #$0 STAA DDRH ;PTH as Input ;PTJ1 controls the LEDs connected to PORTB (For Dragon12+ ONLY) LDAA #$FF STAA DDRJ ;Make PORTJ output, (Needed by Dragon12+) LDAA #$0 STAA PTJ ;Turn off PTJ1 to allow the LEDs on PORTB to show data (Needed by Dragon12+) ; ;-------Toggling ALL LEDs connected to PORTB BACK LDAA PTH ;Get data from DIP Switches of PTH JSR DELAY ;Optional STAA PORTB ;and send it to PORTB BRA BACK ;----------DELAY DELAY PSHA ;Save Reg A on Stack LDAA #1 STAA R3 ;--10 msec delay. The D-Bug12 works at speed of 48MHz with XTAL=8MHz on Dragon12+ board ;Freq. for Instruction Clock Cycle (and Bus Cycle) is 24MHz (1/2 of 48Mhz). ;(1/24MHz) x 10 Clk x240x100=10 msec. Overheads are excluded in this calculation. L3 LDAA #100 STAA R2 L2 LDAA #240 STAA R1 L1 NOP ;1 Intruction Clk Cycle NOP ;1 NOP ;1 DEC R1 ;4 BNE L1 ;3 DEC R2 ;Total Instr.Clk=10 BNE L2 DEC R3 BNE L3 ;-------------- PULA ;Restore Reg A RTS ;-------------------