Skip to main content.
IBAN   NL79 ABNA 0477 3565 08
EU-VAT NL170160656B01
Chamber of Commerce 32041148
http://www.compuphase.com
Eerste Industriestraat 19-21
1401VL  Bussum
tel. +31 35 693 9261
info@compuphase.com
CompuPhase

The Small language forum - message archive for 2001

 

The archive is sorted on date; the oldest messages appear first.


[67] Suggestion: counting branching

Posted By Jim Bellinger on January 01, 2001 at 16:28:07:

It'd be nice if the AMX addin piece could count branches or somesuch and break after a user specified count (as an option). This would be very convenient as I really can't have infinate loops happening (would be very very bad). Thanks, just a suggestioN! :)


[68] Re: Suggestion: counting branching

Posted By Thiadmer Riemersma on January 02, 2001 at 11:37:34:

In Reply to: Suggestion: counting branching posted byJim Bellinger on January 01, 2001 at 16:28:07:

: It'd be nice if the AMX addin piece could count branches or somesuch and break after a user specified count (as an option). This would be very convenient as I really can't have infinate loops happening [...]

I uploaded a new manual which explains how to do this (in the chapter on the abstract machine). The SRUN sample now contains some more-or-less portable code to achieve this.

Thiadmer


[69] how to sleep

Posted By jaleco on January 02, 2001 at 22:51:26:

hi I am newbies to SMALLC ,
if have a question how to "sleep"
should if use "#emit opcode", or ....

and how to resume ? just call AM_EXEC,again ???


[70] Re: how to sleep

Posted By Thiadmer Riemersma on January 03, 2001 at 03:40:12:

In Reply to: how to sleep posted byjaleco on January 02, 2001 at 22:51:26:

: if have a question how to "sleep"
: should if use "#emit opcode", or ....

: and how to resume ? just call AM_EXEC,again ???

The "sleep" functionality is very new, very undocumented and very unfinished...

1. You have to use "#emit sleep 0" where 0 may be replaced by some other value. amx_Exec() will hold that value in its "result" parameter.

2. To resume, call amx_Exec() with the pseudo function index AMX_EXEC_CONT (instead of AMX_EXEC_MAIN or a real index of a public function).


[71] Re: how to sleep

Posted By jaleco on January 03, 2001 at 05:00:54:

In Reply to: Re: how to sleep posted byThiadmer Riemersma on January 03, 2001 at 03:40:12:

thanks for reply ,
I found a bug,
new a = 10 ;
new i = 0 ;
for (i = 0 ;i<10;i++)
{
printf("^nstart %d,%d",a,i) ;
#emit sleep

}

I didn't type sleep 0
this cause strang result
,then I look assmebly
I know why , because it become
"sleep jump 0" not
sleep
jump 0 ,
I wonder why it no error message


[72] how to make fix size program

Posted By jaleco on January 03, 2001 at 05:04:32:

I am build a application,
I want my script do run , by an absolut size,
how to do this ?


[73] Re: how to sleep

Posted By Søren Hannibal on January 03, 2001 at 12:02:29:

In Reply to: Re: how to sleep posted byjaleco on January 03, 2001 at 05:00:54:

Without having looked at how the compiler handles the #emit I would guess that if you don't type a number it won't store a number after the opcode and if you do it will store it.

AFAIK #emit was written to test assembler commands, and the compiler has no clue about whether this opcode uses a variable or not. Therefore "it's not a bug, it's a feature". The final implementation will not use the #emit function so the bug will be eliminated automatically.

-Soren

: thanks for reply ,
: I found a bug,
: new a = 10 ;
: new i = 0 ;
: for (i = 0 ;i<10;i++)
: {
: printf("^nstart %d,%d",a,i) ;
: #emit sleep
:
: }

: I didn't type sleep 0
: this cause strang result
: ,then I look assmebly
: I know why , because it become
: "sleep jump 0" not
: sleep
: jump 0 ,
: I wonder why it no error message



[74] Re: how to sleep

Posted By Thiadmer Riemersma on January 04, 2001 at 08:46:55:

In Reply to: Re: how to sleep posted bySøren Hannibal on January 03, 2001 at 12:02:29:

#emit is very primitive; it was indeed intended to test instructions before "carving them in stone". Nevertheless, I will check the #emit directive: it should not append other data on the same line.

Thiadmer


[75] Re: how to make fix size program

Posted By Thiadmer Riemersma on January 04, 2001 at 08:51:54:

In Reply to: how to make fix size program posted byjaleco on January 03, 2001 at 05:04:32:

: I want my script do run , by an absolut size,
: how to do this ?

If I understand you correctly, you want a compiled Small program to fit in, say, 10 kBytes exactly, no more, not less. This, you cannot do in Small.

With a post-processing step, what you could to is to adjust the stack size after compiling. The total of the program size (code + data) subtracted from the fixed memory space then gives the (new) stack size. You can play with "#pragma dynamic nnn" until it fits, or build a program that changes the stack size value in the header of the compiled file.


[76] Life sign

Posted By Marc Peter on January 05, 2001 at 10:49:52:

Hello everyone!

Just to show I'm still alive and willing to participate
further in the developement of Small, I'm posting this
message.

Of course my primary concern is in the core implemen-
tation of the abstract machine in assembler and the
JIT compiler.

For this I have a suggestion: With the Watcom
compiler going open source there is one special thing
going to be possible: Translate Small into temporay
C code and compile this using an embedded version
of the Watcom compiler. This would yield yet another
great speed boost, as well as simplify the interface
to the AMX. I have to admit though, that with this
solution Small won't be that light weight scripting
engine anymore. Comments? Thiadmer?

Regards
Marc

ps: If you encounter problems with the asssembler
AMX implementations, you should drop me a mail in
addition to posting here, as this will yield a better
response time...


[77] How to prevent user from accessing parent directories etc of INCLUDE directory

Posted By Jim Bellinger on January 07, 2001 at 17:33:06:

For security I need to be able to not allow using INCLUDE files that are in directories such as ..\blah.inc, or C:\blah.inc, etcetra. How can this be done? Thank you.

By the way, I am not sure if this is too much to ask but would it be possible to have floating point support in the future? That would be very useful. Thank you. :)


[79] Re: How to prevent user from accessing parent directories etc of INCLUDE directory

Posted By Thiadmer Riemersma on January 08, 2001 at 07:15:43:

In Reply to: How to prevent user from accessing parent directories etc of INCLUDE directory posted byJim Bellinger on January 07, 2001 at 17:33:06:

: For security I need to be able to not allow using INCLUDE files that are in directories such as ..\blah.inc, or C:\blah.inc, etcetra. How can this be done?

You would need to modify the compiler. In the file SC2.C, you could modify the function plungefile() to fail for every filename that starts with "X:" (where "X" is just any letter) or that contains a ".." substring anywhere in its path.

I don't know what you mean with "security" in this case, or how this limitation could enhance it. Is this a feature that more users could find useful?

: By the way, I am not sure if this is too much to ask but would it be possible to have floating point support in the future?

I have done some initial steps toward "operator overloading" which, in combination with native functions working on floats, would make working with floating point a lot easier. But I cannot say when I will finish this feature (if at all).

Thiadmer


[80] Re: Life sign

Posted By Thiadmer Riemersma on January 08, 2001 at 07:15:54:

In Reply to: Life sign posted byMarc Peter on January 05, 2001 at 10:49:52:

Hello Peter,

Happy new year. Small is still alive too, and evolving slowly.

: [...] With the Watcom
: compiler going open source there is one special thing
: going to be possible: Translate Small into temporay
: C code and compile this using an embedded version
: of the Watcom compiler. This would yield yet another
: great speed boost, as well as simplify the interface
: to the AMX. I have to admit though, that with this
: solution Small won't be that light weight scripting
: engine anymore. Comments? Thiadmer?

At first thought, a JIT should be able to reach about the same performance as code that is compiled directly (see this as a ballpark measure). Compiled C is probably faster than Small+JIT because the Small compiler does not optimize the code very well, and the JIT does not post-optimize either. You could come quite close, I think, to achieving the performance level of compiled C with an optimizing Small compiler and an optimizing JIT.

That said, code optimization has also been off my mind lately, as the performance of your assembler virtual machine is adequate for my needs (and I have received some praise and no complaints on the performance of Small).

: ps: If you encounter problems with the asssembler
: AMX implementations, you should drop me a mail in
: addition to posting here, as this will yield a better
: response time...

I have made some modifications to the assembler interpreter (AMXEXEC.ASM) to support a few new opcodes. This interpreter is very stable and used in production. The JIT also saw some modifications, but it is slightly out of date: I am not sure whether it (still) assembles with MASM and the newly introduced SLEEP opcode is lacking.



[81] Re: How to prevent user from accessing parent directories etc of INCLUDE directory

Posted By James Bellinger on January 09, 2001 at 17:32:19:

In Reply to: Re: How to prevent user from accessing parent directories etc of INCLUDE directory posted byThiadmer Riemersma on January 08, 2001 at 07:15:43:

: You would need to modify the compiler. In the file SC2.C, you could modify the function plungefile() to fail for every filename that starts with "X:" (where "X" is just any letter) or that contains a ".." substring anywhere in its path.

: I don't know what you mean with "security" in this case, or how this limitation could enhance it. Is this a feature that more users could find useful?

Oh, THEY won't find it useful, but as the script gives access to some of the internals of the engine and it is a multiplayer online game I don't want a disgruntled gamemaster to be able to do any damage to the server.

: : By the way, I am not sure if this is too much to ask but would it be possible to have floating point support in the future?

: I have done some initial steps toward "operator overloading" which, in combination with native functions working on floats, would make working with floating point a lot easier. But I cannot say when I will finish this feature (if at all).

: Thiadmer

That'd be great. Floating point would be most helpful :)


[82] Re: Life sign

Posted By Marc Peter on January 10, 2001 at 10:14:03:

In Reply to: Re: Life sign posted byThiadmer Riemersma on January 08, 2001 at 07:15:54:

: Hello Peter,

: Happy new year. Small is still alive too, and evolving slowly.

Oh yes, I forgot. Seasons Greetings, too, from me.
Regarding the evolving of Small, I have some ideas
as well. I will send them in a different post.


: That said, code optimization has also been off my mind lately, as the performance of your assembler virtual machine is adequate for my needs (and I have received some praise and no complaints on the performance of Small).

Glad to hear that. Maybe I was a bit too enthusiastic about the Open Source Watcom...


: The JIT also saw some modifications, but it is slightly out of date: I am not sure whether it (still) assembles with MASM and the newly introduced SLEEP opcode is lacking.

I'm going to have a look at it. Updating the JIT with an opcode can't be that tricky. I think I can remember that I once tried the JIT with M$ VC4.0 and it worked.

Cheers
Marc (That's my first name, btw)



[83] Re: How to prevent user from accessing parent directories etc of INCLUDE directory

Posted By Marc Peter on January 10, 2001 at 10:21:36:

In Reply to: How to prevent user from accessing parent directories etc of INCLUDE directory posted byJim Bellinger on January 07, 2001 at 17:33:06:

: By the way, I am not sure if this is too much to ask but would it be possible to have floating point support in the future? That would be very useful. Thank you. :)

The way I would implement this, is by having a native function that takes a string with a formula and returns a handle that can be given to another function (along with any desired parameters) to calculate a value. That wouldn't require a single change to the small compiler.
(Positive floats can be compared in integer mode, too, if that helps. Anyway, there would be relational operators in the string-grammer to implement coparision of arbitrary floats.) I've already done this kind of parser in Java for my diploma, so this wouldn't be a problem.

Any comments?

Cheers
Marc


[84] unsigned numbers

Posted By Tim Newsome on January 26, 2001 at 19:42:35:

I'm looking to support unsigned compares in Small. I think the most natural way would be to turn < etc. into unsigned, and then have functions to do signed compares. I can see how to make that change (mess with os_lt etc), but I'm wondering if there are other assumptions in the compiler somewhere that would break horribly if I were to do that.

Tim


[85] Re: unsigned numbers

Posted By Thiadmer Riemersma on January 29, 2001 at 03:45:19:

In Reply to: unsigned numbers posted byTim Newsome on January 26, 2001 at 19:42:35:

