diff --git a/README.md b/README.md index 97a8bc4..373b680 100644 --- a/README.md +++ b/README.md @@ -11,11 +11,11 @@ Because it's fun. Don't you like to have fun? Ogre. What does it do? ===== -Right now, not much of anything at all. It boots from a 1.44mB floppy disk, throws some text to the screen, and enters a primitive REPL (where you can do nothing but display a help message, HALT the machine, or RESET the machine). +Right now, not much of anything at all. It boots from a 1.44mB floppy disk, and enters into a BASIC interpreter, just like your favorite home computers of the 70s/80s! ![Image of Piquant v0.1](media/screenshot.png) -I think I'm going to expand the basic REPL into a BASIC interpreter, just like the classic machines of the 80s. "Operating System? Oh, you mean the BASIC ROM, right?" :) +Currently the BASIC only understands simple, 1-digit arithmetic expressions. But this will soon change; I intend to implement at least as many features as uBASIC, maybe QuickBASIC eventually. How can I run it? ===== diff --git a/asm/kernel_syms.S b/asm/kernel_syms.S index ceee2bb..8ff6b8d 100644 --- a/asm/kernel_syms.S +++ b/asm/kernel_syms.S @@ -1,2 +1,2 @@ _extern_c_main: - jmp 0x1000:0x0db4 + jmp 0x1000:0x0cc8 diff --git a/media/screenshot.png b/media/screenshot.png index 6aba617..faf2359 100644 Binary files a/media/screenshot.png and b/media/screenshot.png differ diff --git a/src/basic.c b/src/basic.c index 3839e5d..23d6391 100644 --- a/src/basic.c +++ b/src/basic.c @@ -197,7 +197,21 @@ struct basic_expr *basic_parse_expr(char *expbuf) return ret; } -void basic_run(void) +void basic_print_var(struct basic_variable *var) +{ + char decimal[2]; + decimal[0] = 0; + decimal[1] = 0; + + if ( ( (var->flags & BASIC_VARFLAG_INIT) == BASIC_VARFLAG_INIT ) && + ( (var->flags & BASIC_VARFLAG_TINT) == BASIC_VARFLAG_TINT ) ) { + decimal[0] = dtoa((int)var->value); + _cputs(&decimal); + _cputs("\n"); + } +} + +void basic_repl(void) { char keybuff[512]; char outbuff[128]; @@ -224,9 +238,6 @@ void basic_run(void) memset((void *)&outbuff, 0x00, 128); if ( _cgets((char *)&keybuff) != NULL ) { _cputs("\n"); - _cputs("Analyzing "); - _cputs((char *)&keybuff); - _cputs("\n"); expr = basic_parse_expr((char *)&keybuff); if ( expr == NULL ) { @@ -238,26 +249,6 @@ void basic_run(void) continue; } - /* Debug */ - - decimal[0] = dtoa(expr->type); - memcpy(&outbuff, "Expression type: \0", strlen("Expression type: \0")); - strncat(&outbuff, &decimal, 1); - _cputs(&outbuff); - _cputs("\n"); - - decimal[0] = dtoa(expr->lval); - memcpy(&outbuff, "Expression lval: \0", strlen("Expression lval: \0")); - strncat(&outbuff, &decimal, 1); - _cputs(&outbuff); - _cputs("\n"); - - decimal[0] = dtoa(expr->rval); - memcpy(&outbuff, "Expression rval: \0", strlen("Expression rval: \0")); - strncat(&outbuff, &decimal, 1); - _cputs(&outbuff); - _cputs("\n"); - /* Evaluate */ basic_solve_expr(expr, &result); if ( basic_errno != 0 ) { @@ -266,12 +257,7 @@ void basic_run(void) _cputs(&decimal); _cputs("\n"); } else { - if ( ( (result.flags & BASIC_VARFLAG_INIT) == BASIC_VARFLAG_INIT ) && - ( (result.flags & BASIC_VARFLAG_TINT) == BASIC_VARFLAG_TINT ) ) { - decimal[0] = dtoa((int)result.value); - _cputs(&decimal); - _cputs("\n"); - } + basic_print_var(&result); } } } diff --git a/src/basic.h b/src/basic.h index 287a8cb..6ee9e28 100644 --- a/src/basic.h +++ b/src/basic.h @@ -58,6 +58,6 @@ struct basic_variable { extern int basic_errno; -void run_basic(void); +void basic_repl(void); #endif /* _BASIC_H_ */ diff --git a/src/kernel.c b/src/kernel.c index 7e70076..9950a06 100644 --- a/src/kernel.c +++ b/src/kernel.c @@ -4,5 +4,5 @@ void main(void) { - basic_run(); + basic_repl(); }