Modified the BASIC interpreter to support comments using #

and sol whitespace support (eg tabs or spaces for indentation)
This commit is contained in:
deadvey
2026-02-26 12:26:46 +00:00
parent 7eea8d0ce1
commit 54d0665456
5 changed files with 53 additions and 22 deletions

4
MEMORY_LAYOUT.md Normal file
View File

@@ -0,0 +1,4 @@
The root directory is from byte 24000h to 26FFFh<br/>
The currently opened file's metadata is from 27000h to 2701Fh<br/>
The to be outputted string is stored from 27020h to 27FFFh<br/>
The currently opened file is from 28000h<br/>

View File

@@ -49,6 +49,6 @@ To allow for easier debugging.
# BASIC development # BASIC development
Please refer to the [MikeOS BASIC documentation](https://mikeos.sourceforge.net/handbook-appdev-basic.html)<br/> Please refer to the [MikeOS BASIC documentation](https://mikeos.sourceforge.net/handbook-appdev-basic.html)<br/>
docs on writing BASIC code. In order to create new<br/> docs on writing BASIC code. In order to create new<br/>
files, place them in the /data/ directory, not the file<br/> files, place them in the /data/ directory, note the file<br/>
names are limited to 11 characters due to FAT12 limitations<br/> names are limited to 11 characters due to FAT12 limitations<br/>
(8 for the name and 3 for the extension). (8 for the name and 3 for the extension).

View File

@@ -1,9 +1,11 @@
FOR A = 1 TO 100 # A cool fizzbuzz program
PRINT A ; PRINT "FizzBuzz!"
B = A % 3 FOR A = 1 TO 16
C = A % 5 PRINT A ; # Prints the number
IF B = 0 then PRINT "Fizz" ; B = A % 3
IF C = 0 then PRINT "Buzz" ; C = A % 5
PRINT "" IF B = 0 then PRINT "Fizz" ;
IF C = 0 then PRINT "Buzz" ;
PRINT ""
NEXT A NEXT A
END END

View File

@@ -1,17 +1,17 @@
$1 = "_________" $1 = "_________"
A = & $1 A = & $1
FOR X = 1 TO 9 FOR X = 1 TO 9
FOR Y = 1 TO 9 FOR Y = 1 TO 9
PEEK B A PEEK B A
IF B = 95 THEN PRINT "_" ; IF B = 95 THEN PRINT "_" ;
IF B = 88 THEN PRINT "X" ; IF B = 88 THEN PRINT "X" ;
IF B = 79 THEN PRINT "O" ; IF B = 79 THEN PRINT "O" ;
C = A % 3 C = A % 3
IF C = 0 THEN PRINT " " IF C = 0 THEN PRINT " "
A = A + 1 A = A + 1
NEXT Y NEXT Y
Z = X % 2 Z = X % 2
IF Z = 0 THEN PRINT "You are X" IF Z = 0 THEN PRINT "You are X"
IF Z = 1 THEN PRINT "You are O" IF Z = 1 THEN PRINT "You are O"
NEXT X NEXT X
END END

View File

@@ -3970,6 +3970,14 @@ get_token:
mov word si, [prog] mov word si, [prog]
lodsb lodsb
cmp al, 09h
je .whitespace
cmp al, 20h
je .whitespace
cmp al, '#'
je .comment
cmp al, 10 cmp al, 10
je .newline je .newline
@@ -3990,13 +3998,28 @@ get_token:
jmp get_string_token jmp get_string_token
.whitespace:
inc word [prog]
jmp get_token
.comment:
inc word [prog] ; Move past first quote (") char
mov word si, [prog]
mov di, token
.loop:
lodsb
cmp al, 0Ah
je .done
inc word [prog]
jmp .loop
.done:
inc word [prog] ; Move past final quote
jmp get_token
.newline: .newline:
inc word [prog] inc word [prog]
jmp get_token jmp get_token
get_number_token: get_number_token:
mov word si, [prog] mov word si, [prog]
mov di, token mov di, token
@@ -4273,6 +4296,8 @@ vars_loc:
work_page db 0 ; Page to print to work_page db 0 ; Page to print to
disp_page db 0 ; Page to display disp_page db 0 ; Page to display
tab_skip db " ", 0
space_skip db " ", 0
alert_cmd db "ALERT", 0 alert_cmd db "ALERT", 0
askfile_cmd db "ASKFILE", 0 askfile_cmd db "ASKFILE", 0
break_cmd db "BREAK", 0 break_cmd db "BREAK", 0