From 7f479b91f40f37f5b322c6a8fbc21252092b18a6 Mon Sep 17 00:00:00 2001 From: B. Watson Date: Fri, 28 Apr 2023 10:41:23 +0100 Subject: development/minimal-basic: Added (ECMA-55 Minimal BASIC compiler) Signed-off-by: bedlam Signed-off-by: Willy Sudiarto Raharjo --- development/minimal-basic/README | 20 +++ development/minimal-basic/examples/BAGELS.BAS | 117 +++++++++++++++ development/minimal-basic/examples/HAMURABI.BAS | 160 +++++++++++++++++++++ development/minimal-basic/examples/PI.BAS | 42 ++++++ development/minimal-basic/minimal-basic.SlackBuild | 126 ++++++++++++++++ development/minimal-basic/minimal-basic.info | 10 ++ development/minimal-basic/slack-desc | 19 +++ 7 files changed, 494 insertions(+) create mode 100644 development/minimal-basic/README create mode 100644 development/minimal-basic/examples/BAGELS.BAS create mode 100644 development/minimal-basic/examples/HAMURABI.BAS create mode 100644 development/minimal-basic/examples/PI.BAS create mode 100644 development/minimal-basic/minimal-basic.SlackBuild create mode 100644 development/minimal-basic/minimal-basic.info create mode 100644 development/minimal-basic/slack-desc (limited to 'development/minimal-basic') diff --git a/development/minimal-basic/README b/development/minimal-basic/README new file mode 100644 index 0000000000..6e66cf04d3 --- /dev/null +++ b/development/minimal-basic/README @@ -0,0 +1,20 @@ +minimal-basic (compiler for ECMA-55 Minimal BASIC) + +This software is a compiler for 'Minimal BASIC' as specified by the +ECMA-55 standard. The target is AMD64/EM64T/x86-64 machines running a +modern Linux distribution. + +The compiler is called ecma55, but it's normally called via wrapper +scripts called BASICC, BASICCS, or BASICCW. Man pages are included for +all of these commands. + +There's sample code in /usr/share/minimal-basic, and quite a bit +of documentation in /usr/doc/minimal-basic-$VERSION, including a +copy of the language standard (ECMA-55.TXT) and a complete book +(Learn_BASIC.pdf). + +Note: This will only compile on x86_64 because it's partly written in +x86_64 assembly. No way will it ever compile for 32-bit x86 (or any +ARM). Even if it would build on 32-bit, it would be a cross compiler: +it only generates x86_64 code, which would not be very useful on an +x86 system. diff --git a/development/minimal-basic/examples/BAGELS.BAS b/development/minimal-basic/examples/BAGELS.BAS new file mode 100644 index 0000000000..edd64d77a7 --- /dev/null +++ b/development/minimal-basic/examples/BAGELS.BAS @@ -0,0 +1,117 @@ +1 RANDOMIZE +5 PRINT TAB(33);"BAGELS" +10 PRINT TAB(15);"CREATIVE COMPUTING MORRISTOWN, NEW JERSEY" +12 PRINT TAB(10);"ECMA-55 PORT BY. B. WATSON, URCHLAY AT SLACKWARE.UK" +14 PRINT +16 PRINT +20 REM *** BAGELS NUMBER GUESSING GAME +22 REM *** ORIGINAL SOURCE UNKNOWN BUT SUSPECTED TO BE +25 REM *** LAWRENCE HALL OF SCIENCE, U.C. BERKELEY +29 REM A = ACTUAL ANSWER, G = USER'S GUESS +30 DIM A(3),G(3) +40 LET Y=0 +50 PRINT +55 PRINT +60 PRINT +70 PRINT "WOULD YOU LIKE THE RULES (1=YES, 0=NO)"; +80 INPUT N +90 IF N=0 THEN 150 +100 PRINT +105 PRINT "I AM THINKING OF A THREE-DIGIT NUMBER. TRY TO GUESS" +110 PRINT "MY NUMBER AND I WILL GIVE YOU CLUES AS FOLLOWS:" +120 PRINT " PICO - ONE DIGIT CORRECT BUT IN THE WRONG POSITION" +130 PRINT " FERMI - ONE DIGIT CORRECT AND IN THE RIGHT POSITION" +140 PRINT " BAGELS - NO DIGITS CORRECT" +150 FOR I=1 TO 3 +160 LET A(I)=INT(10*RND) +165 IF I-1=0 THEN 200 +170 FOR J=1 TO I-1 +180 IF A(I)=A(J) THEN 160 +190 NEXT J +200 NEXT I +210 PRINT +215 PRINT "O.K. I HAVE A NUMBER IN MIND." +220 FOR I=1 TO 20 +230 PRINT "GUESS #";I, +240 INPUT N +243 IF N>=1000 THEN 247 +245 IF N<0 THEN 247 +246 GOTO 250 +247 GOSUB 630 +248 GOTO 230 +250 LET G(1)=INT(N/100) +260 LET G(2)=INT((N-G(1)*100)/10) +270 LET G(3)=N-(G(1)*100+G(2)*10) +290 REM UNCOMMENT NEXT LINE FOR DEBUGGING +300 REM GOSUB 800 +320 LET F=0 +322 IF G(1)<>G(2) THEN 330 +325 LET F=1 +330 IF G(2)<>G(3) THEN 340 +335 LET F=1 +340 IF G(3)<>G(1) THEN 345 +342 LET F=1 +345 IF F=0 THEN 350 +347 GOSUB 650 +349 GOTO 230 +350 LET C=0 +355 LET D=0 +360 FOR J=1 TO 2 +370 IF A(J)<>G(J+1) THEN 390 +380 LET C=C+1 +390 IF A(J+1)<>G(J) THEN 410 +400 LET C=C+1 +410 NEXT J +420 IF A(1)<>G(3) THEN 440 +430 LET C=C+1 +440 IF A(3)<>G(1) THEN 460 +450 LET C=C+1 +460 FOR J=1 TO 3 +470 IF A(J)<>G(J) THEN 490 +480 LET D=D+1 +490 NEXT J +500 IF D=3 THEN 680 +505 IF C=0 THEN 545 +520 FOR J=1 TO C +530 PRINT "PICO "; +540 NEXT J +545 IF D=0 THEN 580 +550 FOR J=1 TO D +560 PRINT "FERMI "; +570 NEXT J +580 IF C+D<>0 THEN 600 +590 PRINT "BAGELS"; +600 PRINT +605 NEXT I +610 PRINT "OH WELL." +612 PRINT "THAT'S TWENTY GUESSES. MY NUMBER WAS";100*A(1)+10*A(2)+A(3) +614 LET N=100*A(1)+10*A(2)+A(3) +615 IF N>=100 THEN 620 +617 PRINT "0"; +618 IF N>=10 THEN 620 +619 PRINT "0"; +620 PRINT N +622 GOTO 700 +630 PRINT "TRY GUESSING A THREE-DIGIT NUMBER." +635 RETURN +650 PRINT "OH, I FORGOT TO TELL YOU THAT THE NUMBER I HAVE IN MIND" +660 PRINT "HAS NO TWO DIGITS THE SAME." +670 RETURN +680 PRINT "YOU GOT IT!!!" +685 PRINT +690 LET Y=Y+1 +700 PRINT "PLAY AGAIN (1=YES, 0=NO)"; +710 INPUT N +720 IF N<>0 THEN 150 +730 IF Y=0 THEN 750 +740 PRINT +745 PRINT "A";Y;"POINT BAGELS BUFF!!" +750 PRINT "HOPE YOU HAD FUN. BYE." +760 GOTO 999 +799 REM CHEAT/DEBUG MODE. UNCOMMENT LINE 300 TO ACTIVATE THIS CODE +800 PRINT "GUESS","ANSWER" +805 FOR X=1 TO 3 +810 PRINT G(X),A(X) +820 NEXT X +830 RETURN +999 END diff --git a/development/minimal-basic/examples/HAMURABI.BAS b/development/minimal-basic/examples/HAMURABI.BAS new file mode 100644 index 0000000000..7d8cf17976 --- /dev/null +++ b/development/minimal-basic/examples/HAMURABI.BAS @@ -0,0 +1,160 @@ +5 RANDOMIZE +10 PRINT TAB(32);"HAMURABI" +20 PRINT TAB(15);"CREATIVE COMPUTING MORRISTOWN, NEW JERSEY" +30 PRINT +40 PRINT TAB(11);"ECMA-55 PORT BY B. WATSON, URCHLAY AT SLACKWARE.UK" +50 PRINT +80 PRINT "TRY YOUR HAND AT GOVERNING ANCIENT SUMERIA" +90 PRINT "FOR A TEN-YEAR TERM OF OFFICE." +92 PRINT +95 LET D1=0 +97 LET P1=0 +100 LET Z=0 +102 LET P=95 +104 LET S=2800 +106 LET H=3000 +107 LET E=H-S +110 LET Y=3 +120 LET A=H/Y +130 LET I=5 +140 LET Q=1 +210 LET D=0 +215 PRINT +216 PRINT +217 PRINT "HAMURABI: I BEG TO REPORT TO YOU," +218 LET Z=Z+1 +220 PRINT "IN YEAR";Z;",";D;"PEOPLE STARVED,";I;"CAME TO THE CITY," +225 LET P=P+I +227 IF Q>0 THEN 230 +228 LET P=INT(P/2) +229 PRINT "A HORRIBLE PLAGUE STRUCK! HALF THE PEOPLE DIED." +230 PRINT "POPULATION IS NOW";P +232 PRINT "THE CITY NOW OWNS";A;"ACRES." +235 PRINT "YOU HARVESTED";Y;"BUSHELS PER ACRE." +250 PRINT "THE RATS ATE";E;"BUSHELS." +260 PRINT "YOU NOW HAVE";S;"BUSHELS IN STORE." +261 PRINT +270 IF Z=11 THEN 860 +310 LET C=INT(10*RND) +311 LET Y=C+17 +312 PRINT "LAND IS TRADING AT";Y;"BUSHELS PER ACRE." +320 PRINT "HOW MANY ACRES DO YOU WISH TO BUY"; +321 INPUT Q +322 IF Q<0 THEN 850 +323 IF Y*Q<=S THEN 330 +324 GOSUB 710 +325 GOTO 320 +330 IF Q=0 THEN 340 +331 LET A=A+Q +332 LET S=S-Y*Q +333 LET C=0 +334 GOTO 400 +340 PRINT "HOW MANY ACRES DO YOU WISH TO SELL"; +341 INPUT Q +343 IF Q<0 THEN 850 +345 IF QC/2 THEN 530 +523 REM *** RATS ARE RUNNING WILD!! +525 LET E=INT(S/C) +530 LET S=S-E+H +531 GOSUB 800 +532 REM *** LET'S HAVE SOME BABIES +533 LET I=INT(C*(20*A+S)/P/100+1) +539 REM *** HOW MANY PEOPLE HAD FULL TUMMIES? +540 LET C=INT(Q/20) +541 REM *** HORROS, A 15% CHANCE OF PLAGUE +542 LET Q=INT(10*(2*RND-.3)) +550 IF P.45*P THEN 560 +555 LET P1=((Z-1)*P1+D*100/P)/Z +556 LET P=C +557 LET D1=D1+D +558 GOTO 215 +560 PRINT +562 PRINT "YOU STARVED";D;"PEOPLE IN ONE YEAR!!!" +565 PRINT "DUE TO THIS EXTREME MISMANAGEMENT YOU HAVE NOT ONLY" +566 PRINT "BEEN IMPEACHED AND THROWN OUT OF OFFICE BUT YOU HAVE" +567 PRINT "ALSO BEEN DECLARED NATIONAL FINK!!!!" +569 GOTO 990 +710 PRINT "HAMURABI: THINK AGAIN. YOU HAVE ONLY" +711 PRINT S;"BUSHELS OF GRAIN. NOW THEN," +712 RETURN +720 PRINT "HAMURABI: THINK AGAIN. YOU OWN ONLY";A;"ACRES. NOW THEN," +730 RETURN +800 LET C=INT(RND*5)+1 +801 RETURN +850 PRINT +852 PRINT "HAMURABI: I CANNOT DO WHAT YOU WISH." +855 PRINT "GET YOURSELF ANOTHER STEWARD!!!!!" +857 GOTO 990 +860 PRINT "IN YOUR 10-YEAR TERM OF OFFICE,";P1;"PERCENT OF THE" +862 PRINT "POPULATION STARVED PER YEAR ON THE AVERAGE, I.E. A TOTAL OF" +865 PRINT D1;"PEOPLE DIED!!" +867 LET L=A/P +870 PRINT "YOU STARTED WITH 10 ACRES PER PERSON AND ENDED WITH" +875 PRINT L;"ACRES PER PERSON." +877 PRINT +880 IF P1>33 THEN 565 +885 IF L<7 THEN 565 +890 IF P1>10 THEN 940 +892 IF L<9 THEN 940 +895 IF P1>3 THEN 960 +896 IF L<10 THEN 960 +900 PRINT "A FANTASTIC PERFORMANCE!!! CHARLEMANGE, DISRAELI, AND" +905 PRINT "JEFFERSON COMBINED COULD NOT HAVE DONE BETTER!" +910 GOTO 990 +940 PRINT "YOUR HEAVY-HANDED PERFORMANCE SMACKS OF NERO AND IVAN IV." +945 PRINT "THE PEOPLE (REMAINING) FIND YOU AN UNPLEASANT RULER, AND," +950 PRINT "FRANKLY, HATE YOUR GUTS!!" +955 GOTO 990 +960 PRINT "YOUR PERFORMANCE COULD HAVE BEEN SOMEWHAT BETTER, BUT" +965 PRINT "REALLY WASN'T TOO BAD AT ALL. ";INT(P*.8*RND);"PEOPLE" +970 PRINT "WOULD DEARLY LIKE TO SEE YOU ASSASSINATED BUT WE ALL HAVE" +975 PRINT "OUR TRIVIAL PROBLEMS." +989 REM BAS55 HAS NO CHR$() FUNCTION, NO WAY TO RING A BELL. +990 REM 990 PRINT: FOR N=1 TO 10: PRINT CHR$(7);: NEXT N +991 PRINT +995 PRINT "SO LONG FOR NOW." +997 PRINT +999 END diff --git a/development/minimal-basic/examples/PI.BAS b/development/minimal-basic/examples/PI.BAS new file mode 100644 index 0000000000..8c79f03250 --- /dev/null +++ b/development/minimal-basic/examples/PI.BAS @@ -0,0 +1,42 @@ +1 REM PI CALCULATOR, B. WATSON, URCHLAY AT SLACKWARE.UK +3 REM PORTED FROM PYTHON3, FROM "LEARNPYTHON" PROJECT ON GITHUB +5 REM THE PYTHON VERSION IS MIT-LICENSED. +10 PRINT "CALCULATE HOW MANY DIGITS OF PI"; +20 INPUT P +25 LET P=INT(P) +30 IF P>=1 THEN 60 +40 PRINT "PLEASE ENTER A POSITIVE NUMBER." +50 GOTO 10 +60 IF P<20 THEN 100 +70 PRINT "WARNING: PROGRAM ONLY ACCURATE TO 20 DIGITS OR SO." +100 LET Q=1 +110 LET R=0 +120 LET T=1 +130 LET K=1 +140 LET N=3 +150 LET L=3 +160 LET C=0 +200 IF (4*Q+R-T)>=(N*T) THEN 300 +210 PRINT N; +215 IF C>0 THEN 220 +217 PRINT "."; +220 LET C=C+1 +230 IF C=P THEN 500 +240 LET R1=10*(R-N*T) +250 LET N=INT((10*(3*Q+R))/T)-10*N +260 LET Q=Q*10 +270 LET R=R1 +280 GOTO 200 +300 LET R1=(2*Q+R)*L +310 LET N1=INT((Q*(7*K)+2+(R*L))/(T*L)) +320 LET Q=Q*K +330 LET T=T*L +340 LET L=L+2 +350 LET K=K+1 +360 LET N=N1 +370 LET R=R1 +380 GOTO 200 +500 PRINT +510 REM THE PRINT ABOVE IS NEEDED TO MAKE MINIMALBASIC FLUSH ITS +520 REM OUTPUT BUFFER. OTHERWISE WE GET NO OUTPUT! +9999 END diff --git a/development/minimal-basic/minimal-basic.SlackBuild b/development/minimal-basic/minimal-basic.SlackBuild new file mode 100644 index 0000000000..b72ea11cd6 --- /dev/null +++ b/development/minimal-basic/minimal-basic.SlackBuild @@ -0,0 +1,126 @@ +#!/bin/bash + +# Slackware build script for minimal-basic + +# Written by B. Watson (urchlay@slackware.uk) + +# Licensed under the WTFPL. See http://www.wtfpl.net/txt/copying/ for details. + +# Notes: + +# Abandon all hope, ye who attempt to build this on non-x86_64 +# platforms. The ecma55 binary gets linked with a bunch of x86_64 +# object files in a directory named AMD64 (which ought to be a clue), +# which are built from x86_64 assembly source (not C). Nothing you do +# (hacking up the Makefile, etc) will let you link x86_64 objects with +# non-x86_64 ones. Seriously. Do not email me asking for help with it. + +# Building on multilib should be possible, but I haven't tested it. +# If you do, you can only build an x86_64 binary. See above. + +# There's a Makefile.clang, but it won't work on Slackware 15.0's +# clang 13.x because it's too *new*. That's a rare situation in +# Slackware... + +# There's also a Makefile.tcc, which actually does work with the +# tcc in our repo (20220221_308d8d1), but I see no advantage to +# building with tcc. And no, using tcc won't get around the "only +# builds on x86_64" rule, either. + +cd $(dirname $0) ; CWD=$(pwd) + +PRGNAM=minimal-basic +SRCNAM=MinimalBASIC +VERSION=${VERSION:-2.40} +BUILD=${BUILD:-1} +TAG=${TAG:-_SBo} +PKGTYPE=${PKGTYPE:-tgz} + +if [ -z "$ARCH" ]; then + case "$( uname -m )" in + i?86) ARCH=i586 ;; + arm*) ARCH=arm ;; + *) ARCH=$( uname -m ) ;; + esac +fi + +if [ ! -z "${PRINT_PACKAGE_NAME}" ]; then + echo "$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.$PKGTYPE" + exit 0 +fi + +TMP=${TMP:-/tmp/SBo} +PKG=$TMP/package-$PRGNAM +OUTPUT=${OUTPUT:-/tmp} + +if [ "$ARCH" = "x86_64" ]; then + SLKCFLAGS="-O2 -fPIC" +else + cat < $PKGDOC/$PRGNAM.SlackBuild + +mkdir -p $PKG/install +cat $CWD/slack-desc > $PKG/install/slack-desc + +cd $PKG +/sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.$PKGTYPE diff --git a/development/minimal-basic/minimal-basic.info b/development/minimal-basic/minimal-basic.info new file mode 100644 index 0000000000..e257fc37b1 --- /dev/null +++ b/development/minimal-basic/minimal-basic.info @@ -0,0 +1,10 @@ +PRGNAM="minimal-basic" +VERSION="2.40" +HOMEPAGE="https://buraphakit.sourceforge.io/BASIC.shtml" +DOWNLOAD="UNSUPPORTED" +MD5SUM="" +DOWNLOAD_x86_64="https://downloads.sourceforge.net/project/buraphakit/ECMA55%20Minimal%20BASIC/MinimalBASIC-2.40.tar.xz" +MD5SUM_x86_64="0276e6edcc70a6c343a9adb467df845b" +REQUIRES="" +MAINTAINER="B. Watson" +EMAIL="urchlay@slackware.uk" diff --git a/development/minimal-basic/slack-desc b/development/minimal-basic/slack-desc new file mode 100644 index 0000000000..391dee2fe5 --- /dev/null +++ b/development/minimal-basic/slack-desc @@ -0,0 +1,19 @@ +# HOW TO EDIT THIS FILE: +# The "handy ruler" below makes it easier to edit a package description. +# Line up the first '|' above the ':' following the base package name, and +# the '|' on the right side marks the last column you can put a character in. +# You must make exactly 11 lines for the formatting to be correct. It's also +# customary to leave one space after the ':' except on otherwise blank lines. + + |-----handy-ruler------------------------------------------------------| +minimal-basic: minimal-basic (compiler for ECMA-55 Minimal BASIC) +minimal-basic: +minimal-basic: This software is a compiler for 'Minimal BASIC' as specified by the +minimal-basic: ECMA-55 standard. The target is AMD64/EM64T/x86-64 machines running a +minimal-basic: modern Linux distribution. +minimal-basic: +minimal-basic: +minimal-basic: +minimal-basic: +minimal-basic: +minimal-basic: -- cgit v1.2.3