: I'm looking to support unsigned compares in Small. I think the most natural way would be to turn < etc. into unsigned, and then have functions to do signed compares. I can see how to make that change (mess with os_lt etc), but I'm wondering if there are other assumptions in the compiler somewhere that would break horribly if I were to do that.

One other assumetion that I am aware of is the "constant folding" optimization, which calculates the result of both sides of an operator are constant (e.g. "5 < 8"). This algorithm also assumes signed cells.

Of course, for unsigned numbers, you would have to modify the "lex()" routine to be able to read in numbers larger than the maximum signed value of a cell.

The original Small C, which was the basis for Small, supported both signed and unsigned integers. I removed this, assuming that signed large integers would be "big enough" for purposes that Small would be used. This led to the introduction of a new operator ">>>" for (unsigned shift right").


[86] Multi-module Small programs

Posted By Brian Poe on January 31, 2001 at 14:51:10:

To emulate a multi-module program, is the preferred way to create a "project" .sma file that simply
#includes each file in the project?


[87] Re: Multi-module Small programs

Posted By Thiadmer Riemersma on February 01, 2001 at 07:20:03:

In Reply to: Multi-module Small programs posted byBrian Poe on January 31, 2001 at 14:51:10:

: To emulate a multi-module program, is the preferred way to create a "project" .sma file that simply
: #includes each file in the project?

Yes, that is the only way to do it. The Small compiler is a two-pass, and strips off functions that the program never calls (but you should prefix such optional functions with the "stock" keyword to avoid a warning).

Thiadmer


[88] Floating point (again)...

Posted By Brian Poe on February 01, 2001 at 12:52:22:

Thiadmer, could you briefly outline how Small could be modified to "natively" work with floating
point numbers? By this i mean support for code such as;

new float fX, fY, fZ;
fX = 1.25
fY = 3.25;
fZ = fX * pow(fY) / fX

...you get the idea. I'd be willing to spend a substantial amount of time on the Small source to get
floating point implemented.

thanks,Brian Poe



[89] Re: Floating point (again)...

Posted By Thiadmer Riemersma on February 02, 2001 at 04:07:23:

In Reply to: Floating point (again)... posted byBrian Poe on February 01, 2001 at 12:52:22:

: Thiadmer, could you briefly outline how Small could be modified to "natively" work with floating
: point numbers? By this i mean support for code such as;

: new float fX, fY, fZ;
: fX = 1.25
: fY = 3.25;
: fZ = fX * pow(fY) / fX

If you want to modify Small so that it uses ONLY floating point, you must change the lexographic analysis functions (lex() and number() in SC2.C) to understand floating point literals. Then you must modify at least functions calc() in SC3.C, which is used for constant folding. I think all other changes would be in the abstract machine. In the abstract machine, all arithmetic must be done with floating point, of course, but pay attention for the few implicit comparisons to zero.

If you wish to have Small support both floating point and integers, you will need to re-introduce a kind of "type mechanism" that I removed from the original "Small C" (on which I based Small). In addition to the changes mentioned above, you must add a "type" field to the "symbol", "value" and "constval" structures (SC.H) and modify the expression parser in SC3.C to select the correct operation depending of the types of the operands on both sides of an operator. Then you must generate code for the new floating point operations, requiring changes in SC4.C (code generator) and SC6.C (assembler). Adding error messages is simple, but note that the message table is compressed and that the source and the compressed data are in the same file (SC5.SCP). You should add the new message to the "readable" part of one of the message tables. You may also want to adjust the peephole optimizer. Modifying the AMX is also more work, because many new opcodes (for dealing with floating point) will need to be implemented.

All in all, this is indeed a large investment.

For a compromise, I am currently working on "overloadable operators" in Small. The operator will choose which function to use based on the tags of the operands. So I am not introducing "types" in Small, and there is no type checking; Small has "tag checking" (and this tag checking may need to be made stricter for the purpose of overloaded operators --we'll see). The difference between tags and types may appear subtle, but tags are much more limited: Small will not be able to perform "constant folding" on floating point values, and you will not be able to use floating point constants in preprocessor directives. For convenience, I will try to make one exception: the lex() and number() functions should know how to handle floating point constants.

With overloaded operators, your demo program would look like:

new float:fX, float:fY, float:fZ
fX = 1.25
fY = 3.25
fZ = fX * pow(fY) / fX

plus, of course, the definitions of the overloaded operators:

native operator*(float:a, float:b) = flt_mult
native operator/(float:a, float:b) = flt_div

Now, when will I get this working? I don't know. Since my company doesn't make money on Small, it comes last. I would expect to have it implemented in a month, but don't be disappointed if I am late.


Some background information
---------------------------
When designing Small, I chose integers for two reasons: 1) for the applications that I had in mind (animation), I needed to be able to rule out rounding errors. 2) in interfacing with native functions, I was going to store all kinds of "handles" in a cell. Those handles could be pointers to internal data in the host application. For Small programs, a "handle" was just a magic value, some random bit pattern. With 32-bit integers as a cell, this works, but not all bit patterns form valid floating point numbers and I read that some processors issue an exception when you try to store an invalid bit pattern in a floating point register.


[90] Re: Floating point (again)...

Posted By Brian Poe on February 02, 2001 at 17:06:58:

In Reply to: Re: Floating point (again)... posted byThiadmer Riemersma on February 02, 2001 at 04:07:23:

Thank you for your detailed response. The overloaded
operators looks very promising so i will hold out
and see how that performs. Could a preprocessor
step simplify the declaration of a "float" type i.e.
"new float fX, fY, fZ;" where the preprocessor would
emit the proper "tagged" declaration new float:fX, float:fY, float:fZ; ??


[91] Re: Floating point (again)...

Posted By Thiadmer Riemersma on February 05, 2001 at 05:17:27:

In Reply to: Re: Floating point (again)... posted byBrian Poe on February 02, 2001 at 17:06:58:

: Could a preprocessor step simplify the declaration of a "float" type i.e.
: "new float fX, fY, fZ;" where the preprocessor would
: emit the proper "tagged" declaration new float:fX, float:fY, float:fZ; ??

Possibly, but I am not going to adapt the preprocessor for such a purpose: it adds too much complexity (starting from the fact that the preprocessor is line-based and the compiler is token-based). In most cases, there is a work-around. Instead of the common C-like way to handle variables (declare first, initialize later) I would like to have Small promote the C++ way (declare and initialize where needed). In other words, I would encourage you to write the example snippet presented earlier as:

new float:fX = 1.25
new float:fY = 3.25;
new float:fZ = fX * pow(fY) / fX

Thiadmer


[92] Re: Floating point (again)...

Posted By Brian Poe on February 05, 2001 at 11:57:41:

In Reply to: Re: Floating point (again)... posted byThiadmer Riemersma on February 05, 2001 at 05:17:27:

That is not to say this would not fit into your proposed mods?;

new float:fX = 1.25
new float:fY = 3.25;
new float:fZ = fX * pow(fY) / fX
.
.
.
fZ = .......


[93] Re: Floating point (again)...

Posted By Thiadmer Riemersma on February 06, 2001 at 05:48:56:

In Reply to: Re: Floating point (again)... posted byBrian Poe on February 05, 2001 at 11:57:41:

: That is not to say this would not fit into your proposed mods?;

Exactly


[94] amx_SetString impact on stack/heap

Posted By Florian Zschocke on February 08, 2001 at 09:56:16:

I am a newbie on Small and I have a question on how amx_SetString handles the stack/heap. What happens, when you set a C string to AMX string which is smaller than the AMX string? Imagin the following code:

Some Small program:

main() {
new s1[5];
native_function(s1);
printf("s1: %s\n", s1);
}

And some C code which implements the native_function:

static cell native_function( /* ... */ ) {
char string[21] = "01234567899876543210";
cell* cstr;
/* get the address for the Small string */
amx_SetString(cptr, string , 0);
}

Is this safe to use? Does SetString know how large the string in the VM is? What is going to be the output of the Small program? Am I wrecking havoc on the stack or heap with this? I read in one post that the VM does not allocate dynamic memory. So I guess that the string is not expanded to hold the full string passed in from C. Would there be a way to have it expanded?

Thanks,
Florian.


[95] Re: amx_SetString impact on stack/heap

Posted By Thiadmer Riemersma on February 09, 2001 at 08:34:05:

In Reply to: amx_SetString impact on stack/heap posted byFlorian Zschocke on February 08, 2001 at 09:56:16:

A native function that stores a string that is larger than what the Small program has allocated for it, overwrites the data in the Small "abstract machine". Obviously, native functions should try to avoid this. Unfortunately, a native function cannot always know the bounds of an array. I consider the following rules:

1. In general, use arrays with an indeterminate length only for input. If a native function needs to store data in an array that is passed in as a parameter, declare this array parameter with a fixed size. For example:
     native init_vector(vect[4], x, y, z)

2. If the first rule is cumbersome (as in the case of string functions), the native function can check whether it overwrites the bounds of the stack (or heap) or of the global data, but it cannot check whether it possibly overwrites part of another variable (while staying in the bounds of the stack/heap/data). You may want to add a "size" parameter to the native function so that the Small program already says how big the array is.

You cannot currently grow arrays dynamically. A native function can allocate memory inside the abstract machine, but the only way that a Small routine can access that memory is when the native function calls amx_Exec() and passes the address as a parameter.

Thiadmer


[96] multiple-instances of the same code

Posted By wastiee on February 13, 2001 at 10:53:06:

Well, i haven't dig into Small very much yet, i was searching for a usable stable and binary scripting language to use in a new MUD (Multi User Dungeon), mostly for NPC (non-player character) AIs, and also for other things, like item-scripts, etc.

