; *********************************************************************** ; * * ; * Glass Teletype on the DSLMU Microcontroller Board * ; * * ; *********************************************************************** ; ; Author: John Zaitseff ; Date: 9th March, 2003 ; Version: 1.3 ; ; This program demonstrates one of the features of the Komodo debugger ; (front-end) and of the Komodo ARM Environment (back-end): it sends back ; every character it reads from the microcontroller serial port. This ; allows you to type in characters using the Komodo debugger's Terminal ; tab (in the Features window) and see them displayed in that window. ; ; The reason this program is called a "glass teletype" is historical, ; dating back to the 1960s or '70s. See the Jargon File for more ; information on such topics, at http://www.catb.org/~esr/jargon/html/. ; ; Please consult the DSLMU Microcontroller Board Hardware Reference Manual ; for more information on accessing the microcontroller-based serial port; ; you will find this information on your CD-ROM in the board/doc ; directory. ; ----------------------------------------------------------------------- ; Constant values used in this program .set iobase, 0x10000000 ; Base of the Microcontroller I/O space .set ser_RxD, 0x10 ; Offset to the Serial RxD port .set ser_TxD, 0x10 ; Offset to the Serial TxD port .set ser_stat, 0x14 ; Offset to the Serial Status port .set ser_Rx_rdy, 0b00000001 ; Mask to check for RxD ready bit .set ser_Tx_rdy, 0b00000010 ; Mask to check for TxD ready bit ; ----------------------------------------------------------------------- ; Assembly-language preamble .text ; Executable code follows .global _start ; "_start" is required by the linker .global main ; "main" is our main program _start: b main ; ----------------------------------------------------------------------- ; Start of the main program main: ldr r1, =iobase ; Use R1 as a base register ; Read a character from the internal serial port rb1: ldrb r0, [r1, #ser_stat] ; Read the Serial Status port tst r0, #ser_Rx_rdy ; Check if a character is available beq rb1 ; No: wait until a character comes in ldrb r0, [r1, #ser_RxD] ; Read the actual character into R0 ; Send the character to the internal serial port wb1: ldrb r2, [r1, #ser_stat] ; Check the Serial Status port again tst r2, #ser_Tx_rdy ; Can a character be sent out? beq wb1 ; No: wait until port is ready strb r0, [r1, #ser_TxD] ; Send the actual character out b rb1 ; Do this forever (or until stopped) ; ----------------------------------------------------------------------- .end