From aabea9d9f5d956f907e8f35e86c932664af176f8 Mon Sep 17 00:00:00 2001 From: Tibo Date: Tue, 5 Oct 2021 16:02:17 +0200 Subject: [PATCH] add UART init code and send every char to UART --- messages.asm | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/messages.asm b/messages.asm index 5b863c2..0449d8c 100644 --- a/messages.asm +++ b/messages.asm @@ -11,6 +11,15 @@ PIT_CH2_DATA_PORT equ 0x42 ; PIT channel 2 data port ;; see http://www.ctyme.com/intr/int-10.htm for interrupts start: + +mov sp, 0x2000 ; initialise stack pointer + +;; initialise serial port +mov ah, 0x0 ; initialise UART +mov al, 0b111_00_0_11 ; baud 9600, no parity, 1 stop bit, 8 data bits +mov dx, 0x0 ; COM1 +int 0x14 + ;; Use color mode mov ax, VIDEO_MODE int 10h @@ -31,12 +40,13 @@ mov dh, HEIGHT ; row (bottommost row) mov dl, 0x00 ; col (leftmost col) int 0x10 -mov sp, 0x2000 ; initialise stack pointer - .loop: - mov ah, 0x00 ; Read a character + ;; read a character, ASCII in al + mov ah, 0x00 ; Read character int 0x16 + call UART_send_char + cmp al, 0x08 ; backspace je change_color_mode @@ -52,6 +62,18 @@ mov sp, 0x2000 ; initialise stack pointer call newline jmp .loop +;; Prints a character in al to the serial port +;; +;; CLOBBERS +;; - ax +;; - dx +UART_send_char: + mov ah, 0x01 ; transmit character + mov dx, 0x0 ; COM1 + int 0x14 + + ret + ;; Update the color_mode variable with a byte from the keyboard ;; ;; CLOBBERS