So, this means that, if there're 100 of the same NPC in the MUD World, then there'll be 100 different AIs running. Will Small interpreter (virtual machine, whatever it's called :P) allocate memory for each instance's code differently, or will it use the same code-memory-area with different memory addresses for data?


[97] Re: multiple-instances of the same code

Posted By Thiadmer Riemersma on February 14, 2001 at 03:17:35:

In Reply to: multiple-instances of the same code posted bywastiee on February 13, 2001 at 10:53:06:

: [...], if there're 100 of the same NPC in the MUD World, then there'll be 100 different AIs running. Will Small interpreter (virtual machine, whatever it's called :P) allocate memory for each instance's code differently, or will it use the same code-memory-area with different memory addresses for data?

Small stores code and data in one continuous block, so 100 virtual machines (the manual calls them "abstract machines" or "AMX") with the same code have 100 blocks of memory with that code.

Separating code from data and re-using code has long been on the wish list, but I have not yet implemented it.

Thiadmer


[98] Limiting the number of instructions to be run

Posted By Kerem 'wastiee' HADIMLI on February 15, 2001 at 10:17:19:

Well, is it possible to say the main exec function something like 'execute 50 instuctions, save state, and return', and then, after the program calls it again, it should continue from where it paused?

The reason i need something like this is, i'm planning to run multiple AMXes in an unthreaded program (multiplayer text-adventure server) in a "main_loop()".

If anyone implemented something like this, or have ideas about how this can be implemented, please reply.

Regards,
Kerem 'wastiee' HADIMLI


[99] Re: Limiting the number of instructions to be run

Posted By Kerem 'wastiee' HADIMLI on February 15, 2001 at 17:41:50:

In Reply to: Limiting the number of instructions to be run posted byKerem 'wastiee' HADIMLI on February 15, 2001 at 10:17:19:

I have just examined the code a little bit more, and read the topic named 'how to sleep'.

I guess it'll work if i put a counter variable to it, that'll increase by each instruction, and when it becomes equal to some number (probably a number passed as parameter to amx_Exec()), it'll execute the same code that's executed when a 'sleep' (defined as "op_halt") instruction is seen.

Will this work? I'll be glad if someone can answer.

Regards,
Kerem 'wastiee' HADIMLI


[100] Re: Limiting the number of instructions to be run

Posted By Thiadmer Riemersma on February 19, 2001 at 04:49:51:

In Reply to: Limiting the number of instructions to be run posted byKerem 'wastiee' HADIMLI on February 15, 2001 at 10:17:19:

: Well, is it possible to say the main exec function something like 'execute 50 instuctions, save state, and return', and then, after the program calls it again, it should continue from where it paused?

You can detect how many source code lines were executed (this is not the same as "instructions") with a "debug hook". The "srun" example shows this and (I think) the manual also has a section on it.

The tricky bit now is "restarting". To restart an abstract machine, the full status of the abstract machine should be stored. Currently, only the "sleep" instruction does so. In your case, the debug hook must also be able to store the full status. This is already on my "to do" list.

Thiadmer


[101] Re: Limiting the number of instructions to be run

Posted By Thiadmer Riemersma on February 19, 2001 at 04:53:37:

In Reply to: Re: Limiting the number of instructions to be run posted byKerem 'wastiee' HADIMLI on February 15, 2001 at 17:41:50:

: I guess it'll work if i put a counter variable to it, that'll increase by each instruction, and when it becomes equal to some number (probably a number passed as parameter to amx_Exec()), it'll execute the same code that's executed when a 'sleep' (defined as "op_halt") instruction is seen.

I haven't tried this but, out of the top of my head, this should work.

Thiadmer


[102] regression test

Posted By Dieter Neubauer on March 15, 2001 at 10:00:17:

do you have a regression test that can be used to validate that changes made to small will hurt the code in any other area?

I'm currently porting small to a 16 Bit machine, thereby finding some bugs that only appear with BIT16. Are you interested in getting back the changed sources? in which form?


[103] Re: regression test

Posted By Thiadmer Riemersma on March 15, 2001 at 10:40:17:

In Reply to: regression test posted byDieter Neubauer on March 15, 2001 at 10:00:17:

: do you have a regression test that can be used to validate that changes made to small will hurt the code in any other area?

I have an ad-hoc regression test. Whenever I find a bug, I add a test for that particular bug to my test. The tests are mostly for the compiler. The abstract machine is tested too, but only in one form: usually Watcom/ASM. That is, if a bug is only in the "ANSI C" form of the abstract machine, the regression test is not likely to find it.

: I'm currently porting small to a 16 Bit machine, thereby finding some bugs that only appear with BIT16. Are you interested in getting back the changed sources? in which form?

If you can send me the source code and give me the date of the Small package on which it was based.

Thiadmer


[104] Re: regression test

Posted By Dieter Neubauer on March 16, 2001 at 09:16:26:

In Reply to: Re: regression test posted byThiadmer Riemersma on March 15, 2001 at 10:40:17:

: : do you have a regression test that can be used to validate that changes made to small will hurt the code in any other area?

: I have an ad-hoc regression test. Whenever I find a bug, I add a test for that particular bug to my test. The tests are mostly for the compiler. The abstract machine is tested too, but only in one form: usually Watcom/ASM. That is, if a bug is only in the "ANSI C" form of the abstract machine, the regression test is not likely to find it.

: : I'm currently porting small to a 16 Bit machine, thereby finding some bugs that only appear with BIT16. Are you interested in getting back the changed sources? in which form?

: If you can send me the source code and give me the date of the Small package on which it was based.

: Thiadmer


Is it possible to get your regression test or is it downloadabel in any area?


[105] Re: regression test

Posted By Thiadmer Riemersma on March 17, 2001 at 09:27:28:

In Reply to: Re: regression test posted byDieter Neubauer on March 16, 2001 at 09:16:26:

: Is it possible to get your regression test or is it downloadabel in any area?

I will make it downloadable. The regression test is a set of source files and a large batch file that runs all these source files through the Small compiler. I will keep you informed when I have it uploaded.

Thiadmer


[106] DLL's?

Posted By Joseph Fernald on March 27, 2001 at 11:05:47:

I've spent some time searching through the documentation on the site and have yet to find an answer to this question so I was wondering if one of you would be kind enough to answer. I'm wondering if it's possible to link to C++ dll files and use their functionality in the Small language, if so how? Thanks in advance.


[107] Re: DLL's?

Posted By Steven Blackburn on March 30, 2001 at 07:14:48:

In Reply to: DLL's? posted byJoseph Fernald on March 27, 2001 at 11:05:47:

: I'm wondering if it's possible to link to C++ dll files and use their functionality in the Small language, if so how?

Firstly, I should say that I haven't got around to using Small yet, but intend to in the near future. As such, I cant directly comment on Small but on the problem in general.

The problem with linking from *any* language to a DLL written using C++ is that the C++ compiler mangles the names used by functions to support function overloading. This means that while you think a function should be named "do_something" it will probably be changed to "do_something_iVb" (or some such garbage). Alas, the ANSI standard does not define how the names should be manged, which makes it impossible to predict what names to use when the DLL is loaded. So on the first count, C++ can not be used.

It is possible to write a C++ dll so that names arent mangled, but then your interface can not use classes of overloading. This still might not be supportable by Small though, as DLLs are platform specific and I get the impression that the language should compile on quite a few platforms (Linux, perhaps).

Perhaps you could write a set of native functions which would call the DLLs that you want? This way the language is not polluted with Windows specific things....

Steve.


[108] German translation

Posted By If i only knew! on March 30, 2001 at 08:55:53:

Does anyone know where to get a german translation for the small manual???


[109] problem building compiler

Posted By David Lam on March 30, 2001 at 09:31:45:

I am having problem building the compiler.

In MSVC6, the following were not found during linking:-

_delete_aliastable
_insert_alias
_lookup_alias

These are functions called in sc1 and sc6. The header sc.h suggested that they are in sclist.c. But sclist.c is no where to be found in the smallkit.zip distribution.

Can anyone offer any help?

TIA
David Lam


[110] Re: problem building compiler

Posted By David Lam on March 30, 2001 at 09:36:10:

In Reply to: problem building compiler posted byDavid Lam on March 30, 2001 at 09:31:45:

I forgot to state that the smallkit.zip had a readme.txt file dated 24/03/2001.

Thanks
David Lam

: I am having problem building the compiler.

: In MSVC6, the following were not found during linking:-

: _delete_aliastable
: _insert_alias
: _lookup_alias

: These are functions called in sc1 and sc6. The header sc.h suggested that they are in sclist.c. But sclist.c is no where to be found in the smallkit.zip distribution.

: Can anyone offer any help?

: TIA
: David Lam



[111] Structures

Posted By Richard van Zon on March 30, 2001 at 17:02:57:

I know Small is a typeless language, but in my application I need to define properties to a variable in a structure-way like button.x=30. So it's more like objects than structs, but I thought about solving it with tagnames, but as far as I read, that's not very dynamic in this case.

I mean I can't use variables dynamicly then like button1, button2 etc...
What's the best way and is there a way to simulate structures like described above ?
thanks...


[112] Re: DLL's?

Posted By Thiadmer Riemersma on April 01, 2001 at 08:29:55:

In Reply to: DLL's? posted byJoseph Fernald on March 27, 2001 at 11:05:47:

: I'm wondering if it's possible to link to C++ dll files and use their functionality in the Small language, if so how? Thanks in advance.

I have included a general purpose DLL call function in the DLL versions of the abstract machine; the function is called "calldll()". It is not very well documented, and the corresponding loaddll() and freedll() functions are still missing. I made the function mostly because I needed a quick function to call any Win32 API function and the USER, KERNEL and GDI modules are already loaded for a Win32 "windowed" application.

If you need to call specific native functions from a specific DLL, the DLL just needs to register its functions to the AMX. The readme.txt file has some information on this.

Thiadmer


[113] Re: problem building compiler

Posted By Thiadmer Riemersma on April 01, 2001 at 08:33:37:

In Reply to: problem building compiler posted byDavid Lam on March 30, 2001 at 09:31:45:

I am sorry. The file is missing in the distribution. I will upload a corrected smallkit.zip soon (today if possible).

Thiadmer


[114] Re: Structures

Posted By Thiadmer Riemersma on April 01, 2001 at 08:38:26:

In Reply to: Structures posted byRichard van Zon on March 30, 2001 at 17:02:57:

: I know Small is a typeless language, but in my application I need to define properties to a variable in a structure-way like button.x=30. So it's more like objects than structs, but I thought about solving it with tagnames, but as far as I read, that's not very dynamic in this case.

The closest that one can come to structure is arrays combined with enumerations. The manual skims over the subject, I know, but their is a short description with an example on page 15 (of the latest manual). The example creates a "rectangle" enum and an array based on this: the indices of the array are tag checked.

Thiadmer


[115] Big Endian Compiler

Posted By Robert Daniels on April 13, 2001 at 19:03:44:

I've been attempting to get a version of Small running on a motorola coldfire 5307 running uClinux and have run into some problems with the compiler. I had to make a few tweeks to make it output header information in correct endianess and finally got a simple "Hello World" program to compile and run all on uClinux. When I moved on to bigger and better scripts, my compiler started having problems. I'm wondering if there could be further endian problems, has this compiler been built and tested on a big endian machine? Anyone else out there using small on a big endian machine?


[116] Re: Big Endian Compiler

Posted By Thiadmer Riemersma on April 14, 2001 at 10:19:26:

In Reply to: Big Endian Compiler posted byRobert Daniels on April 13, 2001 at 19:03:44:

: I'm wondering if there could be further endian problems, has this compiler been built and tested on a big endian machine?

A few people wrote me that they intended to port Small to a Macintosh machine, but I have no further news from them. I do not have a big endian machine myself.

I know that at one time there were problems with the header of the .AMX file. I fixed those (I think) but there may be more of those errors left.

Anyway, if you can send me the changes you had to make, I can merge them into the original source, so that you don't have to repeat your modifications every time I update the tools.

Thiadmer


[117] Re: #pragma pack

Posted By Kantharaj Etigi on May 02, 2001 at 11:29:48:

In Reply to: #pragma pack posted byLinus Nuber on November 29, 2000 at 08:45:01:

Hello!

Could any one help me how this " #pragma pack " works in Solaris 7.

When I compile and execute following C program code, it results in "Segmentation Fault(coredump)" while executing gethostbyname system call.

I think it because of pragma. This works fine in winNT.

I appreciate your help in resolving this problem.

Thanks & regards
Kantharaj Etigi

test1.c:
--------


#include
#include
#include
#include
#include
#include
#include
#include
#include


#define BYTE short int
#define ULONG unsigned long
#define RTP_HEADER_SIZE 12


#pragma pack(1)

//typedef struct _RTPPACKET
typedef struct _RTPPACKET
{
BYTE b0;
BYTE b1;
BYTE b2;
BYTE b3;
BYTE b4;
BYTE b5;
BYTE b6;
BYTE b7;
BYTE b8;
BYTE b9;
BYTE b10;
BYTE b11;
BYTE abData[1];
}RTPPACKET;
typedef RTPPACKET * PRTPPACKET;

typedef struct _NODE
{
PRTPPACKET pRTPPacket;
ULONG ulBytesInThisPacket;
ULONG ulTimesPostponed;
struct _NODE * pNext;
} NODE;
typedef NODE * PNODE;

#pragma pack()


void UpdateSilencePacket(void);
int InitRTPProducer(void);
void Init16to8LUT_ULaw(void);

//
// Global variables used by this file
//


PRTPPACKET pRTPSilencePacket = NULL;
unsigned long ulRTPPacketDelay = 40; // Default delay is 40 msecs
unsigned long ulPacketDataLen = 320; // ulRTPPacketDelay * 8
short int bSilenceValue = 127; // Initialize the silence value

/**********************************************************************************
**
** Function: InitRTPProducer
**
** Description:
**
** Parameters: None
**
** Returns: TRUE - success
** FALSE - failure
**
***********************************************************************************/
int InitRTPProducer(void)
{

//
// Initialize the silence packet
//
pRTPSilencePacket = (PRTPPACKET)malloc(RTP_HEADER_SIZE + ulPacketDataLen);
if(pRTPSilencePacket == NULL)
{
return(0);
}

//
// Initialize the 16 to 8 look up table (LUT) -
//
Init16to8LUT_ULaw();


return(1);

} // end of InitRTPProducer

/**********************************************************************************
**
** Function: UpdateSilencePacket
**
** Description: This routine will update the contents of the silence packet
** with the proper silence value
**
** Parameters: None
**
** Returns: None
**
***********************************************************************************/
void UpdateSilencePacket(void)
{
ULONG i;


if(pRTPSilencePacket == NULL)
{
return;
}

for(i = 0; i < ulPacketDataLen; i++)
{
pRTPSilencePacket->abData[i] = bSilenceValue;
}


} // end of UpdateSilencePacket


/**********************************************************************************
**
** Function: Init16to8LUT_ULaw
**
** Description:
**
** Parameters: None
**
** Returns: None
**
***********************************************************************************/
void Init16to8LUT_ULaw(void)
{
ULONG i;

bSilenceValue = 127;
UpdateSilencePacket();

} // end of Init16to8LUT_ULaw


int main(int argc, char * argv[])
{

struct hostent * hp;

InitRTPProducer();

hp =(struct hostent *) gethostbyname("localhost");
if(hp == NULL)
{
return 1;
}

return(0);

} // end of main

testmake.gcc
------------

CFLAGS=-DUNIX -I. -g
CC=gcc

all: mytest

mytest: test1.o
gcc -o $@ $^ -lsocket -lnsl




[118] Succesfully Embedded the Small

Posted By Han cicimen on May 04, 2001 at 08:26:49:

I succesfully embedded small to our new building automation and hospital air climatisation control system. The system controls air temperatures and air speed in high important areas in hospitals like operation rooms, intensive care room etc. The Small is used here to program scenarios and it is installed on a 80386Sx embedded computer. The performance is also excellent. We usd the Small because we wnt to be able to change the scenarios without compiling. We now compile Small programs on PC and download it via FTP. (Our controller support TCP/IP, FTP, HTTP and Telnet)
The system works excellent for more than one month 24 hour a day without a problem or crash down . We plan to expand the project (adding security control etc). Thanks for such a powerfull and small footprint and may be more important reliable language.

Best regards,

HAN CICIMEN


[119] Different headers for Linux and Windows.

Posted By Florian Zschocke on May 09, 2001 at 11:14:27:

The Small compiler, when compiled under Linux,
generates different headers than the Windows version.
Is that an intended behaviour?
We use Small in a cross-platform application and have
to compile Small files seperately for the two platforms.
If we use Windows compiled .amx files in the Linux
applicationa that will segfault the program.

I could code around that in the .amx loading routine but
I wanted to know beforehand if there was a reason for
different Small binaries on different OSes. The only
difference that I could make out is that on Windows
the four struct elements for the number of public
functions, public variables, libraries and, uh, the
forth one :), are two bytes. The Linux compiler writes
them in four bytes.


[120] Re: Different headers for Linux and Windows.

Posted By Linus Nuber on May 09, 2001 at 11:32:02:

In Reply to: Different headers for Linux and Windows. posted byFlorian Zschocke on May 09, 2001 at 11:14:27:

The LINUX compiler DOES write out 2 byte shorts. What you see are padding bytes, because the following 'long' elements in the structure are aligned at 4 byte adresses.

To get rid of these problemns you should enclose the AMX_HEADER declaration in amx.h with

#pragma pack (1)
typedef ...
} AMX_HEADER;
#pragma pack()

