diff --git a/README.md b/README.md index efd2f20..6ea175a 100644 --- a/README.md +++ b/README.md @@ -37,6 +37,9 @@ Passarne il puntatore ad una funzione: ld bc, myVar call lcd_print ``` +### Segmentation fault +Controllare che non si stia puntando ad un registro con le parentesi: +`ld (ix), a` # C ## Deploy diff --git a/assembly/bios/driver_arduino_terminal.asm b/assembly/bios/driver_arduino_terminal.asm index 9c9a7c1..d481eb2 100644 --- a/assembly/bios/driver_arduino_terminal.asm +++ b/assembly/bios/driver_arduino_terminal.asm @@ -5,8 +5,8 @@ DATA_REG: EQU IO_0 ; variables -LCD_VAR_SPACE: EQU DRV_VAR_SPACE + 128 -incoming_string: EQU LCD_VAR_SPACE +TERM_VAR_SPACE: EQU DRV_VAR_SPACE + 128 +incoming_string: EQU TERM_VAR_SPACE ; functions @@ -29,29 +29,29 @@ Term_printc: ; Reads a single character ; @return A The read character Term_readc: - in a, (IO_0) ; reads a character - cp 0 - jp z, Term_readline ; if NULL, ignores it and waits for another character + in a, (DATA_REG) ; reads a character + add a, 0 + jp z, Term_readc ; if char is 0 (NULL), ignores it and waits for another character ret ; if not NULL, returns it in the a register ; Reads a line ; @return BC The pointer to a null-terminated read string Term_readline: - ld ix, incoming_string ; this array will contain read string - in a, (IO_0) ; reads a character + ld bc, incoming_string ; this array will contain read string + in a, (DATA_REG) ; reads a character ; if char is 0 (ascii NULL), ignore it - cp 0 + add a, 0 jp z, Term_readline ; if 0 (= ascii NULL), ignores it and waits for another character - ; if char is a newline (CR or LF), line is finished. + ; if char is a newline (CR or LF), line is finished. cp 10 ; CR jp z, term_readline_foundcr ; Found newline. Jump to term_readline_foundcr cp 13 ; LF jp z, term_readline_foundcr ; Found newline. Jump to term_readline_foundcr ; At this point the read character is a valid ascii character - ld (ix), a ; adds char to the read string - inc ix ; point to next array position + ld (bc), a ; adds char to the read string + inc bc ; point to next array position jp Term_readline term_readline_foundcr: ; called when carriage return was found (end of line) - ld (ix), 0 ; Null-terminate string - ld bc, incoming_string ; Returns read string + ld (bc), 0 ; Null-terminate string + ld bc, incoming_string ; Returns read string pointer ret diff --git a/assembly/bios/driver_hd44780.asm b/assembly/bios/driver_hd44780.asm index 0bbb5c7..9c8a700 100644 --- a/assembly/bios/driver_hd44780.asm +++ b/assembly/bios/driver_hd44780.asm @@ -1,5 +1,11 @@ ; HD44780 20x4 characters LCD display driver ; @author Daniele Verducci +; +; USAGE: +; STR: DB "Hello world!",0 <-- null terminated string +; call Lcd_init <-- inits hd44780 controller +; ld bc, STR <-- load pointer to string's first char in reg BC +; call Lcd_print <-- this function will print the string ; LCD config (IO port 0) LCD_INSTR_REG: EQU IO_0 diff --git a/assembly/bios/main.asm b/assembly/bios/main.asm index 2c57014..f47fcf0 100644 --- a/assembly/bios/main.asm +++ b/assembly/bios/main.asm @@ -2,7 +2,7 @@ jp Sysinit ; Startup vector: DO NOT MOVE! Must be the first instruction ; Pat80 BIOS v0.01 ; @author: Daniele Verducci -; +; ; MEMORY MAP ; ROM is at 0x0000 ; RAM is at 0x8000 @@ -78,30 +78,23 @@ Readline: ; System initialization Sysinit: - ;call Lcd_init - - ; position to line 2 char 3 - ;ld b, 1 - ;ld c, 1 - ;call Lcd_locate - - ; I/O TEST - - ; write characters to display ld bc, SYSINIT_GREETING - call Lcd_print ; write string to screen - _io_test_loop: - in a, (IO_0) ; legge dal terminale - cp 0 - jp z, _io_test_loop - ;sub a, 32 ; trasforma in maiuscola (ascii - 32) - out (IO_0), a ; scrive la lettera trasformata + call Print + + _io_test_loop: + call Readline + call Print + + ; call Printc + ; call Readline + ; ld a, (bc) + ; cp a, 0 + ; jp z, _io_test_loop + ; ld (APP_VAR_SPACE), bc + ; ld bc, SAYS + ; call Print + ; ld bc, (APP_VAR_SPACE) + ; call Print jp _io_test_loop - halt - - ; poll keyboard - ;_poll_keyb: - ;call Keyb_read - ;jp _poll_keyb