
M68HC16 Z SERIES
INITIALIZATION AND PROGRAMMING EXAMPLES
MOTOROLA
USER’S MANUAL
E-15
LDD
#$3030
STD
CSOR1
;set Chip Select 1, lower byte, write only
LDD
#$0303
STD
CSBAR2
;set Chip Select 2 to fire at base addr $30000
LDD
#$7830
STD
CSOR2
;set Chip Select 2, both bytes, read and write
LDD
#$3FFF
STD
CSPAR0
;set Chip Selects 0,1,2 to 16-bit ports
*****
The Main Program
*****
MAIN:
;Move data from another place in memory
;into the U1 and U3 RAM slots.....
LDAB
#$00
TBXK
;set XK to bank 0 for access to the STRING
LDX
#STRING
;load the starting address of STRING into IX
LDAB
#$03
;set ZK to bank 3
TBZK
;for access to U1 & U3 during write in XLOOP
LDZ
#0000
;clear IZ so ZK:IZ = $30000
XLOOP:
LDD
0,X
;load two bytes from $10000 into accum. D
STD
0,Z
;store accum. D into U1 and U3 RAM:
;the chip select logic takes care of us!
AIX
#2
;increment X index register to next word
AIZ
#2
;increment Z index register to next word
CMPA
#$00
BEQ
PRINT
;end xloop if the end of the string $00 is
CMPB
#$00
;detected in either accumulator A or B
BNE
XLOOP
PRINT:
;This loop reads its string from the U1 and U3
;slots and prints it at the dummy terminal....
LDAB
#$03
TBXK
;set XK:IX index to point to bank 3
LDX
#$0000
;point to the beginning of the ASCII string
JSR
SEND_STRING
;go output the ASCII string
BRA
PRINT
;loop back and print again
*****
Subroutines
*****
SEND_STRING:
;subroutine to send out the entire ASCII
;string
LDAB
0,X
;get next char in string as pointed to by IX
BEQ
STRING_DONE
;if B=00, then message is done
JSR
SEND_CH
;go send out a character
AIX
#1
;increment IX to point to the next ASCII char
BRA
SEND_STRING
;loop back
STRING_DONE:
RTS
;go back to whence we came
SEND_CH:
;subroutine to send out one character at a
time
LDAA
SCSR
;read the SCI status reg to check TDRE bit
ANDA
#01
;check only the tdre flag bit