In the newest version of the compiler, this is already done!


[121] Re: Different headers for Linux and Windows.

Posted By Florian Zschocke on May 09, 2001 at 13:16:43:

In Reply to: Re: Different headers for Linux and Windows. posted byLinus Nuber on May 09, 2001 at 11:32:02:

: The LINUX compiler DOES write out 2 byte shorts. What you see are padding bytes, because the following 'long' elements in the structure are aligned at 4 byte adresses.

Thought so. We had plenty of problems with the pack pragma because it messed up our other structures.

: In the newest version of the compiler, this is already done!

Oh, good thing I asked. :-) I'll get the latest version then.
Is the code produced by it compatible with the AMX from February?

Thanks a lot,
Florian.


[122] Re: Different headers for Linux and Windows.

Posted By Linus Nuber on May 14, 2001 at 04:34:10:

In Reply to: Re: Different headers for Linux and Windows. posted byFlorian Zschocke on May 09, 2001 at 13:16:43:

: Thought so. We had plenty of problems with the pack pragma because it messed up our other structures.

As far as I know, the '#pragma pack ()' line resets the compiler to the standard alignment, so that only the AMX_HEADER structure is packed. The new version packs ALL structures, so you should reset the alignment after the AMX_HEADER typedef!

: Is the code produced by it compatible with the AMX from February?

The last version, which broke the AMX is AFAIK older. It was the compiler vesion, which invents the 'if (a < b < c)' syntax.

Linus


[123] Re: Different headers for Linux and Windows.

Posted By Thiadmer Riemersma on May 14, 2001 at 06:52:19:

In Reply to: Re: Different headers for Linux and Windows. posted byLinus Nuber on May 14, 2001 at 04:34:10:

: As far as I know, the '#pragma pack ()' line resets the compiler to the standard alignment, so that only the AMX_HEADER structure is packed. The new version packs ALL structures, so you should reset the alignment after the AMX_HEADER typedef!

I will reset the #pragma pack() at the end of the AMX.H file.

: : Is the code produced by it compatible with the AMX from February?

: The last version, which broke the AMX is AFAIK older. It was the compiler vesion, which invents the 'if (a < b < c)' syntax.

I added a "sleep" instruction in January 2001 (at least, in January it got is final shape). That was the last time that I added or removed opcodes. The AMX header (and file format) only changed since then to solve problems with Big Endian versus Little Endian processors.

By the way, only the "compact" file format is portable accross Big Endian and Little Endian processors. The format is currently not the default output file format of the compiler.


[124] Re: Different headers for Linux and Windows.

Posted By Thiadmer Riemersma on May 15, 2001 at 03:19:53:

In Reply to: Re: Different headers for Linux and Windows. posted byLinus Nuber on May 14, 2001 at 04:34:10:

: The last version, which broke the AMX is AFAIK older. It was the compiler vesion, which invents the 'if (a < b < c)' syntax.

Off topic, by the way: I did not invent the syntax "if (a < b < c)"; I copied it from BCPL. Optional semicolons is another feature that I copied from BCPL.

Thiadmer



[126] Re: multiple-instances of the same code

Posted By John W. Ratcliff on June 14, 2001 at 10:31:11:

In Reply to: multiple-instances of the same code posted bywastiee on February 13, 2001 at 10:53:06:

I am currently writing a C++ wrapper for Small that accomplishes exactly this. There is only one copy of the Small code and multiple copies of the data block. Each time you execute on that Small script the wrapper will copy that instance's version of the data into and then out of VM space.

There are some performance issues in this, especially if the small script has a huge data space, but in most cases I don't expect it to be a problem.

The data space for a script shouldn't be that huge, and the overhead of doing a memcpy into and out of the script's memory space will hopefully just be a necessary and acceptable cost of executing a script.

I am also looking at writing an object oriented wrapper for Small, so you can use a more conventional looking class model and then a pre-processor will convert the C++'ish looking code into C/Small script code behind the scenes.

When/If I get this stuff finished I will be releasing it open source.

John


[127] Re: #pragma pack

Posted By Chandra on June 20, 2001 at 20:57:47:

In Reply to: Re: #pragma pack posted byKantharaj Etigi on May 02, 2001 at 11:29:48:

Hi Kantha,
I am working on a Solaris driver for our chip & the same driver code plus libraries r working in NT but it panics & crashes the Sun Sparc. I am running Solaris 7 too. I think gcc doesnt have a -misalign option unlike the Sun's Workshop C compiler. I too am unable to fix this problem cos i dont ave access to Sun C compiler. If u find any other problem/ if u find a solution to this pragma problem, can u pl let me know too??

Thanks in advance,
Chandra


: Hello!

: Could any one help me how this " #pragma pack " works in Solaris 7.

: When I compile and execute following C program code, it results in "Segmentation Fault(coredump)" while executing gethostbyname system call.

: I think it because of pragma. This works fine in winNT.

: I appreciate your help in resolving this problem.

: Thanks & regards
: Kantharaj Etigi


: test1.c:
: --------

:
: #include
: #include
: #include
: #include
: #include
: #include
: #include
: #include
: #include

:
: #define BYTE short int
: #define ULONG unsigned long
: #define RTP_HEADER_SIZE 12

:
: #pragma pack(1)

: //typedef struct _RTPPACKET
: typedef struct _RTPPACKET
: {
: BYTE b0;
: BYTE b1;
: BYTE b2;
: BYTE b3;
: BYTE b4;
: BYTE b5;
: BYTE b6;
: BYTE b7;
: BYTE b8;
: BYTE b9;
: BYTE b10;
: BYTE b11;
: BYTE abData[1];
: }RTPPACKET;
: typedef RTPPACKET * PRTPPACKET;

: typedef struct _NODE
: {
: PRTPPACKET pRTPPacket;
: ULONG ulBytesInThisPacket;
: ULONG ulTimesPostponed;
: struct _NODE * pNext;
: } NODE;
: typedef NODE * PNODE;

: #pragma pack()

:
: void UpdateSilencePacket(void);
: int InitRTPProducer(void);
: void Init16to8LUT_ULaw(void);

: //
: // Global variables used by this file
: //

:
: PRTPPACKET pRTPSilencePacket = NULL;
: unsigned long ulRTPPacketDelay = 40; // Default delay is 40 msecs
: unsigned long ulPacketDataLen = 320; // ulRTPPacketDelay * 8
: short int bSilenceValue = 127; // Initialize the silence value

: /**********************************************************************************
: **
: ** Function: InitRTPProducer
: **
: ** Description:
: **
: ** Parameters: None
: **
: ** Returns: TRUE - success
: ** FALSE - failure
: **
: ***********************************************************************************/
: int InitRTPProducer(void)
: {

: //
: // Initialize the silence packet
: //
: pRTPSilencePacket = (PRTPPACKET)malloc(RTP_HEADER_SIZE + ulPacketDataLen);
: if(pRTPSilencePacket == NULL)
: {
: return(0);
: }


: //
: // Initialize the 16 to 8 look up table (LUT) -
: //
: Init16to8LUT_ULaw();

:
: return(1);

: } // end of InitRTPProducer

: /**********************************************************************************
: **
: ** Function: UpdateSilencePacket
: **
: ** Description: This routine will update the contents of the silence packet
: ** with the proper silence value
: **
: ** Parameters: None
: **
: ** Returns: None
: **
: ***********************************************************************************/
: void UpdateSilencePacket(void)
: {
: ULONG i;

:
: if(pRTPSilencePacket == NULL)
: {
: return;
: }

: for(i = 0; i < ulPacketDataLen; i++)
: {
: pRTPSilencePacket->abData[i] = bSilenceValue;
: }

:
: } // end of UpdateSilencePacket

:
: /**********************************************************************************
: **
: ** Function: Init16to8LUT_ULaw
: **
: ** Description:
: **
: ** Parameters: None
: **
: ** Returns: None
: **
: ***********************************************************************************/
: void Init16to8LUT_ULaw(void)
: {
: ULONG i;

: bSilenceValue = 127;
: UpdateSilencePacket();

: } // end of Init16to8LUT_ULaw

:
: int main(int argc, char * argv[])
: {

: struct hostent * hp;

: InitRTPProducer();

: hp =(struct hostent *) gethostbyname("localhost");
: if(hp == NULL)
: {
: return 1;
: }

: return(0);

: } // end of main

: testmake.gcc
: ------------

: CFLAGS=-DUNIX -I. -g
: CC=gcc

: all: mytest

: mytest: test1.o
: gcc -o $@ $^ -lsocket -lnsl




[128] Socket programming in Small?

Posted By Ron Jamison on June 21, 2001 at 04:36:48:

Hello,

Is it possible to do socket programming in Small? I've tried to include the correct headers and I get a segfault. Perhaps I'm missing something.. could you help me out?

Thank you,
Ron Jamison


[129] Re: Socket programming in Small?

Posted By Thiadmer Riemersma on June 22, 2001 at 03:17:31:

In Reply to: Socket programming in Small? posted byRon Jamison on June 21, 2001 at 04:36:48:

: Is it possible to do socket programming in Small? I've tried to include the correct headers and I get a segfault.

You need a native function library with the socket functions. I know this library has been made, but I do not have it myself.

Thiadmer


[130] The License

Posted By Nicholas Cooper on June 22, 2001 at 19:16:38:

I have read and understand the license that covers the Small language and all associate files, but I have one major question:
As stated in the license :
"The use of this software as a subsystem of a larger software product is explicitly allowed, regardless of whether that larger product is proprietary, gratis or commercially available"

