Commit da4faa04 authored by kollo's avatar kollo

version 1.18

parent a1314c13
......@@ -34,7 +34,7 @@ DEF= @def@
# Compiler
#CC=@CC@ @static@ $(REGS)
CC=@CC@ $(REGS)
CC=@CC@ $(REGS) -g
# Cross-Compiler fuer Windows-Excecutable
......@@ -51,17 +51,17 @@ CPP=@CPP@
CFLAGS= $(INC) $(DEF) $(OPT) $(SFLAGS)
OBJS= xbasic.o file.o ccs.o io.o parser.o variablen.o array.o\
OBJS= xbasic.o file.o ccs.o io.o parser.o variablen.o array.o parameter.o \
runtime.o wort_sep.o ltext.o functions.o sfunctions.o afunctions.o \
kommandos.o gkommandos.o bitmap.o do_gets.o errortxt.o window.o\
sysVstuff.o aes.o graphics.o sound.o number.o decode.o
sysVstuff.o aes.o graphics.o sound.o number.o decode.o virtual-machine.o
# Object group for framebuffer variant
OBJS1= xbasic.o file.o ccs.o io.o parser.o variablen.o array.o\
OBJS1= xbasic.o file.o ccs.o io.o parser.o variablen.o array.o parameter.o\
runtime.o wort_sep.o ltext.o functions.o sfunctions.o afunctions.o \
kommandos.o do_gets.o errortxt.o number.o decode.o \
sysVstuff.o aes.o sound.o
sysVstuff.o aes.o sound.o virtual-machine.o
# Sources for libx11basic
......@@ -70,7 +70,7 @@ LIBCSRCFB=$(OBJS:.o=.c) framebuffer.c mathematics.c spat-a-fnt.c 5x7.c
DISTOBJS=$(OBJS) main.o mathemat_dummy.o
LIBOBJS= $(OBJS) mathematics.o
EXTRAOBJS= virtual-machine.o bytecode.o xbbc.o xbvm.o xb2c.o framebuffer.o spat-a-fnt.o 5x7.o
EXTRAOBJS= bytecode.o xbbc.o xbvm.o xb2c.o framebuffer.o spat-a-fnt.o 5x7.o
WINLIBOBJS= $(OBJS) mathematics.o Windows.extension/fnmatch.o Windows.extension/memfrob.o
AOBJS= main.o $(LIBOBJS)
BOBJS= main.o blowfish.o $(LIBOBJS)
......@@ -80,8 +80,8 @@ DEPSRC= $(CSRC)
# Headerfiles which should be added to the distribution
HSRC= aes.h array.h bitmap.h defs.h file.h functions.h gkommandos.h globals.h kommandos.h \
options.h xbasic.h window.h vtypes.h ptypes.h bytecode.h number.h \
HSRC= aes.h array.h bitmap.h defs.h file.h functions.h gkommandos.h kommandos.h \
options.h xbasic.h window.h bytecode.h number.h parameter.h \
framebuffer.h parser.h io.h afunctions.h sfunctions.h graphics.h \
sound.h wort_sep.h variablen.h mathematics.h sysVstuff.h x11basic.h \
decode.h xb2csol.h
......@@ -89,6 +89,10 @@ HSRC= aes.h array.h bitmap.h defs.h file.h functions.h gkommandos.h globals.h k
EXAMPLES=examples2/calculation/randomminmax.bas \
examples2/calculation/sieve.bas \
examples2/calculation/sqr.bas \
examples/c-usage/c-demo.c \
examples/c-usage/c-demo2.c \
examples/c-usage/library.bas \
examples/c-usage/Makefile \
examples/compiler/bas2x11basic.bas \
examples/compiler/gui2bas.bas \
examples/graphics/*.bas \
......@@ -129,7 +133,10 @@ DIST= README INSTALL COPYING doc/man-pages/*.1 doc/ACKNOWLEGEMENTS \
examples/compiler/bas2x11basic.bas \
examples/compiler/gui2bas.bas \
examples/compiler/xbc-win.bas \
examples/compiler/c-demo.c \
examples/c-usage/c-demo.c \
examples/c-usage/c-demo2.c \
examples/c-usage/library.bas \
examples/c-usage/Makefile \
examples/tests/* \
examples/graphics/*
......@@ -140,7 +147,10 @@ BINDIST=README INSTALL COPYING doc/man-pages/*.1 doc/ACKNOWLEGEMENTS \
examples/compiler/inline.bas \
examples/compiler/bas2x11basic.bas \
examples/compiler/gui2bas.bas \
examples/compiler/c-demo.c \
examples/c-usage/c-demo.c \
examples/c-usage/c-demo2.c \
examples/c-usage/library.bas \
examples/c-usage/Makefile \
examples/tests/* \
examples/graphics/*
......@@ -226,19 +236,19 @@ xbc : xbasic libx11basic.so
# Make the bytecode compiler xbbc
xbbc : bytecode.h bytecode.o virtual-machine.o xbbc.c
gcc -o $@ xbbc.c bytecode.o virtual-machine.o -L . $(LIBS) -lx11basic -L /usr/X11/lib/ -lX11
xbbc : bytecode.h bytecode.o xbbc.c
gcc -o $@ xbbc.c bytecode.o -L . $(LIBS) -lx11basic -L /usr/X11/lib/ -lX11
strip $@
xbbcstatic : xbbc.c bytecode.h bytecode.o virtual-machine.o x11basic.a
gcc -o xbbc xbbc.c bytecode.o virtual-machine.o x11basic.a -lm -L /usr/X11/lib/ -lX11 -lreadline -lcurses -lncurses
xbbcstatic : xbbc.c bytecode.h bytecode.o x11basic.a
gcc -o xbbc xbbc.c bytecode.o x11basic.a -lm -L /usr/X11/lib/ -lX11 $(LIBS)
# Make the virtual machine for interpreting the bytecode
xbvm : bytecode.h xbvm.c virtual-machine.o
gcc -o $@ xbvm.c virtual-machine.o -L .$(LIBS) -lx11basic -L /usr/X11/lib/ -lX11
xbvm : bytecode.h xbvm.c
gcc -o $@ xbvm.c -L .$(LIBS) -lx11basic -L /usr/X11/lib/ -lX11
strip $@
xbvmstatic : bytecode.h xbvm.c virtual-machine.o bytecode.h x11basic.a
gcc -o xbvm xbvm.c virtual-machine.o x11basic.a -lm -L /usr/X11/lib/ -lX11 -lreadline -lcurses -lncurses
xbvmstatic : bytecode.h xbvm.c bytecode.h x11basic.a
gcc -o xbvm xbvm.c x11basic.a -lm -L /usr/X11/lib/ $(LIBS) -lX11
###################################################
#### Fundamentals for X11-Basic (MS WINDOWS) ######
......@@ -263,24 +273,22 @@ xbasic.exe: x11basic.lib main.c
$(WINCC) -DWINDOWS $(OPT) $(WINLINKFLAGS) main.c -o $@ $(MYWINLIBS) \
$(WINLIBS)
strip $@
xbbc.exe: x11basic.lib bytecode.h bytecode.c xbbc.c virtual-machine.c
xbbc.exe: x11basic.lib bytecode.h bytecode.c xbbc.c
$(WINCC) -DWINDOWS $(OPT) $(WINLINKFLAGS) -o $@ xbbc.c bytecode.c \
virtual-machine.c $(MYWINLIBS) $(WINLIBS)
$(MYWINLIBS) $(WINLIBS)
strip $@
xbvm.exe: x11basic.lib bytecode.h xbvm.c virtual-machine.c
xbvm.exe: x11basic.lib bytecode.h xbvm.c
$(WINCC) -DWINDOWS $(OPT) $(WINLINKFLAGS) -o $@ xbvm.c \
virtual-machine.c $(MYWINLIBS) $(WINLIBS)
$(MYWINLIBS) $(WINLIBS)
strip $@
# Make th X11-Xasic psydocompiler (for MS WINDOWS)
xbc-win.b : xbbc examples/compiler/xbc-win.bas
LD_LIBRARY_PATH=. ./xbbc examples/compiler/xbc-win.bas -o $@
xbc.exe : xbasic xbc-win.b examples/compiler/xbc-win.bas xbvm.exe
LD_LIBRARY_PATH=. ./xbasic examples/compiler/xbc-win.bas xbc-win.b -o $@
xbc.exe : xbasic examples/compiler/xbc-win.bas xbvm.exe xbbc
LD_LIBRARY_PATH=. ./xbasic -q examples/compiler/xbc-win.bas -o $@
chmod 755 $@
strip $@
###################################################
......@@ -364,17 +372,17 @@ xbasic.tomtom : main.c x11basic.a.tomtom
arm-linux-strip $@
rm -f config.h
xbvm.tomtom : bytecode.h xbvm.c virtual-machine.c x11basic.a.tomtom
xbvm.tomtom : bytecode.h xbvm.c x11basic.a.tomtom
rm -f config.h
ln -s config.h.tomtom config.h
$(ARMCC) -DFRAMEBUFFER $(OPT) $(LINKFLAGS) -o $@ xbvm.c virtual-machine.c x11basic.a.tomtom $(LIBS2)
$(ARMCC) -DFRAMEBUFFER $(OPT) $(LINKFLAGS) -o $@ xbvm.c x11basic.a.tomtom $(LIBS2)
arm-linux-strip $@
rm -f config.h
xbbc.tomtom : xbbc.c bytecode.h bytecode.c virtual-machine.c x11basic.a.tomtom
xbbc.tomtom : xbbc.c bytecode.h bytecode.c x11basic.a.tomtom
rm -f config.h
ln -s config.h.tomtom config.h
$(ARMCC) -DFRAMEBUFFER $(OPT) $(LINKFLAGS) -o $@ xbbc.c bytecode.c virtual-machine.c x11basic.a.tomtom $(LIBS2)
$(ARMCC) -DFRAMEBUFFER $(OPT) $(LINKFLAGS) -o $@ xbbc.c bytecode.c x11basic.a.tomtom $(LIBS2)
rm -f config.h
......@@ -485,7 +493,7 @@ xb2c : xb2c.c
gcc -o $@ xb2c.c -L . $(LIBS) -lx11basic -L /usr/X11/lib/ -lX11
strip $@
xb2cstatic : xb2c.c x11basic.a
gcc -o xb2c xb2c.c x11basic.a -lm -L /usr/X11/lib/ -lX11 -lreadline
gcc -o xb2c xb2c.c x11basic.a -lm -L /usr/X11/lib/ -lX11 $(LIBS)
x11basic.tga: x11basic.pov
povray +I$< +O$@ +FT +W160 +H200 +V -D +X
......@@ -528,7 +536,7 @@ uninstall :
rm -f $(INCDIR)/xb2csol.h
rmdir $(INCDIR)
clean :
rm -f *.o a.out b.b xbc-win.b Makefile.bak x11basic.a \
rm -f *.o a.out b.out b.b Makefile.bak \
backup-*.tgz
distclean : clean
......@@ -563,9 +571,10 @@ rpm : $(DIR).tar.gz x11basic.spec
# rpm --buildroot /usr/src/packages/SOURCES/ -ba --clean x11basic.spec
rpmbuild -ba --clean --nodeps x11basic.spec
deb : $(BINDIST)
sudo checkinstall -D --pkgname x11basic --pkgversion @version@ --arch i386 \
sudo checkinstall -D --pkgname x11basic --pkgversion @version@ --pkgrelease 3 --arch i386 \
--maintainer kollo@users.sourceforge.net --requires libreadline5 --backup \
--pkggroup Interpreters --provides libx11basic --provides xbasic
--pkggroup interpreters --provides libx11basic \
--pkglicense GPL --strip=yes --stripso=yes --reset-uids
rm -f backup-*.tgz
tinerpm : $(TINEDIR).tar.gz tinexbasic.spec
cp $(TINEDIR).tar.gz /usr/src/packages/SOURCES/
......
......@@ -10,32 +10,57 @@
VERSION 1.17
VERSION 1.18
(C) 1997-2011 by Markus Hoffmann
(kollo@users.sourceforge.net)
Name : X11Basic
Version : 1.17 Vendor: Markus Hoffmann
Version : 1.18 Vendor: Markus Hoffmann
Group : Development/Languages License: GPL
Packager : Markus Hoffmann <kollo@users.sourceforge.net>
URL : http://x11-basic.sourceforge.net/
Summary : A Basic Interpreter with X11-Graphics capabilities
Description :
X11-Basic implements the most common elements of the basic langugage. With
X11-graphics. The structure of the language is similar to the old ATARI ST
GFA-Basic. GFA-Basic programs should run with only few changes.
X11-Basic is a dialect of the BASIC programming language with graphics
capability that integrates features like shell scripting, cgi-Programming and
full graphical visualisation into the easy to learn basic language on modern
computers.
This package includes the basic interpreter named xbasic. It can be used as a
shell, can run basic-scripts. You can make excecutable scripts p.ex.
*.cgi-Scripts for handling web-input. A pseudo compiler (xbc) is included which
makes stand alone binaries out of the scripts. Also a ANSI-Basic-to-X11-Basic-
converter (bas2x11basic) is now included.
The structure of the language is similar to the ATARI-ST GFA-BASIC.
GFA-Basic programs should run with only few changes.
On UNIX and linux systems, the X11 graphics engine can be used as well as the
SDL library, the framebuffer devices or no graphics at all. The MS WINDOWS
version supports only SDL (or no graphics at all). On LINUX systems the ALSA
sound engine can be used.
This package includes the basic interpreter named xbasic and a set of different
compilers. The interpreter can be used as a shell, and can so run basic-scripts.
You can make excecutable scripts p.ex. *.cgi-Scripts for handling web-input.
A compiler (xbc) is included which makes stand alone binaries out of the
scripts, which run more than 10 times faster than the interpreted code. The
compiler can either pseudo-compile the X11-Basic sources by attaching the
source to a run-only interpreter (In which case the program will not run faster
than is the interpreter is used, but you have everythin in one excecutable
file), or the compiler can do a real compilation of the BASIC source into
bytecode, then c, and finally machine language. This way the code excecutes
about 10 times faster. (** This is a relatively new feature, so be prepared to
catch errors here. Please report them. **)
X11-Basic programs can also be compiled into a bytecode (see xbbc). This bytecode
can be interpreted by a virtual machine (see xbvm). Finally, the bytecode can be
converted to c sourcefiles (see xb2c) which can be compiles with the gnu C
compiler to native excecutables.
Ancient ANSI-Basic programs (with line numbers) can be converted to X11-Basic
with the bas2x11basic program (see the man page bas2x11basic(1) ).
You will find the compiler sourcecode and some other sample programs in
/usr/share/doc/packages/X11Basic/examples. A variety of other sample programs
can be found in X11-Basic-examples-1.12.zip, which you can download from the
can be found in X11-Basic-examples-1.18.zip, which you can download from the
homepage (http://x11-basic.sourceforge.net/). Also an up-to-date pdf-version
of the manual can be found there.
......
Release notes for Version 1.16 (Feb 2010)
Release notes for Version 1.18 (Sept 2011)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- Bugfix in SORT (Feb 2010)
- new function word$() June 2010
- Improved DATA/RESTORE handling Dez 2010
- Improved xbbc/bytecode/xbvm
- Fixed memory leak accuring in varptr()
- added xbbc and xbvm to windows distribution
- started xb2c project
- new psydocompiler for MS-WINDOWS, can produce standalone .exe files
- Bug fixed: LINEINPUT and LINEINPUT$() now can read arbitrary long lines
- fixed bug with PBOX: now 2nd coordinate is inside the filled area.
- new commands WATCH/(UNWATCH)/FILEEVENT$
- fixed bug with bitmaps (PUT)
- added support for bitmaps with transparency/alpha channel
- fixed bug in DEFFILL
- fixed bug in objc_draw()
- Reworked variable management
- Reworked xb2c compiler, produced code is now much(!) faster.
- interpreter is now 8% faster
- virtual machine is 20 times faster than interpreter
- compiled code is 30 times faster than interpreter
- improved detection of const expressions.
- improved detection of fieldindex too large (less segfaults now)
- fixed a memory leak
- updated the documentation
- changed DIM behavior: DIM a(10) means elements a(0) to a(9) are there.
- fixed some bugs.
- New command: CURVE
- Implemented DEFFN
- Optimized Compiler: simple math functions and Square
Release notes for Version 1.17 (May 2011)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- Adapted windows version to use the SDL library (2011-04)
- added PLAYSOUND command (works only in SDL and WINDOWS version) 2011-05
- modifyed syntax of SOUND command 2011-05
- added ALSA sound support for SOUND command. 2011-05
- made syntax a bit more tolerant against extra blanks
- bugfix with BOX (confusion with curses library, segfault)
- worked on the xb2c compiler/translator 2011-08
......@@ -13,6 +13,7 @@
#include <stdio.h>
#include <string.h>
#include "defs.h"
#include "x11basic.h"
#include "graphics.h"
#include "aes.h"
#include "file.h"
......
......@@ -11,30 +11,29 @@
#include <string.h>
#include <math.h>
#include "config.h"
#include "defs.h"
#include "globals.h"
#include "vtypes.h"
#include "x11basic.h"
#include "variablen.h"
#include "xbasic.h"
#include "array.h"
#include "afunctions.h"
#include "xbasic.h"
ARRAY f_smula(PARAMETER *plist, int e) {
ARRAY ergeb;
ergeb.typ=plist[0].typ;
ergeb.dimension=plist[0].integer;
ergeb.pointer=plist[0].pointer;
ergeb=double_array(ergeb);
ergeb.typ=plist->typ;
ergeb.dimension=plist->integer;
ergeb.pointer=plist->pointer;
ergeb=double_array(&ergeb);
array_smul(ergeb,plist[1].real);
return(ergeb);
}
ARRAY f_nullmat(PARAMETER *plist, int e) {
int dimlist[2]={plist[0].integer,plist[1].integer};
return(nullmatrix(FLOATARRAYTYP,e,dimlist));
return(nullmatrix(FLOATTYP,e,dimlist));
}
ARRAY f_einsmat(PARAMETER *plist, int e) {
int dimlist[2]={plist[0].integer,plist[0].integer};
return(einheitsmatrix(FLOATARRAYTYP,2,dimlist));
return(einheitsmatrix(FLOATTYP,2,dimlist));
}
extern double *SVD(double *a, double *w, double *v,int anzzeilen, int anzspalten);
......
This diff is collapsed.
......@@ -6,51 +6,49 @@
* COPYING for details
*/
#include "vtypes.h"
extern double *SVD(double *a, double *w, double *v,int anzzeilen, int anzspalten);
extern double *backsub(double *, double *, double *, double *,int,int);
ARRAY create_array(int , int ,int *);
ARRAY create_int_array(int dimension, int *dimlist,int value);
ARRAY create_float_array(int dimension, int *dimlist,double value);
ARRAY create_string_array(int dimension, int *dimlist,STRING *value);
ARRAY nullmatrix(int , int ,int *);
ARRAY einheitsmatrix(int , int ,int *);
ARRAY array_const(char *);
ARRAY copy_var_array(int);
ARRAY array_info(int);
ARRAY double_array(ARRAY);
ARRAY double_array(ARRAY *);
ARRAY einheitsmatrix(int, int, int *);
ARRAY nullmatrix(int, int, int *);
ARRAY form_array(int, int, int *, char *);
ARRAY mul_array(ARRAY, ARRAY);
ARRAY trans_array(ARRAY);
ARRAY inv_array(ARRAY);
ARRAY convert_to_floatarray(ARRAY a);
ARRAY convert_to_intarray(ARRAY a);
void free_array(ARRAY arr);
void convert_float_to_int_array(int vnr1, int vnr2);
void convert_int_to_float_array(int vnr1, int vnr2);
void copy_int_array(int vnr1, int vnr2);
void copy_float_array(int vnr1, int vnr2);
void copy_string_array(int vnr1, int vnr2);
void fill_string_array(int vnr, STRING inh);
void erase_string_array(int vnr);
ARRAY convert_to_floatarray(ARRAY *a);
ARRAY convert_to_intarray(ARRAY *a);
ARRAY get_subarray(ARRAY *arr,int *indexliste);
void array_add(ARRAY a1, ARRAY a2);
void array_sub(ARRAY a1, ARRAY a2);
void array_smul(ARRAY a1, double m);
void feed_array_and_free(int, ARRAY);
void free_array(ARRAY *arr);
/* Operieren auf Variablen */
void fill_int_array(int, int);
void fill_float_array(int, double);
void array_zuweis_and_free(char *, ARRAY);
void free_array(ARRAY);
int anz_eintraege(ARRAY a);
int do_dimension(int vnr);
void fill_string_array (ARRAY *,STRING );
void fill_int_array (ARRAY *,int);
void fill_float_array (ARRAY *,double);
int do_dimension (VARIABLE *v);
int anz_eintraege(ARRAY *a);
char *arrptr(char *n);
char *arrptr(PARAMETER *,int);
void *arrayvarptr(int vnr, char *n,int size);
void *arrayvarptr2(int vnr, int *indexliste,int size);
STRING array_to_string(ARRAY inhalt);
ARRAY string_to_array(STRING in);
int make_indexliste(int dim, char *pos, int *index);
void make_indexliste_plist(int dim, PARAMETER *p, int *index);
This diff is collapsed.
......@@ -8,23 +8,29 @@
#define BC_STACKLEN 256
#define BC_VERSION 0x117
#define BC_VERSION 0x118
typedef struct {
unsigned char BRAs; /* DC_BRAs */
unsigned char offs; /* sizeof(BYTECODE_HEADER)-2*/
unsigned long textseglen; /* size of the text/code segment */
unsigned long dataseglen; /* size of the data segment */
unsigned long bssseglen; /* not used */
unsigned long rodataseglen; /* size of the readonly data segment */
unsigned long sdataseglen; /* size of the data segment for DATA statements*/
unsigned long dataseglen; /* size of the data segment */
unsigned long bssseglen; /* storage space for variables */
unsigned long symbolseglen; /* size of the symbol table segment */
unsigned long stringseglen; /* size of the string segment */
unsigned short reserved; /* reserved, not used */
unsigned long relseglen; /* size of the relocation data */
unsigned short flags; /* not used */
unsigned short version; /* version, currently=0x117 */
} BYTECODE_HEADER;
#define EXE_REL 1 /* If relocation is needed */
typedef struct {
unsigned short typ; /* Typ of the symbol */
unsigned char typ; /* Typ of the symbol */
unsigned char subtyp;
unsigned long name; /* Pointer to Symbol string table */
unsigned long adr; /* address */
} BYTECODE_SYMBOL;
......@@ -67,11 +73,11 @@ typedef struct {
/* 00010101 --- */
#define BC_BSR 0x16 /* 00010110 --- BSR Branch to Subroutine */
#define BC_JSR 0x17 /* 00010111 --- JSR jump to Subroutine */
/* 00011000 --- */
#define BC_BLKSTART 0x18 /* 00011000 --- Save context */
#define BC_BEQs 0x19 /* 00011001 --- BEQ.s short Branch if 0 */
#define BC_BEQ 0x1a /* 00011010 --- BEQ short Branch if 0 */
#define BC_JEQ 0x1b /* 00011011 --- JEQ jump if 0 */
/* 00011100 --- */
#define BC_BLKEND 0x1c /* 00011100 --- Restore context */
/* 00011101 --- */
/* 00011110 --- */
#define BC_RESTORE 0x1f /* 00011111 --- RESTORE Restore datapointer */
......@@ -148,18 +154,32 @@ typedef struct {
/* Gruppe 10: Operatoren (x in 0 out) */
#define BC_POP 0xa0 /* 10100000 --- POP */
#define BC_CLEAR 0xa4 /* 10100100 --- CLEAR remove all elements from stack*/
#define BC_LOCAL 0xa6 /* 10100110 --- LOCAL */
#define BC_NOOP 0xa8 /* 10101000 --- NOOP */
#define BC_ZUWEIS 0xac /* 10101100 --- ZUWEIS */
#define BC_ZUWEIS 0xae /* 10101110 --- ZUWEIS */
#define BC_COMMENT 0xaf /* 10101111 --- Comment */
/* Gruppe 11: Variablen Management */
#define BC_PUSHA 0xb0 /* 10110000 --- */
#define BC_PUSHVVI 0xb0 /* 10110000 --- */
#define BC_ZUWEISINDEX 0xb3 /* 10110011 --- */
#define BC_EVAL 0xb4 /* 10110100 --- EVAL */
#define BC_PUSHV 0xb8 /* 10111000 --- PUSHV */
#define BC_PUSHVV 0xbc /* 10111100 --- PUSHVV */
#define BC_PUSHARRAYELEM 0xbf /* 10111111 --- PUSHARRAYELEM */
/* Gruppe 12: Memory Management */
#define BC_LOADi 0xc3 /* 11000011 --- push integer from address*/
#define BC_LOADf 0xc7 /* 11000111 --- push float from address */
#define BC_LOADs 0xcb /* 11001011 --- push string from address */
#define BC_LOADa 0xcf /* 11001111 --- push array from address */
/* Gruppe 13: Memory Management */
#define BC_SAVEi 0xd3 /* 11010011 --- store integer from address*/
#define BC_SAVEf 0xd7 /* 11010111 --- store float from address */
#define BC_SAVEs 0xdb /* 11011011 --- store string from address */
#define BC_SAVEa 0xdf /* 11011111 --- store array from address */
#define BC_FALSE BC_PUSH0 /* Push a logical FALSE */
#define BC_TRUE BC_PUSHM1 /* Push a logical TRUE */
......@@ -178,3 +198,35 @@ PARAMETER *virtual_machine(STRING, int *);
void bc_jumptosr2(int ziel);
void plist_to_stack(PARAMETER *pp, short *pliste, int anz, int pmin, int pmax);
void compile();
void bc_pushv_name(char *var);
void bc_pushv(int vnr);
void bc_zuweis_name(char *var);
int vm_x2i(PARAMETER *sp);
int vm_x2f(PARAMETER *sp);
int vm_add(PARAMETER *sp);
int vm_sub(PARAMETER *sp);
int vm_mul(PARAMETER *sp);
int vm_pow(PARAMETER *sp);
int vm_mod(PARAMETER *sp);
int vm_equal(PARAMETER *sp);
int vm_greater(PARAMETER *sp);
int vm_less(PARAMETER *sp);
int vm_sysvar(PARAMETER *sp,int n);
int vm_ssysvar(PARAMETER *sp,int n);
int vm_asysvar(PARAMETER *sp,int n);
int vm_dup(PARAMETER *sp);
int vm_exch(PARAMETER *sp);
int vm_neg(PARAMETER *sp);
void cast_to_real(PARAMETER *sp);
void cast_to_int(PARAMETER *sp);
int vm_sfunc(PARAMETER *sp,int i, int anzarg);
int vm_func(PARAMETER *sp,int i, int anzarg);
int vm_comm(PARAMETER *sp,int i, int anzarg);
int vm_pushvv(int vnr,PARAMETER *sp);
int vm_zuweis(int vnr,PARAMETER *sp);
void zuweis_v_parameter(VARIABLE *v,PARAMETER *p);
int vm_zuweisindex(int vnr,PARAMETER *sp,int dim);
int vm_pusharrayelem(int vnr,PARAMETER *sp, int dim);
int vm_pushv(int vnr,PARAMETER *sp);
void push_v(PARAMETER *p, VARIABLE *v);
int vm_eval(PARAMETER *sp);
......@@ -13,9 +13,11 @@
#include <stdlib.h>
#include "defs.h"
#include "options.h"
#include "vtypes.h"
#include "globals.h"
#include "x11basic.h"
#include "variablen.h"
#include "xbasic.h"
int ccs_err;
/* Falls mit Kontrollsystem */
......@@ -45,6 +47,8 @@ int pidanz=0;
#include "attrdef.h"
#include "resourcebaseman.h"
/* Kontrollsystemstuff */
void cs_init() {
......@@ -312,41 +316,33 @@ ARRAY *csvget(char *n,int nn, int o) {
}
char *csgets(char *n) {
char *ergebnis,s[256];
int pid,j;
int pid;
ccs_convert_parametername_id(n, &pid );
if (CCSERR) {
printf("ERROR in ccs_convert_parametername_id\n");
ergebnis=malloc(8);
strcpy(ergebnis,"<ERROR>");
ccs_err=CCSERR;
return(ergebnis);
return(strdup("<ERROR>"));
} else {
/* switch appropriate to type */
if ( IS_PID_STRING(pid) ) {
int bytes;
char s[256];
ccs_get_value( pid, s, &bytes, sizeof(s), NULL );
if (CCSERR) {
printf("ERROR in ccs_get_value: %s\n", ccs_get_error_message());
ergebnis=malloc(8);
strcpy(ergebnis,"<ERROR>");
ccs_err=CCSERR;
return(ergebnis);
return(strdup("<ERROR>"));
}
ergebnis=malloc(strlen(s)+1);
strcpy(ergebnis,s);
ccs_err=CCSERR;
return(ergebnis);
return(strdup(s));
} else {
xberror(47,n); /* Parameter hat falschen Typ */
ergebnis=malloc(8);
strcpy(ergebnis,"<ERROR>");
ccs_err=CCSERR;
return(ergebnis);
return(strdup("<ERROR>"));
}
}
}
......@@ -425,7 +421,7 @@ void c_csvput(char *w) {
/* Typ bestimmem. Ist es Array ? */
typ=type2(n);
typ=type(n)&(~CONSTTYP);
if(typ & ARRAYTYP) {
r=varrumpf(n);
vnr=variable_exist(r,typ);
......@@ -509,15 +505,15 @@ void c_csput(char *w) {
free(test);
/* switch appropriate to type */
if ( IS_PID_ANALOG(pid) && (type2(t) & (FLOATTYP|INTTYP)) ) {
if ( IS_PID_ANALOG(pid) && (type(t) & (FLOATTYP|INTTYP)) ) {
f=(float)parser(t);
ccs_put_value_secure( pid, 1, &f, &j );
if (CCSERR) printf("ERROR in ccs_set_value: %s\n", ccs_get_error_message());
} else if ( IS_PID_DIGITAL(pid) && (type2(t) & (FLOATTYP|INTTYP)) ) {
} else if ( IS_PID_DIGITAL(pid) && (type(t) & (FLOATTYP|INTTYP)) ) {
i=(int)parser(t);
ccs_put_value_secure( pid, 1, &i, &j );
if (CCSERR) printf("ERROR in ccs_set_value: %s\n", ccs_get_error_message());
} else if ( IS_PID_STRING(pid) && (type2(t) & STRINGTYP) ) {
} else if ( IS_PID_STRING(pid) && (type(t) & STRINGTYP) ) {
test=s_parser(t);
ccs_put_value_secure( pid, strlen(test), test, &j );
free(test);
......@@ -548,7 +544,7 @@ void c_cssweep(char *w) {
free(test);
/* switch appropriate to type */
if ( IS_PID_ANALOG(pid) && (type2(t) & FLOATTYP) ) {
if ( IS_PID_ANALOG(pid) && (type(t) & FLOATTYP) ) {
float end,deltatime;
int nsteps;
e=wort_sep(t,',',TRUE,n,t);
......@@ -1244,13 +1240,13 @@ void c_tineput(char *w) {
dout.dTag[0] = 0;
dout.data.vptr = buf;
if(type2(t)&ARRAYTYP) {
if(type(t)&ARRAYTYP) {
ARRAY abuffer=array_parser(t);
int l=anz_eintraege(abuffer);
int l=anz_eintraege(&abuffer);
int i;
void *ptr=(char *)abuffer.pointer+abuffer.dimension*INTSIZE;
l=min(l,dout.dArrayLength);
printf("Ist Vektor [%d]!!!\n",anz_eintraege(abuffer));
printf("Ist Vektor [%d]!!!\n",anz_eintraege(&abuffer));
if(abuffer.typ & (FLOATTYP|INTTYP)) {
/* Tu was hier !!! */
switch (LFMT(prpinfo.prpFormat)) {
......@@ -1291,10 +1287,10 @@ void c_tineput(char *w) {
break;
default:
printf("output format type %d is not numeric !\n",LFMT(prpinfo.prpFormat));
free_array(abuffer);
free_array(&abuffer);
free(buf);return;
}
} else if(type2(t) & STRINGTYP) {
} else if(type(t) & STRINGTYP) {
switch (LFMT(prpinfo.prpFormat)) {
case CF_BYTE:
case CF_TEXT:
......@@ -1309,15 +1305,15 @@ void c_tineput(char *w) {
break;
default:
printf("output format type %d is not a Stringtype !\n",LFMT(prpinfo.prpFormat));
free(buf);free_array(abuffer); return;
free(buf);free_array(&abuffer); return;
}
}
free_array(abuffer);
free_array(&abuffer);
} else {
/* switch appropriate to type */
if(type2(t) & (FLOATTYP|INTTYP)) {
if(type(t) & (FLOATTYP|INTTYP)) {
switch (LFMT(prpinfo.prpFormat)) {
case CF_BYTE:
*((char *)buf)=(char)parser(t); break;
......@@ -1333,7 +1329,7 @@ void c_tineput(char *w) {
printf("output format type %d is not a number !\n",LFMT(prpinfo.prpFormat));
free(buf);return;
}
} else if(type2(t) & STRINGTYP) {
} else if(type(t) & STRINGTYP) {
STRING sss=string_parser(t);
memcpy(buf,sss.pointer,min(sss.len,buflen));
free(sss.pointer);
......@@ -1402,7 +1398,7 @@ int tineserver_callback(char *devName,char *Property, DTYPE *dout, DTYPE *din, s