LISP: update version

git-svn-id: svn://kolibrios.org@7844 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
pavelyakov 2020-04-29 18:58:22 +00:00
parent 3aee626ccb
commit da33359efc
3 changed files with 550 additions and 428 deletions

View File

@ -1 +0,0 @@
(set var1 "test string")(print (get var1))

View File

@ -1,42 +1,34 @@
/* /*
* Author Pavel Iakovlev * Author Pavel Iakovlev by PaulCodeman
*/ */
#define MEMSIZE 4096*10 #define MEMSIZE 4096*10
#include "../lib/io.h" #include "../lib/io.h"
#include "../lib/obj/console.h" #include "../lib/obj/console.h"
#include "../lib/array.h"
#define TString 1
#define TSymbol 2
#define TNumber 3
#define TList 4
#define Proc 5
#define Lambda 6
#define TObject 7
#define sizeStruct 4*4
byte initConsole = 0; byte initConsole = 0;
Dictionary functions = {0}; dword maxLoop = 100;
Dictionary variables = {0};
#include "stdcall.h"
#define bufferSize 10000;
#define memoryBrainfuck 30000*4
#define memoryByteBF 1
#define stackBrainFuck 4*1024
#define TStr 1
#define TInt 2
#define TSym 3
#define TBol 4
#define TLen 4*5
dword buffer = 0; dword buffer = 0;
word bufferSymbol = 0; dword bufferSize = 1000;
dword memory = 0; dword variable = 0;
dword key = 0;
dword stack = 0; dword treeItem = 0;
dword code = 0; dword NIL = 0;
byte tempBuffer[100] = {0};
void consoleInit() void consoleInit()
{ {
IF(!initConsole) IF(!initConsole)
{ {
load_dll(libConsole, #con_init, 0); load_dll(libConsole, #con_init, 0);
con_init stdcall (-1, -1, -1, -1, "Lisp interpreter"); con_init stdcall (-1, -1, -1, -1, "Lisp interpreter");
@ -44,192 +36,423 @@ void consoleInit()
} }
} }
dword evalLisp() dword error_message(dword text)
{
con_printf stdcall (text);
ExitProcess();
}
dword crc32Table = 0;
dword makeCRCTable(void)
{
dword i = 0;
dword c = 0;
dword ii = 0;
dword crcTable = 0;
IF (crc32Table) RETURN 0;
crc32Table = malloc(4*256);
crcTable = crc32Table;
WHILE (i < 256)
{
c = i;
ii = 0;
WHILE (ii < 8)
{
IF (c&1)
{
c >>= 1;
c ^= 0xEDB88320;
}
ELSE c >>= 1;
ii++;
}
DSDWORD[crcTable] = c;
crcTable += 4;
i++;
}
}
dword crc32(dword bytes)
{
dword crc = 0;
byte b = 0;
IF (!crc32Table) makeCRCTable();
crc = 0xFFFFFFFF;
WHILE (DSBYTE[bytes])
{
b = DSBYTE[bytes];
bytes++;
EDX = crc^b;
EDX &= 0xFF;
EDX <<= 2;
EDX += crc32Table;
crc >>= 8;
crc ^= DSDWORD[EDX];
}
RETURN crc ^ 0xFFFFFFFF;
}
dword indexArray(dword address, key)
{
dword offset = key&11b;
dword offsetAddress = offset*4+address;
IF (key==offset) RETURN 4*4+offsetAddress;
IF (!DSDWORD[offsetAddress]) DSDWORD[offsetAddress] = malloc(4*4*2);
RETURN indexArray(DSDWORD[offsetAddress], key>>2);
}
void set_procedure(dword name, address)
{
dword data = 0;
data = malloc(sizeStruct);
DSDWORD[data] = Proc;
DSDWORD[data+4] = address;
indexArray(variable, crc32(name));
DSDWORD[EAX] = data;
}
void set_variable(dword name, data)
{
indexArray(variable, crc32(name));
DSDWORD[EAX] = data;
}
dword string(dword lisp)
{
dword buffer = 0;
if (DSDWORD[lisp] == TList)
{
return "";
}
switch (DSDWORD[lisp])
{
case TString:
case TSymbol:
return DSDWORD[lisp+4];
case TNumber:
return itoa(DSDWORD[lisp+4]);
case Lambda:
return "[LAMBDA]";
case Proc:
return "[PROC]";
case TObject:
return "[OBJECT]";
case TList:
return "[LIST]";
}
}
dword number(dword lisp)
{
if (DSDWORD[lisp] == TNumber)
{
return DSDWORD[lisp+4];
}
if (DSDWORD[lisp] == TString)
{
//return atoi(DSDWORD[lisp+4]);
}
return 0;
}
dword lexer(dword code)
{ {
byte s = 0; byte s = 0;
byte args = 0; dword alloc = 0;
dword pos = 0; dword buffer = 0;
dword name = 0; dword position = 0;
dword tmp = 0; dword key = 0;
dword tmp2 = 0; alloc = malloc(32);
dword dataArgs = 0; //con_printf stdcall(code);
dword posArgs = 0; while(DSBYTE[code])
dword ret = 0;
dword p = 0;
dword i = 0;
dword ii = 0;
dataArgs = malloc(16*4);
posArgs = dataArgs;
loop()
{ {
s = DSBYTE[code]; s = DSBYTE[code];
while (s == ' ') || (s == 9) || (s == 10) || (s == 13) code++;
if (s == ' ') || (s == '\n') || (s == '\t') || (s == '\r') continue;
if (s == '(') || (s == ')')
{ {
code++; buffer = malloc(2);
s = DSBYTE[code]; DSBYTE[buffer] = s;
} indexArray(alloc, key);
if (!s) return 0; DSDWORD[EAX] = buffer;
if (s==')') key++;
{
code++;
args--;
ret = StdCall(args, name, dataArgs);
free(name);
//free(dataArgs);
return ret;
}
if(s == '(')
{
code++;
DSDWORD[posArgs] = evalLisp();
args++;
posArgs += 4;
continue; continue;
} }
else if (!args) buffer = malloc(25);
position = buffer;
DSBYTE[position] = s;
if (s == '"')
{ {
if (s != ')') // name function while(DSBYTE[code])
{ {
name = malloc(100); s = DSBYTE[code];
pos = name; position++;
while (s) && (s != ' ') && (s != ')') DSBYTE[position] = s;
{ code++;
DSBYTE[pos] = s; if (s == '"') && (DSBYTE[code-2] != '\\') break;
pos++;
code++;
s = DSBYTE[code];
}
DSBYTE[pos] = 0;
args++;
continue;
} }
} }
else else
{ {
if (s >= '0') && (s <= '9') while(DSBYTE[code])
{ {
tmp = 0;
while (s >= '0') && (s <= '9')
{
tmp *= 10;
tmp += s-'0';
code++;
s = DSBYTE[code];
}
args++;
EDX = malloc(TLen);
DSDWORD[EDX] = tmp;
DSDWORD[EDX+4] = TInt;
DSDWORD[posArgs] = EDX;
posArgs += 4;
continue;
}
else if (s == '"')
{
i = 1;
tmp = malloc(1<<i);
p = tmp;
code++;
s = DSBYTE[code]; s = DSBYTE[code];
ii = 0; if (s == ' ') || (s == '\n') || (s == '\t') || (s == '\r') || (s == '(') || (s == ')') break;
while (s != '"') && (s) position++;
{ DSBYTE[position] = s;
ii++;
if (1<<i < ii)
{
i++;
tmp2 = p-tmp;
tmp = realloc(tmp, 1<<i);
p = tmp+tmp2;
}
DSBYTE[p] = s;
p++;
code++;
s = DSBYTE[code];
}
DSBYTE[p] = 0;
EDX = malloc(TLen);
DSDWORD[EDX] = tmp;
DSDWORD[EDX+4] = TStr;
DSDWORD[EDX+8] = p-tmp;
DSDWORD[posArgs] = EDX;
posArgs += 4;
code++; code++;
args++;
continue;
} }
else }
indexArray(alloc, key);
DSDWORD[EAX] = buffer;
key++;
}
indexArray(alloc, key);
DSDWORD[EAX] = 0;
/*key = 0;
do {
buffer = indexArray(alloc, key);
if (!DSDWORD[buffer]) break;
con_printf stdcall ("\r\n");
con_printf stdcall (DSDWORD[buffer]);key++;
} while(1);*/
return alloc;
}
dword tree(dword alloc)
{
dword token = 0;
dword list = 0;
dword buffer = 0;
dword temp = 0;
dword listBuffer = 0;
dword i = 0;
token = indexArray(alloc, treeItem);
treeItem++;
buffer = DSDWORD[token];
if (DSBYTE[buffer] == '(')
{
list = malloc(32);
while(1) {
token = indexArray(alloc, treeItem);
token = DSDWORD[token];
if (!token) || (DSBYTE[token] == ')') break;
buffer = indexArray(list, i);
DSDWORD[buffer] = tree(alloc);
i++;
}
treeItem++;
indexArray(list, i);
DSDWORD[EAX] = 0;
malloc(sizeStruct);
DSDWORD[EAX] = TList;
DSDWORD[EAX+4] = list;
return EAX;
}
return atom(DSDWORD[token]);
}
dword hexdec2(dword buffer, length)
{
dword r = 0;
length += buffer;
while (length != buffer)
{
length--;
r <<= 4;
if (DSBYTE[length] >= 'A') && (DSBYTE[length] <= 'F') r |= DSBYTE[length]-'A'+10;
else if (DSBYTE[length] >= 'a') && (DSBYTE[length] <= 'f') r |= DSBYTE[length]-'a'+10;
else if (DSBYTE[length] >= '0') && (DSBYTE[length] <= '9') r |= '9'-DSBYTE[length];
}
return r;
}
dword atom(dword token)
{
dword buffer = 0;
dword pos = 0;
dword data = 0;
if (DSBYTE[token] == '-') && (DSBYTE[token+1] >= '0') && (DSBYTE[token+1] <= '9')
{
malloc(sizeStruct);
DSDWORD[EAX] = TNumber;
DSDWORD[EAX+4] = atoi(token);
return EAX;
}
if (DSBYTE[token] >= '0') && (DSBYTE[token] <= '9')
{
while (DSBYTE[token]) && (DSBYTE[token] >= '0') && (DSBYTE[token] <= '9')
{
data *= 10;
data += DSBYTE[token]-'0';
token++;
}
malloc(sizeStruct);
DSDWORD[EAX] = TNumber;
DSDWORD[EAX+4] = data;
return EAX;
}
if (DSBYTE[token] == '"')
{
pos = token;
buffer = token;
pos++;
while (DSBYTE[pos]) && (DSBYTE[pos] != '"')
{
if (DSBYTE[pos] == '\\')
{ {
tmp = malloc(20); pos++;
p = tmp; switch (DSBYTE[pos])
while (s) && (s != ')') && (s != '(') && (s != ' ') && (s != 10) && (s != 13)
{ {
DSBYTE[p] = s; case 'n': DSBYTE[buffer] = 13; break;
p++; case 'r': DSBYTE[buffer] = 10; break;
code++; case 't': DSBYTE[buffer] = 9; break;
s = DSBYTE[code]; case 'x':
pos++;
DSBYTE[buffer] = hexdec2(pos, 2);
pos++;
break;
default:
DSBYTE[buffer] = DSBYTE[pos];
} }
DSBYTE[p] = 0; }
args++; else DSBYTE[buffer] = DSBYTE[pos];
EDX = malloc(TLen); buffer++;
DSDWORD[EDX] = tmp; pos++;
DSDWORD[EDX+4] = TSym; }
DSDWORD[posArgs] = EDX; DSBYTE[buffer] = 0;
posArgs += 4; malloc(sizeStruct);
continue; DSDWORD[EAX] = TString;
DSDWORD[EAX+4] = token;
DSDWORD[EAX+8] = token-buffer;
return EAX;
}
pos = token;
while (DSBYTE[pos])
{
if (DSBYTE[pos] >= 'a') && (DSBYTE[pos] <= 'z') DSBYTE[pos] = DSBYTE[pos]-'a'+'A';
pos++;
}
malloc(sizeStruct);
DSDWORD[EAX] = TSymbol;
DSDWORD[EAX+4] = token;
return EAX;
}
dword lisp(dword tree)
{
dword buffer = 0;
dword list = 0;
dword args = 0;
dword key = 0;
dword item = 0;
switch (DSDWORD[tree])
{
case TSymbol:
buffer = indexArray(variable, crc32(DSDWORD[tree+4]));
IF (!DSDWORD[buffer]) return tree;
return DSDWORD[buffer];
case TNumber:
case TString:
return tree;
case TList:
list = DSDWORD[tree+4];
buffer = indexArray(list, 0);
if (!buffer) {
malloc(sizeStruct);
DSDWORD[buffer] = TSymbol;
DSDWORD[buffer+4] = NIL;
return buffer;
} }
DSDWORD[posArgs] = tmp; buffer = DSDWORD[buffer];
posArgs += 4; if (DSDWORD[buffer] == TSymbol) || (DSDWORD[buffer] == TList)
} {
code++; buffer = DSDWORD[buffer+4];
args++; if (DSBYTE[buffer] == '\'') return tree;
args = malloc(32);
key = 0;
while (1)
{
buffer = indexArray(list, key);
buffer = DSDWORD[buffer];
if (!buffer) break;
item = indexArray(args, key);
DSDWORD[item] = lisp(buffer);
key++;
}
item = indexArray(args, 0);
item = DSDWORD[item];
if (DSDWORD[item] == Proc)
{
EAX = DSDWORD[item+4];
EAX(args);
if (!EAX)
{
malloc(sizeStruct);
DSDWORD[EAX] = TSymbol;
DSDWORD[EAX+4] = NIL;
return EAX;
}
return EAX;
}
malloc(sizeStruct);
DSDWORD[EAX] = TSymbol;
DSDWORD[EAX+4] = NIL;
return EAX;
}
malloc(sizeStruct);
DSDWORD[EAX] = TSymbol;
DSDWORD[EAX+4] = NIL;
return EAX;
} }
args--;
ret = StdCall(args, name, dataArgs);
free(name);
//free(dataArgs);
return ret;
} }
#include "stdcall.h"
void main() void main()
{ {
dword brainFuckCode = 0; dword xxx = 0;
word maxLoop = 1000; dword item = 0;
dword txt = "(set name (input \"Enter you name: \"))(print \"You name \" (get name))"; dword data = 0;
buffer = malloc(bufferSize); buffer = malloc(bufferSize);
memory = malloc(memoryBrainfuck);
stack = malloc(stackBrainFuck); variable = malloc(32);
NIL = "NIL";
initFunctionLisp();
Init(); if(DSBYTE[I_Param])
IF(DSBYTE[I_Param])
{ {
IF(io.read(I_Param)) IF(io.read(I_Param))
{ {
code = EAX; lisp(tree(lexer(EAX)));
evalLisp();
} }
} }
else else
{ {
consoleInit(); consoleInit();
con_printf stdcall ("Lisp interpreter v1.5\r\n"); con_printf stdcall ("Lisp v2.0\r\n");
while(maxLoop) while(maxLoop)
{ {
treeItem = 0;
con_printf stdcall ("\r\n$ "); con_printf stdcall ("\r\n$ ");
con_gets stdcall(buffer, bufferSize); con_gets stdcall(buffer+1, bufferSize);
code = EAX; DSBYTE[buffer] = '(';
//code = txt; xxx= lisp(tree(lexer(buffer)));
con_printf stdcall ("Output: "); con_printf stdcall (string(xxx));
evalLisp();
maxLoop--; maxLoop--;
} }
} }
IF(initConsole) con_exit stdcall (1); IF(initConsole) con_exit stdcall (1);
ExitProcess(); ExitProcess();
} }

View File

@ -1,293 +1,193 @@
/*
STDCALL function
Author: PaulCodeman
*/
/* Lisp functions */ void initFunctionLisp()
:dword std_sleep(dword count, args)
{ {
dword ret = 0; set_procedure("TEST", #lisp_test);
dword arg = 0; set_procedure("SLEEP", #lisp_sleep);
dword val = 0; set_procedure("PRINT", #lisp_print);
WHILE(count) set_procedure("INPUT", #lisp_input);
{ set_procedure("STDCALL", #lisp_stdcall);
arg = DSDWORD[args]; set_procedure("SETQ", #lisp_setq);
REPEAT1: set_procedure("DEFVAR", #lisp_setq);
IF (DSDWORD[arg+4] == TSym) set_procedure("+", #lisp_add);
{ set_procedure("-", #lisp_sub);
arg = std_get(1, args); set_procedure("=", #lisp_cmp);
goto REPEAT1;
}
IF (DSDWORD[arg+4] == TInt)
{
EAX = 5;
EBX = DSDWORD[arg];
$int 0x40
}
args+=4;
count--;
}
RETURN ret;
} }
:dword std_set(dword count, args) dword lisp_test(dword args)
{ {
malloc(sizeStruct);
DSDWORD[EAX] = TString;
DSDWORD[EAX+4] = "ZZZ";
return EAX;
}
dword lisp_setq(dword args)
{
dword i = 0;
dword name = 0; dword name = 0;
dword value = 0; dword data = 0;
WHILE(count > 0) while(1)
{ {
name = DSDWORD[args]; i++;
IF (DSDWORD[name+4] == TSym) name = DSDWORD[name]; data = indexArray(args, i);
ELSE data = DSDWORD[data];
IF (!data) break;
if (i&1)
{ {
con_printf stdcall ("Error variable!"); name = DSDWORD[data+4];
ExitProcess();
} }
args += 4; else
value = DSDWORD[args];
args += 4;
variables.set(name, value);
count -= 2;
}
}
:dword std_get(dword count, args)
{
dword name = 0;
IF(!count) RETURN 0;
name = DSDWORD[args];
IF (DSDWORD[name+4] != TSym)
{
con_printf stdcall ("Error variable!");
ExitProcess();
}
RETURN variables.get(DSDWORD[name]);
}
:dword std_str(dword count, args)
{
dword tmp = 0;
IF(!count) RETURN "";
tmp = malloc(15);
itoa_(tmp,DSDWORD[args]);
RETURN tmp;
}
/* Math functions */
:dword std_add(dword count, args)
{
dword ret = 0;
WHILE(count)
{
ret += DSDWORD[args];
args+=4;
count--;
}
RETURN ret;
}
:dword std_exit(dword count, args)
{
IF(initConsole) con_exit stdcall (1);
ExitProcess();
}
:dword std_sub(dword count, args)
{
dword ret = 0;
IF(count)
{
ret = DSDWORD[args];
count--;
args+=4;
}
WHILE(count)
{
ret -= DSDWORD[args];
args += 4;
count--;
}
RETURN ret;
}
:dword std_type(dword count, args)
{
dword ret = 0;
dword arg = 0;
dword val = 0;
ret = malloc(TLen);
DSDWORD[ret] = "nil";
DSDWORD[ret+4] = TStr;
WHILE(count)
{
arg = DSDWORD[args];
REPEAT1:
IF (DSDWORD[arg+4] == TSym)
{ {
arg = std_get(1, args); set_variable(name, data);
goto REPEAT1;
} }
switch (DSDWORD[arg+4])
{
case TStr:
DSDWORD[ret] = "string";
break;
case TInt:
DSDWORD[ret] = "integer";
break;
}
args+=4;
count--;
} }
RETURN ret; return 0;
} }
/* Console functions */ dword lisp_print(dword args)
:dword std_print(dword count, args)
{ {
dword ret = 0; dword i = 0;
dword arg = 0;
dword val = 0;
consoleInit(); consoleInit();
IF (!count) con_printf stdcall ("nil"); while(1)
WHILE(count)
{ {
arg = DSDWORD[args]; i++;
REPEAT1: indexArray(args, i);
IF (DSDWORD[arg+4] == TInt) val = itoa(DSDWORD[arg]); IF (!DSDWORD[EAX]) break;
ELSE IF (DSDWORD[arg+4] == TStr) val = DSDWORD[arg]; con_printf stdcall (string(DSDWORD[EAX]));
ELSE IF (DSDWORD[arg+4] == TSym)
{
arg = std_get(1, args);
goto REPEAT1;
}
IF(!arg) con_printf stdcall ("nil");
ELSE con_printf stdcall (val);
args+=4;
count--;
} }
RETURN ret; con_printf stdcall ("\r\n");
return 0;
} }
:dword std_len(dword count, args) dword lisp_stdcall(dword args)
{ {
dword ret = 0; dword i = 0;
dword arg = 0; dword buffer = 0;
dword val = 0; while(1)
ret = malloc(TLen);
DSDWORD[ret] = 0;
DSDWORD[ret+4] = TInt;
WHILE(count)
{ {
arg = DSDWORD[args]; i++;
REPEAT1: indexArray(args, i);
IF (DSDWORD[arg+4] == TStr) val = DSDWORD[arg]; buffer = DSDWORD[EAX];
ELSE IF (DSDWORD[arg+4] == TSym) IF (!buffer) break;
{ $push DSDWORD[buffer+4];
arg = std_get(1, args);
goto REPEAT1;
}
ELSE return ret;
DSDWORD[ret] += DSDWORD[arg+8];
args+=4;
count--;
} }
RETURN ret; IF (i == 2) $pop eax
IF (i == 3) $pop ebx
IF (i == 4) $pop ecx
$int 0x40
return EAX;
} }
:dword std_cmp(dword count, args) dword lisp_input(dword args)
{ {
dword ret = 0; dword buffer = 0;
dword arg = 0;
dword val = 0;
dword tmp = 0;
dword x = 0;
dword y = 0;
byte start = 0;
ret = malloc(TLen);
DSDWORD[ret] = 0;
DSDWORD[ret+4] = TInt;
IF (!count) return ret;
while(count)
{
arg = DSDWORD[args];
REPEAT2:
IF (DSDWORD[arg+4] == TSym)
{
arg = std_get(1, args);
goto REPEAT2;
}
IF (!start)
{
start = 1;
tmp = arg;
args+=4;
count--;
continue;
}
IF (DSDWORD[tmp+4] != DSDWORD[arg+4]) return ret;
IF (DSDWORD[tmp+4] == TInt)
{
IF (DSDWORD[tmp] != DSDWORD[arg]) return ret;
}
ELSE IF (DSDWORD[tmp+4] == TStr)
{
/*IF (!DSDWORD[tmp+8]) DSDWORD[tmp+8] = crc32(DSDWORD[tmp]);
IF (!DSDWORD[arg+8]) DSDWORD[arg+8] = crc32(DSDWORD[arg]);
IF (DSDWORD[tmp+8] != DSDWORD[arg+8]) return ret;*/
IF (strcmp(DSDWORD[tmp], DSDWORD[arg])) return ret;
}
args+=4;
count--;
}
DSDWORD[ret] = 1;
return ret;
}
:dword std_input(dword count, args)
{
dword buf = 0;
consoleInit(); consoleInit();
buf = malloc(100); buffer = malloc(100);
IF (count) std_print(count, args); con_gets stdcall(buffer, 100);
con_gets stdcall(buf, 100); malloc(sizeStruct);
EDX = malloc(TLen); DSDWORD[EAX] = TString;
DSDWORD[EDX] = buf; DSDWORD[EAX+4] = buffer;
DSDWORD[EDX+4] = TStr; return EAX;
RETURN EDX;
} }
void Init() dword lisp_inc(dword args)
{ {
functions.init(100); dword i = 0;
dword sum = 0;
/* Console functions */ dword buffer = 0;
functions.set("print", #std_print); while(1)
functions.set("input", #std_input); {
i++;
/* String functions */ buffer = indexArray(args, i);
functions.set("str", #std_str); IF (!DSDWORD[buffer]) break;
functions.set("len", #std_len); buffer = DSDWORD[buffer];
}
/* System functions */ return 0;
functions.set("exit", #std_exit);
/* Math functions */
functions.set("+", #std_add);
functions.set("-", #std_sub);
functions.set("==", #std_cmp);
/* Lisp functions */
functions.set("set", #std_set);
functions.set("get", #std_get);
functions.set("type", #std_type);
functions.set("sleep", #std_sleep);
variables.init(100);
} }
dword StdCall(dword count, name, args) dword lisp_add(dword args)
{ {
functions.get(name); dword i = 0;
IF(EAX) RETURN EAX(count, args); dword sum = 0;
RETURN 0; dword buffer = 0;
while(1)
{
i++;
buffer = indexArray(args, i);
IF (!DSDWORD[buffer]) break;
buffer = DSDWORD[buffer];
sum += number(buffer);
}
malloc(sizeStruct);
DSDWORD[EAX] = TNumber;
DSDWORD[EAX+4] = sum;
return EAX;
} }
dword lisp_sub(dword args)
{
dword i = 0;
dword sum = 0;
while(1)
{
i++;
indexArray(args, i);
IF (!DSDWORD[EAX]) break;
sum -= number(DSDWORD[EAX]);
}
malloc(sizeStruct);
DSDWORD[EAX] = TNumber;
DSDWORD[EAX+4] = sum;
return EAX;
}
dword lisp_cmp(dword args)
{
dword i = 0;
dword first = 0;
dword buffer = 0;
while(1)
{
i++;
buffer = indexArray(args, i);
buffer = DSDWORD[buffer];
IF (!buffer) break;
if (i == 1)
{
first = buffer;
}
else
{
if (DSDWORD[first+4] != DSDWORD[buffer+4])
{
malloc(sizeStruct);
DSDWORD[EAX] = TSymbol;
DSDWORD[EAX+4] = NIL;
return EAX;
}
}
}
if (i == 1) error_message("*** - EVAL: too few arguments given to =: (=)");
malloc(sizeStruct);
DSDWORD[EAX] = TSymbol;
DSDWORD[EAX+4] = "T";
return EAX;
}
dword lisp_sleep(dword args)
{
dword time = 0;
indexArray(args, 1);
time = number(DSDWORD[EAX]);
EAX = 5;
EBX = time;
$int 0x40
return 0;
}