Now i bring attention to " ... a subsystem of a larger software product ... ". What about a product that essentially IS the small script compiler and abstract machine; BUT for Palm. The generaly premise behind the product is a way to compile memo-text files on the palm into a program, which can then be executed. I already have a working version, and i also have a working version that produces the program files for palm, with no abstract machine required.

Anyone know? Is there any additional Licensing info? Or anyone who has knowlegde of how the terms set out within the license can be interpreted?



[131] Switch?

Posted By Joe Hansche on June 23, 2001 at 03:09:30:

Call me crazy, but why do my switch statements not work?? I noticed that you don't need a break; command, so that's affirmative. I haven't found any documentation on how the language works, as far as regular commands go. Anyone have any tips? Please e-mail me. Thanks
-Joe


[132] Re: The License

Posted By Thiadmer Riemersma on June 23, 2001 at 06:31:04:

In Reply to: The License posted byNicholas Cooper on June 22, 2001 at 19:16:38:

: As stated in the license :
: "The use of this software as a subsystem of a larger software product is explicitly allowed, regardless of whether that larger product is proprietary, gratis or commercially available"

: Now i bring attention to " ... a subsystem of a larger software product ... ". What about a product that essentially IS the small script compiler and abstract machine; BUT for Palm. [...]

It is okay to distribute a modified Small (even if those modifications are very minor). Typically, a license permits one to only distribute *unmodified* files. I wanted people to be able to use adapted versions of Small in their applications.

The other clause in the license permits you to do what you want:
"Permission is hereby granted, without written agreement and without paid license or royalty fees, to use, copy, modify, and distribute this software and its documentation for any purpose, subject to the following conditions: [...]"

Then, there are four conditions that tell you to include the copyright and the license if you are going to distribute source code, to acknowledge the origin of the software and to take responsibility for the changes that you made.

Thiadmer (author of Small)


[133] Re: Switch?

Posted By Thiadmer Riemersma on June 23, 2001 at 06:42:29:

In Reply to: Switch? posted byJoe Hansche on June 23, 2001 at 03:09:30:

: Call me crazy, but why do my switch statements not work?? I noticed that you don't need a break; command, so that's affirmative.

The switch statement is very different from that of C/C++ (it is closer to the CASE statement in Pascal). There is no break, and only one statement can (and must) follow each case. To have multiple statements in a case, you must create a compound block for those statements. You can specify multiple values (and even ranges) per case.

You may want to look at the The "weekday.sma" example in the toolkit, which has a switch.

: I haven't found any documentation on how the language works, as far as regular commands go.

All instructions are in the Small manual, the chapter is "Statements". Also read the chapter "Pitfalls" that covers more differences from C/C++.

Thiadmer


[134] Re: Switch?

Posted By Joe on June 23, 2001 at 18:56:42:

In Reply to: Re: Switch? posted byThiadmer Riemersma on June 23, 2001 at 06:42:29:

Ahhh thanks... I guess in that case, the reason I haven't seen any of these is that I didn't actually download a toolkit. I'm writing a plugin for AdminMod for Counter-Strike =P ... So, is Case a function (ie: case(1) ..) or is it like C in the sense that it has no parentheses, but maybe no colon? Sorry, I know I could get these answered if I had the manual, but I don't even know where to download the toolkit. Thanks Thiadmer
-Joe


: : Call me crazy, but why do my switch statements not work?? I noticed that you don't need a break; command, so that's affirmative.

: The switch statement is very different from that of C/C++ (it is closer to the CASE statement in Pascal). There is no break, and only one statement can (and must) follow each case. To have multiple statements in a case, you must create a compound block for those statements. You can specify multiple values (and even ranges) per case.

: You may want to look at the The "weekday.sma" example in the toolkit, which has a switch.

: : I haven't found any documentation on how the language works, as far as regular commands go.

: All instructions are in the Small manual, the chapter is "Statements". Also read the chapter "Pitfalls" that covers more differences from C/C++.

: Thiadmer



[135] Re: Switch?

Posted By Joe on June 23, 2001 at 19:01:58:

In Reply to: Switch? posted byJoe Hansche on June 23, 2001 at 03:09:30:

OK, I know I'm not doing this right. and since I just figured the language out from other sources, I didn't actually see a switch statement. So, could anyone tell me if this is correct or what I need to change?? Thanks!

switch(iWarns) {
case 1
for(new i=0;i<10;i++)
slap(iUser);
case 2
execclient(iUser,"kill");
case 3
kick(iUser);
case 4
ban(iUser,15);
}
return PLUGIN_CONTINUE;

Whenver I try compiling it, it just hangs the compiler. It will never actually show an error or display "Done". Any tips are appreciated


[136] BrowseRelocate Errors! ??

Posted By Joe on June 23, 2001 at 20:10:23:

I'm getting a strange error whenever I register my plugin... It say something like "amx_BrowseRelocate: Assertion ... 'op>0 && op-Joe


[137] Re: BrowseRelocate Errors! ??

Posted By joe on June 23, 2001 at 20:14:32:

In Reply to: BrowseRelocate Errors! ?? posted byJoe on June 23, 2001 at 20:10:23:

Sorry about that... This forum doesn't like < signs unless they're part of HTML... It should read like this:

"amx_BrowseRelocate: Assertion ... 'op>0 && op


[138] Re: BrowseRelocate Errors! ??

Posted By joe on June 23, 2001 at 20:16:13:

In Reply to: BrowseRelocate Errors! ?? posted byJoe on June 23, 2001 at 20:10:23:

You know what? Just screw it... Look at the quoted reply in the Comments box. This thing doesn't even use & codes... ohh well.


[139] Re: Socket programming in Small?

Posted By Ron Jamison on June 24, 2001 at 02:37:43:

In Reply to: Re: Socket programming in Small? posted byThiadmer Riemersma on June 22, 2001 at 03:17:31:

: You need a native function library with the socket functions. I know this library has been made, but I do not have it myself.

Thiadmer, I realize I'm way below everybody else posting here in terms of knowledge of compilers and the Small API, so please be understanding of my newbie-like request. Although I know enough C to change existing code I am not very adept at writing my own. I could, given the proper amount of time, but my time is alotted to projects which I can finish efficiently. I can easily modify existing code in small and recompile it, but locating the person who wrote the "native function library" for small which contains socket functions is beyond me. This seems like a small community, and I'm unable to locate much info about Small online. Could you please point me in the right direction? I'd love to find such a library to work with.

Thank you,
Ron Jamison


[140] Re: BrowseRelocate Errors! ??

Posted By Thiadmer Riemersma on June 24, 2001 at 12:22:20:

In Reply to: BrowseRelocate Errors! ?? posted byJoe on June 23, 2001 at 20:10:23:

: I'm getting a strange error whenever I register my plugin... It say something like "amx_BrowseRelocate: Assertion ... 'op>0 && opThe abstract machine sees an invalid opcode. This can mean either a code generation bug in the Small compiler, or that you do not pass the correct (and/or complete) data to amx_Exec().

Thiadmer


[141] Re: Switch?

Posted By Thiadmer Riemersma on June 24, 2001 at 12:31:46:

In Reply to: Re: Switch? posted byJoe on June 23, 2001 at 19:01:58:

: [...]
: Whenver I try compiling it, it just hangs the compiler. It will never actually show an error or display "Done". Any tips are appreciated

What is missing are the colons after each case. So you should say "case 1:" instead of "case 1".

Then again, you did find a bug (the Small compiler shouldn't hang). I will fix that. Thank you for reporting it.

Thiadmer


[142] Re: BrowseRelocate Errors! ??

Posted By Thiadmer Riemersma on June 24, 2001 at 12:43:48:

In Reply to: BrowseRelocate Errors! ?? posted byJoe on June 23, 2001 at 20:10:23:

I just saw your other message where you mentioned that you are making a plug-in for Counter-Strike (I have heard of the game, but I do not know it).

Small's compiler and manuals are evolving. Once in a while, someone takes the toolkit and embeds it. From that point on, Small is "frozen" as far as their application is concerned, but I continue to work on Small. That is to say, the people from AdminMod should provide you with the Small manual that reflects the compiler and abstract machine that they used. If you grab the manual from my side, it will probably mention features that AdminMod's "Small" compiler does not have. Worse, if you grab my Small compiler, chances are that the newest compiler uses an instruction that the abstract machine in AdminMod does not support. This would explain the error in amx_BrowseRelocate() that you saw.

I will try to get in touch with the programmers of AdminMod to find out what version they are using (and to suggest that they update to the latest version). I suggest that you do that too; they may have a manual that matches their version of the compiler. If their compiler is over a year old, the syntax of the "switch" instruction may be quite different, for example.

Thiadmer


[143] Re: BrowseRelocate Errors! ??

Posted By Florian Zschocke on June 25, 2001 at 07:28:36:

In Reply to: BrowseRelocate Errors! ?? posted byJoe on June 23, 2001 at 20:10:23:

: It say something like "amx_BrowseRelocate: Assertion ... 'op>0 && opThe current version of AdminMod (2.50x) uses the 1.5 version of the Small compiler. The error you see stems from a bug in that compiler version. My guess is that you have something like this in your code:

someArray[iIndex]++;

That does not work. You have to use

someArray[iIndex] += 1;



[144] Re: BrowseRelocate Errors! ??

Posted By Thiadmer Riemersma on June 25, 2001 at 12:13:58:

In Reply to: Re: BrowseRelocate Errors! ?? posted byFlorian Zschocke on June 25, 2001 at 07:28:36:

: The current version of AdminMod (2.50x) uses the 1.5 version of the Small compiler. The error you see stems from a bug in that compiler version. My guess is that you have something like this in your code:

: someArray[iIndex]++;

: That does not work. You have to use

: someArray[iIndex] += 1;

Indeed I recently fixed such an error. The fix is in a version that I just oploaded (June 25, 2001). Sorry for the trouble it gave you.

Thiadmer


[145] Re: Switch?

Posted By Luke Sankey on July 04, 2001 at 19:38:39:

In Reply to: Switch? posted byJoe Hansche on June 23, 2001 at 03:09:30:

: Call me crazy, but why do my switch statements not work?? I noticed that you don't need a break; command, so that's affirmative. I haven't found any documentation on how the language works, as far as regular commands go. Anyone have any tips? Please e-mail me. Thanks
: -Joe

Yeah that stupid '{' got me today in a switch statement too. I call it an error in the language but I guess it's by design for some reason.


[146] Problem compiling on RedHat Linux 7.0.

Posted By Rob Candland on July 12, 2001 at 14:14:27:

After issuing the make -f makefile.linux, I received this error:
sc2.o: In function `checktongue':
/home/robc/small/compiler/sc2.c:560: undefined reference to `strnicmp'

After changing line 560 in sc2.c it compiled (all I did was change "strnicmp" to "strncmp".)

I'll admit that I am not much of a C coder, but I have never heard of the strnicmp function.



[147] Re: Problem compiling on RedHat Linux 7.0.

Posted By Rob C on July 12, 2001 at 17:10:59:

In Reply to: Problem compiling on RedHat Linux 7.0. posted byRob Candland on July 12, 2001 at 14:14:27:

: After issuing the make -f makefile.linux, I received this error:
: sc2.o: In function `checktongue':
: /home/robc/small/compiler/sc2.c:560: undefined reference to `strnicmp'

: After changing line 560 in sc2.c it compiled (all I did was change "strnicmp" to "strncmp".)

: I'll admit that I am not much of a C coder, but I have never heard of the strnicmp function.

Ah, stricmp is the case-insensitive compare.
So, therefore:
for (ptr=plebeian; *ptr!='\0' && strncmp(tolower(string), tolower(ptr), (int)(strchr(ptr,'|')-ptr))!=0; ptr=strchr(ptr,'|')+1)

seemed to work fine on my Linux box.



[148] Re: Problem compiling on RedHat Linux 7.0.

Posted By Thiadmer Riemersma on July 13, 2001 at 03:44:09:

In Reply to: Problem compiling on RedHat Linux 7.0. posted byRob Candland on July 12, 2001 at 14:14:27:

: After issuing the make -f makefile.linux, I received this error:
: sc2.o: In function `checktongue':
: /home/robc/small/compiler/sc2.c:560: undefined reference to `strnicmp'

Another strnicmp() pops up (I thought I had fixed removed all those functions long ago).

strnicmp() is a string compare, case insensitive, and with a specified maximum length. It is a blend of strncmp() and stricmp() (or strcmpi() as some compilers have it). This function is not defined by ANSI and GLIBC doesn't have it. At least, not by that name. GLIBC has a function strncasecmp() which does extactly what is needed.

So what is needed, is a #define that renames strnicmp() to strncasecmp(). I suggest that you add this in the file "sclinux.h".

In the next upload, I will have fixed this too, by the way.

Thiadmer


[149] I am a newbie please help.

Posted By Hollin WIlkins on July 20, 2001 at 22:02:49:

Hello everyone, and thank you for veiwing this. I have recently com across the admin mod, and downloaded a few plugins for it, I then realized I MUST know how to make my own. If anyone has a good website for me to learn small or a manual, e-mail me or reply please. FYI I have some programming history, if that helps at all.

Thanks SOOOOO much,
Hollin Wilkins


[150] Re: I am a newbie please help.

Posted By Thiadmer Riemersma on July 22, 2001 at 11:06:16:

In Reply to: I am a newbie please help. posted byHollin WIlkins on July 20, 2001 at 22:02:49:

:[...] If anyone has a good website for me to learn small or a manual, e-mail me or reply please. FYI I have some programming history, if that helps at all.

The Small manual is at this site (see the link at the bottom of this message too). It includes a tutorial. Note that the Small manual does not mention admin mod even once. However, the main site for admin mod has tutorials too.

Thiadmer


[151] Re: I am a newbie please help.

Posted By Florian Zschocke on July 24, 2001 at 07:58:15:

In Reply to: I am a newbie please help. posted byHollin WIlkins on July 20, 2001 at 22:02:49:

: Hello everyone, and thank you for veiwing this. I have recently com across the admin mod, and downloaded a few plugins for it, I then realized I MUST know how to make my own. If anyone has a good website for me to learn small or a manual, e-mail me or reply please. FYI I have some programming history, if that helps at all.

You will find a link to the manual for the Small version that Adminmod uses at this page: http://www.adminmod.org/index.php?go=config


[152] Small Tools

Posted By David Dickhaut on July 24, 2001 at 16:30:37:

Just wanted to briefly touch the subject of existing or necessary Small tools. I have been working with the language for only a limited time now, but am truly impressed by it's facilities and ease of use for both systems developers and scripters.

I have been working on a set of tools that I find useful when working in a Small environment, including a GUI interface to the compiler and a disassembler. In the future I am also hoping of adding run-time debugging, and a set of windows specific extensions.

I am curious to know if there are any Small developers or communities that are collaborating in projects such as this. Are there enough Small users to warrant such development? What is the dominant OS among small users?

I'd appreciate any input on the subject. As previously stated, I am truly amazed by Small and would like to contribute to the community as much as possible.

Thanks,
Dave


[153] Passing array of strings to a function

Posted By Patrick Down on July 25, 2001 at 18:01:29:

It seems like I sould be able to doing something like the following but of course it generates this error:

hello.sma(14) Error [048]: array dimensions must match

Is there some syntax that I am missing that allows me to pass an array of strings to functions like this?

#include 
func(test[],size)
{
for(new i = 0; i < size; ++i)
printf("Element %s^n",test[i]);
}
main()
{
new TestArray1[2][] = {
"String1",
"String2" }
func(TestArray1,2);
new TestArray2[3][] = {
"String1",
"String2",
"String3" }
func(TestArray2,3);
}

[154] Re: Passing array of strings to a function

Posted By Thiadmer Riemersma on July 26, 2001 at 10:34:08:

In Reply to: Passing array of strings to a function posted byPatrick Down on July 25, 2001 at 18:01:29:

:
: It seems like I sould be able to doing something like
: the following but of course it generates this error:

: hello.sma(14) Error [048]: array dimensions must match

: Is there some syntax that I am missing that allows
: me to pass an array of strings to functions like this?

Your func() function is defined to take a one-dimensional array, but in your main() you are passing it two-dimensional arrays. This cannot work in Small. One option is to make func() accept a two-dimensional array, but then you would have to define it as either:

    func(test[2][],size)
or
    func(test[3][],size)

neither of which matches your intention (if I understood that right). The other option is to have the loops in main() and pass func() one-dimensional arrays, like in:

    for(new i = 0; i < 2; ++i)
func(TestArray1[i],2);

This is not exactly what you want either. Actually, what you would need is to declare func() as:

    func(text[][],size)
but Small does currently not support this. I have just looked up the Small manual and concluded that it must be possible to change the compiler so that it accepts this syntax for function parameters. I will put that on my wish list.

[155] Re: Passing array of strings to a function

Posted By Patrick Down on July 26, 2001 at 14:25:07:

In Reply to: Re: Passing array of strings to a function posted byThiadmer Riemersma on July 26, 2001 at 10:34:08:


: This is not exactly what you want either. Actually, what you would need is to declare func() as:

: func(text[][],size)

Yes that would do it.

: but Small does currently not support this. I have just looked up the Small manual and concluded that it must be possible to change the compiler so that it accepts this syntax for function parameters. I will put that on my wish list.

Thanks, I've worked around it for now. I hope the compiler will support it in the future.


[156] Re: Small Tools

Posted By Thiadmer Riemersma on July 27, 2001 at 05:27:31:

In Reply to: Small Tools posted byDavid Dickhaut on July 24, 2001 at 16:30:37:

: I am curious to know if there are any Small developers or communities that are collaborating in projects such as this. Are there enough Small users to warrant such development? What is the dominant OS among small users?

Small is used for very diverse goals. I originally intended to use it for scriptable animation and games. When Dr. Dobb's published an article about Small, I was surprised to see that they put it in the "Embedded Systems" column, but it turns out that Small fits well in that catagory.

On the main Small page (http://www.compuphase.com/small.htm), I list the users and usages that I am aware of (under the caption "Where is Small used?"). From that list, you can make educated guesses about a lot of things. Below are a few of my guesses:

1. The predominant operating systems that Small is used with are Win32 and Linux, on desktop machines anyway. On embedded systems, the OS-gamma is more diverse.

2. There are no communities that cooperate in enhancing Small. The "Enlightenment" projects came the closest to the concept of a Small development community, but I haven't heard from the Enlightenment team for a while. Several individuals and several companies have made modifications to better fit Small into their systems. Not every extension to Small is donated for inclusion in the main distribution, however, and I do not always merge the modifications that were donated into the main distribution.

3. Many products that use Small have a way to shield users from the command line tools. Usually, the compiler is launched automatically from the host application and it runs in the background; the abstract machine is embedded into the host application (nobody actually uses the "SRUN" sample, except for testing). I have never cared a lot about giving Small a GUI, because most host applications would need a host-specific GUI anyway. Where I have been wrong is the debugger. Writing a debugger from scratch is a lot of work. My "SDBG" sample is not application-specific and too spartan. This leads to many host applications that lack a debugger.

Anyway, I am glad that you like Small.

Thiadmer


[157] Mail

Posted By Sashi on July 28, 2001 at 05:35:19:

Please explain how to give the user name and password in the mailing script given with remotely anywhere

Please!!1


[158] Bugs and bits and pieces

Posted By Stewy on July 29, 2001 at 12:25:58:

various bits and pieces...

about()
has printf and puts. be consistent. i changed them all to printfs and added line feeds to the end of strings (ok ok so minor minor nitpick!;)

stop using longjmp/setjmp! augh. what ugly code. it also crashes djgpp most horridly.

get rid of the waitkey in about(). its inconsitent with every other CLI program out there. thats what piping to more/less is for.

below is test3.sma to reproduce compiler crashing.

/*
test3.sma
SC v1.6
29-jul-01
BUG: create an enum then a new variable of same name.
crashes compiler
*/
#include 
enum myvar { blah=1, sdf, xyz, frobnitz };
new myvar;
main()
{
}

[159] Re: Mail

Posted By Thiadmer Riemersma on July 30, 2001 at 04:56:11:

In Reply to: Mail posted bySashi on July 28, 2001 at 05:35:19:

: Please explain how to give the user name and password in the mailing script given with remotely anywhere

All I know about the application "Remotely Anywhere" is that it uses Small for scripting. Setting the name and password is probably specific to the application, although it may be hardcoded in the script. I suggest that you ask this at www.remotelyanywhere.com (they ought to know).

Thiadmer


[160] Re: Bugs and bits and pieces

Posted By Thiadmer Riemersma on July 30, 2001 at 05:06:49:

In Reply to: Bugs and bits and pieces posted byStewy on July 29, 2001 at 12:25:58:

: about()
: has printf and puts. be consistent.
In the version that I am working on, all string output will run through an "interface" function similar to sc_error().

: stop using longjmp/setjmp! augh. what ugly code. it also crashes djgpp most horridly.
longjmp() replaces and exir() or abort(). In some cases, you want to stop compiling right now. However, when running the compiler as a "library function" (instead of as an application), you cannot abort the program with exit(), as this would kill the entire application instead of just the compiler.

Actually, one would want to tackle this with exception handling. But the code is in C and the closest thing that C offers is longjmp(). I will try to verify longjmp() with djgpp; it shouldn't crash.

: get rid of the waitkey in about(). its inconsitent with every other CLI program out there. thats what piping to more/less is for.
I will make it conditionally compiled. In the Linux version, the waitkey() function is already unused.

: below is test3.sma to reproduce compiler crashing.

I will look into this. Thank you for the report.

Thiadmer


[161] Re: Bugs and bits and pieces

Posted By Stewy on August 01, 2001 at 14:50:06:

In Reply to: Re: Bugs and bits and pieces posted byThiadmer Riemersma on July 30, 2001 at 05:06:49:


: : below is test3.sma to reproduce compiler crashing.

: I will look into this. Thank you for the report.


thanks thiadmer. i'm gonne poke around more in the compiler, see if i can create some more test file examples to help pin down bugs in compilation.

i'll let you know how i go.



[162] Can a native C/C++ function call some small function explicitely or pass parameters to small ?

Posted By Dick Guan on August 04, 2001 at 02:00:20:

I am interested in small if it can be integrated into our game engine.
The situation is that at each frame(or at each step in game-loop), we would decide which small script to run and we have several related parameters to pass. how can we do that with small AMX smoothly?

thanx :)


[163] Re: Can a native C/C++ function call some small function explicitely or pass parameters to small ?

Posted By Thiadmer Riemersma on August 04, 2001 at 07:35:01:

In Reply to: Can a native C/C++ function call some small function explicitely or pass parameters to small ? posted byDick Guan on August 04, 2001 at 02:00:20:

: The situation is that at each frame(or at each step in game-loop), we would decide which small script to run and we have several related parameters to pass. how can we do that with small AMX smoothly?

1. In the Small script, you must make the functions that you want to call from the outside "public".

2. When you load the script, you can either look up specific public functions by name (amx_FindPublic) or browse through the list of all public functions (amx_GetPublic). In either case, you will end up matching a function name to a function index (an integer).

3. In amx_Exec, pass the function index plus all parameters. The parameters must be cell-sized. If you are going to pass arrays, you must allocate space for these arrays in the abstract machine. To this end, use amx_Allot and amx_Release.

Hope this helps. By the way, I do something along these lines in a demo for our EGI animation toolkit. At various events (e.g. just before displaying a new frame, or when reaching a label) the EGI player calls an associated "event function" from the animation script.

Thiadmer


[164] Re: Can a native C/C++ function call some small function explicitely or pass parameters to small ?

Posted By Dick Guan on August 05, 2001 at 06:04:24:

In Reply to: Re: Can a native C/C++ function call some small function explicitely or pass parameters to small ? posted byThiadmer Riemersma on August 04, 2001 at 07:35:01:

Thanx a lot :)
I'll give it a try~

Dick


[165] Re: Can a native C/C++ function call some small function explicitely or pass parameters to small ?

Posted By Florian Zschocke on August 07, 2001 at 10:13:01:

In Reply to: Re: Can a native C/C++ function call some small function explicitely or pass parameters to small ? posted byThiadmer Riemersma on August 04, 2001 at 07:35:01:

: 3. In amx_Exec, pass the function index plus all parameters. The parameters must be cell-sized. If you are going to pass arrays, you must allocate space for these arrays in the abstract machine. To this end, use amx_Allot and amx_Release.

