nedoPC.org

Electronics hobbyists community established in 2002
Atom Feed | View unanswered posts | View active topics It is currently 19 Apr 2024 05:27



Reply to topic  [ 9 posts ] 
Можно портануть к нам в ПЗУ новый маленький Бейсик! 
Author Message
Admin
User avatar

Joined: 08 Jan 2003 23:22
Posts: 22542
Location: Silicon Valley
Reply with quote
Вот чего нашёл :mrgreen:
https://hackaday.io/project/194248-one-kilobyte-tiny-basic-for-the-8080

Quote:
This project is a birthday present for the Intel 8080. I wanted to investigate writing a BASIC interpreter in assembly language and decided to fit a BASIC interpreter into 1K. It’s not the only sub-1K BASIC that I’ve come across, but as far as I can see it is the most feature rich and also makes efficient use of memory for storing programs. It is probably fast compared to other Tiny BASICs because programs are tokenised. The set of features is similar to Palo Alto Tiny BASIC (PATB) but the syntax is slightly different in a few places. It supports GOSUB/RETURN, FOR/NEXT loops, and functions RND, ABS and USR. It has a single array variable @. Since it fits in 1K, it is about 60% of the size of the smallest PATB implementation. It is written in 8080 assembly language, and developed on a bespoke 8080 emulator. It hasn’t been run on a real 8080 yet. If anybody has a working 8080 system I’d be really interested in seeing it running.

Репа с сырцами (GPLv3): https://github.com/WillStevens/basic1K

_________________
:dj: https://mastodon.social/@Shaos


11 Mar 2024 20:40
Profile WWW
Admin
User avatar

Joined: 08 Jan 2003 23:22
Posts: 22542
Location: Silicon Valley
Reply with quote
Бейсик целочисленный (16-битные переменные A...Z) плюс имеется один массив @, который способен занять всю доступную память:
Code:
10 FOR I=1 TO 10
20 LET @(I)=I*255
30 NEXT
40 FOR I=1 TO 10
50 PRINT I," : ",@(I)
60 NEXT

Сама программа сидит в начале адресного пространства (там ожидается ПЗУ 1К) и использует RST для пущей компактности (там даже короткие джампы в пределах 256-байтовой страницы делаются через RST) - далее она ожидает как минимум 1К ОЗУ (как я понял)

Quote:
The following statements are supported:

PRINT <expression>
LET <var> = <expression>
IF <expression> <statement>
GOTO <expression>
GOSUB <expression>
RETURN
INPUT <var>
FOR <var> = <expression> TO <expression> [STEP <expression>]
NEXT
END

and additionally, these commands can be issued if not prefixed by a line number:

LIST
RUN
NEW

<var> is a letter A-Z. A single array called @ is supported, its elements are @( <expression> ). The array uses all remaining memory after the program - it will eventually collide with the stack. Two system variables are available in ^ (address of start of array) and _ (current state of Random Number Generator). ^ can be used to work out how much free memory there is by subtracting it from the highest RAM address, and then subtracting 8+however much stack the program is likely to use (a few tens of bytes typically).

Signed 16-bit integer arithmetic is supported, with no overflow detection. Operators are + - * /.

Comparison operators are = <> < > <= >=. The result of a comparison is 1 if true, 0 if false.

Three functions taking a single parameter are available: ABS, USR and RND. The USR(x) function calls the address x. The RND(x) function returns a random number between 0 and x-1.

Program editing features are minimal - lines can be deleted by typing the line number by itself. Unlike in most BASIC implementations, overwriting a line is not permitted, a line must be deleted and then re-entered.

_________________
:dj: https://mastodon.social/@Shaos


11 Mar 2024 20:48
Profile WWW
Admin
User avatar

Joined: 08 Jan 2003 23:22
Posts: 22542
Location: Silicon Valley
Reply with quote
Вообще RST там через макросы заведены - можно наверное и в наш расширенный монитор этот бейсик попробовать затолкать (заменив RST-ы на CALL-ы с раздуванием размера кода за пределы 1КБ) ну и надо будет переписать PutChar и GetLine на РК-шные аналоги. Ещё надо будет деление переписать - оно там щас через вычитание сделано. Ну и функций/директив добавить - типа PEEK/POKE, POINT, MOVETO/LINETO, SAVE/LOAD и т.д.

_________________
:dj: https://mastodon.social/@Shaos


11 Mar 2024 21:48
Profile WWW
Admin
User avatar

Joined: 08 Jan 2003 23:22
Posts: 22542
Location: Silicon Valley
Reply with quote
Shaos wrote:
... далее она ожидает как минимум 1К ОЗУ (как я понял)
кстати я спросил у автора сколько максимум ОЗУ он могёт и автор сказал, что вплоть до 63КБ :mrgreen:
Quote:
The RAM size has been set to 1K during development only because I have a lot of old 2K RAM chips and it is nice to be able to have the BASIC interpreter and any of the example programs all fit under 2K.

