Browse Source

Added serial test

master
Stephen 1 year ago
parent
commit
9ce64441cf
2 changed files with 69 additions and 1 deletions
  1. +1
    -1
      debug/Makefile
  2. +68
    -0
      debug/serial_test.s

+ 1
- 1
debug/Makefile View File

@ -1,4 +1,4 @@
all: timer_test.bin basic_test.bin
all: timer_test.bin basic_test.bin serial_test.bin
%.bin: %.o
m68k-elf-ld --oformat binary -Ttext=0x0 -o $@ $<


+ 68
- 0
debug/serial_test.s View File

@ -0,0 +1,68 @@
/*
Serial port is located at 15MB + 3*64KB = 0xF30000
Note that since the port is connected to 8 bits of a 16 bit bus,
The offsets for each serial register have to be doubled.
*/
.equ SPORT_LOC, 0xF30000
.global _start
.long 0x12500 /* stack ptr */
.long _start
.org 0x400
_start:
/* disable interrupts */
ORI.W #0x700, %sr
/* Setup serial */
JSR init_serial
/* Send hello world */
MOVE.L HELLO_WORLD, %a0
JSR serial_send_string
/* Echo chars forever */
ECHO_LOOP:
JSR serial_rx_char
JSR serial_send_char
JMP ECHO_LOOP
init_serial:
MOVE.B #0b00000011, (SPORT_LOC) /* Channel A mode reg 1 */
MOVE.B #0b00000111, (SPORT_LOC) /* Channel A mode reg 2 */
MOVE.B #0b10111011, (SPORT_LOC + 2) /* 9600 baud */
MOVE.B #0b01100000, (SPORT_LOC + 8) /* ACR */
MOVE.B #0b00000101, (SPORT_LOC + 4) /* CRA, enable serial A */
RTS
# char goes in d0
serial_send_char:
MOVE.B (SPORT_LOC + 2), %d1 /* SRA */
AND #0b00000100, %d1 /* TXRDY */
CMP #0, %d1
BEQ serial_send_char /* wait for TXRDY */
MOVE.B %d0, (SPORT_LOC + 6) /* send char */
RTS
# a0 - pointer to string
serial_send_string:
MOVE.B (%a0), %d0 /* load cur char */
CMP #0, %d0 /* check if NULL */
BEQ serial_send_string_done
JSR serial_send_char /* print char */
ADD.L #1, %a0 /* inc ptr */
JMP serial_send_string /* loop */
serial_send_string_done:
RTS
/* char placed in d0 */
serial_rx_char:
MOVE.B (SPORT_LOC + 2), %d1 /* SRA */
AND.B #1, %d1
CMP.B #0, %d1 /* wait for RXRDY */
BEQ serial_rx_char
MOVE.B (SPORT_LOC + 6), %d0
RTS
HELLO_WORLD:
.ascii "Hello World!"
.byte 0

Loading…
Cancel
Save