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,5 +1,7 @@
FOR A = 1 TO 100 # A cool fizzbuzz program
PRINT A ; PRINT "FizzBuzz!"
FOR A = 1 TO 16
PRINT A ; # Prints the number
B = A % 3 B = A % 3
C = A % 5 C = A % 5
IF B = 0 then PRINT "Fizz" ; IF B = 0 then PRINT "Fizz" ;

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