From 30ec4f2975b0baf17c7a79003287dd99f10f8f5a Mon Sep 17 00:00:00 2001 From: "Daniele Verducci (ZenPenguin)" Date: Sun, 22 Nov 2020 23:01:22 +0100 Subject: [PATCH] Added Arduino terminal, moved drivers config variables to each driver asm file --- assembly/bios/driver_arduino_terminal.asm | 23 +++++++++++++++++++++++ assembly/bios/driver_hd44780.asm | 8 ++++---- assembly/bios/driver_keyboard.asm | 6 ++++++ assembly/bios/main.asm | 13 ++----------- 4 files changed, 35 insertions(+), 15 deletions(-) create mode 100644 assembly/bios/driver_arduino_terminal.asm diff --git a/assembly/bios/driver_arduino_terminal.asm b/assembly/bios/driver_arduino_terminal.asm new file mode 100644 index 0000000..7a6f510 --- /dev/null +++ b/assembly/bios/driver_arduino_terminal.asm @@ -0,0 +1,23 @@ +; Arduino terminal driver +; @author Daniele Verducci + +; config (IO port 0) +DATA_REG: EQU IO_0 + +; functions + +; Sends string +; @param BC Pointer to a null-terminated string first character +Term_print: + ld a, (bc) ; bc is the pointer to passed string's first char + cp 0 ; compare A content with 0 (subtract 0 from value and set zero flag Z if result is 0) + ret z ; if prev compare is true (Z flag set), string is finished, return + out (DATA_REG),a ; output char + inc bc ; increment bc to move to next char + jp Term_print + +; Writes a single character +; @param A Value of character to print +Term_printc: + out (DATA_REG),a + ret diff --git a/assembly/bios/driver_hd44780.asm b/assembly/bios/driver_hd44780.asm index 7485c46..8b22530 100644 --- a/assembly/bios/driver_hd44780.asm +++ b/assembly/bios/driver_hd44780.asm @@ -1,9 +1,9 @@ ; HD44780 20x4 characters LCD display driver ; @author Daniele Verducci -; -; Requires declaration of following pointers: -; LCD_INSTR_REG -; LCD_DATA_REG + +; LCD config (IO port 0) +LCD_INSTR_REG: EQU IO_0 +LCD_DATA_REG: EQU IO_0 + 1 ; constants LCD_LINES_LEFT: DB 0x80, 0xA8, 0x94, 0xBC ;array defining lcd command codes for the first char of every line diff --git a/assembly/bios/driver_keyboard.asm b/assembly/bios/driver_keyboard.asm index f3c0340..2b0aac9 100644 --- a/assembly/bios/driver_keyboard.asm +++ b/assembly/bios/driver_keyboard.asm @@ -23,6 +23,12 @@ ; KEYB_A3_REG = 0000011 ; etc... +; Keyboard config (IO port 1) +KEYB_A0_REG: EQU IO_1 + %00000001 +KEYB_A1_REG: EQU IO_1 + %00000010 +KEYB_A2_REG: EQU IO_1 + %00000100 +KEYB_A3_REG: EQU IO_1 + %00001000 +KEYB_A4_REG: EQU IO_1 + %00010000 ; Reads the keyboard ; @return: a 0-terminated array of keycodes representing the pressed keys diff --git a/assembly/bios/main.asm b/assembly/bios/main.asm index c0b7622..db1b42c 100644 --- a/assembly/bios/main.asm +++ b/assembly/bios/main.asm @@ -35,16 +35,6 @@ IO_5: EQU 0xA0 IO_6: EQU 0xC0 IO_7: EQU 0xE0 -; LCD config (IO port 0) -LCD_INSTR_REG: EQU IO_0 -LCD_DATA_REG: EQU IO_0 + 1 - -; Keyboard config (IO port 1) -KEYB_A0_REG: EQU IO_1 + %00000001 -KEYB_A1_REG: EQU IO_1 + %00000010 -KEYB_A2_REG: EQU IO_1 + %00000100 -KEYB_A3_REG: EQU IO_1 + %00001000 -KEYB_A4_REG: EQU IO_1 + %00010000 ; CONSTANTS @@ -55,8 +45,9 @@ SYSINIT_GREETING: -include 'driver_hd44780.asm' +;include 'driver_hd44780.asm' ;include 'driver_keyboard.asm' +include 'driver_arduino_terminal.asm' ; System initialization Sysinit: