Close

Current progress

A project log for ELLO LC1

World's thinnest fully standalone DIY computer - 2mm!!

knvdKn/vD 10/04/2022 at 19:261 Comment

Finally managed to track down and fix a nasty memory leak which was happening when using string constants. Took a week, this thing alone!

Below is the list of currently supported keywords and what is left to do to full release:

Bitling BASIC interpreter

' comment until the end of the line

        
=== Data types

INT     (also INTEGER for compatibility)
REAL    (also FLOAT for compatibility)
STRING


=== operators
        
+   -   *   /
//  or  MOD     ' modulo
^               ' power
<<              ' shift left
>>              ' shift right
=               ' (in statements) attribution
==  or  =       ' (in expressions) compare for equal
<>              ' compare for not equal
<   <=   =>   >
AND   OR   XOR


=== variables

VAR  <type>  <name>  { [dimension [, dimension...] ] }  { , <name> ... }
' DIM is alias to VAR for backward compatibility

examples:
var int a, b[3,3]
var real x, z[10,10,10]
var string s[5]     ' array of five zero-terminated strings
' () are also supported in variable indexes instead of [] for backward compatibility

        
=== control structures

IF  <expression>  THEN
{ ELSE }
END IF  or  ENDIF

FOR  <variable>  =  <expression>  TO  <expression>  { STEP <expression> }
NEXT  { <variable> }

WHILE  <expression>
END WHILE  or  WEND

REPEAT
UNTIL  <expression>
        
CONTINUE            ' valid for FOR, WHILE, and REPEAT structures
EXIT                ' valid for FOR, WHILE, and REPEAT structures
        
LABEL  <label_name>
GOTO   <label_name>
        
END
' STOP is also supported and act the same way as END
        
        
=== subroutines
        
SUB     <name> {  (  <type>  {  @  }  <variable>  { ,  <type>  ...  }  )  }
FUNC    <name> {  (  <type>  {  @  }  <variable>  { ,  <type>  ...  }  )  }  {  AS  <type>  }
RETURN  {  variable  }
END SUB  or  ENDSUB
GOSUB   <sub_name(...)>      ' optional calling format for subs

        
examples:
sub test1
func average(real a, real b) as real
sub store1(int x, int y, int @arr)


=== commands
        
PRINT   { expression  { ,  expression ... } }
DATA    expression  { ,  expression ... }
READ    variable  { ,  variable ... }
REWIND                      ' return to the first DATA element
POP                         ' remove one return address from the stack
POKE    <addr, val
RESET                       ' restart the system
SLEEP                       ' put the system to sleep
INKEY   variable
GET     variable  { ,  variable ... }
INPUT   variable  { ,  variable ... }
CLS
HLOC    <column>
VLOC    <row>
PUTCH   <ascii>
DEFCH   <chrcode>  <byte1>  <byte2>  <byte3>  <byte4>  <byte5>  <byte6>  <byte7>  <byte8>
SELCHT  < 1, 2, or 3 >
CURSOR  < bit.0 blink, bit.1 enable >
SCROLL  < bit.0 up, bit.1 down, bit.2 left, bit.3 right >
TDREF                       ' refresh the text display (used after direct writes into TD RAM)
WAIT    <milliseconds>
 

=== functions

RND     (val)               ' parameter other than 0 first seeds the generator with the value
ABS     (val)
ROUND   (val)
TRUNC   (val)
FRACT   (val)
LOGN    (val)
LOGD    (val)
EXP     (val)
SQR     (val)               ' square root
CBR     (val)               ' cube root
SIN     (val)
ASIN    (val)
HSIN    (val)
COS     (val)
ACOS    (val)
HCOS    (val)
TAN     (val)
ATAN    (val)
HTAN    (val)
COTAN   (val)
FREE    ()                  ' return the largest free block in memory
TDRAM   ()                  ' return the text display RAM address
TDTDT   ()                  ' text display width
TDHGT   ()                  ' text display height
PEEK    (addr)              ' 0 and positive numbers: RAM address, negative numbers: ROM address-1
ASC     (str)               ' character (first in string) to ASCII
CHR$    (val)               ' ASCII to character (one-character string)
VAL     (str)               ' string to number
STR$    (val, d)            ' number to string; "d" specifies the number of digits after decimal point
LEN$    (str)
LEFT$   (str, count)
RIGHT$  (str, count)
MID$    (str, start, count)
INSTR   (substr, str, start)
TIMER   (value)             ' read system millisecond incremental counter; any value different than 0 first loads the counter


=== TODO:

CLEAR  [ ALL  or  var [ , ... ] ]   ' undefine variables
 
work with files
OPEN    <filename>  as  #<variable>
PRINT   #<variable> ,  .....
INPUT   #<variable> ,  .....
GET     #<variable> ,  .....
CLOSE   <variable>

IO port
UART
PWM
ADC
DAC
    

Discussions

Ed S wrote 10/13/2022 at 15:02 point

Very nice !  Hope you'll be sharing source, when you're ready.  Is this in C? It's presumably quite small, to fit.

  Are you sure? yes | no