MPL Bytecode Compiler Code
Micro Programming Language - A Portable Language for Micro Computers
Status: Beta
Brought to you by:
buzzphp
/*
** MPL - Micro Programming Language
** DEMO OF MPL PROGRAMING USED FOR TESTING
*/
+libhdr+mlib+mint+mcon+mchr
.buff = %128
.name = "MPL STRINGS. This is kinda cool"
.info = "this is a quick test. Still some bugs"
.please = "Please enter some text: "
.youtyped = "You typed: "
.table = 5,10,20,30,40,50
.names = "Derek","was","here",%1
apple = 1
orange = 52
next() apple+=1
main2() [
apple=1; @[
puti(apple);
next();
apple!=20
];
apple=10; apple>0 @[
puti(apple);
apple-=1
];
puti(.max(10,20));
puti(.min(10,20))
]
// ---------------------------------
// main entry point, just like c/c++
// ---------------------------------
inc(v) [
!v=!v+1
]
fff() 45
test() fff
main22() [
newline();
puts(strdel(strcpy(.buff, "DEREK! EVANS"),2,4));
strmid(.buff, "APPLE PEAR", 7,4);
strins(.buff, 2, "-WELCOME-");
strcat(.buff, "<<<");
strins(.buff,1,">>>");
puts(.buff);
gets(.buff)
]
ttt(a!1,b) [
a$!1=123;
puti(a$!1);
puti(b)
]
here(a,b%2,c) [
a=10;
c=20;
b$%4 = 123;
puti(c)
]
memtest(a,b,c,d,e,f) [
usevec(a$+1000,8000);
writef("MEMUSED=%n*n", memused());
puti(a=getvec(10));
puti(b=getvec(20));
puti(c=getvec(30));
puti(d=getvec(40));
puti(e=getvec(50));
puti(f=getvec(60));
writef("MEMUSED=%n*n", memused());
freevec(f);
freevec(e);
freevec(d);
freevec(c);
freevec(b);
freevec(a);
Writef("MEMUSED=%n*n", memused());
puti(a=getvec(10));
puti(b=getvec(10));
puti(c=getvec(10));
puti(d=getvec(10));
puti(e=getvec(10));
puti(f=getvec(10));
writef("MEMUSED=%n*n", memused());
freevec(f);
freevec(e);
freevec(d);
freevec(c);
freevec(b);
freevec(a);
writef("MEMUSED=%n*n", memused());
0
]
.derek: -1234
cold(a,b!10) [
b$!0=1234;
a=4567;
puti(100);
puti(!a$);
puti(b$!0)
]
main(s,i) [
cold();
puti(.derek);
s=101;
writen(s&=1);
writen(s);
reads(.buff);
memtest();
apple=10;
puti(apple--);
puti(apple);
strcpy(.buff, "AEREK");
apple = .buff;
puti(apple);
puti(%apple++);
puti(apple);
//puti(!(.table+2)-=1);
//puti(!(.table+2));
puti(compstring("DEREK", "AEREK"));
reads(.buff);
puts(.buff);
.clrscr();
newline();
puti(str2numb("-4321"));
newline();
writet("A",2);
writet("A",2);
writebin(16,8);
newline();
writef("%s here %s %oa*n", "DEREK IS", "NOW", 10);
WriteS("APPLE*n");
wrch(toupper('z'));
gets(.buff);
ttt(10,20,30);
main22();
puti(.max(10,20));
i=0;i<=10@[puti(i);i+=1];
puti(-test()());
puti(strset(.buff,1000));
writes("writing file ...*n");
.fcreate(.fmin,"test.txt")==0?[
writes("HERE*n");
fprintf(.fmin,"Welcome to MPL.. %i*n", 2018);
fprintf(.fmin,"Welcome to MPL.. %i*n", 2019);
fprintf(.fmin,"Welcome to MPL.. %i*n", 2020);
i=1;i<=10 @ fprintf(.fmin,"Numbers #%i*n", i++);
.fclose(.fmin)
];
puti(-1234);
puti(-1234);
writef("hello [number=%n]%% %s there %s*n*n", -123, "derek", "again");
puts(strcat(strcpy(.buff, "DEREK"), " EVANS."));
puti(apple);
puti(.min(10,20));
printf("Welcome to new MPL.%s %d*n*n", "THIS IS DAM COOL!", 2018*2);
cputs(.please);
gets(.buff);
puts(.youtyped);
puts(.buff);
s=puts;
s("Hello THERE FROM MPL-------------");
.table!2=s;
(.table!2)("This is called via a vector table");
.table!2=123;
i=!.table; i@[
puti(.table!i);
i-=1
];
i=.names; %i@[
puts(i);
i+=%i+1
];
puts("INC TEST");
i=123;
puti(inc(i$));
apple=10;
puti(inc(apple$));
puti(inc(apple$));
puti(inc(apple$));
puti(inc(apple$));
apple=1;
apple=-apple*10+2
]
// end of program