Thiadmer, could you elaborate som more on amx_Alloc() and amx_Release()? How are they used? Do I understand you correctly when i assume that amx_Alloc() is called before amx_Exec() and after the Exec() returns amx_Release() gets called to free up the allocated space? Does the space get allocated on the stack or on the heap?

Also, what could be possible causes for a stack/heap collision?

Thanks,
Florian.


[166] Re: Switch?

Posted By Joe on August 07, 2001 at 11:28:48:

In Reply to: Switch? posted byJoe Hansche on June 23, 2001 at 03:09:30:

: Call me crazy, but why do my switch statements not work?? I noticed that you don't need a break; command, so that's affirmative. I haven't found any documentation on how the language works, as far as regular commands go. Anyone have any tips? Please e-mail me. Thanks
: -Joe

hehe... I was just reading thru the Small page again today, and I saw something that caught my eye... Well, it should -- it's my NAME! =P Seemed somehow I found a bug =) Then I came here and found this reply... So, NOW I know it's a bug in the compiler =) Just thought I'd share that with you. hehe, thought it was pretty funny =P

-Joe


[167] Re: Can a native C/C++ function call some small function explicitely or pass parameters to small ?

Posted By Thiadmer Riemersma on August 08, 2001 at 09:41:43:

In Reply to: Re: Can a native C/C++ function call some small function explicitely or pass parameters to small ? posted byFlorian Zschocke on August 07, 2001 at 10:13:01:

: Thiadmer, could you elaborate som more on amx_Alloc() and amx_Release()? How are they used? Do I understand you correctly when i assume that amx_Alloc() is called before amx_Exec() and after the Exec() returns amx_Release() gets called to free up the allocated space? Does the space get allocated on the stack or on the heap?

I was going to write you how to use the functions and to direct you to the manual, when I found that the manual is very, very brief on the subject and also, the description does not match the code. I have to look more carefully, but at the moment, I think that the code is correct and the documentation is wrong.

The intended usage is, indeed, that you call amx_Allot() before calling amx_Exec() and to call amx_Release() afterwards. Three points:

1. Between amx_Allot() and amx_Exec() you can fill the memory that you grabbed (with string data, or otherwise), using a pointer that amx_Allot() returns.

2. axm_Allot() also returns a second address: the AMX address. This value, you must pass in the call to amx_Exec() at the position of the array (or reference parameter).

3. Between the return from amx_Exec() and the call to amx_Release(), you can read back the contents of the array. If the Small function filled the array, you can read the new data.

This also works for reference parameters. In this context, a reference parameter is just an array with size 1.

The memory is allocated from the "heap".

: Also, what could be possible causes for a stack/heap collision?

I have always used small stack sizes, because my own scripts are only little and I rarely need large arrays. The default stack has been 2048 cells for a long time. I think that recently I increased it to 4096 cells. For some purposes, this is still a small stack. So one possible cause for a stack heap collision is a stack that is simply to small for your purposes.

Note that the "heap" in Small is more like a second stack. Default values for arrays and references stored on the heap. If you make heavy use of default values (for arrays and references) the heap fills quickly.

There is a compiler option and a #pragma to set the size of the stack. Actually, it sets the size for the stack and the heap combined (both share the same block). The more recent versions of the compiler support a config file (SC.CFG) in which you can set your default options.

Of course, a recursive function can also be quite "stack intensive". Calling amx_Allot() repeatedly without ever calling amx_Release() also does the trick.

Thiadmer


[168] Different AMX sharing the same Heap/Stack space

Posted By Odie Calima on August 09, 2001 at 18:00:17:

I am loading multiple scripts at one time. To save some memory I am sharing one Heap/Stack space among the multiple AMX. Is there anything in the Heap or Stack that needs to be preserved in between function calls? Aren't the global variables in a different memory space? As soon as I exit from a public function, I should be able to trash the Heap/Stack space, correct?


[169] Re: Different AMX sharing the same Heap/Stack space

Posted By Thiadmer Riemersma on August 10, 2001 at 05:40:47:

In Reply to: Different AMX sharing the same Heap/Stack space posted byOdie Calima on August 09, 2001 at 18:00:17:

: I am loading multiple scripts at one time. To save some memory I am sharing one Heap/Stack space among the multiple AMX. Is there anything in the Heap or Stack that needs to be preserved in between function calls? Aren't the global variables in a different memory space? As soon as I exit from a public function, I should be able to trash the Heap/Stack space, correct?

What is mostly requested is the ability to share the "code", not the data.

Global variables are in a memory block that follows the code and precedes the stack. The stack holds local variables and grows downwards. The heap is actually a second stack; it holds temporary copies of the "default values" of array or reference parameters. The heap grows upward.

In absence of multi-threading, I see no reason why multiple abstarct machines could not share the stack and the heap. The important thing to straighten out is that the stack and heap pointers in all AMX structures must be kept synchronized.

After amx_Exec() returns, the stack and heap pointers (i.e. the STK and HEA pseudo-registers) should have exactly the same values as just before the call to amx_Exec(), with one exception (!) the "sleep" instruction causes amx_Exec() to abort *without* resetting the stack and heap, so that the abstract machine can be restarted.

Thiadmer


[170] Documentation

Posted By B. Ahrenholz on August 14, 2001 at 12:10:15:

Hi all,
a simple question: where can I get a documentation or manual for small? It's downloadable? If somebody can give me a hint it would be greatly appreciated. Thanks in advance


[171] Re: Documentation

Posted By Thiadmer Riemersma on August 15, 2001 at 02:56:35:

In Reply to: Documentation posted byB. Ahrenholz on August 14, 2001 at 12:10:15:

: [...] where can I get a documentation or manual for small? It's downloadable?

The latest manual is at:

http://www.compuphase.com/small.htm (You can also use the link at the bottom of this message.)

If you are useing AdminMod, the manual for the Small version that AdminMod currently embeds is at:
http://www.adminmod.org/index.php?go=config

Thiadmer


[172] Problems compiling AMX DLL under MSVC 6

Posted By Jason Reeve on August 18, 2001 at 12:15:05:

I wanted to make sure the Console window started minimised and I'll probably want to make other modifications to the DLL later. So I started a new MSVC project, imported the files, set the preprocessor flags AMXAPI = __stdcall and predefining amx_Init, this is where the problems start, push() causes compiler errors and the whole amx_Init rempping seems to be causing problems too. Can anybody please help! Or better still does anybody have an MSVC project for building the AMX32M DLL.

Cheers!

-Jason


[173] Re: Problems compiling AMX DLL under MSVC 6

Posted By Thiadmer Riemersma on August 19, 2001 at 09:55:32:

In Reply to: Problems compiling AMX DLL under MSVC 6 posted byJason Reeve on August 18, 2001 at 12:15:05:

: [...], push() causes compiler errors and the whole amx_Init rempping seems to be causing problems too.

I have no immediate solution, but I will look into this. The push() function is a trick which I copied from a programming book from the Windows 3.1 era. I know that it works under 16-bit compilers by Borland and Microsoft and in 32-bit compilers by Watcom and Borland. Perhaps, indeed, Microsoft Visual C/C++ imposes stricter checks. You should be compiling in "C" mode, by the way, not in "C++" mode. The reason is that in C++ the definition "void push()" is equal to "void push(void)".

By the way, function push() is only called from CallDLL(), if you don't need the functionality of calldll(), you can just put a "#if 0 ... #endif" pair around it.

The amx_Init() remapping should work, though. Make sure that you compile all AMX related source files with amx_Init defined to amx_InitAMX.

Thiadmer


[174] Re: Problems compiling AMX DLL under MSVC 6

Posted By Jason Reeve on August 19, 2001 at 15:11:18:

In Reply to: Re: Problems compiling AMX DLL under MSVC 6 posted byThiadmer Riemersma on August 19, 2001 at 09:55:32:

Ok, thanks, I'll recheck what I have amx_Init defined as. I've not had much experience with DLL's and I'm having difficulty generating the .lib file for the AMX DLL. I usually just ask MSVC for a DLL project and it does all that stuff for me! Now I have to convert the AMX DLL project and I'm stuffed without my handy dandy DLL wizard!

Any tips?

Cheers,

Jason


[175] Update,,,

Posted By Jason Reeve on August 19, 2001 at 20:36:16:

In Reply to: Re: Problems compiling AMX DLL under MSVC 6 posted byJason Reeve on August 19, 2001 at 15:11:18:

I have managed to create the lib file using a .DEF file. So now it compiles, links, generates the lib and dll files. But I have a new problem. The DLL for AMX seems to init ok, the test program loads but when it comes to print "hello" (I'm using hello.sma example) it fails to open the console window, I debugged it as far as 'printstring' in amxcons.c where it should call 'amx_putchar' but it never seems to get there and so never opens the console window.

Any ideas?

Cheers,

Jason



[176] Fixed!

Posted By Jason Reeve on August 20, 2001 at 15:41:25:

In Reply to: Update,,, posted byJason Reeve on August 19, 2001 at 20:36:16:

I fixed the problem with the console, I noticed after looking around the Watcom make file there was a preprocessor directive to define NO_DEF_FUNCS I added this to my MSVC compiler options and I now have the AMX (with assembler core) compiling as a DLL.

If anybody wants the project files then give me a shout and I'll place them on our webserver and publish the link.

Cheers,

Jason.



[177] About sc(small compiler)'s length restriction on symbol name

Posted By Dick Guan on August 29, 2001 at 11:30:53:

Hi,
Through our testing on small, we figure out that there are length restriction on symbol name, and we are interested in increasing it a little :)

in sc.h
#define sEXPMAX 19 /* maximum length of exported symbol name */
#define sSTKMAX 80 /* stack for nested #includes and other uses */

If we modify it (bigger or smaller), what points should we care and what's your opinions and suggestions ?

thanx.


[178] Re: About sc(small compiler)'s length restriction on symbol name

Posted By Clem Vasseur on August 29, 2001 at 14:03:23:

In Reply to: About sc(small compiler)'s length restriction on symbol name posted byDick Guan on August 29, 2001 at 11:30:53:

: If we modify it (bigger or smaller), what points should we care and what's your opinions and suggestions ?

Be careful, there is a #define sEXPMAX in amx.c (SRUN source code) too.


[179] Re: About sc(small compiler)'s length restriction on symbol name

Posted By Thiadmer Riemersma on August 30, 2001 at 06:52:29:

In Reply to: About sc(small compiler)'s length restriction on symbol name posted byDick Guan on August 29, 2001 at 11:30:53:

: Through our testing on small, we figure out that there are length restriction on symbol name, and we are interested in increasing it a little :)

The Small compiler makes a difference between maximum lengths of "public" symbols and maximum lengths of all other symbols.

sNAMEMAX (non-public symbols) can be increased without problems, the only drawback is increased memory usage.

When changing sEXPMAX, the file format changes (as the names of public symbols are stored in the compiled file). If you increase it:

1. make sure that the abstract machine is aware of this too (as Clem Vasseur mentioned, the definition of sEXPMAX also occurs in AMX.C; I copied this #define rather than using a shared include file so that the abstract machine could be compiled separately).

2. make sure there won't be mixups between compiled files produced by different compilers, so if you are going to provide the compiler with your product, tell your users that they should use the compiler that they can grab from this site.

: #define sSTKMAX 80

sSTKMAX is used for entirely different purposes; it is most heavily used for nested include files. A small stack can be a problem if you heavily nest your include files. There is no problem in increasing it.

Thiadmer


[180] Syntax Highlight

Posted By Conrad on September 04, 2001 at 17:09:23:

I'm new to Small (thx (or not) to AdminMod)

I wanted to highlight the syntax. I'm using TextPad and i'm doing this for PHP and it works well.

I've search for Small but didn't find it :/
At the moment i'm using the C-textpad-file to do the job but i'm not sure it's so good since i'm not a C programmer.


[181] Re: Syntax Highlight

Posted By Thiadmer Riemersma on September 05, 2001 at 06:42:32:

In Reply to: Syntax Highlight posted byConrad on September 04, 2001 at 17:09:23:

: I wanted to highlight the syntax. I'm using TextPad and i'm doing this for PHP and it works well.

: I've search for Small but didn't find it :/
: At the moment i'm using the C-textpad-file to do the job but i'm not sure it's so good since i'm not a C programmer.

Small is not THAT popular that text editors include the syntax highlighting definitions. Most keywords in Small are shared with C. There are a few differences: type names ("int", "double", etc.) are no keywords in Small, and Small has a few more keywords for different purposes ("native", "public", "new").

I do not know TextPad, but usually, these editors allow you to add syntax highlighting formats. A list of all keywords can be found in the Small manual (http://www.compuphase.com/smalldoc.pdf).

Thiadmer


[182] Re: Syntax Highlight

Posted By Florian Zschocke on September 07, 2001 at 14:22:31:

In Reply to: Syntax Highlight posted byConrad on September 04, 2001 at 17:09:23:

: I wanted to highlight the syntax. I'm using TextPad and i'm doing this for PHP and it works well.

As Thiadmer explained you should do fine with the C text highlighting. There is a syntax file available at the Adminmod Scripting forum which defines the syntax highlighting for Small for the editor UltraEdit. As of now I know of no such file for TextPad. You could check there if somebody else has done it for TextPad, though.



[183] Help with *property functions

Posted By Conrad on September 07, 2001 at 18:04:43:

I try to use these *property functions and nothing work :/ I've read the manual and i'm a bit confused with the four parameters. Maybe my English (i'm french) isn't so good :P

So if I could have a exemple wich works it will be great.

In fact I try to access to vars by a dynamic method thru a function which takes the var name in param and return the value (or a default value). don't getproperty and setproperty could help doing this ?

Transition from an interpreted language (php) is a bit difficult :)


[184] Getting unresolved external symbol using AMX_NATIVE_INFO

Posted By Alexander bierbrauer on September 10, 2001 at 07:59:32:

Hi people,

I've written a small SMALL testing program ;)The program has only to call the hello.amx.

When I want to compile my console app I'm getting the following error:

error LNK2001: Nichtaufgeloestes externes Symbol "struct AMX_NATIVE_INFO * console_Natives" (?console_Nativesb_3PAUAMX_NATIVE_INFOb_A)

Does someone know how I can get it working?

Bye,
Alex

The code:

#define AMX_NATIVE_CALL __stdcall
#define AMXAPI __stdcall
#include <stdlib.h>
#include <stdio.h>
#include <iostream.h>
#include <memory.h>
#include <amx.h>
void core_Init(void);   /* two functions from AMX_CORE.C */
void core_Exit(void);
extern AMX_NATIVE_INFO console_Natives[];
/*******************************
* this function loads a amx-file
*******************************/
void *loadprogram(AMX *amx,char *path)
{
FILE        *file;
AMX_HEADER  header;
void        *program=NULL;
file=fopen(path,"rb");
if(!file)
{
cout<<endl<<path<<" does not exist!"<<endl;
return NULL;
}
fread(&header,sizeof(AMX_HEADER),1,file);
if((program=malloc((int)header.stp))!=NULL)
{
rewind(file);
fread(program,1,(int)header.size,file);
fclose(file);
memset(amx,0,sizeof(AMX));
if(amx_Init(amx,program)==AMX_ERR_NONE)
return program;
free(program);
}
return NULL;
}
void main()
{
char        path[256];
AMX         amx;
cell        ret;
int         error;
void        *program;
cout<<"SMALL testprogram\n"<<endl;
cout<<"AMX file to run: ";
cin>>path;
cout<<"running "<<path<<"...";
program=loadprogram(&amx,path);
error=amx_Register(&amx,console_Natives,-1);
if(error=AMX_ERR_NONE)
error=amx_Exec(&amx,&ret,AMX_EXEC_MAIN,0);
if(error!=AMX_ERR_NONE)
cout<<"run time error "<<error<<" on line "<<amx.curline <<endl;
free(program);
}


[185] Syntax Highlight

Posted By Xanathar on September 10, 2001 at 11:58:24:

In Reply to: Re: Syntax Highlight posted byFlorian Zschocke on September 07, 2001 at 14:22:31:

If you use EditPro (shareware from Serpiksoft at http://www.serpik.com/) you can build your own syntax file (or I can give you mine). However it's shareware so if you find some FREE counterpart, let me know on this forum :)



[186] Re: Getting unresolved external symbol using AMX_NATIVE_INFO

Posted By Xanathar on September 10, 2001 at 12:05:27:

In Reply to: Getting unresolved external symbol using AMX_NATIVE_INFO posted byAlexander bierbrauer on September 10, 2001 at 07:59:32:

At first sight it seems a name decoration problem between C++ and C.

Maybe the solution is something like :

extern "C" { //extern "C" avoids name decoration
extern AMX_NATIVE_INFO console_Natives[];
void core_Init(void);
void core_Exit(void);
}


[187] Help!! anyone got some code or can help me??

Posted By Alexander Bierbrauer on September 10, 2001 at 13:17:44:

Hi people,

I've read the documentation and understand everything so far...but I can't get it working in practice! Does anyone have some sample VC6 code for me???

I'm getting error 19 but don't know how to get rid of it.

that's the code of test.sma:

native test();

main()
{
test();
}

I'm getting the error on amx_Init(amx,program);
Does someone know why??

Here's the rest of the code:
cell AMX_NATIVE_CALL test(AMX *amx,cell *params)
{
cout<<"Hallo!";
return 0;
}

AMX_NATIVE_INFO test_Natives[]={{"test",test}};

/*******************************
* this function loads a amx-file
*******************************/
void *loadprogram(AMX *amx,char *path)
{
FILE *file;
AMX_HEADER header;
void *program=NULL;
int error=0;

file=fopen(path,"rb");
if(!file)
{
cout< return NULL;
}

fread(&header,sizeof(AMX_HEADER),1,file);

if((program=malloc((int)header.stp))!=NULL)
{
rewind(file);
fread(program,1,(int)header.size,file);
fclose(file);
memset(amx,0,sizeof(*amx));

error=amx_Init(amx,program);
if(error==AMX_ERR_NONE)return program;
else cout<<" Fehler:"< free(program);
}

return NULL;
}

void main()
{
char path[256];
AMX amx;
cell ret;
int error;
void *program;

cout<<"SMALL testprogram\n"< cout<<"AMX file to run: ";
cin>>path;
cout<<"running "< program=loadprogram(&amx,path);

error=amx_Register(&amx,test_Natives,-1);

if(error=AMX_ERR_NONE)
error=amx_Exec(&amx,&ret,AMX_EXEC_MAIN,0);

if(error!=AMX_ERR_NONE)
cout<<"run time error "< free(program);
}


[188] What kind of error do you get?

Posted By Xanathar on September 10, 2001 at 18:09:31:

In Reply to: Help!! anyone got some code or can help me?? posted byAlexander Bierbrauer on September 10, 2001 at 13:17:44:


--


[189] Re: Help!! anyone got some code or can help me??

Posted By Thiadmer Riemersma on September 11, 2001 at 02:49:13:

In Reply to: Help!! anyone got some code or can help me?? posted byAlexander Bierbrauer on September 10, 2001 at 13:17:44:


: I'm getting error 19 but don't know how to get rid of it.

Error 19 is AMX_ERR_NOTFOUND (from AMX.H). Are you sure that it is amx_Init() that returns this? When looking through the code in AMX.C, it would be amx_Register() that causes error AMX_ERR_NOTFOUND rather than amx_Init().

amx_Register() returns AMX_ERR_NOTFOUND when the compiled Small program contains (still more) unresolved native functions after the call to amx_Register().

: AMX_NATIVE_INFO test_Natives[]={{"test",test}};
: [...]
: error=amx_Register(&amx,test_Natives,-1);

One error that I see in your code (but I do not know if that is related to your problem) is that the test_Natives list is not NULL terminated, but the count passed into amx_Register() is nevertheless set to -1. amx_Register() has two options: either you pass in a valid count of native functions in the structure (1, in your case), or you pass in a NULL-terminated list.

Thiadmer


[190] Re: What kind of error do you get?

Posted By Alexander Bierbrauer on September 11, 2001 at 08:53:03:

In Reply to: What kind of error do you get? posted byXanathar on September 10, 2001 at 18:09:31:

Hi,

I've changed the program a little. I'm using hello.amx now (provided by SMALL)...now, I'm getting an error on this line:
error=amx_Exec(&amx,&ret,AMX_EXEC_MAIN,0);

It's error Nr.6 (must be signed to an array...).. what the hell went wrong?? I do not see any important differences between my code and srun.c.

Here's the code...please....helpp!!!!!!!!!!!

extern "C"
extern AMX_NATIVE_INFO core_Natives[];

/*******************************
* this function loads a amx-file
*******************************/
void *loadprogram(AMX *amx,char *path)
{
FILE *file;
AMX_HEADER header;
void *program=NULL;
int error=0;

file=fopen(path,"rb");
if(!file)
{
cout< return NULL;
}

fread(&header,sizeof(AMX_HEADER),1,file);

if((program=malloc((int)header.stp))!=NULL)
{
rewind(file);
fread(program,1,(int)header.size,file);
fclose(file);
memset(amx,0,sizeof(*amx));

error=amx_Init(amx,program);
if(error==AMX_ERR_NONE)return program;
else cout<<" Fehler:"< free(program);
}

return NULL;
}

void main()
{
AMX amx;
cell ret;
int error;
void *program;

program=loadprogram(&amx,"hello.amx");

error=amx_Register(&amx,core_Natives,-1);

if(error==AMX_ERR_NONE)
error=amx_Exec(&amx,&ret,AMX_EXEC_MAIN,0);

if(error!=AMX_ERR_NONE)
cout<<"run time error "< free(program);
}<<>>


[191] Bug Report (?)

Posted By Xanathar on September 14, 2001 at 03:10:06:

Small compiler 1.6 Copyright (c) 1997-2001, ITB CompuPhase

An integer divide by zero was encountered at address 0x004096ca.

-----------------------------------------------------
Small compiler 1.7 Copyright (c) 1997-2001, ITB CompuPhase
An integer divide by zero was encountered at address 0x00409dcf

-----------------------------------------------------

This seems to happen when compiling certain files with a #pragma tabsize 0.
If I delete the pragma, the compiler builds ok (except for warning 217 of course).

Thank you for all :)


[192] Also..

Posted By Xanathar again on September 14, 2001 at 03:16:45:

In Reply to: Bug Report (?) posted byXanathar on September 14, 2001 at 03:10:06:

If you need the files to test it, I'll send them thru mail :D



[193] Re: Bug Report (?)

Posted By Thiadmer Riemersma on September 14, 2001 at 03:38:24:

In Reply to: Bug Report (?) posted byXanathar on September 14, 2001 at 03:10:06:

: Small compiler 1.7 Copyright (c) 1997-2001, ITB CompuPhase
: An integer divide by zero was encountered at address 0x00409dcf

Yes, please send me the files that provoke this error by e-mail (thiadmer@compuphase.com).

Thank you.

Thiadmer


[194] Sent...

Posted By Xanathar on September 14, 2001 at 09:28:02:

In Reply to: Re: Bug Report (?) posted byThiadmer Riemersma on September 14, 2001 at 03:38:24:

I've noticed some mail problems.. tell me if you don't receive it :)


[195] Please !!

Posted By Conrad on September 21, 2001 at 17:20:30:

In Reply to: Help with *property functions posted byConrad on September 07, 2001 at 18:04:43:

plz just a getproperty or setproperty example which works !!


[196] Proposal

Posted By Xanathar on September 23, 2001 at 06:39:54:

Can in some future pragma pack(1) be changed in something like (for example) :

#ifdef LINUX
#define PACK_NEEDED __attribute__ ((packed))
#else
#define PACK_NEEDED
#pragma pack(1)
// add anything regarding TC :)
#endif
struct ___amx_native_info {
char *name;
AMX_NATIVE func;
} PACK_NEEDED;
typedef struct ___amx_native_info AMX_NATIVE_INFO;
#endif

The problem is that it's extremely difficult to manage pragma pack under GCC/G++ since a pragma pack misplaced can actually trash STL code and/or other classes/structs [trashed vtables, etc].

Thanx for the attention :)




[197] Re: Help with *property functions

Posted By Thiadmer Riemersma on September 24, 2001 at 03:28:19:

In Reply to: Help with *property functions posted byConrad on September 07, 2001 at 18:04:43:


Here you are.

There is one problem though, when testing the second part of this example program (on "value properties"), I noticed two bugs in the code that make it not work. This is how it should work, however; I will have these bugs fixed in the