Login [Register]
Don't have an account? Register now to chat, post, use our tools, and much more.
sorry for the long post
I have been working tirelessly on an entirely new BOS-BASIC interpreter.
The syntax of the language has drastically changed.
Hopefully it doesn't change again...

Initially, this was a simple terminal interface with some small commands.
I then realised that it could be much more.
It still functions in-console, but now it can run programs as well.
Also: the [ON] key will stop a program.

Bugfix update!
Download: BOS-BASIC v2.2

Values:

0-9: base 10 number
ex: 10

0x or $: base 16 number
ex: 0x0, $3F

"string of text"

//Bytes array
{48656c6c6f20576f726c64212057454c434f4d4520544f2048454c4c2e20424f53732d48656c6c2c20746861742069732e}

commands:
//Comment

PRINT [value]: print a number to the terminal, return result in Ans
ex: PRINT(100
ex: PRINT("Hello

PUTS [value]: print a string to the terminal, does not return a value
ex: PUTS(Var
ex PUTS("Hello

CLS: clear the terminal
PAUSE: pause execution until a key is pressed
PASS: Do nothing.

getKey: get a keypress, store into Ans. same as ICE/Asm keycodes.
WaitKey: Wait until a keypress, store into Ans.

Input [Value]: Input Value characters from user input. Return string in Ans. Return void if no input or canceled.
NInput [Value]: Input Value characters from user input. Return numerical representation of string in Ans. Return void if no input or canceled.
VInput [Value]: Input Value characters from user input. Return value of the variable named from the string. Return void if no input or canceled.

DOECHO: commands will display in the terminal as they are executed
NOECHO: commands are not displayed during execution. Only gfx and print commands will display.

BBAS [program]: Run a BOS-BASIC program
EXEC [program]: Execute a BASIC program or an Asm program

BBSAVE: Save the terminal and variables.
BBLOAD: Load the terminal and variables from a previous save.

QUIT: Exit the interpreter immediately.

EDIT (Math):
mathematical, comparison, and bitwise operators:
Standard: Add, subtract, multiply, divide, parenthisis.
There is currently no order of operations. The arithmetic goes sequentially.
"+" Add
"-" Subtract
"*" Multiply
"/" Divide
"[value]()" multiply by the value in brackets
"[math]()" do math with the value in brackets
">" Greater than
"<" Less than
">=" Greater than or equal to
"<=" Less than or equal to
"=" Equal to
"!=" Not equal to
"!a" and
"!o" or
"!x" xor
"!+" bitwise and
"!-" bitwise or
"!*" bitwise xor
"!m" modulus (remainder)

If condition: If True, do stuff until the next end
Lbl Label: we can go here later
Goto Label: jump to a label
Call Label: jump to a label, and return on the next line
Return: return to caller.
Test([value]: If value is true, execute next line, else skip it.

ZFILL(numchars,"string",value: Convert value into a string containing at least numchars characters. Fills with "string". Return string.

IO functions:
IO.CLOSEALL
IO.OPEN(varname,mode,vartype->slot
IO.CLOSE(slot
IO.READ(data,len,slot
IO.WRITE(data,len,slot
IO.DELETE(varname,vartype
IO.RENAME(varname_in,varname_out,vartype
IO.GETC(slot->Char
IO.PUTC(char,slot
IO.PUTS(string,slot
IO.SEEK(amount,start,slot: If start==0, seek from beginning of file. If start==1, seek from the current position. If start==2, seek from the end of the file.
IO.PTR(slot: Get a pointer to a file's data at the current offset
IO.LEN(slot: Get the length of a file.


OS functions:
OS.RAND: store a random number into Ans
OS.WAIT(milliseconds: Pause execution for milliseconds.

GFX functions:
GFX.INIT: Set full-graphics mode
GFX.RETURN: Return to console mode
GFX.FLIP: Update the screen
GFX.Sprite(SpritePtr,Xpos,Ypos,{Xscl,Yscl,Mode}: Put a sprite to the screen at (Xpos, Ypos), with scale (Xscl,YScl). If bit 0 of Mode is set, put a transparent sprite.
ex: GFX.Sprite({0202C0E0E0C0},0,0,{404000}

Note on IO functions: they will do nothing if they are passed a string of pointer 0, or a string starting with 0.
Also, Ans is usually set to the return value of the function.

In any expression that returns a value, you may append a "->" followed by a variable. This will store Ans into that variable. This can be done any number of times.

There are two classes of type for each value type. The value, or a pointer to the value. (Kinda like C)

value types:
Void
Int
Bool
Char
Byte
Short

pointer types
Ptr: Pointer to Void. Any kind of data.
Str: Pointer to Char
FS: File slot

type functions:
TYPE.CAST.PTR(value: Get the adress of value.
TYPE.CAST.INT(value: Get the int stored at value.
TYPE.CAST.BYTE(value: Get the byte stored at value.
TYPE.CAST.SHORT(value: Get the short (2 bytes) stored at value.

TYPE.INVERT(value: Get the bitwise xor of value.
TYPE.ABS(vaue: Get the absolute value of value.

TYPE.VOID: Return the type number for void.
TYPE.INT: Return the type number for int.
TYPE.BOOL: Return the type number for bool.
TYPE.CHAR: Return the type number for char.
TYPE.BYTE: Return the type number for byte.
TYPE.SHORT: Return the type number for short.
TYPE.STR: Return the type number for str.
TYPE.PTR: Return the type number for ptr.

Quick examples of BOS-BASIC:

Code:

PUTS("Hello World!
PUTS("How are you today?
PUTS("What is your name?
//Input up to 32 characters and store into Name
Input 32->Name
PUTS("Welcome,
PUTS(Name
PUTS(":)


Code:

//This code will write ["txt",0,0,"Hello World!",0] to the appvar "hello"
"hello->Fname
IO.OPEN(Fname,"w",21->FP
IO.PUTS("txt",FP
IO.PUTC(0,FP
IO.PUTS("Hello World!",FP
IO.CLOSE(FP


What do you guys think? Smile
Added a few new things over the course of this evening...

Get 1 byte, 2 bytes, or 3 bytes from an adress
BYTE([adress]->byte
SHORT([adress]->short
WORD([adress]->word


Store 1 byte, 2 bytes, or 3 bytes to an adress
BYTEOUT(byte,[adress]
SHORTOUT(short,[adress]
WORDOUT(word,[adress]

NOTE: there is currently no catch if you try to write to an unmapped adress or flash.

compare two strings
Compare(stringA,stringB->value


A note upon the BOS-BASIC console:
There are 16 colors that can be set, however I have not included a way to easily set them yet.
If any of the bytes 0x80-0x8F are found in a string, the text color will change until the next line, or the next color switch.
Byte 0x90, if found in a string, will set the text color to whatever the next byte is, skipping it during display.

And here's a way to do it:

Code:

" Hello World!->Data
BYTEOUT(0x81,Data

And that's all folks!

I will be distributing an early closed-release version of BOS-BASIC very soon...

EDIT: all the commands are now case-insensitive!
Added another new function, and made the language 10% faster (I hope)


Code:

TEST([value],[value]
//Do if equal
//jump here otherwise

This ends up being a bit faster than an If block, because of the time it takes to compare strings.

EDIT:
I finally have fixed everything that BOS-BASIC has to offer.
A release is on it's way.
Added hex strings using the curly brackets:

Code:

{48656c6c6f20576f726c64212057454c434f4d4520544f2048454c4c2e20424f53732d48656c6c2c20746861742069732e->Str1->A->B

Etcetera.

Also added 4 graphics functions
//Set full-graphics mode
GFX.INIT
//Return to console mode
GFX.RETURN
//Update the screen
GFX.FLIP
//Put a sprite to the screen
GFX.Sprite(SpritePtr,Xpos,Ypos,{Xscl,Yscl,Mode}
ex: GFX.Sprite({0202C0E0E0C0},0,0,{404000}

A release is coming A.S.A.P.
Fixed the recursive math so that functions can also be recursive! Very Happy
Added an error code for attempting to write to flash. Now only adresses D00000 to D3FFFF can be written to.

I'm also adding a type system!
There are two classes of type for each value type. The value, or a pointer to the value. (Kinda like C)

value types:
Void
Int
Bool
Char
Byte
Short

pointer types
Ptr: Pointer to Void. Any kind of data.
Str: Pointer to Char
FS: File slot

type functions:
TYPE.CAST.PTR(value: Get the adress of value.
TYPE.CAST.INT(value: Get the int stored at value.
TYPE.CAST.BYTE(value: Get the byte stored at value.
TYPE.CAST.SHORT(value: Get the short (2 bytes) stored at value.

TYPE.INVERT(value: Get the bitwise xor of value.
TYPE.ABS(vaue: Get the absolute value of value.

TYPE.VOID: Return the type number for void.
TYPE.INT: Return the type number for int.
TYPE.BOOL: Return the type number for bool.
TYPE.CHAR: Return the type number for char.
TYPE.BYTE: Return the type number for byte.
TYPE.SHORT: Return the type number for short.
TYPE.STR: Return the type number for str.
TYPE.PTR: Return the type number for ptr.

I also added two more IO functions:
IO.PTR(slot: Get a pointer to a file's data at the current offset
IO.LEN(slot: Get the length of a file.

And some more new functions:
TOSTRING(value: Convert a number to a string
ZFILL(numchars,"string",value: Convert value into a string containing at least numchars characters. Fills with "string". Return string.
CONCAT("string A","string B": Concatenate strings A and B. return string.
Wow progress on this has exploded!
You're making the ICE that everyone wants, thanks. Functionality on this seems very strong, I'm especially excited about the different variable types and the data out functions (store data to a pointer). Keep it up! I'm really looking forward to seeing this in action for your CC23 entry.

EDIT- Sorry PT_, ICE is really good, it just hasn't received any updates in a while. Please don't take that the wrong way.
Exclamation BOS-BASIC is now in the archives! Exclamation
Very Happy Very Happy Very Happy Very Happy
Super neat! Did you write this in assembly?
What benefits does this interpreter bring vs something like Axe? (Besides being in active development)
zeldaking wrote:
Super neat! Did you write this in assembly?
What benefits does this interpreter bring vs something like Axe? (Besides being in active development)

BOS-BASIC is written in ICE, for the TI-84+CE (eZ80 family) graphing calculators.
The benefits? Typed values, type casting, built-in terminal command interface, etc.

Plus, this language is incredibly extensible internally.

Internals:
To get a function argument, I call one function, which will recursively parse the code, and return a value.
All I need to do for multi-argument functions is push that number to the stack and call the function again.
If any errors occur, I pop the arguments on the stack, and return. There is one variable internally which conains the current error code. All of the subroutines in BOS-BASIC will stop (safely) if an error code occurs.
The error code is zero if no error, otherwise a pointer to the error code string.
The only other case is error code -2, which quits the currently running program.
This system took blood, sweat and tears to get correct.

TL;DR: I can add new things blazing fast. This is the main advantage of BOS-BASIC.

Currently the main downside is the way this language handles data.
Every time BOS-BASIC sees a string, data, or prints something, it reserves space for it.
However, due to the internals of the interpreter, I could fix this easily once I find a decent algorithm.
BOS-BASIC allocates 63k of data when it starts up.
Despite the flaw in data processing, BOS-BASIC's data allocation actually loops around once the end of it's memory is reached. Since data is re-allocated every time it's parsed, this won't usually cause any issues.

I plan to change the way variable names are allocated. To keep them separate from the remainder of the data, so that they don't get overwritten when the data block overflows.
I found some bugs. A number of which break the functionality of BOS-BASIC.
Apologies.

BOS-BASIC 2.2 is on it's way, bringing many fixes, and new functionality.
EDIT: I broke BOSshell integration...
Use this in the meantime:

Code:

BBAS [program]



New I/O commands:
IO.ARC([slot]: Archive the variable slot
IO.UNARC([slot]: Unarchive the variable slot
IO.ISARC([slot]: Return True if the slot is archived, else False.

New Type commands:
TYPE([value]: Return type string of value

New graphics commands:
GFX.TEXT.CLS([color]: Set the terminal background color (Clear screen)
GFX.TEXT.SPACING([amount]: Set the text spacing
GFX.TEXT.SETPALETTE([data]: Set the entire text palette
GFX.TEXT.SETPALETTE([index],[bgfg]: Set an index of the text palette to bg,fg, where bg/fg are the upper/lower bytes of a short integer.
Ex. GFX.TEXT.SETPALETTE(0,0xFF20
GFX.TEXT.GETPALETTE: Get a pointer to the palette data
GFX.TEXT.GETPALETTE([index]: Get the [bgfg] short integer representing the bg,fg text colors of index.

Fixed commands:
TYPE.INVERT([value]
TYPE.ABS([value
BBAS [program]
EXEC [program]


TIPS:
Use GFX.INIT to disable redrawing of text in the terminal, that's all it does lol. Use GFX.RETURN to re-enable it
You can concatenate a bytes array to a string just like any other string.
The bytes 0x80 through 0x8F in a string change the current text color palette index
The bytes 0x90,0xZZ will set the current text foreground color to 0xZZ.
Despite your bugs, I'm impressed with how far you've come! I have a few comments on those commands though.

GFX.TEXT.CLS([color]: Set the text background color
That's a dumb name, I'm never going to remember that or know what it does! Make it GFX.TEXT.BGC for background color or something like that. Razz

GFX.TEXT.SPCAING([amount]
Small typo, it should be GFX.TEXT.SPACING([amount]
Just realised, I broke "If" statements.
Use "Test(value" instead for the time being.
I'm also not sure about "Return" working 100% when it's in the last two lines of a program.
and type casting doesn't seem to work as expected.

I will release another bugfix update A.S.A.P.

Also in the next update:
Var.([index]
[value]->Var.([index]

Perhaps in a future update:
Var.[subvar]
[value]->Var.[subvar]
Another update to BOS-BASIC is coming very soon...
I FINALLY FIXED BOSSHELL INTEGRATION! Very Happy
Turns out BOS-BASIC is a memory hog. Adding BOSshell makes for a horribly low memory combination. I had to basically add a loop to decrease the amount of RAM allocated to BOS-BASIC until the ti_Resize() call returns the same length as I passed it

Also I re-added chr(number) and ord(character)
chr(1
ord("A

And I added
sub(string,start,len)
instring(string,substring,start)

Speaking of BOSshell integration,
BBEXPORT program appvar
this will parse the program and store it into a appvar, and add itself to the current BOSshell file page!
I fixed BOSshell integration for running programs from the shell, but I have not had much success making BOS-BASIC export appvars for BOSshell to run in BOS-BASIC.
For the next update, the BBEXPORT command will throw an NotImplementedError.
Sorry to dissapoint.
However, upon the next minor release of BOSshell, I will release a program to de-tokenize a program and store it into an appvar, with headers of your choice.
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are GMT - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement