Hardware Reference
In-Depth Information
The C language version of the function is as follows:
char getcSCI0 (void)
{
while(!(SCI0SR1 & RDRF));
return (SCI0DRL);
}
Example 9.6
Write a subroutine that outputs a NULL-terminated string pointed to by index register X
to the SCI0 using the polling method.
Solution: The subroutine will call putcSCI0() repeatedly until all characters of the string have
been outputted.
putsSCI0
ldaa
1,x 1
; get a character and move the pointer
beq
done
; is this the end of the string?
jsr
putcSCI0
bra
putsSCI0
done rts
The C language version of the program is as follows:
void
putsSCI0 (char *cx)
{
while (!(*cx)) {
putcSCI0(*cx);
cx 11 ;
}
}
Example 9.7
Write a subroutine that inputs a string from the SCI0 module. The string is terminated by
the carriage return character and must be stored in a buffer pointed to by index register X. This
subroutine must allow the user to backspace to erase errors.
Solution: The subroutine will call getsSCI0() repeatedly until the carriage return character is
inputted.
getsSCI0
jsr
getch
cmpa
#CR
; is it a carriage return?
beq
qi
staa
0,x
; save the character and increment the pointer
jsr
putch
; echo it back to SCI0
cmpa
#BS
; is it a backspace character?
 
Search WWH ::




Custom Search