RAM_BASE and RAM_TOP can be set to anything up to 63K. Maximum BASIC program size is RAM size minus 64 bytes for variables, minus 8 bytes for a small buffer used by the INPUT statement, minus stack space used by the interpreter and by FOR/NEXT and GOSUB/RETURN, minus a few bytes needed to be able to run direct mode commands without colliding with the stack. So on 1K RAM system this is about 900 bytes and with 63K about 62.9K.

_________________
:dj: https://mastodon.social/@Shaos


12 Mar 2024 21:40
Profile WWW
Senior
User avatar

Joined: 14 Oct 2023 06:59
Posts: 131
Reply with quote
Кстати, RC2014 BASIC не подойдет?

_________________
uselessretro.blogspot.com


12 Mar 2024 23:05
Profile
Admin
User avatar

Joined: 08 Jan 2003 23:22
Posts: 22542
Location: Silicon Valley
Reply with quote
shiny wrote:
Кстати, RC2014 BASIC не подойдет?
он большой
и вроде тоже на базе микрософтовского как и "микрон"
а тут суть в том, что бейсик совсем маленький - как раз в расширенный монитор воткнуть ;)

_________________
:dj: https://mastodon.social/@Shaos


12 Mar 2024 23:09
Profile WWW
Admin
User avatar

Joined: 08 Jan 2003 23:22
Posts: 22542
Location: Silicon Valley
Reply with quote
Сегодня у килобайтного бейсика случился апдейт:
Code:
; 2024-03-15 Realised during testing that
;     ExpEvaluate can sometimes try to return
;     when stack isn't a return address.
;     Realised that ExpEvaluate must either
;     succeed or fail, with no backtrack.
;     This required substantial changes to
;     PrintSub, especially a change to how it
;     knows if it has just had a comma. This
;     is now done based on parity of H.
;     To be retested.
;
;     Had an idea that operators and statements
;     could reside on different pages, creating
;     more space for both, and perhaps removing
;     the need for some of the Jumps out of
;     page 2 to statement implementation.
https://github.com/WillStevens/basic1K/commit/29d91cfeab713e40998a19481c25ac72b74299e4

_________________
:dj: https://mastodon.social/@Shaos


14 Mar 2024 21:12
Profile WWW
Admin
User avatar

Joined: 08 Jan 2003 23:22
Posts: 22542
Location: Silicon Valley
Reply with quote
Вчера случился мелкий апдейт в комментариях - в частности в исходнике было явно указано, что он покрывается лицензией GPLv3:

https://github.com/WillStevens/basic1K/commit/0e6e6d98153ac8d6859ff86cf0a883734b4c634e

_________________
:dj: https://mastodon.social/@Shaos


16 Mar 2024 22:16
Profile WWW
Admin
User avatar

Joined: 08 Jan 2003 23:22
Posts: 22542
Location: Silicon Valley
Reply with quote
Зарелизилась версия 1.0.0 - вот что добавилось с прошлого раза:
Code:
;2024-03-23
;     Changed INPUT so that it doesn't display
;     a prompt. It was confusing to have the
;     > prompt as is used in direct mode. Instead
;     programs that need a prompt before input
;     can use the multistatement line
;     PRINT "?", INPUT A
; 2024-03-25 Found a fix for problem where
;     -32768/2 has wrong sign. It costs 3 bytes
;     so need to find 2 byte saving before Ready
;     and 1 byte saving after Ready
; 2024-03-26 In the process of making major
;     rearrangements to save several bytes and
;     fix the bug mentioned above.
; 2024-03-27 Major rearrangements have been done.
;      Net reault is to save 5 bytes, but need
;      to carefully check whether any same-page
;      assumptions are violated
; 2024-03-28 Found and fixed several bugs related
;          to above changes. Execution of ? token
;          seems to take too long, implying a
;          remaining bug. 9 bytes free now, 5 of
;          which are contiguous at the end of the
;          program.
; 2024-03-29 Two bugs to fix : prompt appears
;        twice after entering first line.
;          detection of syntax errors is slow
; 2024-04-01 Fixed several bugs introduced above.
;      Need to run all tests again.
; 2024-04-03 Changed newline behaviour so that
;      VT100 terminals require LNM reset rather
;      than set.
; 2024-04-04 Reclaimed 2 bytes in
;      DigitClassNotEnd. Used those two bytes to
;      add a colon token. It can be used as a
;      statement separator in multi-statement
;      lines.


Attachments:
basic1K-1.0.0.zip [63.26 KiB]
Downloaded 7 times

_________________
:dj: https://mastodon.social/@Shaos
07 Apr 2024 00:49
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 9 posts ] 

Who is online

Users browsing this forum: No registered users and 13 guests


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 post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group
Designed by ST Software.