*************************************************
*						*
*     Program:	Port A Switch Inputs		*
*						*
*     Name   :	paievbu.src			*
*						*
*     Date   :	28 Mar 2001			*
*						*
*     By     :	Steven J. Dombrowski		*
*						*
*						*
*     This program reads all 4 switches on	*
* the M68HC11EVBU and continuously updates all	*
* readings.					*
*						*
*     To execute this program type G 0100 <CR>	*
*						*
*************************************************
*			      *
*  program origin and equates *
*			      *
*******************************
	 org $0100
outcrlf  equ $ffc4
outstrg0 equ $ffca
outa	 equ $ffb8
porta    equ $1000
pactl    equ $1026
swmsg1	 equ $01D0
	ldx #swmsg1
	ldy #table1
	ldab #$29
loop1	ldaa 0,y
	staa 0,x
	inx
	iny
	decb
	cmpb #0
	bne loop1
************************
*		       *
* Introductory message *
*		       *
************************
	ldaa #$1a		* clear screen
	jsr outa
************************
*		       *
* Main part of program *
*		       *
************************
	ldaa #$00		*set bit 7 of
	staa pactl		*porta as input
start	ldaa porta
	anda #1
	jsr  rh 	
	staa swmsg1+13	* output to screen
	ldaa porta
	anda #2
	lsra
	jsr  rh 	
	staa swmsg1+21	* output to screen
	ldaa porta
	anda #4
	lsra
	lsra
	jsr rh
	staa swmsg1+29	* output to screen
	ldaa porta
	anda #$80
	lsra
	lsra
	lsra
	lsra
	lsra
	lsra
	lsra
	jsr  rh 	
	staa swmsg1+37	* output to screen
	ldaa #20	* indent 20 spaces
	jsr spaces
	ldx #swmsg1	* display sw1-4
	jsr outstrg0
	jsr bkspc	* update switch readings
	jmp start	* continue program
***********************************
*				  *
*  Subroutine to backspace cursor *
*				  *
***********************************
bkspc	ldy #$40
bkspc1 ldaa #$08
	jsr outa
	dey
	cpy #0
	bne bkspc1
	rts
*******************************
*			      *
* Subroutine to convert right *
* half of binary byte in acca *
* to an ascii character       *
*			      *
*******************************
rh	asla
	asla
	asla
	asla
	lsra
	lsra
	lsra
	lsra
	anda #$0f
	adda #$30
	cmpa #$39
	ble out1
	adda #$07
out1	rts
*******************************************
*					  *
* Subroutine to skip spaces on the screen *
*					  *
*******************************************
spaces	  tab
	  ldaa #$20
spaces2   jsr outa
	  decb
	  cmpb #0
	  bne spaces2
	  rts
******************************************************
*						     *
*		   Screen messages		     *
*						     *
******************************************************
table1 fcc 'reading PA0:    PA1:    PA2:    PA7:    '
       fcb 4
