diff --git a/compiler/scasm/Makefile b/compiler/scasm/Makefile deleted file mode 100755 index 919d6b70..00000000 --- a/compiler/scasm/Makefile +++ /dev/null @@ -1,14 +0,0 @@ -CPPFILES = amxasm.cpp cexpr.cpp amx_symbol.cpp amx_proc.cpp \ -amx_parser.cpp amx_natives.cpp amx_macro.cpp amx_label.cpp \ -amx_error.cpp amx_define.cpp amx_data.cpp amx_compiler.cpp - -FLAGS = -march=i386 -m32 - -all: sasm - -sasm: - g++ $(FLAGS) -DHAVE_STDINT_H -Wall $(CPPFILES) -o sasm -s - -clean: - -rm *.o - -rm sasm diff --git a/compiler/scasm/Makefile.pl b/compiler/scasm/Makefile.pl deleted file mode 100755 index d732ecb4..00000000 --- a/compiler/scasm/Makefile.pl +++ /dev/null @@ -1,176 +0,0 @@ -#!/usr/bin/perl -#(C)2004 AMX Mod X Development Team -# by David "BAILOPAN" Anderson - -# output will occur in bin.x.proc -# where x is debug or opt and proc is ix86 or amd64 -# You must use this script from the project src dir - -#options = -# debug - enable gdb debugging -# amd64 - compile for AMD64 -# proc=ix86 - assumed not amd64 -# clean - clean the specifications above - -$PROJECT = "sasm"; -$gccf = "gcc"; - -@CPP_SOURCE_FILES = ("amx_compiler.cpp", "amx_data.cpp", "amx_define.cpp", "amx_error.cpp", "amx_label.cpp", "amx_macro.cpp", "amx_natives.cpp", "amx_proc.cpp", "amx_parser.cpp", "amx_symbol.cpp", "amxasm.cpp", "cexpr.cpp"); - -@C_SOURCE_FILES = (); -my %OPTIONS, %OPT; - -$OPT{"debug"} = "-g -ggdb"; -$OPT{"opt"} = "-O2 -ffast-math -funroll-loops -fomit-frame-pointer -s -DHAVE_STDINT_H -DNDEBUG -Wall -Wno-unknown-pragmas -DOPT_TYPE=\"optimized\""; - -$OPTIONS{"include"} = ""; - -while ($cmd = shift) -{ - if ($cmd =~ /amd64/) { - $OPTIONS{"amd64"} = 1; - } elsif ($cmd =~ /debug/) { - $OPTIONS{"debug"} = 1; - } elsif ($cmd =~ /proc=i(\d)86/) { - $proc = $1; - if ($OPTIONS{"amd64"}) - { - die "You cannot compile for i".$proc."86 and AMD64.\n"; - } else { - $OPTIONS{"proc"} = "i".$proc."86"; - } - } elsif ($cmd =~ /clean/) { - $OPTIONS{"clean"} = 1; - } -} - -$gcc = `$gccf --version`; -if ($gcc =~ /2\.9/) -{ - $OPT{"opt"} .= " -malign-loops=2 -malign-jumps=2 -malign-functions=2"; -} else { - $OPT{"opt"} .= " -falign-loops=2 -falign-jumps=2 -falign-functions=2"; -} - -if ($OPTIONS{"debug"}) -{ - $cflags = $OPT{"debug"}; -} else { - if (!$OPTIONS{"amd64"}) - { - $proc = $OPTIONS{"proc"}; - if (!$proc) - { - $proc = 3; - } - $cflags = "-march=i".$proc."86 -m32 ".$OPT{"opt"}; - } else { - $cflags = $OPT{"opt"}; - } -} - -if ($OPTIONS{"amd64"}) -{ - $cflags .= " -m64 -DHAVE_I64 -DSMALL_CELL_SIZE=64 $cflags"; -} - -if ($OPTIONS{"debug"}) -{ - $outdir = "bin.debug"; -} else { - $outdir = "bin.opt"; -} - -if ($OPTIONS{"amd64"}) -{ - $outdir .= ".amd64"; - $bin = $PROJECT."_amd64.so"; -} else { - $proc = $OPTIONS{"proc"}; - if ($proc) - { - $outdir .= ".i".$proc."86"; - $bin = $PROJECT."_i".$proc."86.so"; - } else { - $outdir .= ".i386"; - $bin = $PROJECT."_i386.so"; - } -} - -unlink("$outdir/$bin"); -if ($OPTIONS{"clean"}) -{ - `rm $outdir/*.o`; - die("Project cleaned.\n"); -} - -#create the dirs -#build link list -my @LINK; -for ($i=0; $i<=$#CPP_SOURCE_FILES; $i++) -{ - $file = $CPP_SOURCE_FILES[$i]; - $file =~ s/\.cpp/\.o/; - push(@LINK, $outdir."/".$file); -} -for ($i=0; $i<=$#C_SOURCE_FILES; $i++) -{ - $file = $C_SOURCE_FILES[$i]; - $file =~ s/\.c/\.o/; - push(@LINK, $outdir."/".$file); -} - -if (!(-d $outdir)) -{ - mkdir($outdir); -} - -$inc = $OPTIONS{"include"}; - -for ($i=0; $i<=$#CPP_SOURCE_FILES; $i++) -{ - $file = $CPP_SOURCE_FILES[$i]; - $ofile = $file; - $ofile =~ s/\.cpp/\.o/; - $ofile = "$outdir/$ofile"; - $gcc = "$gccf $cflags -Dstrcmpi=strcasecmp $inc -c $file -o $ofile"; - if (-e $ofile) - { - $file_time = (stat($file))[9]; - $ofile_time = (stat($ofile))[9]; - if ($file_time > $ofile_time) - { - print "$gcc\n"; - `$gcc`; - } - } else { - print "$gcc\n"; - `$gcc`; - } -} - -for ($i=0; $i<=$#CPP_SOURCE_FILES; $i++) -{ - $file = $C_SOURCE_FILES[$i]; - $ofile = $file; - $ofile =~ s/\.c/\.o/; - $ofile = "$outdir/$ofile"; - $gcc = "cc $cflags -Dstrcmpi=strcasecmp $inc -c $file -o $ofile"; - if (-e $ofile) - { - $file_time = (stat($file))[9]; - $ofile_time = (stat($file))[9]; - if ($file_time > $ofile_time) - { - print "$gcc\n"; - `$gcc`; - } - } else { - print "$gcc\n"; - `$gcc`; - } -} - -$gcc = "$gccf $cflags -shared -lstdc++ -ldl -lm @LINK -o $outdir/$bin"; -print "$gcc\n"; -`$gcc`; diff --git a/compiler/scasm/adminslots.asm b/compiler/scasm/adminslots.asm deleted file mode 100755 index 2966301c..00000000 --- a/compiler/scasm/adminslots.asm +++ /dev/null @@ -1,240 +0,0 @@ -;(C)2004 David "BAILOPAN" Anderson -; Assembler version of Anti-Flood -#define VERSION "0.20-A" -#define PLUGIN_HANDLED -#macro ARGN(argc) (12+(argc*CELL)) - -.CODE - halt 0 ;Return point for end - -.NATIVE - register_plugin - register_cvar - random_num - register_clcmd - server_cmd - get_maxplayers - get_playersnum - get_cvar_num - set_cvar_num - get_user_flags - client_cmd - get_user_userid - -.DATA - Plugin db "Slots Reservation" - Version db VERSION - Author db "AMXX Dev Team" - Cvar db "amx_reservation" - CvarVal db "1" - Callback db "ackSignal" - loopBack db "amxres0000" - -.CODE -PROC plugin_init - push.c Author ;push author - push.c Version ;push version - push.c Plugin ;push name - push.c CELL*3 ;push 3 args - sysreq.c register_plugin ;call register_plugin - stack CELL*4 ;clean-up - - push.c CvarVal ;push Cvar initial value - push.c Cvar ;push Cvar - push.c CELL*2 ;push 2 args - sysreq.c register_cvar ;call register_cvar - stack CELL*3 ;clean-up - - push.c 90 ;push max range - push.c 65 ;push min range - push.c CELL*2 ;push 2 args - sysreq.c random_num ;call random_num - stack CELL*3 ;clean-up - stor.pri loopBack+CELL*6 ;store pri in loopBack[6] - - push.c 90 ;push max range - push.c 65 ;push min range - push.c CELL*2 ;push 2 args - sysreq.c random_num ;call random_num - stack CELL*3 ;clean-up - stor.pri loopBack+CELL*7 ;store pri in loopBack[7] - - push.c 90 ;push max range - push.c 65 ;push min range - push.c CELL*2 ;push 2 args - sysreq.c random_num ;call random_num - stack CELL*3 ;clean-up - stor.pri loopBack+CELL*8 ;store pri in loopBack[8] - - push.c 90 ;push max range - push.c 65 ;push min range - push.c CELL*2 ;push 2 args - sysreq.c random_num ;call random_num - stack CELL*3 ;clean-up - stor.pri loopBack+CELL*9 ;store pri in loopBack[9] - - push.c Callback ;push callback - push.c loopBack ;push loopback - push.c CELL*2 - sysreq.c register_clcmd ;call register_clcmd - stack CELL*3 ;clean-up - - zero.pri ;return 0 - retn ;final cleanup -ENDP - -.DATA - KickMsg db "kick #%d \"Dropped due to slot reservation\"" - -.CODE -PROC ackSignal - push.s ARGN(0) ;push the first argument - push.c CELL*1 ;push one argument - sysreq.c get_user_userid ;call get_user_userid - stack CELL*2 ;clean-up - - push.pri ;push the result of the last call - push.c KickMsg ;push the kick message - push.c CELL*2 ;push 2 args - sysreq.c server_cmd ;call server_cmd - stack CELL*3 ;clean-up - - zero.pri ;return 0 - retn ;final cleanup -ENDP - -.DATA - VisCvar db "sv_visiblemaxplayers" - -.CODE -;players, maxplayrs, limit -PROC setVisibleSlots - stack -CELL ;new variable - - load.s.pri ARGN(0) ;get first parameter into [PRI] - add.c 1 ;[PRI] += 1 - stor.s.pri -CELL ;[var] = [PRI] - - load.s.pri ARGN(0) ;Reset [PRI] to first param - load.s.alt ARGN(1) ;get second parameter into [ALT] - jeq setMax ;does players == maxplayers? - jump setLimitCheck ; -- no, jump to next check -setMax: ; -- yes - stor.s.alt -CELL ; store the maxplayers into [var] - jump endSetIf ; we're done, jump to the end -setLimitCheck: - load.s.alt ARGN(2) ;load the third param into [ALT] - jless setLimit ;is playres < limit? - jump endSetIf ; -- no, jump to end -setLimit: ; -- yes - stor.s.alt -CELL ;store limit into [var] -endSetIf: - - push.s -CELL ;push [var] onto stack - push.c VisCvar ;push cvar onto stack - push.c CELL*2 ;push 2 args - sysreq.c set_cvar_num ;call set_cvar_num - stack CELL*3 ;clean-up - - stack CELL ;restore stack - zero.pri ;return 0 - retn ;final cleanup -ENDP - -PROC client_authorized - push.c 0 ;push 0 args - sysreq.c get_maxplayers ;call get_maxplayers - stack CELL ;clean-up - push.pri ;store the result - maxplayers - - push.c 1 ;push 1 - push.c CELL ;push 1 args - sysreq.c get_playersnum ;call get_playersnum - stack CELL*2 ;clean-up - push.pri ;store the result - players - - push.c Cvar ;push cvar - push.c CELL ;push 1 arg - sysreq.c get_cvar_num ;call get_cvar_num - stack CELL*2 ;clean-up - xchg ;last result is now in alt - - load.s.pri -CELL ;load the first result into pri - sub ;pri = maxplayers - cvar - push.pri ;store the result - limit - - push.s ARGN(0) ;push the id - push.c CELL ;push 1 arg - sysreq.c get_user_flags ;call get_user_flags - stack CELL*2 ;clean-up - const.alt 2 ;2 = ADMIN_RESERVATION - and ;flags & 2 - - jeq setVis ;if (flags & 2) == 2, short circuit - ;otherwise check this condition - load.s.pri -CELL*2 ;load players into pri - load.s.alt -CELL*3 ;load limit into alt - jleq setVis ;if players <= limit, jump - jump setVisSkip ;otherwise skip -setVis: - push.s -CELL*3 ;push limit - push.s -CELL ;push maxplayers - push.s -CELL*2 ;push players - push.c CELL*3 ;push 3 args - call setVisibleSlots ;call setVisibleSlots - stack CELL*3 ;restore stack - zero.pri ;return 0 - retn ;finalize -setVisSkip: - - push.c loopBack ;push loopback cmd - push.s ARGN(0) ;push the id passed - push.c CELL*2 ;push 2 args - sysreq.c client_cmd ;call client_cmd - stack CELL*3 ;clean-up - - stack CELL*3 ;restore stack - const.pri PLUGIN_HANDLED ;return - retn ;finalize -ENDP - -PROC client_disconnect - push.c 0 ;push 0 args - sysreq.c get_maxplayers ;call get_maxplayers - stack CELL ;clean-up - push.pri ;store the result - maxplayers - - push.c 1 ;push 1 - push.c CELL ;push 1 args - sysreq.c get_playersnum ;call get_playersnum - stack CELL*2 ;clean-up - push.pri ;store the result - players - dec.s -CELL*2 ;players-- - - push.c Cvar ;push cvar - push.c CELL ;push 1 arg - sysreq.c get_cvar_num ;call get_cvar_num - stack CELL*2 ;clean-up - xchg ;last result is now in alt - load.s.pri -CELL ;[pri] = maxplayers - sub ;[pri] = maxplayers - cvar - push.pri ;store the result - limit - - push.s -CELL*3 ;push limit - push.s -CELL ;push maxplayers - push.s -CELL*2 ;push playersnum-1 - push.c CELL*3 ;push 3 args - call setVisibleSlots ;call - - stack 3*CELL ;clean up 3 vars - - zero.pri ;return 0 - retn ;finalize -ENDP - - -.PUBLIC - ackSignal - plugin_init - client_authorized - client_disconnect \ No newline at end of file diff --git a/compiler/scasm/amx.h b/compiler/scasm/amx.h deleted file mode 100755 index f237b537..00000000 --- a/compiler/scasm/amx.h +++ /dev/null @@ -1,432 +0,0 @@ -/* Pawn Abstract Machine (for the Pawn language) - * - * Copyright (c) ITB CompuPhase, 1997-2005 - * - * This software is provided "as-is", without any express or implied warranty. - * In no event will the authors be held liable for any damages arising from - * the use of this software. - * - * Permission is granted to anyone to use this software for any purpose, - * including commercial applications, and to alter it and redistribute it - * freely, subject to the following restrictions: - * - * 1. The origin of this software must not be misrepresented; you must not - * claim that you wrote the original software. If you use this software in - * a product, an acknowledgment in the product documentation would be - * appreciated but is not required. - * 2. Altered source versions must be plainly marked as such, and must not be - * misrepresented as being the original software. - * 3. This notice may not be removed or altered from any source distribution. - * - * Version: $Id: amx.h 3736 2008-08-16 20:13:12Z damagedsoul $ - */ - -#if defined FREEBSD && !defined __FreeBSD__ - #define __FreeBSD__ -#endif -#if defined LINUX || defined __FreeBSD__ || defined __OpenBSD__ - #include -#endif - -#ifndef AMX_H_INCLUDED -#define AMX_H_INCLUDED - -#if defined HAVE_STDINT_H - #include -#else - #if defined __LCC__ || defined __DMC__ || defined LINUX - #if defined HAVE_INTTYPES_H - #include - #else - #include - #endif - #elif !defined __STDC_VERSION__ || __STDC_VERSION__ < 199901L - /* The ISO C99 defines the int16_t and int_32t types. If the compiler got - * here, these types are probably undefined. - */ - #if defined __MACH__ - #include - typedef unsigned short int uint16_t; - typedef unsigned long int uint32_t; - #elif defined __FreeBSD__ - #include - #else - typedef short int int16_t; - typedef unsigned short int uint16_t; - #if defined SN_TARGET_PS2 - typedef int int32_t; - typedef unsigned int uint32_t; - #else - typedef long int int32_t; - typedef unsigned long int uint32_t; - #endif - #if defined __WIN32__ || defined _WIN32 || defined WIN32 - typedef __int64 int64_t; - typedef unsigned __int64 uint64_t; - #define HAVE_I64 - #elif defined __GNUC__ - typedef long long int64_t; - typedef unsigned long long uint64_t; - #define HAVE_I64 - #endif - #endif - #endif - #define HAVE_STDINT_H -#endif -#if defined _LP64 || defined WIN64 || defined _WIN64 - #if !defined __64BIT__ - #define __64BIT__ - #endif -#endif - -#if HAVE_ALLOCA_H - #include -#endif -#if defined __WIN32__ || defined _WIN32 || defined WIN32 /* || defined __MSDOS__ */ - #if !defined alloca - #define alloca(n) _alloca(n) - #endif -#endif - -#if !defined arraysize - #define arraysize(array) (sizeof(array) / sizeof((array)[0])) -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -#if defined PAWN_DLL - #if !defined AMX_NATIVE_CALL - #define AMX_NATIVE_CALL __stdcall - #endif - #if !defined AMXAPI - #define AMXAPI __stdcall - #endif -#endif - -/* calling convention for native functions */ -#if !defined AMX_NATIVE_CALL - #define AMX_NATIVE_CALL -#endif -/* calling convention for all interface functions and callback functions */ -#if !defined AMXAPI - #if defined STDECL - #define AMXAPI __stdcall - #elif defined CDECL - #define AMXAPI __cdecl - #elif defined GCC_HASCLASSVISIBILITY - #define AMXAPI __attribute__ ((visibility("default"))) - #else - #define AMXAPI - #endif -#endif -#if !defined AMXEXPORT - #define AMXEXPORT -#endif - -/* File format version Required AMX version - * 0 (original version) 0 - * 1 (opcodes JUMP.pri, SWITCH and CASETBL) 1 - * 2 (compressed files) 2 - * 3 (public variables) 2 - * 4 (opcodes SWAP.pri/alt and PUSHADDR) 4 - * 5 (tagnames table) 4 - * 6 (reformatted header) 6 - * 7 (name table, opcodes SYMTAG & SYSREQ.D) 7 - * 8 (opcode STMT, renewed debug interface) 8 - */ -#define CUR_FILE_VERSION 8 /* current file version; also the current AMX version */ -#define MIN_FILE_VERSION 6 /* lowest supported file format version for the current AMX version */ -#define MIN_AMX_VERSION 8 /* minimum AMX version needed to support the current file format */ - -#if !defined PAWN_CELL_SIZE - #define PAWN_CELL_SIZE 32 /* by default, use 32-bit cells */ -#endif -#if PAWN_CELL_SIZE==16 - typedef uint16_t ucell; - typedef int16_t cell; -#elif PAWN_CELL_SIZE==32 - typedef uint32_t ucell; - typedef int32_t cell; -#elif PAWN_CELL_SIZE==64 - typedef uint64_t ucell; - typedef int64_t cell; -#else - #error Unsupported cell size (PAWN_CELL_SIZE) -#endif - -#define UNPACKEDMAX ((1L << (sizeof(cell)-1)*8) - 1) -#define UNLIMITED (~1u >> 1) - -struct tagAMX; -typedef cell (AMX_NATIVE_CALL *AMX_NATIVE)(struct tagAMX *amx, cell *params); -typedef int (AMXAPI *AMX_CALLBACK)(struct tagAMX *amx, cell index, - cell *result, cell *params); -typedef int (AMXAPI *AMX_DEBUG)(struct tagAMX *amx); -#if !defined _FAR - #define _FAR -#endif - -#if defined _MSC_VER - #pragma warning(disable:4103) /* disable warning message 4103 that complains - * about pragma pack in a header file */ - #pragma warning(disable:4100) /* "'%$S' : unreferenced formal parameter" */ -#endif - -/* Some compilers do not support the #pragma align, which should be fine. Some - * compilers give a warning on unknown #pragmas, which is not so fine... - */ -#if (defined SN_TARGET_PS2 || defined __GNUC__) && !defined AMX_NO_ALIGN - #define AMX_NO_ALIGN -#endif - -#if defined __GNUC__ - #define PACKED __attribute__((packed)) -#else - #define PACKED -#endif - -#if !defined AMX_NO_ALIGN - #if defined LINUX || defined __FreeBSD__ - #pragma pack(1) /* structures must be packed (byte-aligned) */ - #elif defined MACOS && defined __MWERKS__ - #pragma options align=mac68k - #else - #pragma pack(push) - #pragma pack(1) /* structures must be packed (byte-aligned) */ - #if defined __TURBOC__ - #pragma option -a- /* "pack" pragma for older Borland compilers */ - #endif - #endif -#endif - -typedef struct tagAMX_NATIVE_INFO { - const char _FAR *name PACKED; - AMX_NATIVE func PACKED; -} PACKED AMX_NATIVE_INFO; - -#define AMX_USERNUM 4 -#define sEXPMAX 19 /* maximum name length for file version <= 6 */ -#define sNAMEMAX 31 /* maximum name length of symbol name */ - -typedef struct tagAMX_FUNCSTUB { - ucell address PACKED; - char name[sEXPMAX+1]; -} PACKED AMX_FUNCSTUB; - -typedef struct tagFUNCSTUBNT { - ucell address PACKED; - ucell nameofs PACKED; //we need this for amxx to be backwards comaptible -} PACKED AMX_FUNCSTUBNT; - -/* The AMX structure is the internal structure for many functions. Not all - * fields are valid at all times; many fields are cached in local variables. - */ -typedef struct tagAMX { - unsigned char _FAR *base PACKED; /* points to the AMX header plus the code, optionally also the data */ - unsigned char _FAR *data PACKED; /* points to separate data+stack+heap, may be NULL */ - AMX_CALLBACK callback PACKED; - AMX_DEBUG debug PACKED; /* debug callback */ - /* for external functions a few registers must be accessible from the outside */ - cell cip PACKED; /* instruction pointer: relative to base + amxhdr->cod */ - cell frm PACKED; /* stack frame base: relative to base + amxhdr->dat */ - cell hea PACKED; /* top of the heap: relative to base + amxhdr->dat */ - cell hlw PACKED; /* bottom of the heap: relative to base + amxhdr->dat */ - cell stk PACKED; /* stack pointer: relative to base + amxhdr->dat */ - cell stp PACKED; /* top of the stack: relative to base + amxhdr->dat */ - int flags PACKED; /* current status, see amx_Flags() */ - /* user data */ - long usertags[AMX_USERNUM] PACKED; - void _FAR *userdata[AMX_USERNUM] PACKED; - /* native functions can raise an error */ - int error PACKED; - /* passing parameters requires a "count" field */ - int paramcount; - /* the sleep opcode needs to store the full AMX status */ - cell pri PACKED; - cell alt PACKED; - cell reset_stk PACKED; - cell reset_hea PACKED; - cell sysreq_d PACKED; /* relocated address/value for the SYSREQ.D opcode */ - /* support variables for the JIT */ - int reloc_size PACKED; /* required temporary buffer for relocations */ - long code_size PACKED; /* estimated memory footprint of the native code */ -} PACKED AMX; - -/* The AMX_HEADER structure is both the memory format as the file format. The - * structure is used internaly. - */ -typedef struct tagAMX_HEADER { - int32_t size PACKED; /* size of the "file" */ - uint16_t magic PACKED; /* signature */ - char file_version; /* file format version */ - char amx_version; /* required version of the AMX */ - int16_t flags PACKED; - int16_t defsize PACKED; /* size of a definition record */ - int32_t cod PACKED; /* initial value of COD - code block */ - int32_t dat PACKED; /* initial value of DAT - data block */ - int32_t hea PACKED; /* initial value of HEA - start of the heap */ - int32_t stp PACKED; /* initial value of STP - stack top */ - int32_t cip PACKED; /* initial value of CIP - the instruction pointer */ - int32_t publics PACKED; /* offset to the "public functions" table */ - int32_t natives PACKED; /* offset to the "native functions" table */ - int32_t libraries PACKED; /* offset to the table of libraries */ - int32_t pubvars PACKED; /* the "public variables" table */ - int32_t tags PACKED; /* the "public tagnames" table */ - int32_t nametable PACKED; /* name table */ -} PACKED AMX_HEADER; - -//This is always the same for us -#define AMX_MAGIC 0xf1e0 - -enum { - AMX_ERR_NONE, - /* reserve the first 15 error codes for exit codes of the abstract machine */ - AMX_ERR_EXIT, /* forced exit */ - AMX_ERR_ASSERT, /* assertion failed */ - AMX_ERR_STACKERR, /* stack/heap collision */ - AMX_ERR_BOUNDS, /* index out of bounds */ - AMX_ERR_MEMACCESS, /* invalid memory access */ - AMX_ERR_INVINSTR, /* invalid instruction */ - AMX_ERR_STACKLOW, /* stack underflow */ - AMX_ERR_HEAPLOW, /* heap underflow */ - AMX_ERR_CALLBACK, /* no callback, or invalid callback */ - AMX_ERR_NATIVE, /* native function failed */ - AMX_ERR_DIVIDE, /* divide by zero */ - AMX_ERR_SLEEP, /* go into sleepmode - code can be restarted */ - AMX_ERR_INVSTATE, /* invalid state for this access */ - - AMX_ERR_MEMORY = 16, /* out of memory */ - AMX_ERR_FORMAT, /* invalid file format */ - AMX_ERR_VERSION, /* file is for a newer version of the AMX */ - AMX_ERR_NOTFOUND, /* function not found */ - AMX_ERR_INDEX, /* invalid index parameter (bad entry point) */ - AMX_ERR_DEBUG, /* debugger cannot run */ - AMX_ERR_INIT, /* AMX not initialized (or doubly initialized) */ - AMX_ERR_USERDATA, /* unable to set user data field (table full) */ - AMX_ERR_INIT_JIT, /* cannot initialize the JIT */ - AMX_ERR_PARAMS, /* parameter error */ - AMX_ERR_DOMAIN, /* domain error, expression result does not fit in range */ - AMX_ERR_GENERAL, /* general error (unknown or unspecific error) */ -}; - -/* AMX_FLAG_CHAR16 0x01 no longer used */ -#define AMX_FLAG_DEBUG 0x02 /* symbolic info. available */ -#define AMX_FLAG_COMPACT 0x04 /* compact encoding */ -#define AMX_FLAG_BYTEOPC 0x08 /* opcode is a byte (not a cell) */ -#define AMX_FLAG_NOCHECKS 0x10 /* no array bounds checking; no STMT opcode */ -#define AMX_FLAG_NTVREG 0x1000 /* all native functions are registered */ -#define AMX_FLAG_JITC 0x2000 /* abstract machine is JIT compiled */ -#define AMX_FLAG_BROWSE 0x4000 /* busy browsing */ -#define AMX_FLAG_RELOC 0x8000 /* jump/call addresses relocated */ - -#define AMX_EXEC_MAIN -1 /* start at program entry point */ -#define AMX_EXEC_CONT -2 /* continue from last address */ - -#define AMX_USERTAG(a,b,c,d) ((a) | ((b)<<8) | ((long)(c)<<16) | ((long)(d)<<24)) - -#if !defined AMX_COMPACTMARGIN - #define AMX_COMPACTMARGIN 64 -#endif - -/* for native functions that use floating point parameters, the following - * two macros are convenient for casting a "cell" into a "float" type _without_ - * changing the bit pattern - */ -#if PAWN_CELL_SIZE==32 - #define amx_ftoc(f) ( * ((cell*)&f) ) /* float to cell */ - #define amx_ctof(c) ( * ((float*)&c) ) /* cell to float */ -#elif PAWN_CELL_SIZE==64 - #define amx_ftoc(f) ( * ((cell*)&f) ) /* float to cell */ - #define amx_ctof(c) ( * ((double*)&c) ) /* cell to float */ -#else - #error Unsupported cell size -#endif - -#define amx_StrParam(amx,param,result) \ - do { \ - cell *amx_cstr_; int amx_length_; \ - amx_GetAddr((amx), (param), &amx_cstr_); \ - amx_StrLen(amx_cstr_, &amx_length_); \ - if (amx_length_ > 0 && \ - ((result) = (void*)alloca((amx_length_ + 1) * sizeof(*(result)))) != NULL) \ - amx_GetString((char*)(result), amx_cstr_, sizeof(*(result))>1, amx_length_); \ - else (result) = NULL; \ - } while (0) - -uint16_t * AMXAPI amx_Align16(uint16_t *v); -uint32_t * AMXAPI amx_Align32(uint32_t *v); -#if defined _I64_MAX || defined HAVE_I64 - uint64_t * AMXAPI amx_Align64(uint64_t *v); -#endif -int AMXAPI amx_Allot(AMX *amx, int cells, cell *amx_addr, cell **phys_addr); -int AMXAPI amx_Callback(AMX *amx, cell index, cell *result, cell *params); -int AMXAPI amx_Cleanup(AMX *amx); -int AMXAPI amx_Clone(AMX *amxClone, AMX *amxSource, void *data); -int AMXAPI amx_Exec(AMX *amx, cell *retval, int index); -int AMXAPI amx_FindNative(AMX *amx, const char *name, int *index); -int AMXAPI amx_FindPublic(AMX *amx, const char *funcname, int *index); -int AMXAPI amx_FindPubVar(AMX *amx, const char *varname, cell *amx_addr); -int AMXAPI amx_FindTagId(AMX *amx, cell tag_id, char *tagname); -int AMXAPI amx_Flags(AMX *amx,uint16_t *flags); -int AMXAPI amx_GetAddr(AMX *amx,cell amx_addr,cell **phys_addr); -int AMXAPI amx_GetNative(AMX *amx, int index, char *funcname); -int AMXAPI amx_GetPublic(AMX *amx, int index, char *funcname); -int AMXAPI amx_GetPubVar(AMX *amx, int index, char *varname, cell *amx_addr); -int AMXAPI amx_GetString(char *dest,const cell *source, int use_wchar, size_t size); -int AMXAPI amx_GetTag(AMX *amx, int index, char *tagname, cell *tag_id); -int AMXAPI amx_GetUserData(AMX *amx, long tag, void **ptr); -int AMXAPI amx_Init(AMX *amx, void *program); -int AMXAPI amx_InitJIT(AMX *amx, void *reloc_table, void *native_code); -int AMXAPI amx_MemInfo(AMX *amx, long *codesize, long *datasize, long *stackheap); -int AMXAPI amx_NameLength(AMX *amx, int *length); -AMX_NATIVE_INFO * AMXAPI amx_NativeInfo(const char *name, AMX_NATIVE func); -int AMXAPI amx_NumNatives(AMX *amx, int *number); -int AMXAPI amx_NumPublics(AMX *amx, int *number); -int AMXAPI amx_NumPubVars(AMX *amx, int *number); -int AMXAPI amx_NumTags(AMX *amx, int *number); -int AMXAPI amx_Push(AMX *amx, cell value); -int AMXAPI amx_PushArray(AMX *amx, cell *amx_addr, cell **phys_addr, const cell array[], int numcells); -int AMXAPI amx_PushString(AMX *amx, cell *amx_addr, cell **phys_addr, const char *string, int pack, int use_wchar); -int AMXAPI amx_RaiseError(AMX *amx, int error); -int AMXAPI amx_Register(AMX *amx, const AMX_NATIVE_INFO *nativelist, int number); -int AMXAPI amx_Release(AMX *amx, cell amx_addr); -int AMXAPI amx_SetCallback(AMX *amx, AMX_CALLBACK callback); -int AMXAPI amx_SetDebugHook(AMX *amx, AMX_DEBUG debug); -int AMXAPI amx_SetString(cell *dest, const char *source, int pack, int use_wchar, size_t size); -int AMXAPI amx_SetUserData(AMX *amx, long tag, void *ptr); -int AMXAPI amx_StrLen(const cell *cstring, int *length); -int AMXAPI amx_UTF8Check(const char *string, int *length); -int AMXAPI amx_UTF8Get(const char *string, const char **endptr, cell *value); -int AMXAPI amx_UTF8Len(const cell *cstr, int *length); -int AMXAPI amx_UTF8Put(char *string, char **endptr, int maxchars, cell value); - -#if PAWN_CELL_SIZE==16 - #define amx_AlignCell(v) amx_Align16(v) -#elif PAWN_CELL_SIZE==32 - #define amx_AlignCell(v) amx_Align32(v) -#elif PAWN_CELL_SIZE==64 && (defined _I64_MAX || defined HAVE_I64) - #define amx_AlignCell(v) amx_Align64(v) -#else - #error Unsupported cell size -#endif - -#define amx_RegisterFunc(amx, name, func) \ - amx_Register((amx), amx_NativeInfo((name),(func)), 1); - -#if !defined AMX_NO_ALIGN - #if defined LINUX || defined __FreeBSD__ - #pragma pack() /* reset default packing */ - #elif defined MACOS && defined __MWERKS__ - #pragma options align=reset - #else - #pragma pack(pop) /* reset previous packing */ - #endif -#endif - -#ifdef __cplusplus -} -#endif - -#endif /* AMX_H_INCLUDED */ diff --git a/compiler/scasm/amx_compiler.cpp b/compiler/scasm/amx_compiler.cpp deleted file mode 100755 index c537d3c0..00000000 --- a/compiler/scasm/amx_compiler.cpp +++ /dev/null @@ -1,2392 +0,0 @@ -/* AMX Assembler - * Copyright (C)2004 David "BAILOPAN" Anderson - * - * This software is provided 'as-is', without any express or implied - * warranty. In no event will the authors be held liable for any damages - * arising from the use of this software. - * - * Permission is granted to anyone to use this software for any purpose, - * including commercial applications, and to alter it and redistribute it - * freely, subject to the following restrictions: - * - * 1. The origin of this software must not be misrepresented; you must not - * claim that you wrote the original software. If you use this software - * in a product, an acknowledgment in the product documentation would be - * appreciated but is not required. - * 2. Altered source versions must be plainly marked as such, and must not be - * misrepresented as being the original software. - * 3. This notice may not be removed or altered from any source distribution. - * - * Version: $Id: amx_compiler.cpp 921 2004-08-21 06:20:27Z dvander $ - */ - -#include "amxasm.h" - -Compiler::Compiler() -{ - curLine = -1; - cellsize = 4; - Output = 0; - stacksize = cellsize * 4096; - debug = false; - pack = false; - dopt = false; - Init(); -} - -Compiler::~Compiler() -{ - Clear(); - delete CDefines; - delete CError; - delete CLabels; - delete CMacros; - delete CNatives; - delete CSymbols; - delete PROC; - delete DAT; -} - -Compiler::Compiler(std::string &f) -{ - curLine = -1; - cellsize = 4; - Output = 0; - filename.assign(f); - stacksize = cellsize * 4096; - debug = false; - pack = false; - dopt = false; - Init(); -} - -bool Compiler::SetDOpt() -{ - bool state = dopt; - - dopt = dopt ? false : true; - - return state; -} - -bool Compiler::SetDebug() -{ - bool state = debug; - - debug = debug ? false : true; - - return state; -} - -bool Compiler::SetPack() -{ - bool state = pack; - - pack = pack ? false : true; - - return state; -} - -void Compiler::Load(std::string &f) -{ - filename.assign(f); -} - -void Compiler::Init() -{ - Compiler *c = this; - /* Load error handling */ - CError = new ErrorMngr(c); - /* Load symbol management */ - CSymbols = new SymbolList; - /* Load constant management */ - CDefines = new DefineMngr; - /* Load macro management */ - CMacros = new MacroList(this); - /* Load DAT management */ - DAT = new DataMngr(cellsize); - /* Load Proc management */ - PROC = new ProcMngr(CError); - /* Load Label management */ - CLabels = new LabelMngr(CError); - /* Load Native management */ - CNatives = new NativeMngr; - /* Load the default symbols + opcodes */ - InitOpcodes(); -} - -int Compiler::CipCount() -{ - std::vector::iterator i; - std::vector::iterator j; - int cipc = 0; - - for (i=CodeList.begin(); i!=CodeList.end(); i++) - { - cipc+=cellsize; - for (j=(*i)->params.begin(); j!=(*i)->params.end(); j++) - { - cipc+=cellsize; - } - } - - return cipc; -} - -void Compiler::WriteCell(FILE *fp, ucell *c, int repeat) -{ - unsigned char T[5] = {0,0,0,0,0}; - unsigned char code = 0; - int index = 0; - ucell p = (*c); - int i = 0; - - for (i=1; i<=repeat; i++) - { - if (pack) - { - for (index=0;index<5;index++) - { - T[index]=(unsigned char)(p & 0x7f); - p>>=7; - } - while (index>1 && T[index-1]==0 && (T[index-2] & 0x40)==0) - { - index--; - } - if (index==5 && T[index-1]==0x0f && (T[index-2] & 0x40)!=0) - { - index--; - } - while (index>1 && T[index-1]==0x7f && (T[index-2] & 0x40)!=0) - { - index--; - } - assert(index>0); - while (index-->0) - { - code=(unsigned char)((index==0)?T[index]:(T[index]|0x80)); - fwrite((void*)&code, sizeof(unsigned char), 1, fp); - bitsOut += sizeof(unsigned char); - } - } else { - fwrite((void*)c, sizeof(ucell), 1, fp); - bitsOut += sizeof(ucell); - } - } -} - -bool Compiler::Compile(std::string &out) -{ - if (CodeList.size() < 1 || !CError || CError->GetStatus() >= Err_Error) - { - return false; - } - - bitsOut = 0; - int32_t fileSize = 0; - int16_t magic = (int16_t)AMX_MAGIC; - char file_version = CUR_FILE_VERSION; - char amx_version = MIN_AMX_VERSION; - int16_t flags = 0; - int16_t defsize = 8; - int32_t cod, dat, hea, stp, cip, publics, natives, libraries; - int32_t pubvars, tags, names; - int hdrEnd = sizeof(AMX_HEADER); - - if (debug) - { - flags |= AMX_FLAG_DEBUG; - } - if (pack) - { - flags |= AMX_FLAG_COMPACT; - } - - std::vector ProcList; - std::vector::iterator pl; - std::vector NativeList; - std::vector::iterator nl; - std::map NameMap; - - /* Tables */ - std::vector Nametbl; - std::vector PublicsTable; - std::vector NativesTable; - std::vector::iterator ai; - std::vector::iterator nt; - - PROC->GetPublics(ProcList); - CNatives->GetNatives(NativeList); - - /* The only way I see to do this is to build the nametable first. - */ - - /* Public table starts right after the header */ - publics = hdrEnd; - for (pl = ProcList.begin(); pl != ProcList.end(); pl++) - { - NameRecord n; - AddrTable a; - n.Name = (*pl)->Symbol->sym.c_str(); - a.addr = (*pl)->ASM->cip; - a.offset = (int)Nametbl.size(); - Nametbl.push_back(n); - PublicsTable.push_back(a); - } - - natives = publics + (int)(PublicsTable.size() * (sizeof(int32_t) * 2)); - for (nl = NativeList.begin(); nl != NativeList.end(); nl++) - { - NameRecord n; - AddrTable a; - n.Name = (*nl)->S->sym.c_str(); - a.addr = 0; - a.offset = (int)Nametbl.size(); - Nametbl.push_back(n); - NativesTable.push_back(a); - } - - libraries = natives + (int)(NativesTable.size() * (sizeof(int32_t) * 2)); - pubvars = libraries; - tags = pubvars; - names = tags; - - /* Fill out the tables */ - int cOffset = names + sizeof(int16_t); - int16_t nameHdr = 0x1F; - for (ai = PublicsTable.begin(); ai != PublicsTable.end(); ai++) - { - int off = (*ai).offset; - NameMap[cOffset] = off; - (*ai).offset = cOffset; - cOffset += (int)strlen(Nametbl.at(off).Name) + 1; - } - for (ai = NativesTable.begin(); ai != NativesTable.end(); ai++) - { - int off = (*ai).offset; - NameMap[cOffset] = off; - (*ai).offset = cOffset; - cOffset += (int)strlen(Nametbl.at(off).Name) + 1; - } - - bitsOut = cOffset; - cod = cOffset; - dat = cod + CipCount(); - hea = dat + DAT->GetSize(); - stp = hea + stacksize; - cip = -1; - fileSize = hea; - - std::string amxname; - amxname.assign(out); - size_t pos = amxname.find(".asm"); - if (pos != std::string::npos) - { - amxname.replace(pos, 4, ".amx"); - } else { - amxname.append(".amx"); - } - - FILE *fp = fopen(amxname.c_str(), "wb"); - - fwrite((void*)&fileSize, sizeof(int32_t), 1, fp); - fwrite((void*)&magic, sizeof(int16_t), 1, fp); - fwrite((void*)&file_version, sizeof(char), 1, fp); - fwrite((void*)&amx_version, sizeof(char), 1, fp); - fwrite((void*)&flags, sizeof(int16_t), 1, fp); - fwrite((void*)&defsize, sizeof(int16_t), 1, fp); - - fwrite((void*)&cod, sizeof(int32_t), 1, fp); - fwrite((void*)&dat, sizeof(int32_t), 1, fp); - fwrite((void*)&hea, sizeof(int32_t), 1, fp); - fwrite((void*)&stp, sizeof(int32_t), 1, fp); - fwrite((void*)&cip, sizeof(int32_t), 1, fp); - fwrite((void*)&publics, sizeof(int32_t), 1, fp); - fwrite((void*)&natives, sizeof(int32_t), 1, fp); - fwrite((void*)&libraries, sizeof(int32_t), 1, fp); - fwrite((void*)&pubvars, sizeof(int32_t), 1, fp); - fwrite((void*)&tags, sizeof(int32_t), 1, fp); - fwrite((void*)&names, sizeof(int32_t), 1, fp); - - for (ai = PublicsTable.begin(); ai != PublicsTable.end(); ai++) - { - fwrite((void*)&((*ai).addr), sizeof(int32_t), 1, fp); - fwrite((void*)&((*ai).offset), sizeof(int32_t), 1, fp); - } - - for (ai = NativesTable.begin(); ai != NativesTable.end(); ai++) - { - fwrite((void*)&((*ai).addr), sizeof(int32_t), 1, fp); - fwrite((void*)&((*ai).offset), sizeof(int32_t), 1, fp); - } - - fwrite((void*)&(nameHdr), sizeof(int16_t), 1, fp); - - for (ai = PublicsTable.begin(); ai != PublicsTable.end(); ai++) - { - int off = (*ai).offset; - int offs = NameMap[off]; - const char *s = Nametbl.at(offs).Name; - fwrite(s, sizeof(char), strlen(s)+1, fp); - } - - for (ai = NativesTable.begin(); ai != NativesTable.end(); ai++) - { - int off = (*ai).offset; - int offs = NameMap[off]; - const char *s = Nametbl.at(offs).Name; - fwrite(s, sizeof(char), strlen(s)+1, fp); - } - - /* Write the code */ - - std::vector::iterator ci; - std::vector::iterator di; - ucell cop = 0; - for (ci = CodeList.begin(); ci != CodeList.end(); ci++) - { - cop = (*ci)->op; - WriteCell(fp, &cop, 1); - for (di = (*ci)->params.begin(); di != (*ci)->params.end(); di++) - { - cop = (*di); - WriteCell(fp, &cop, 1); - } - } - - std::vector dm; - std::vector::iterator dmi; - DAT->GetData(dm); - - ucell val = 0; - const char *s = 0; - for (dmi = dm.begin(); dmi != dm.end(); dmi++) - { - if ( (*dmi)->db ) - { - if ( (*dmi)->e.GetType() == Val_Number ) - { - val = (*dmi)->e.GetNumber(); - fwrite((void *)&val, sizeof(int32_t), 1, fp); - } else { - s = (*dmi)->e.GetString(); - for (int q = 0; q < (*dmi)->e.Size(); q++) - { - val = s[q]; - WriteCell(fp, &val, 1); - } - } - } else { - if (DAT->IsOptimized()) - break; - ucell c = (*dmi)->fill; - WriteCell(fp, &c, (*dmi)->e.GetNumber()); - } - } - - /* Was packing enabled? Re-output the actual size */ - if (pack) - { - fseek(fp, 0, SEEK_SET); - fwrite((void *)&bitsOut, sizeof(int32_t), 1, fp); - fseek(fp, 0, SEEK_END); - } - - fclose(fp); - - return true; -} - -void Compiler::Clear() -{ - DAT->Clear(); - CDefines->Clear(); - CMacros->Clear(); - CLabels->Clear(); - CNatives->Clear(); - PROC->Clear(); - CSymbols->Clear(); -} - -/* Two pass parser. - * The first pass applies macros + defines + directives - * natives, and data. - * The second pass eats up everything else (code, publics) - */ -bool Compiler::Parse() -{ - FILE *fp = 0; - char buffer[256] = {0}; - std::stack DefStack; - curLine = 0; - AsmSection sec = Asm_None; - lastCip = 0-cellsize; - int pass = 0; -Start: - fp = fopen(filename.c_str(), "rt"); - curLine = 0; - sec = Asm_None; - lastCip = 0-cellsize; - - if (!fp) - { - CError->ErrorMsg(Err_FileOpen, filename.c_str()); - return false; - } - - while (!feof(fp)) - { - fgets(buffer, 255, fp); - curLine+=1; - - /* Check for preprocessor directives */ - if (buffer[0] == '#') - { - std::string procline(buffer); - if (procline.substr(0, 6).compare("#ifdef") == 0) - { - std::string def; - std::string temp; - std::string comp; - StringBreak(procline, def, temp); - StringBreak(temp, def, comp); - DefineMngr::Define *D = 0; - if ( (D = CDefines->FindDefine(def)) == NULL) - { - DefStack.push(0); - } else { - if (D->GetDefine()->compare("0") == 0) - { - DefStack.push(0); - } else { - DefStack.push(1); - } - } - } else if (procline.substr(0, 7).compare("#ifndef") == 0) { - std::string def; - std::string temp; - std::string comp; - StringBreak(procline, def, temp); - StringBreak(temp, def, comp); - DefineMngr::Define *D = 0; - if ( (D = CDefines->FindDefine(def)) == NULL) - { - DefStack.push(1); - } else { - if (D->GetDefine()->compare("0") == 0) - { - DefStack.push(1); - } else { - DefStack.push(0); - } - } - } else if (procline.substr(0, 5).compare("#else") == 0) { - if (!DefStack.empty()) - { - if (DefStack.top() == 1) - { - DefStack.pop(); - DefStack.push(0); - } else if (DefStack.top() == 0) { - DefStack.pop(); - DefStack.push(1); - } - } else { - CError->ErrorMsg(Err_Misplaced_Directive); - } - continue; - } else if (procline.substr(0, 6).compare("#endif") == 0) { - if (!DefStack.empty()) - { - DefStack.pop(); - } else { - CError->ErrorMsg(Err_Misplaced_Directive); - } - continue; - } else { - /* Check for previous operations */ - if (DefStack.size()) - { - if (DefStack.top() < 1) - { - continue; - } - } - // only process directives on pass one - if (pass == 0) - { - ProcessDirective(procline); - } - } - continue; - } - - /* Check for previous operations */ - if (DefStack.size()) - { - if (DefStack.top() < 1) - { - continue; - } - } - - /* Strip the line */ - std::string line(buffer); - - StripComments(line); - Strip(line); - - if (line.size() < 1) - continue; - - /* Check for section state changes */ - if (line[0] == '.') - { - if (line.compare(".DATA") == 0) - { - sec = Asm_Data; - } else if (line.compare(".CODE") == 0) {; - sec = Asm_Code; - } else if (line.compare(".PUBLIC") == 0) { - sec = Asm_Public; - } else if (line.compare(".NATIVE") == 0) { - sec = Asm_Native; - } else { - sec = Asm_Invalid; - CError->ErrorMsg(Err_Invalid_Section, buffer); - } - if (pass == 1) - { - /* Update the labels */ - CLabels->CompleteQueue(true); - while (!LabelStack.empty()) - { - CLabels->EraseLabel(LabelStack.top()); - CSymbols->EraseSymbol(LabelStack.top()); - LabelStack.pop(); - } - } - } else { - /* Do pre-processing */ - CMacros->SearchAndReplace(line); - CDefines->SearchAndReplace(line); - - /* See if we're not in a section */ - if (sec == Asm_None) - { - if (line.size() > 0) - { - CError->ErrorMsg(Err_Wandering_Stuff); - } - } else if (sec == Asm_Invalid) { - /* Just ignore it */ - } else if (sec == Asm_Data) { - if (pass == 1) - continue; - /* Format is Symbol, [db|stat], Data */ - std::string symbol; - std::string data; - std::string buf; - std::string fmt; - - /* Do two splits - line into symbol into data */ - StringBreak(line, symbol, buf); - StringBreak(buf, fmt, data); - - /* Check if the symbol is already defined */ - SymbolList::Symbol *S = NULL; - if ((S = CSymbols->FindSymbol(symbol)) != NULL) - { - CError->ErrorMsg(Err_Symbol_Reuse, symbol.c_str(), S->line); - continue; - } - - if (fmt.compare("db") && fmt.compare("stat")) - { - CError->ErrorMsg(Err_Invalid_Stor, fmt.c_str()); - continue; - } - - if (fmt.compare("db") == 0) - { - /* Add and evaluate the expression */ - CExpr e(CError); - e.Set(data); - e.Evaluate(); - - /* Add into the DAT section */ - DAT->Add(symbol, e, true); - } else if (fmt.compare("stat") == 0) { - CExpr e(CError); - - if (data.find("fill") != std::string::npos) - { - std::string fill, amt; - StringBreak(data, amt, buf); - StringBreak(buf, data, fill); - CExpr t(CError); - t.Set(fill); - t.Evaluate(); - e = EvalE(amt, Sym_None); - DAT->Add(symbol, e, false, t.GetNumber()); - } else { - e = EvalE(data, Sym_None); - DAT->Add(symbol, e, false, 0); - } - } - CSymbols->AddSymbol(symbol, Sym_Dat, CurLine()); - } else if (sec == Asm_Public) { - if (pass == 0) - continue; - if (!IsValidSymbol(line)) - { - CError->ErrorMsg(Err_Invalid_Symbol); - continue; - } - SymbolList::Symbol *S = NULL; - if ( (S = CSymbols->FindSymbol(line)) == NULL) - { - CError->ErrorMsg(Err_Unknown_Symbol, line.c_str()); - continue; - } - if ( (S->type != Sym_Proc) ) - { - CError->ErrorMsg(Err_Symbol_Type, Sym_Proc, S->type); - continue; - } - if (!PROC->SetPublic(line)) - { - CError->ErrorMsg(Err_Unknown_Symbol, line.c_str()); - continue; - } - } else if (sec == Asm_Native) { - if (pass == 1) - continue; - if (!IsValidSymbol(line)) - { - CError->ErrorMsg(Err_Invalid_Symbol); - continue; - } - SymbolList::Symbol *S = NULL; - if ( (S = CSymbols->FindSymbol(line)) != NULL) - { - CError->ErrorMsg(Err_Invalid_Symbol, line.c_str(), S->line); - continue; - } - S = CSymbols->AddSymbol(line, Sym_Native, CurLine()); - CNatives->AddNative(S); - } else if (sec == Asm_Code) { - if (pass == 0) - continue; - std::string code; - std::string params; - SymbolList::Symbol *S; - - StringBreak(line, code, params); - - if (code.compare("PROC") == 0 || code.compare("proc") == 0) - { - /* Check if symbol is valid */ - if (!IsValidSymbol(params)) - { - CError->ErrorMsg(Err_Invalid_Symbol); - continue; - } - /* Check if the symbol is already used */ - if ( (S = CSymbols->FindSymbol(params)) != NULL) - { - if (S->type != Sym_Proc) - { - CError->ErrorMsg(Err_Symbol_Reuse, params.c_str(), S->line); - continue; - } - } - /* Create instruction */ - Asm *ASM = new Asm; - ASM->cip = lastCip + cellsize; - ASM->op = OpCodes["proc"]; - ASM->line = curLine; - lastCip += cellsize; - if (S == NULL) - { - /* Add symbol */ - S = CSymbols->AddSymbol(params, Sym_Proc, CurLine()); - /* Add to PROC list */ - PROC->AddProc(S, ASM); - } else { - ProcMngr::AsmProc *p = 0; - p = PROC->FindProc(params); - - if (p == NULL || p->ASM != NULL) - { - CError->ErrorMsg(Err_Symbol_Reuse, params.c_str(), S->line); - continue; - } else { - p->ASM = ASM; - } - } - /* Add to code list */ - CodeList.push_back(ASM); - } else if (code.compare("ENDP") == 0) { - /* This is, in theory, not needed - * Nonetheless, we check labels here - */ - CLabels->CompleteQueue(true); - while (!LabelStack.empty()) - { - CLabels->EraseLabel(LabelStack.top()); - CSymbols->EraseSymbol(LabelStack.top()); - LabelStack.pop(); - } - } else if (params.size() < 1 && code[code.size()-1] == ':') { - /* Label! */ - /* Check if symbol is valid */ - code.erase(code.size()-1, 1); - if (!IsValidSymbol(code)) - { - CError->ErrorMsg(Err_Invalid_Symbol); - continue; - } - /* Check if the symbol is already used */ - if ( (S = CSymbols->FindSymbol(code)) != NULL) - { - if (S->type == Sym_Label) - { - LabelMngr::Label *p = CLabels->FindLabel(code); - if (p == NULL) - { - CError->ErrorMsg(Err_Invalid_Symbol); - } else { - p->cip = lastCip+cellsize; - p->sym->line = CurLine(); - } - } else { - CError->ErrorMsg(Err_Symbol_Reuse, code.c_str(), S->line); - } - continue; - } else { - if (code[0] == '_') - { - LabelStack.push(code); - } - S = CSymbols->AddSymbol(code, Sym_Label, CurLine()); - CLabels->AddLabel(S, lastCip+cellsize); - } - } else { - /* Check if there is a valid opcode */ - int op = OpCodes[code]; - int argPos; - if (op == OP_NONE) - { - CError->ErrorMsg(Err_Opcode); - continue; - } - - Asm *ASM = 0; - - if (debug) - { - ASM = new Asm; - ASM->cip = lastCip+cellsize; - ASM->op = OP_LINE; - ASM->line = curLine; - ASM->params.push_back(curLine); - ASM->params.push_back(0); - CodeList.push_back(ASM); - lastCip+=cellsize*3; - } - - ASM = new Asm; - - curAsm = ASM; - - std::vector paramList; - - if (params.size() > 0) - { - FindArguments(params, paramList, argPos, true); - if (argPos != (int)(params.size()-1)) - { - assert(0); - CError->ErrorMsg(Err_Unexpected_Char, params[argPos]); - continue; - } - } - - ASM->cip = (lastCip+cellsize); - ASM->op = op; - ASM->line = curLine; - lastCip += cellsize; - - switch (op) - { - case OP_LOAD_PRI: - { - CHK_PARAMS(1); - PUSH_PARAM(1, Sym_Dat); - break; - } - case OP_LOAD_ALT: - { - CHK_PARAMS(1); - PUSH_PARAM(1, Sym_Dat); - break; - } - case OP_LOAD_S_PRI: - { - CHK_PARAMS(1); - PUSH_PARAM(1, Sym_Dat); - break; - } - case OP_LOAD_S_ALT: - { - CHK_PARAMS(1); - PUSH_PARAM(1, Sym_Dat); - break; - } - case OP_LREF_PRI: - { - CHK_PARAMS(1); - PUSH_PARAM(1, Sym_Dat); - break; - } - case OP_LREF_ALT: - { - CHK_PARAMS(1); - PUSH_PARAM(1, Sym_Dat); - break; - } - case OP_LREF_S_PRI: - { - CHK_PARAMS(1); - PUSH_PARAM(1, Sym_Dat); - break; - } - case OP_LREF_S_ALT: - { - CHK_PARAMS(1); - PUSH_PARAM(1, Sym_Dat); - break; - } - case OP_LOAD_I: - { - CHK_PARAMS(0); - break; - } - case OP_LODB_I: - { - CHK_PARAMS(1); - PUSH_PARAM(1, Sym_Dat); - break; - } - case OP_CONST_PRI: - { - CHK_PARAMS(1); - PUSH_PARAM(1, Sym_Dat); - break; - } - case OP_CONST_ALT: - { - CHK_PARAMS(1); - PUSH_PARAM(1, Sym_Dat); - break; - } - case OP_ADDR_PRI: - { - CHK_PARAMS(1); - PUSH_PARAM(1, Sym_Dat); - break; - } - case OP_ADDR_ALT: - { - CHK_PARAMS(1); - PUSH_PARAM(1, Sym_Dat); - break; - } - case OP_STOR_PRI: - { - CHK_PARAMS(1); - PUSH_PARAM(1, Sym_Dat); - break; - } - case OP_STOR_ALT: - { - CHK_PARAMS(1); - PUSH_PARAM(1, Sym_Dat); - break; - } - case OP_STOR_S_PRI: - { - CHK_PARAMS(1); - PUSH_PARAM(1, Sym_Dat); - break; - } - case OP_STOR_S_ALT: - { - CHK_PARAMS(1); - PUSH_PARAM(1, Sym_Dat); - break; - } - case OP_SREF_PRI: - { - CHK_PARAMS(1); - PUSH_PARAM(1, Sym_Dat); - break; - } - case OP_SREF_ALT: - { - CHK_PARAMS(1); - PUSH_PARAM(1, Sym_Dat); - break; - } - case OP_SREF_S_PRI: - { - CHK_PARAMS(1); - PUSH_PARAM(1, Sym_Dat); - break; - } - case OP_SREF_S_ALT: - { - CHK_PARAMS(1); - PUSH_PARAM(1, Sym_Dat); - break; - } - case OP_STOR_I: - { - CHK_PARAMS(0); - break; - } - case OP_STRB_I: - { - CHK_PARAMS(1); - PUSH_PARAM(1, Sym_Dat); - break; - } - case OP_LIDX: - { - CHK_PARAMS(0); - break; - } - case OP_LIDX_B: - { - CHK_PARAMS(1); - PUSH_PARAM(1, Sym_Dat); - break; - } - case OP_IDXADDR: - { - CHK_PARAMS(0); - break; - } - case OP_IDXADDR_B: - { - CHK_PARAMS(1); - PUSH_PARAM(1, Sym_Dat); - break; - } - case OP_ALIGN_PRI: - { - CHK_PARAMS(1); - PUSH_PARAM(1, Sym_Dat); - break; - } - case OP_ALIGN_ALT: - { - CHK_PARAMS(1); - PUSH_PARAM(1, Sym_Dat); - break; - } - case OP_LCTRL: - { - CHK_PARAMS(1); - PUSH_PARAM(1, Sym_Dat); - break; - } - case OP_SCTRL: - { - CHK_PARAMS(1); - PUSH_PARAM(1, Sym_Dat); - break; - } - case OP_MOVE_PRI: - { - CHK_PARAMS(0); - break; - } - case OP_MOVE_ALT: - { - CHK_PARAMS(0); - break; - } - case OP_XCHG: - { - CHK_PARAMS(0); - break; - } - case OP_PUSH_PRI: - { - CHK_PARAMS(0); - break; - } - case OP_PUSH_ALT: - { - CHK_PARAMS(0); - break; - } - case OP_PUSH_R: - { - CHK_PARAMS(1); - PUSH_PARAM(1, Sym_Dat); - break; - } - case OP_PUSH_C: - { - CHK_PARAMS(1); - PUSH_PARAM(1, Sym_Dat); - break; - } - case OP_PUSH: - { - CHK_PARAMS(1); - PUSH_PARAM(1, Sym_Dat); - break; - } - case OP_PUSH_S: - { - CHK_PARAMS(1); - PUSH_PARAM(1, Sym_Dat); - break; - } - case OP_POP_PRI: - { - CHK_PARAMS(0); - break; - } - case OP_POP_ALT: - { - CHK_PARAMS(0); - break; - } - case OP_STACK: - { - CHK_PARAMS(1); - PUSH_PARAM(1, Sym_Dat); - break; - } - case OP_HEAP: - { - CHK_PARAMS(1); - PUSH_PARAM(1, Sym_Dat); - break; - } - case OP_PROC: - { - CHK_PARAMS(0); - break; - } - case OP_RET: - { - CHK_PARAMS(0); - break; - } - case OP_RETN: - { - CHK_PARAMS(0); - break; - } - case OP_CALL: - { - CHK_PARAMS(1); - PUSH_PARAM(1, Sym_Proc); - break; - } - case OP_CALL_PRI: - { - CHK_PARAMS(0); - break; - } - case OP_JUMP: - { - CHK_PARAMS(1); - PUSH_PARAM(1, Sym_Label); - break; - } - case OP_JREL: - { - CHK_PARAMS(1); - PUSH_PARAM(1, Sym_Label); - break; - } - case OP_JZER: - { - CHK_PARAMS(1); - PUSH_PARAM(1, Sym_Label); - break; - } - case OP_JNZ: - { - CHK_PARAMS(1); - PUSH_PARAM(1, Sym_Label); - break; - } - case OP_JEQ: - { - CHK_PARAMS(1); - PUSH_PARAM(1, Sym_Label); - break; - } - case OP_JNEQ: - { - CHK_PARAMS(1); - PUSH_PARAM(1, Sym_Label); - break; - } - case OP_JLESS: - { - CHK_PARAMS(1); - PUSH_PARAM(1, Sym_Label); - break; - } - case OP_JLEQ: - { - CHK_PARAMS(1); - PUSH_PARAM(1, Sym_Label); - break; - } - case OP_JGRTR: - { - CHK_PARAMS(1); - PUSH_PARAM(1, Sym_Label); - break; - } - case OP_JGEQ: - { - CHK_PARAMS(1); - PUSH_PARAM(1, Sym_Label); - break; - } - case OP_JSLESS: - { - CHK_PARAMS(1); - PUSH_PARAM(1, Sym_Label); - break; - } - case OP_JSLEQ: - { - CHK_PARAMS(1); - PUSH_PARAM(1, Sym_Label); - break; - } - case OP_JSGRTR: - { - CHK_PARAMS(1); - PUSH_PARAM(1, Sym_Label); - break; - } - case OP_JSGEQ: - { - CHK_PARAMS(1); - PUSH_PARAM(1, Sym_Label); - break; - } - case OP_SHL: - { - CHK_PARAMS(0); - break; - } - case OP_SHR: - { - CHK_PARAMS(0); - break; - } - case OP_SSHR: - { - CHK_PARAMS(0); - break; - } - case OP_SHL_C_PRI: - { - CHK_PARAMS(1); - PUSH_PARAM(1, Sym_Dat); - break; - } - case OP_SHL_C_ALT: - { - CHK_PARAMS(1); - PUSH_PARAM(1, Sym_Dat); - break; - } - case OP_SHR_C_PRI: - { - CHK_PARAMS(1); - PUSH_PARAM(1, Sym_Dat); - break; - } - case OP_SHR_C_ALT: - { - CHK_PARAMS(1); - PUSH_PARAM(1, Sym_Dat); - break; - } - case OP_SMUL: - { - CHK_PARAMS(0); - break; - } - case OP_SDIV: - { - CHK_PARAMS(0); - break; - } - case OP_SDIV_ALT: - { - CHK_PARAMS(0); - break; - } - case OP_UMUL: - { - CHK_PARAMS(0); - break; - } - case OP_UDIV: - { - CHK_PARAMS(0); - break; - } - case OP_UDIV_ALT: - { - CHK_PARAMS(0); - break; - } - case OP_ADD: - { - CHK_PARAMS(0); - break; - } - case OP_SUB: - { - CHK_PARAMS(0); - break; - } - case OP_SUB_ALT: - { - CHK_PARAMS(0); - break; - } - case OP_AND: - { - CHK_PARAMS(0); - break; - } - case OP_OR: - { - CHK_PARAMS(0); - break; - } - case OP_XOR: - { - CHK_PARAMS(0); - break; - } - case OP_NOT: - { - CHK_PARAMS(0); - break; - } - case OP_NEG: - { - CHK_PARAMS(0); - break; - } - case OP_INVERT: - { - CHK_PARAMS(0); - break; - } - case OP_ADD_C: - { - CHK_PARAMS(1); - PUSH_PARAM(1, Sym_Dat); - break; - } - case OP_SMUL_C: - { - CHK_PARAMS(1); - PUSH_PARAM(1, Sym_Dat); - break; - } - case OP_ZERO_PRI: - { - CHK_PARAMS(0); - break; - } - case OP_ZERO_ALT: - { - CHK_PARAMS(0); - break; - } - case OP_ZERO: - { - CHK_PARAMS(1); - PUSH_PARAM(1, Sym_Dat); - break; - } - case OP_ZERO_S: - { - CHK_PARAMS(1); - PUSH_PARAM(1, Sym_Dat); - break; - } - case OP_SIGN_PRI: - { - CHK_PARAMS(0); - break; - } - case OP_SIGN_ALT: - { - CHK_PARAMS(0); - break; - } - case OP_EQ: - { - CHK_PARAMS(0); - break; - } - case OP_NEQ: - { - CHK_PARAMS(0); - break; - } - case OP_LESS: - { - CHK_PARAMS(0); - break; - } - case OP_LEQ: - { - CHK_PARAMS(0); - break; - } - case OP_GRTR: - { - CHK_PARAMS(0); - break; - } - case OP_GEQ: - { - CHK_PARAMS(0); - break; - } - case OP_SLESS: - { - CHK_PARAMS(0); - break; - } - case OP_SLEQ: - { - CHK_PARAMS(0); - break; - } - case OP_SGRTR: - { - CHK_PARAMS(0); - break; - } - case OP_SGEQ: - { - CHK_PARAMS(0); - break; - } - case OP_EQ_C_PRI: - { - CHK_PARAMS(1); - PUSH_PARAM(1, Sym_Dat); - break; - } - case OP_EQ_C_ALT: - { - CHK_PARAMS(1); - PUSH_PARAM(1, Sym_Dat); - break; - } - case OP_INC_PRI: - { - CHK_PARAMS(0); - break; - } - case OP_INC_ALT: - { - CHK_PARAMS(0); - break; - } - case OP_INC: - { - CHK_PARAMS(1); - PUSH_PARAM(1, Sym_Dat); - break; - } - case OP_INC_S: - { - CHK_PARAMS(1); - PUSH_PARAM(1, Sym_Dat); - break; - } - case OP_INC_I: - { - CHK_PARAMS(0); - break; - } - case OP_DEC_PRI: - { - CHK_PARAMS(0); - break; - } - case OP_DEC_ALT: - { - CHK_PARAMS(0); - break; - } - case OP_DEC: - { - CHK_PARAMS(1); - PUSH_PARAM(1, Sym_Dat); - break; - } - case OP_DEC_S: - { - CHK_PARAMS(1); - PUSH_PARAM(1, Sym_Dat); - break; - } - case OP_DEC_I: - { - CHK_PARAMS(0); - break; - } - case OP_MOVS: - { - CHK_PARAMS(1); - PUSH_PARAM(1, Sym_Dat); - break; - } - case OP_CMPS: - { - CHK_PARAMS(1); - PUSH_PARAM(1, Sym_Dat); - break; - } - case OP_FILL: - { - CHK_PARAMS(1); - PUSH_PARAM(1, Sym_Dat); - break; - } - case OP_HALT: - { - CHK_PARAMS(1); - PUSH_PARAM(1, Sym_Dat); - break; - } - case OP_BOUNDS: - { - CHK_PARAMS(1); - PUSH_PARAM(1, Sym_Dat); - break; - } - case OP_SYSREQ_PRI: - { - CHK_PARAMS(0); - break; - } - case OP_SYSREQ_C: - { - CHK_PARAMS(1); - PUSH_PARAM(1, Sym_Native); - break; - } - case OP_FILE: - { - /* Not yet implemented */ - assert(0); - /*CHK_PARAMS(3); - PUSH_PARAM(1, Sym_Dat); - PUSH_PARAM(1, Sym_Dat); - PUSH_PARAM(1, Sym_Dat);*/ - break; - } - case OP_LINE: - { - CHK_PARAMS(2); - PUSH_PARAM(1, Sym_Dat); - PUSH_PARAM(1, Sym_Dat); - break; - } - case OP_SYMBOL: - { - /* Not yet implemented */ - assert(0); - /*CHK_PARAMS(3); - PUSH_PARAM(1, Sym_Dat); - PUSH_PARAM(1, Sym_Dat); - PUSH_PARAM(1, Sym_Dat);*/ - break; - } - case OP_SRANGE: - { - CHK_PARAMS(2); - PUSH_PARAM(1, Sym_Dat); - PUSH_PARAM(1, Sym_Dat); - break; - } - case OP_JUMP_PRI: - { - CHK_PARAMS(0); - break; - } - case OP_SWITCH: - { - /* Not yet implemented */ - assert(0); - CHK_PARAMS(1); - PUSH_PARAM(1, Sym_Label); - break; - } - case OP_CASETBL: - { - /* Not yet implemented */ - assert(0); - CHK_PARAMS(1); - PUSH_PARAM(1, Sym_Native); - break; - } - case OP_SWAP_PRI: - { - CHK_PARAMS(0); - break; - } - case OP_SWAP_ALT: - { - CHK_PARAMS(0); - break; - } - case OP_PUSHADDR: - { - CHK_PARAMS(1); - PUSH_PARAM(1, Sym_Dat); - break; - } - case OP_NOP: - { - CHK_PARAMS(0); - break; - } - case OP_SYSREQ_D: - { - CHK_PARAMS(1); - PUSH_PARAM(1, Sym_Dat); - break; - } - case OP_SYMTAG: - { - CHK_PARAMS(1); - PUSH_PARAM(1, Sym_Dat); - break; - } - } /* Switch */ - CodeList.push_back(ASM); - } /* Asm_Code */ - } /* Section If */ - } /* Line processing */ - } /* While */ - - // go for second pass - if (pass == 0) - { - pass = 1; - fclose(fp); - if (dopt) - DAT->Optimize(); - goto Start; - } - - /* We're not done! Check the label Queue */ - CLabels->CompleteQueue(); - - /* and the procedure queue ... */ - PROC->CompleteQueue(); - - CError->PrintReport(); - - if (CError->GetStatus() >= Err_Error) - { - return false; - } - - return true; -} - -void Compiler::InitOpcodes() -{ - OpCodes["nop"] = 0; - OpCodes["load.pri"] = 1; - OpCodes["load.alt"] = 2; - OpCodes["load.s.pri"] = 3; - OpCodes["load.s.alt"] = 4; - OpCodes["lref.pri"] = 5; - OpCodes["lref.alt"] = 6; - OpCodes["lref.s.pri"] = 7; - OpCodes["lref.s.alt"] = 8; - OpCodes["load.i"] = 9; - OpCodes["lodb.i"] = 10; - OpCodes["const.pri"] = 11; - OpCodes["const.alt"] = 12; - OpCodes["addr.pri"] = 13; - OpCodes["addr.alt"] = 14; - OpCodes["stor.pri"] = 15; - OpCodes["stor.alt"] = 16; - OpCodes["stor.s.pri"] = 17; - OpCodes["stor.s.alt"] = 18; - OpCodes["sref.pri"] = 19; - OpCodes["sref.alt"] = 20; - OpCodes["sref.s.pri"] = 21; - OpCodes["sref.s.alt"] = 22; - OpCodes["stor.i"] = 23; - OpCodes["strb.i"] = 24; - OpCodes["lidx"] = 25; - OpCodes["lidx.b"] = 26; - OpCodes["idxaddr"] = 27; - OpCodes["idxaddr.b"] = 28; - OpCodes["align.pri"] = 29; - OpCodes["align.alt"] = 30; - OpCodes["lctrl"] = 31; - OpCodes["sctrl"] = 32; - OpCodes["move.pri"] = 33; - OpCodes["move.alt"] = 34; - OpCodes["xchg"] = 35; - OpCodes["push.pri"] = 36; - OpCodes["push.alt"] = 37; - OpCodes["push.r"] = 38; - OpCodes["push.c"] = 39; - OpCodes["push"] = 40; - OpCodes["push.s"] = 41; - OpCodes["pop.pri"] = 42; - OpCodes["pop.alt"] = 43; - OpCodes["stack"] = 44; - OpCodes["heap"] = 45; - OpCodes["proc"] = 46; - OpCodes["ret"] = 47; - OpCodes["retn"] = 48; - OpCodes["call"] = 49; - OpCodes["call.pri"] = 50; - OpCodes["jump"] = 51; - OpCodes["jrel"] = 52; - OpCodes["jzer"] = 53; - OpCodes["jnz"] = 54; - OpCodes["jeq"] = 55; - OpCodes["jneq"] = 56; - OpCodes["jless"] = 57; - OpCodes["jleq"] = 58; - OpCodes["jgrtr"] = 59; - OpCodes["jgeq"] = 60; - OpCodes["jsless"] = 61; - OpCodes["jsleq"] = 62; - OpCodes["jsgrtr"] = 63; - OpCodes["jsgeq"] = 64; - OpCodes["shl"] = 65; - OpCodes["shr"] = 66; - OpCodes["sshr"] = 67; - OpCodes["shl.c.pri"] = 68; - OpCodes["shl.c.alt"] = 69; - OpCodes["shr.c.pri"] = 70; - OpCodes["shr.c.alt"] = 71; - OpCodes["smul"] = 72; - OpCodes["sdiv"] = 73; - OpCodes["sdiv.alt"] = 74; - OpCodes["umul"] = 75; - OpCodes["udiv"] = 76; - OpCodes["udiv.alt"] = 77; - OpCodes["add"] = 78; - OpCodes["sub"] = 79; - OpCodes["sub.alt"] = 80; - OpCodes["and"] = 81; - OpCodes["or"] = 82; - OpCodes["xor"] = 83; - OpCodes["not"] = 84; - OpCodes["neg"] = 85; - OpCodes["invert"] = 86; - OpCodes["add.c"] = 87; - OpCodes["smul.c"] = 88; - OpCodes["zero.pri"] = 89; - OpCodes["zero.alt"] = 90; - OpCodes["zero"] = 91; - OpCodes["zero.s"] = 92; - OpCodes["sign.pri"] = 93; - OpCodes["sign.alt"] = 94; - OpCodes["eq"] = 95; - OpCodes["neq"] = 96; - OpCodes["less"] = 97; - OpCodes["leq"] = 98; - OpCodes["grtr"] = 99; - OpCodes["geq"] = 100; - OpCodes["sless"] = 101; - OpCodes["sleq"] = 102; - OpCodes["sgrtr"] = 103; - OpCodes["sgeq"] = 104; - OpCodes["eq.c.pri"] = 105; - OpCodes["eq.c.alt"] = 106; - OpCodes["inc.pri"] = 107; - OpCodes["inc.alt"] = 108; - OpCodes["inc"] = 109; - OpCodes["inc.s"] = 110; - OpCodes["inc.i"] = 111; - OpCodes["dec.pri"] = 112; - OpCodes["dec.alt"] = 113; - OpCodes["dec"] = 114; - OpCodes["dec.s"] = 115; - OpCodes["dec.i"] = 116; - OpCodes["movs"] = 117; - OpCodes["cmps"] = 118; - OpCodes["fill"] = 119; - OpCodes["halt"] = 120; - OpCodes["bounds"] = 121; - OpCodes["sysreq.pri"] = 122; - OpCodes["sysreq.c"] = 123; - OpCodes["file"] = 124; - OpCodes["line"] = 125; - OpCodes["symbol"] = 126; - OpCodes["srange"] = 127; - OpCodes["jump.pri"] = 128; - OpCodes["switch"] = 129; - OpCodes["casetbl"] = 130; - OpCodes["swap.pri"] = 131; - OpCodes["swap.alt"] = 132; - OpCodes["pushaddr"] = 133; - OpCodes["nop"] = 134; - OpCodes["sysreq.d"] = 135; - OpCodes["symtag"] = 136; - - std::map::iterator i; - for (i=OpCodes.begin(); i!=OpCodes.end(); i++) - { - CSymbols->AddSymbol((*i).first.c_str(), Sym_Reserved, 0); - } - - CSymbols->AddSymbol("db", Sym_Reserved, 0); - CSymbols->AddSymbol("PROC", Sym_Reserved, 0); - CSymbols->AddSymbol("ENDP", Sym_Reserved, 0); - CSymbols->AddSymbol("stat", Sym_Reserved, 0); - - char buf[24]; - sprintf(buf, "%d", cellsize?cellsize:4); - std::string CellDef("CELL"); - std::string Cell(buf); - CDefines->AddDefine(CellDef, Cell); - CSymbols->AddSymbol("CELL", Sym_Define, 0); -} - -char Compiler::OperChar(OpToken c) -{ - switch (c) - { - case Token_Or: - return '|'; - break; - case Token_Xor: - return '^'; - break; - case Token_And: - return '&'; - break; - case Token_Shr: - return '>'; - break; - case Token_Shl: - return '<'; - break; - case Token_Mod: - return '%'; - break; - case Token_Div: - return '/'; - break; - case Token_Mul: - return '*'; - break; - case Token_Sub: - return '-'; - break; - case Token_Add: - return '+'; - break; - case Token_Not: - return '~'; - break; - default: - return Token_None; - break; - } -} - -OpToken Compiler::OperToken(char c) -{ - switch (c) - { - case '|': - return Token_Or; - break; - case '^': - return Token_Xor; - break; - case '&': - return Token_And; - break; - case '>': - return Token_Shr; - break; - case '<': - return Token_Shl; - break; - case '%': - return Token_Mod; - break; - case '/': - return Token_Div; - break; - case '*': - return Token_Mul; - break; - case '-': - return Token_Sub; - break; - case '+': - return Token_Add; - break; - case '~': - return Token_Not; - break; - default: - return Token_None; - break; - } -} - char OperToken(OpToken c); - -/* Returns all the arguments in a list - * This takes literals and expressions into account - * In non-simple mode, It is assumed that the first ( is stripped! - */ -int Compiler::FindArguments(std::string &text, std::vector &List, int &end, bool simple) -{ - unsigned int i = 0, pos = 0; - char c = 0, d = 0, l = 0, size = 0; - std::stack Stack; - end = -1; - - for (i=0; iassign(text.substr(pos, - (i==text.size()-1 && text[i]!=')')? - (i-pos+1):(i-pos))); - } else { - p->assign(text.substr(pos, i-pos+1)); - } - Strip(*p); - pos = i+1; - if (p->size() < 1) - { - delete p; - } else { - List.push_back(p); - size++; - } - end = i; - if (text[i] == ')') - break; - } - } - } - - c = d; - } - - if (!Stack.empty()) - { - CError->ErrorMsg(Err_FatalTokenError); - } - - return size; -} - -void Compiler::ProcessDirective(std::string &text) -{ - Strip(text); - if (text[0] == '#') - text.erase(0, 1); - std::string directive; - std::string definition; - /* Split the directive */ - StringBreak(text, directive, definition); - if (!directive.compare("macro")) - { - Strip(definition); - size_t argPos = definition.find('(', 0); - if (argPos == std::string::npos) - { - CError->ErrorMsg(Err_InvalidMacro, curLine); - } else { - /* Store the symbol, which is read up to the occurrence of ( */ - std::string symbol; - symbol.assign(definition.substr(0, argPos-1)); - /* Check if the symbol is already defined */ - SymbolList::Symbol *S; - if ((S = CSymbols->FindSymbol(symbol)) != NULL) - { - CError->ErrorMsg(Err_SymbolRedef, S->sym.c_str(), S->line); - } - /* Store the argstring, which is the rest of the data */ - std::string argstring; - argstring.assign(definition.substr(argPos+1, definition.size()-argPos+1)); - /* Parse the arg string, storing the results and the offset to the end */ - int bPos; - std::vector ArgList; - FindArguments(argstring, ArgList, bPos); - /* Store the rest in a function string (macro definition) */ - std::string funcstring; - funcstring.assign(argstring.substr(bPos+1, argstring.size()-bPos+1)); - /* Push the macro onto the Macro List */ - Strip(funcstring); - Strip(symbol); - MacroList::Macro *m = CMacros->AddMacroBegin(symbol, funcstring); - std::vector::iterator i; - for (i=ArgList.begin(); i!=ArgList.end(); i++) - { - CMacros->AddMacroArgument(m, *(*i)); - } - CMacros->AddMacroEnd(m); - /* Make sure to add the symbol */ - CSymbols->AddSymbol(symbol, Sym_Macro, curLine); - //TODO: ClearList(ArgList); - } - } else if (!directive.compare("pragma")) { - std::string pragma; - std::string entry; - StringBreak(definition, pragma, entry); - if (pragma.compare("stacksize") == 0) - { - int stksz = atoi(entry.c_str()); - if (stksz < 100) - { - CError->ErrorMsg(Err_Invalid_Pragma); - } else { - stacksize = stksz; - } - } else { - CError->ErrorMsg(Err_Invalid_Pragma); - } - } else if (!directive.compare("define")) { - std::string symbol; - std::string def; - StringBreak(definition, symbol, def); - SymbolList::Symbol *S; - if ((S = CSymbols->FindSymbol(symbol)) != NULL) - { - CError->ErrorMsg(Err_SymbolRedef, S->sym.c_str(), S->line); - } - if (def.size() < 1) - def.assign("1"); - CSymbols->AddSymbol(symbol, Sym_Define, curLine); - CDefines->AddDefine(symbol, def); - } -} - -int Compiler::Eval(std::string &str, SymbolType sym) -{ - CExpr e(CError); - - e = EvalE(str, sym); - - return e.GetNumber(); -} - -/* The evaluator works by storing expressions on a stack. - Each expression is an RPN-ordered pair of lists for ops and values - Every time the stack is popped, the expression is evaluated by searching - for the highest operators and evaluating them. - Note that string literals are not allowed here yet. - */ -CExpr Compiler::EvalE(std::string &str, SymbolType sym) -{ - std::stack Stack; - std::string bpstr; - int i = 0; - rpn *r = new rpn; - int pos = 0; - - Stack.push(r); - - for (i=0; i<(int)str.size(); i++) - { - if (OperToken(str[i]) != Token_None) - { - if ((i == (int)(str.size() - 1)) - || ((OperToken(str[i]) != Token_Not && OperToken(str[i]) != Token_Sub) - && i == 0)) - { - CError->ErrorMsg(Err_Unexpected_Char, str[i]); - return 0; - } - if (str[i] == '<' && str[i+1] != '<') - { - CError->ErrorMsg(Err_Unexpected_Char, str[i]); - return 0; - } - if (str[i] == '>' && str[i+1] != '>') - { - CError->ErrorMsg(Err_Unexpected_Char, str[i]); - return 0; - } - /* Check to see if there are extra tokens */ - if (pos < i || (pos == i && (OperToken(str[i]) == Token_Sub))) - { - bpstr.assign(str.substr(pos, i-pos)); - Strip(bpstr); - CExpr e(CError); - e.Set(bpstr); - e.Evaluate(sym); - r->vals.push_back(e); - } - r->ops.push_back((char)str[i]); - if (str[i] == '>' || str[i] == '<') - { - i++; - } - pos = i+1; - continue; - } else { - if (str[i] == '(') - { - if (pos < i) - { - bpstr.assign(str.substr(pos, i-pos)); - Strip(bpstr); - CExpr e(CError); - e.Set(bpstr); - e.Evaluate(sym); - r->vals.push_back(e); - } - r = new rpn; - Stack.push(r); - pos = i+1; - continue; - } else if (str[i] == ')') { - if (pos < i) - { - bpstr.assign(str.substr(pos, i-pos)); - Strip(bpstr); - CExpr e(CError); - e.Set(bpstr); - e.Evaluate(sym); - r->vals.push_back(e); - } - if (Stack.size() < 2) - { - while (!Stack.empty()) - { - rpn *t = Stack.top(); - if (t) - delete t; - t = 0; - Stack.pop(); - } - CError->ErrorMsg(Err_Unmatched_Token, str[i]); - return 0; - } else { - CExpr t; - t = EvalRpn(r, sym); - delete r; - r = 0; - Stack.pop(); - r = Stack.top(); - r->vals.push_back(t); - pos = i + 1; - } - } else if (i == (int)(str.size() - 1)) { - if (pos < i) - { - bpstr.assign(str.substr(pos)); - } else if (pos == i) { - bpstr.assign(str.substr(pos, 1)); - } - if (pos < i || pos == i) - { - Strip(bpstr); - CExpr e(CError); - e.Set(bpstr); - e.Evaluate(sym); - r->vals.push_back(e); - } - } - } - } - - if (Stack.size() != 1) - { - rpn *t = 0; - while (!Stack.empty()) - { - t = Stack.top(); - if (t) - delete t; - t = 0; - Stack.pop(); - } - CError->ErrorMsg(Err_Unmatched_Token, '('); - return 0; - } - - Stack.pop(); - CExpr final; - final = EvalRpn(r, sym); - - delete r; - r = 0; - - return final; -} - -CExpr Compiler::EvalRpn(rpn *r, SymbolType sym) -{ - int i = 0, j = 0; - CExpr er, el; - std::vector::iterator Q; - std::vector::iterator R; - - while (r->ops.size()) - { - for (i=1; iops.size(); j++) - { - if (r->ops[j] == c) - { - if ((int)r->vals.size() <= j) - assert(0);// Can't have more ops than values - el = r->vals[j]; - if (i != Token_Not) - { - if ((int)r->vals.size() <= j+1) - { - assert(0); - } - er = r->vals[j+1]; - el.Oper((OpToken)i, er); - } else { - el.Not(); - } - R = r->ops.begin(); - Q = r->vals.begin(); - if (i != Token_Not) - { - R += j; - Q += j; - r->ops.erase(R); - r->vals[j+1] = el; - r->vals.erase(Q); - j--; - } else { - R += j; - r->ops.erase(R); - r->vals[j] = el; - } - } - } - } - } - - return r->vals[0]; -} - -void DestroyArgList(std::vector &List) -{ - std::vector::iterator i; - - for (i=List.begin(); i!=List.end(); i++) - { - if ( (*i) ) - delete (*i); - } - - List.clear(); -} - -void Compiler::PrintCodeList() -{ - std::vector::iterator i; - std::vector::iterator j; - - for (i=CodeList.begin(); i!=CodeList.end(); i++) - { - printf("OP: %d [%d]\n", (*i)->op, (*i)->cip); - for (j=(*i)->params.begin(); j!=(*i)->params.end(); j++) - { - printf("\tParameter: %d\n", (*j)); - } - } -} - -int Compiler::DerefSymbol(std::string &str, SymbolType sym) -{ - int val = 0; - - SymbolList::Symbol *S = NULL; - if ( ((S = CSymbols->FindSymbol(str)) == NULL) ) - { - if (sym == Sym_Label) - { - S = CSymbols->AddSymbol(str, Sym_Label, -1); - } else if (sym == Sym_Proc) { - S = CSymbols->AddSymbol(str, Sym_Proc, -1); - } else { - CError->ErrorMsg(Err_Unknown_Symbol, str.c_str()); - return 0; - } - } - if (sym != Sym_Dat && S->type != sym) - { - CError->ErrorMsg(Err_Invalid_Symbol); - return 0; - } - switch (S->type) - { - case Sym_Proc: - { - ProcMngr::AsmProc *p = 0; - - if ( ((p = PROC->FindProc(str)) == NULL) ) - { - /* Labels we handle differently. - Add it to the label queue - */ - p = PROC->AddProc(S, NULL); - PROC->QueueProc(str, CurAsm()); - val = ProcMngr::ncip; - } else if (p->ASM == NULL) { - PROC->QueueProc(str, CurAsm()); - val = ProcMngr::ncip; - } else { - val = p->ASM->cip; - } - break; - } - case Sym_Native: - { - val = CNatives->GetNativeId(str); - if (val == NativeMngr::ncip) - { - CError->ErrorMsg(Err_Invalid_Symbol); - return 0; - } - break; - } - case Sym_Dat: - { - val = DAT->GetOffset(str); - if (val == DataMngr::nof) - { - CError->ErrorMsg(Err_Invalid_Symbol); - return 0; - } - break; - } - case Sym_Label: - { - LabelMngr::Label *L = 0; - - if ( (L = CLabels->FindLabel(str)) == NULL ) - { - /* Labels we handle differently. - Add it to the label queue - */ - L = CLabels->AddLabel(S, LabelMngr::ncip); - CLabels->QueueLabel(str, CurAsm()); - LabelStack.push(str); - } else if (L->cip == LabelMngr::ncip) { - //if we don't queue the label the jump won't be resolved! - CLabels->QueueLabel(str, CurAsm()); - } - - val = L->cip; - break; - } - default: - { - CError->ErrorMsg(Err_Invalid_Symbol); - return 0; - break; - } - } - - return val; -} - -bool Compiler::IsSymbol(std::string &str) -{ - SymbolList::Symbol *S = 0; - - if ( (S = CSymbols->FindSymbol(str)) == NULL ) - return false; - - return true; -} - -rpn::~rpn() -{ -// ops.clear(); -// vals.clear(); -} diff --git a/compiler/scasm/amx_compiler.h b/compiler/scasm/amx_compiler.h deleted file mode 100755 index d919d030..00000000 --- a/compiler/scasm/amx_compiler.h +++ /dev/null @@ -1,110 +0,0 @@ -/* AMX Assembler - * Copyright (C)2004 David "BAILOPAN" Anderson - * - * This software is provided 'as-is', without any express or implied - * warranty. In no event will the authors be held liable for any damages - * arising from the use of this software. - * - * Permission is granted to anyone to use this software for any purpose, - * including commercial applications, and to alter it and redistribute it - * freely, subject to the following restrictions: - * - * 1. The origin of this software must not be misrepresented; you must not - * claim that you wrote the original software. If you use this software - * in a product, an acknowledgment in the product documentation would be - * appreciated but is not required. - * 2. Altered source versions must be plainly marked as such, and must not be - * misrepresented as being the original software. - * 3. This notice may not be removed or altered from any source distribution. - * - * Version: $Id: amx_compiler.h 835 2004-08-12 16:31:50Z dvander $ - */ - -#ifndef _INCLUDE_AMXCOMPILER_H -#define _INCLUDE_AMXCOMPILER_H - -#define CHK_PARAMS(d) \ - if (paramList.size() > d) \ - { \ - CError->ErrorMsg(Warning_Param_Count, paramList.size(), d); \ - } else if (paramList.size() < d) { \ - CError->ErrorMsg(Err_Param_Count, paramList.size(), d); \ - delete ASM; \ - ASM = 0; \ - } - -#define PUSH_PARAM(n,sym) \ - if (paramList.size() >= n) \ - { \ - ASM->params.push_back(Eval(*(paramList[n-1]), sym)); \ - lastCip+=cellsize; \ - } - -class rpn -{ -public: - ~rpn(); - //TODO: use linked lists, but not std::list - std::vector ops; - std::vector vals; -}; - -class Compiler -{ -public: - Compiler(); - ~Compiler(); - Compiler(std::string &f); - void Load(std::string &f); - bool Parse(); - bool Compile(std::string &out); - int CurLine() { return curLine; } - ErrorMngr *ErrorHandler() { return CError; } - void PrintCodeList(); -public: - int FindArguments(std::string &text, std::vector &List, int &end, bool simple = false); - void Clear(); - int CipCount(); - int CurCip() { return lastCip; } - Asm *CurAsm() { return curAsm; } - bool SetDebug(); - bool SetPack(); - bool SetDOpt(); - int DerefSymbol(std::string &str, SymbolType sym = Sym_None); - bool IsSymbol(std::string &str); -private: - void ProcessDirective(std::string &text); - void Init(); - void InitOpcodes(); - int Eval(std::string &str, SymbolType sym = Sym_None); - CExpr EvalE(std::string &str, SymbolType sym = Sym_None); - CExpr EvalRpn(rpn *r, SymbolType sym); - OpToken OperToken(char c); - char OperChar(OpToken c); - void WriteCell(FILE *fp, ucell *c, int repeat); -private: - std::vector CodeList; - std::map OpCodes; - std::stack LabelStack; - char *Output; - ErrorMngr *CError; - SymbolList *CSymbols; - DefineMngr *CDefines; - MacroList *CMacros; - DataMngr *DAT; - ProcMngr *PROC; - LabelMngr *CLabels; - NativeMngr *CNatives; - std::string filename; - int curLine; - int lastCip; - int cellsize; - int stacksize; - bool debug; - bool pack; - bool dopt; - int bitsOut; - Asm *curAsm; -}; - -#endif //_INCLUDE_AMXCOMPILER_H diff --git a/compiler/scasm/amx_data.cpp b/compiler/scasm/amx_data.cpp deleted file mode 100755 index 48758c35..00000000 --- a/compiler/scasm/amx_data.cpp +++ /dev/null @@ -1,196 +0,0 @@ -/* AMX Assembler - * Copyright (C)2004 David "BAILOPAN" Anderson - * - * This software is provided 'as-is', without any express or implied - * warranty. In no event will the authors be held liable for any damages - * arising from the use of this software. - * - * Permission is granted to anyone to use this software for any purpose, - * including commercial applications, and to alter it and redistribute it - * freely, subject to the following restrictions: - * - * 1. The origin of this software must not be misrepresented; you must not - * claim that you wrote the original software. If you use this software - * in a product, an acknowledgment in the product documentation would be - * appreciated but is not required. - * 2. Altered source versions must be plainly marked as such, and must not be - * misrepresented as being the original software. - * 3. This notice may not be removed or altered from any source distribution. - * - * Version: $Id: amx_data.cpp 828 2004-08-11 14:31:26Z dvander $ - */ - -#include "amxasm.h" - -DataMngr::~DataMngr() -{ - Clear(); -} - -void DataMngr::Clear() -{ - std::vector::iterator i; - - for (i=List.begin(); i!=List.end(); i++) - { - if ( (*i) ) - delete (*i); - } - - List.clear(); -} - -DataMngr::Datum::Datum() -{ - db = false; - offset = -1; - fill = 0; - zeroed = false; -} - -void DataMngr::Add(std::string &s, CExpr &expr, bool db, int fill) -{ - DataMngr::Datum *D = new DataMngr::Datum(); - - D->symbol.assign(s); - D->e = expr; - D->fill = fill; - D->db = db; - - int size = 0; - - if (db) - { - size = ((D->e.GetType() == Val_Number) ? - cellsize : D->e.Size() * cellsize); - } else { - size = (D->e.GetNumber() * cellsize); - } - - if (List.size() == 0) - { - D->offset = 0; - } else { - DataMngr::Datum *p = List[List.size()-1]; - if (p->db) - { - D->offset = p->offset + - ((p->e.GetType() == Val_Number) ? - cellsize : p->e.Size() * cellsize); - } else { - D->offset = p->offset + (p->e.GetNumber() * cellsize); - } - } - - cursize += size; - - List.push_back(D); -} - -DataMngr::Datum *DataMngr::FindData(std::string &sym) -{ - std::vector::iterator i; - - for (i=List.begin(); i!=List.end(); i++) - { - if ((*i)->symbol.compare(sym) == 0) - { - return (*i); - } - } - - return NULL; -} - -int DataMngr::GetOffset(std::string &sym) -{ - DataMngr::Datum *D = NULL; - - D = FindData(sym); - - if (D == NULL) - return DataMngr::nof; - - return D->offset; -} - -int DataMngr::GetSize() -{ - return cursize; -} - -void DataMngr::GetData(std::vector &dList) -{ - std::vector::iterator i; - - for (i=List.begin(); i!=List.end(); i++) - { - dList.push_back( (*i) ); - } -} - -void DataMngr::PrintTable() -{ - std::vector::iterator i; - DataMngr::Datum *p = 0; - - printf("Symbol\tSize\n"); - for (i=List.begin(); i!=List.end(); i++) - { - p = (*i); - printf("%s\t%d\n", p->symbol.c_str(), p->offset); - } -} - -//Rewrite the DAT section so empties are at the end -void DataMngr::Optimize() -{ - std::vector DbList; - std::vector MtList; - std::vector::iterator i; - - for (i=List.begin(); i!=List.end(); i++) - { - if ( (*i)->db ) - { - DbList.push_back( (*i) ); - } else if ( (*i)->fill == 0 ) { - MtList.push_back( (*i) ); - } else { - DbList.push_back( (*i) ); - } - } - - List.clear(); - - lastOffset = 0; - cursize = 0; - int size = 0; - - for (i=DbList.begin(); i!=DbList.end(); i++) - { - size = (( (*i)->e.GetType() == Val_Number - || (*i)->e.GetType() == Val_Float ) ? - cellsize : (*i)->e.Size() * cellsize); - (*i)->offset = lastOffset; - lastOffset += size; - (*i)->zeroed = false; - List.push_back( (*i) ); - } - - cursize = lastOffset; - DbList.clear(); - - for (i=MtList.begin(); i!=MtList.end(); i++) - { - size = ( (*i)->e.GetNumber() * cellsize ); - (*i)->offset = lastOffset; - lastOffset += size; - (*i)->zeroed = true; - List.push_back( (*i) ); - } - - MtList.clear(); - - optimized = true; -} diff --git a/compiler/scasm/amx_data.h b/compiler/scasm/amx_data.h deleted file mode 100755 index 3281a1e4..00000000 --- a/compiler/scasm/amx_data.h +++ /dev/null @@ -1,63 +0,0 @@ -/* AMX Assembler - * Copyright (C)2004 David "BAILOPAN" Anderson - * - * This software is provided 'as-is', without any express or implied - * warranty. In no event will the authors be held liable for any damages - * arising from the use of this software. - * - * Permission is granted to anyone to use this software for any purpose, - * including commercial applications, and to alter it and redistribute it - * freely, subject to the following restrictions: - * - * 1. The origin of this software must not be misrepresented; you must not - * claim that you wrote the original software. If you use this software - * in a product, an acknowledgment in the product documentation would be - * appreciated but is not required. - * 2. Altered source versions must be plainly marked as such, and must not be - * misrepresented as being the original software. - * 3. This notice may not be removed or altered from any source distribution. - * - * Version: $Id: amx_data.h 828 2004-08-11 14:31:26Z dvander $ - */ - -#ifndef _INCLUDE_AMXDATA_H -#define _INCLUDE_AMXDATA_H - -class DataMngr -{ -public: - class Datum - { - public: - Datum(); - std::string symbol; - CExpr e; - bool db; - int offset; - int fill; - bool zeroed; - }; -public: - ~DataMngr(); - DataMngr() { cellsize = 4; lastOffset = 0; cursize = 0; optimized = false; } - DataMngr(int cell) { lastOffset = 0; cellsize = cell; cursize = 0; optimized = false; } - void Add(std::string &s, CExpr &expr, bool db = false, int fill = 0); - DataMngr::Datum *FindData(std::string &sym); - void GetData(std::vector &dList); - int GetOffset(std::string &sym); - int GetSize(); - void Clear(); - void PrintTable(); - void Optimize(); - bool IsOptimized() { return optimized; } -private: - std::vector List; - int lastOffset; - int cellsize; - int cursize; - bool optimized; -public: - static const int nof = -1; -}; - -#endif //_INCLUDE_AMXDATA_H diff --git a/compiler/scasm/amx_define.cpp b/compiler/scasm/amx_define.cpp deleted file mode 100755 index dabe1767..00000000 --- a/compiler/scasm/amx_define.cpp +++ /dev/null @@ -1,90 +0,0 @@ -/* AMX Assembler - * Copyright (C)2004 David "BAILOPAN" Anderson - * - * This software is provided 'as-is', without any express or implied - * warranty. In no event will the authors be held liable for any damages - * arising from the use of this software. - * - * Permission is granted to anyone to use this software for any purpose, - * including commercial applications, and to alter it and redistribute it - * freely, subject to the following restrictions: - * - * 1. The origin of this software must not be misrepresented; you must not - * claim that you wrote the original software. If you use this software - * in a product, an acknowledgment in the product documentation would be - * appreciated but is not required. - * 2. Altered source versions must be plainly marked as such, and must not be - * misrepresented as being the original software. - * 3. This notice may not be removed or altered from any source distribution. - * - * Version: $Id: amx_define.cpp 826 2004-08-11 10:01:56Z dvander $ - */ - -#include "amxasm.h" - -DefineMngr::~DefineMngr() -{ - Clear(); -} - -void DefineMngr::Clear() -{ - std::vector::iterator i; - - for (i=List.begin(); i!=List.end(); i++) - { - if ( (*i) ) - delete (*i); - } - - List.clear(); -} - -void DefineMngr::Define::Set(std::string &s, std::string &d) -{ - sym.assign(s); - def.assign(d); -} - -DefineMngr::Define *DefineMngr::AddDefine(std::string &sym, std::string &def) -{ - DefineMngr::Define *D = new DefineMngr::Define; - - D->Set(sym, def); - - List.push_back(D); - - return D; -} - -DefineMngr::Define *DefineMngr::FindDefine(std::string &sym) -{ - std::vector::iterator i; - for (i=List.begin(); i!=List.end(); i++) - { - if ((*i)->GetSymbol()->compare(sym)==0) - { - return (*i); - } - } - return NULL; -} - -void DefineMngr::SearchAndReplace(std::string &text) -{ - std::vector::iterator i; - DefineMngr::Define *D = NULL; - int pos; - - for (i=List.begin(); i!=List.end(); i++) - { - D = (*i); - pos = FindSymbol(text, *(D->GetSymbol()), 0); - if (pos != -1) - { - text.replace(pos, D->GetSymbol()->size(), *(D->GetDefine())); - i = List.begin(); - } - } -} - diff --git a/compiler/scasm/amx_define.h b/compiler/scasm/amx_define.h deleted file mode 100755 index 6a543f99..00000000 --- a/compiler/scasm/amx_define.h +++ /dev/null @@ -1,49 +0,0 @@ -/* AMX Assembler - * Copyright (C)2004 David "BAILOPAN" Anderson - * - * This software is provided 'as-is', without any express or implied - * warranty. In no event will the authors be held liable for any damages - * arising from the use of this software. - * - * Permission is granted to anyone to use this software for any purpose, - * including commercial applications, and to alter it and redistribute it - * freely, subject to the following restrictions: - * - * 1. The origin of this software must not be misrepresented; you must not - * claim that you wrote the original software. If you use this software - * in a product, an acknowledgment in the product documentation would be - * appreciated but is not required. - * 2. Altered source versions must be plainly marked as such, and must not be - * misrepresented as being the original software. - * 3. This notice may not be removed or altered from any source distribution. - * - * Version: $Id: amx_define.h 821 2004-08-11 08:18:14Z dvander $ - */ - -#ifndef _INCLUDE_DEFINE_H -#define _INCLUDE_DEFINE_H - -class DefineMngr -{ -public: - class Define - { - public: - void Set(std::string &s, std::string &d); - const std::string *GetSymbol() { return &sym; } - const std::string *GetDefine() { return &def; } - private: - std::string sym; - std::string def; - }; -private: - std::vector List; -public: - ~DefineMngr(); - void Clear(); - DefineMngr::Define *AddDefine(std::string &sym, std::string &def); - DefineMngr::Define *FindDefine(std::string &sym); - void SearchAndReplace(std::string &text); -}; - -#endif //_INCLUDE_DEFINE_H diff --git a/compiler/scasm/amx_error.cpp b/compiler/scasm/amx_error.cpp deleted file mode 100755 index 5b145536..00000000 --- a/compiler/scasm/amx_error.cpp +++ /dev/null @@ -1,198 +0,0 @@ -/* AMX Assembler - * Copyright (C)2004 David "BAILOPAN" Anderson - * - * This software is provided 'as-is', without any express or implied - * warranty. In no event will the authors be held liable for any damages - * arising from the use of this software. - * - * Permission is granted to anyone to use this software for any purpose, - * including commercial applications, and to alter it and redistribute it - * freely, subject to the following restrictions: - * - * 1. The origin of this software must not be misrepresented; you must not - * claim that you wrote the original software. If you use this software - * in a product, an acknowledgment in the product documentation would be - * appreciated but is not required. - * 2. Altered source versions must be plainly marked as such, and must not be - * misrepresented as being the original software. - * 3. This notice may not be removed or altered from any source distribution. - * - * Version: $Id: amx_error.cpp 835 2004-08-12 16:31:50Z dvander $ - */ - -#include "amxasm.h" - -ErrorMngr::ErrorMngr() -{ - printf("Not instantiated with a compiler."); - Cmp = NULL; - line = -1; - assert(Cmp); -} - -void ErrorMngr::Clear() -{ - Totals[0] = 0; - Totals[1] = 0; - Totals[2] = 0; - Totals[3] = 0; - HighestError = Err_None; -} - -int ErrorMngr::CurLine() -{ - return ((Compiler *)Cmp)->CurLine(); -} - -int ErrorMngr::CurCip() -{ - return ((Compiler *)Cmp)->CurCip(); -} - -ErrorMngr::ErrorMngr(void *c) -{ - Cmp = c; - DefineErrors(); - Totals[0] = 0; - Totals[1] = 0; - Totals[2] = 0; - Totals[3] = 0; - line = -1; - HighestError = Err_None; -} - -ErrorType ErrorMngr::GetErrorType(ErrorCode id) -{ - if (id > fatals_start && id < fatals_end) - return Err_Fatal; - if (id > warnings_start && id < warnings_end) - return Err_Warning; - if (id > notices_start && id < notices_end) - return Err_Notice; - if (id > errors_start && id < errors_end) - return Err_Error; - return Err_None; -} - -void ErrorMngr::DefineErrors() -{ - List.resize(fatals_end+1); - - List.at(Warning_Hex_Start) = "Hexadecimal notation is 0xN, 0 missing"; - List.at(Warning_Null_Expression) = "Bad expression will evaluate to 0"; - List.at(Warning_Param_Count) = "Expected %d parameters, found %d"; - - List.at(Err_String_Terminate) = "String not terminated properly"; - List.at(Err_String_Extra) = "Unexpected characters after string end (character '%c')"; - List.at(Err_Unexpected_Char) = "Unexpected character found (character '%c')"; - List.at(Err_Wandering_Stuff) = "Unknown directive placed outside of a section"; - List.at(Err_Symbol_Reuse) = "Symbol \"%s\" already defined on line %d"; - List.at(Err_Invalid_Stor) = "Invalid DAT storage identifier \"%s\""; - List.at(Err_Unknown_Symbol) = "Unknown symbol \"%s\""; - List.at(Err_Symbol_Type) = "Expected symbol type %d, got %d (bad symbol)"; - List.at(Err_Invalid_Symbol) = "Invalid symbol"; - List.at(Err_Opcode) = "Invalid or unrecognized opcode"; - List.at(Err_Unmatched_Token) = "Unmatched token '%c'"; - List.at(Err_Param_Count) = "Expected %d parameters, found %d"; - List.at(Err_Unknown_Define) = "Unknown define referenced"; - List.at(Err_Misplaced_Directive) = "Misplaced preprocessor directive"; - List.at(Err_Bad_Label) = "Label referenced without being created"; - List.at(Err_Bad_Not) = "Wrong type argument to bit-complement"; - List.at(Err_Invalid_Operator) = "Operator used on bad type"; - List.at(Err_Invalid_Pragma) = "Invalid pragma"; - List.at(Err_Invalid_Proc) = "Procedure referenced that does not exist"; - - List.at(Err_FileNone) = "No file specified"; - List.at(Err_FileOpen) = "Could not open file \"%s\""; - List.at(Err_NoMemory) = "Ran out of memory"; - List.at(Err_PragmaStacksize) = "Invalid stacksize on #pragma stacksize"; - List.at(Err_InvalidMacro) = "Invalid or empty macro definition"; - List.at(Err_SymbolRedef) = "Symbol \"%s\" already defined on line %d"; - List.at(Err_Reserved) = "Symbol assigned to a reserved token"; - List.at(Err_MacroParamCount) = "Parameter count for macro \"%s\" incorrect"; - List.at(Err_FatalTokenError) = "Fatal token error encountered"; - List.at(Err_Invalid_Section) = "Section identifier \"%s\" is not valid, ignoring section."; -} - -void ErrorMngr::PrintReport() -{ - static char *ErrorSwi[4] = {"Notice", "Warning", "Error", "Fatal Error"}; - int i = 0; - - printf("+---------------------------+\n"); - - for (i=0; i<4; i++) - { - printf("| %ss: %s%d |\n", ErrorSwi[i], (i!=3)?"\t\t":"\t", Totals[i]); - } - - printf("+---------------------------+\n"); -} - -void ErrorMngr::ErrorMsg(ErrorCode error, ...) -{ - static char *ErrorSwi[4] = {"Notice", "Warning", "Error", "Fatal Error"}; - static char errbuf[1024]; - ErrorType type = GetErrorType(error); - if (type == -1) - return; - - int curLine = 0; - - if (line == -1) - { - curLine = ((Compiler *)Cmp)->CurLine(); - } else { - curLine = line; - line = -1; - } - - va_list argptr; - va_start(argptr, error); - - if (((Compiler *)Cmp)->CurLine() == -1) - sprintf(errbuf, "%s(%d): %s\n", ErrorSwi[type], error, GetError(error)); - else - sprintf(errbuf, "%s(%d) on line %d: %s\n", ErrorSwi[type], error, curLine, GetError(error)); - vprintf(errbuf, argptr); - - va_end(argptr); - - Totals[type]++; - - if (type == Err_Fatal) - exit(0); - if (type > HighestError) - HighestError = type; -} - -const char *ErrorMngr::GetError(ErrorCode id) -{ - if (id == fatals_start || id == fatals_end) - return NULL; - if (id == warnings_start || id == warnings_end) - return NULL; - if (id == notices_start || id == notices_end) - return NULL; - if (id == errors_start || id == errors_end) - return NULL; - if (id < notices_start || id > fatals_end) - return NULL; - return List.at(id); -} - -int ErrorMngr::DerefSymbol(std::string &str, int sym) -{ - return ((Compiler *)Cmp)->DerefSymbol(str, (SymbolType)sym); -} - -bool ErrorMngr::IsSymbol(std::string &str) -{ - return ((Compiler *)Cmp)->IsSymbol(str); -} - -void ErrorMngr::SetLine(int ln) -{ - line = ln; -} - diff --git a/compiler/scasm/amx_error.h b/compiler/scasm/amx_error.h deleted file mode 100755 index 83a0d8f1..00000000 --- a/compiler/scasm/amx_error.h +++ /dev/null @@ -1,109 +0,0 @@ -/* AMX Assembler - * Copyright (C)2004 David "BAILOPAN" Anderson - * - * This software is provided 'as-is', without any express or implied - * warranty. In no event will the authors be held liable for any damages - * arising from the use of this software. - * - * Permission is granted to anyone to use this software for any purpose, - * including commercial applications, and to alter it and redistribute it - * freely, subject to the following restrictions: - * - * 1. The origin of this software must not be misrepresented; you must not - * claim that you wrote the original software. If you use this software - * in a product, an acknowledgment in the product documentation would be - * appreciated but is not required. - * 2. Altered source versions must be plainly marked as such, and must not be - * misrepresented as being the original software. - * 3. This notice may not be removed or altered from any source distribution. - * - * Version: $Id: amx_error.h 835 2004-08-12 16:31:50Z dvander $ - */ - -#ifndef _INCLUDE_AMX_ERROR -#define _INCLUDE_AMX_ERROR - -typedef enum -{ - Err_None=-1, - Err_Notice, - Err_Warning, - Err_Error, - Err_Fatal, -} ErrorType; - -typedef enum -{ - notices_start, - notices_end, - - warnings_start, - Warning_Hex_Start, - Warning_Null_Expression, - Warning_Param_Count, - warnings_end, - - errors_start, - Err_String_Terminate, - Err_String_Extra, - Err_Unexpected_Char, - Err_Invalid_Section, - Err_Wandering_Stuff, - Err_Symbol_Reuse, /* Non-fatal version of Redef */ - Err_Invalid_Stor, - Err_Unknown_Symbol, - Err_Symbol_Type, - Err_Invalid_Symbol, - Err_Opcode, - Err_Unmatched_Token, - Err_Param_Count, - Err_Unknown_Define, - Err_Misplaced_Directive, - Err_Bad_Label, - Err_Bad_Not, - Err_Invalid_Operator, - Err_Invalid_Pragma, - Err_Invalid_Proc, - errors_end, - - fatals_start, - Err_FileNone, - Err_FileOpen, - Err_NoMemory, - Err_PragmaStacksize, - Err_InvalidMacro, - Err_SymbolRedef, - Err_Reserved, - Err_MacroParamCount, - Err_FatalTokenError, - fatals_end, - -} ErrorCode; - -class ErrorMngr -{ -private: - void DefineErrors(); - const char *GetError(ErrorCode id); - ErrorType GetErrorType(ErrorCode id); -private: - std::vector List; - ErrorType HighestError; - void *Cmp; - int Totals[4]; - int line; -public: - ErrorMngr(); - ErrorMngr(void *c); - void Clear(); - void ErrorMsg(ErrorCode error, ...); - ErrorType GetStatus() { return HighestError; } - void PrintReport(); - int CurLine(); - int CurCip(); - void SetLine(int ln); - int DerefSymbol(std::string &str, int sym = 0); - bool IsSymbol(std::string &str); -}; - -#endif //_INCLUDE_AMX_ERROR diff --git a/compiler/scasm/amx_label.cpp b/compiler/scasm/amx_label.cpp deleted file mode 100755 index 20882acd..00000000 --- a/compiler/scasm/amx_label.cpp +++ /dev/null @@ -1,182 +0,0 @@ -/* AMX Assembler - * Copyright (C)2004 David "BAILOPAN" Anderson - * - * This software is provided 'as-is', without any express or implied - * warranty. In no event will the authors be held liable for any damages - * arising from the use of this software. - * - * Permission is granted to anyone to use this software for any purpose, - * including commercial applications, and to alter it and redistribute it - * freely, subject to the following restrictions: - * - * 1. The origin of this software must not be misrepresented; you must not - * claim that you wrote the original software. If you use this software - * in a product, an acknowledgment in the product documentation would be - * appreciated but is not required. - * 2. Altered source versions must be plainly marked as such, and must not be - * misrepresented as being the original software. - * 3. This notice may not be removed or altered from any source distribution. - * - * Version: $Id: amx_label.cpp 926 2004-08-21 18:57:47Z dvander $ - */ - -#include "amxasm.h" - -LabelMngr::~LabelMngr() -{ - Clear(); -} - -LabelMngr::Label::Label() -{ - cip = -1; - sym = 0; -} - -void LabelMngr::Clear() -{ - std::list::iterator i; - - for (i=List.begin(); i!=List.end(); i++) - { - if ( (*i) ) - delete (*i); - } - - List.clear(); -} - -LabelMngr::Label *LabelMngr::AddLabel(SymbolList::Symbol *sym, int cip) -{ - LabelMngr::Label *p = new LabelMngr::Label; - - p->sym = sym; - p->cip = cip; - - List.push_back(p); - - return p; -} - -LabelMngr::Label *LabelMngr::FindLabel(std::string &sym) -{ - std::list::iterator i; - - for (i=List.begin(); i!=List.end(); i++) - { - if ( (*i)->sym->IsEqual(sym) ) - { - return (*i); - } - } - - return NULL; -} - -bool LabelMngr::SetCip(std::string &sym, int cip) -{ - LabelMngr::Label *p = NULL; - - p = FindLabel(sym); - - if (p == NULL) - return false; - - p->cip = cip; - - return true; -} - -void LabelMngr::QueueLabel(std::string &sym, Asm *ASM) -{ - std::string d(sym); - LQ[d].push(ASM); -} - -void LabelMngr::CompleteQueue(bool isLocal) -{ - std::map >::iterator i; - std::stack *stk = 0; - std::stack >::iterator> DeleteStack; - std::string search; - Asm *ASM = 0; - LabelMngr::Label *p = 0; - - for (i=LQ.begin(); i!=LQ.end(); i++) - { - search.assign( (*i).first ); - p = FindLabel(search); - stk = &((*i).second); - if (p == NULL || p->cip == LabelMngr::ncip) - { - if ((!isLocal || (isLocal && search[0]=='_')) && CError) - { - while (!stk->empty()) - { - CError->SetLine(stk->top()->line); - CError->ErrorMsg(Err_Bad_Label); - stk->pop(); - } - DeleteStack.push( i ); - } - } else { - while (!stk->empty()) - { - ASM = stk->top(); - ASM->params[0] = p->cip; - stk->pop(); - } - DeleteStack.push( i ); - } - } - - while (!DeleteStack.empty()) - { - LQ.erase(DeleteStack.top()); - DeleteStack.pop(); - } -} - -int LabelMngr::GetCip(std::string &sym) -{ - LabelMngr::Label *p = NULL; - - p = FindLabel(sym); - - if (p == NULL) - return ncip; - - return p->cip; -} - -bool LabelMngr::EraseLabel(std::string &sym) -{ - std::list::iterator i; - LabelMngr::Label *L = 0; - - for (i=List.begin(); i!=List.end(); i++) - { - L = (*i); - if ( L->sym->IsEqual(sym) ) - { - i = List.erase(i); - L->sym = 0; - delete L; - L = 0; - return true; - } - } - - return false; -} - -void LabelMngr::PrintList() -{ - std::list::iterator i; - - for (i=List.begin(); i!=List.end(); i++) - { - printf("Label:\t%s\t%d\t%d\n", (*i)->sym->sym.c_str(), (*i)->cip, (*i)->sym->line); - } -} - diff --git a/compiler/scasm/amx_label.h b/compiler/scasm/amx_label.h deleted file mode 100755 index 6cc5a245..00000000 --- a/compiler/scasm/amx_label.h +++ /dev/null @@ -1,57 +0,0 @@ -/* AMX Assembler - * Copyright (C)2004 David "BAILOPAN" Anderson - * - * This software is provided 'as-is', without any express or implied - * warranty. In no event will the authors be held liable for any damages - * arising from the use of this software. - * - * Permission is granted to anyone to use this software for any purpose, - * including commercial applications, and to alter it and redistribute it - * freely, subject to the following restrictions: - * - * 1. The origin of this software must not be misrepresented; you must not - * claim that you wrote the original software. If you use this software - * in a product, an acknowledgment in the product documentation would be - * appreciated but is not required. - * 2. Altered source versions must be plainly marked as such, and must not be - * misrepresented as being the original software. - * 3. This notice may not be removed or altered from any source distribution. - * - * Version: $Id: amx_label.h 835 2004-08-12 16:31:50Z dvander $ - */ - -#ifndef _INCLUDE_AMXLABEL_H -#define _INCLUDE_AMXLABEL_H - -class LabelMngr -{ -public: - class Label - { - public: - Label(); - SymbolList::Symbol *sym; - int cip; - }; -public: - ~LabelMngr(); - LabelMngr() { CError = NULL; assert(CError!=NULL); } - LabelMngr(ErrorMngr *e) { CError = e; } - LabelMngr::Label *AddLabel(SymbolList::Symbol *sym, int cip); - LabelMngr::Label *FindLabel(std::string &sym); - int GetCip(std::string &sym); - void Clear(); - bool SetCip(std::string &sym, int cip); - void QueueLabel(std::string &sym, Asm *ASM); - void CompleteQueue(bool isLocal = false); - bool EraseLabel(std::string &sym); - void PrintList(); -private: - std::list List; - std::map > LQ; - ErrorMngr *CError; -public: - static const int ncip = -1; -}; - -#endif //_INCLUDE_AMXLABEL_H diff --git a/compiler/scasm/amx_macro.cpp b/compiler/scasm/amx_macro.cpp deleted file mode 100755 index fdec1348..00000000 --- a/compiler/scasm/amx_macro.cpp +++ /dev/null @@ -1,173 +0,0 @@ -/* AMX Assembler - * Copyright (C)2004 David "BAILOPAN" Anderson - * - * This software is provided 'as-is', without any express or implied - * warranty. In no event will the authors be held liable for any damages - * arising from the use of this software. - * - * Permission is granted to anyone to use this software for any purpose, - * including commercial applications, and to alter it and redistribute it - * freely, subject to the following restrictions: - * - * 1. The origin of this software must not be misrepresented; you must not - * claim that you wrote the original software. If you use this software - * in a product, an acknowledgment in the product documentation would be - * appreciated but is not required. - * 2. Altered source versions must be plainly marked as such, and must not be - * misrepresented as being the original software. - * 3. This notice may not be removed or altered from any source distribution. - * - * Version: $Id: amx_macro.cpp 826 2004-08-11 10:01:56Z dvander $ - */ - -#include "amxasm.h" - -MacroList::~MacroList() -{ - Clear(); -} - -void MacroList::Clear() -{ - std::vector::iterator i; - - for (i=List.begin(); i!=List.end(); i++) - { - if ( (*i) ) - delete (*i); - } - - List.clear(); -} - -MacroList::Macro::~Macro() -{ - std::vector::iterator i; - - for (i=argList.begin(); i!=argList.end(); i++) - { - if ( (*i) ) - delete (*i); - } - - argList.clear(); -} - -MacroList::MacroList() -{ - printf("Not instantiated with a compiler\n"); - exit(0); -} - -MacroList::MacroList(void *c) -{ - CError = ((Compiler *)c)->ErrorHandler(); - Cmp = c; -} - -std::string *MacroList::BeginReplacement(MacroList::Macro *macro) -{ - std::string *mstring = new std::string(macro->macro); - - macro->arg = macro->argList.begin(); - macro->argpos = 0; - - return mstring; -} - -int MacroList::ReplaceArgument(MacroList::Macro *m, std::string *macro, std::string &arg, int pos = 0) -{ - int bPos = 0; - - bPos = FindSymbol(*macro, *(*m->arg), pos); - - if (bPos != -1) - { - macro->replace(bPos, (*m->arg)->size(), arg); - bPos += (int)arg.size(); - } - - m->arg++; - m->argpos++; - - return bPos; -} - -void MacroList::EndReplacement(MacroList::Macro *m, std::string *macro) -{ - if (m->arg != m->argList.end()) - { - CError->ErrorMsg(Err_MacroParamCount, m->symbol.c_str()); - } - - m->arg = m->argList.begin(); - m->argpos = 0; -} - -MacroList::Macro *MacroList::AddMacroBegin(std::string &symbol, std::string &mac) -{ - Macro *macro = new Macro; - macro->macro.assign(mac); - macro->symbol.assign(symbol); - return macro; -} - -void MacroList::AddMacroArgument(MacroList::Macro *m, std::string &arg) -{ - std::string *sArg = new std::string(arg); - m->argList.push_back(sArg); -} - -void MacroList::AddMacroEnd(MacroList::Macro *m) -{ - List.push_back(m); -} - -MacroList::Macro *MacroList::FindMacro(std::string &sym) -{ - std::vector::iterator i; - for (i=List.begin(); i!=List.end(); i++) - { - if ((*i)->macro.compare(sym) == 0) - return (*i); - } - - return NULL; -} - -void MacroList::SearchAndReplace(std::string &text) -{ - std::vector::iterator i; - MacroList::Macro *m = NULL; - int pos=0, symPos=0, bPos=0, argPos=0; - - for (i=List.begin(); i!=List.end(); i++) - { - m = (*i); - pos = FindSymbol(text, m->symbol, 0); - if (pos != -1) - { - /* Strip the arguments */ - std::string argstring; - symPos = pos + (int)m->symbol.size(); - argstring.assign(text.substr(symPos+1, text.size()-symPos)); - std::vector argList; - ((Compiler *)Cmp)->FindArguments(argstring, argList, bPos, true); - /* Build the macro */ - std::string *ms; - ms = BeginReplacement(m); - std::vector::iterator j; - for (j=argList.begin(); j!=argList.end(); j++) - { - argPos = ReplaceArgument(m, ms, *(*j), argPos); - } - EndReplacement(m, ms); - /* Search and replace */ - text.replace(pos, bPos-pos, *ms); - /* Cleanup */ - delete ms; - i = List.begin(); - } - } -} - diff --git a/compiler/scasm/amx_macro.h b/compiler/scasm/amx_macro.h deleted file mode 100755 index e8445f27..00000000 --- a/compiler/scasm/amx_macro.h +++ /dev/null @@ -1,58 +0,0 @@ -/* AMX Assembler - * Copyright (C)2004 David "BAILOPAN" Anderson - * - * This software is provided 'as-is', without any express or implied - * warranty. In no event will the authors be held liable for any damages - * arising from the use of this software. - * - * Permission is granted to anyone to use this software for any purpose, - * including commercial applications, and to alter it and redistribute it - * freely, subject to the following restrictions: - * - * 1. The origin of this software must not be misrepresented; you must not - * claim that you wrote the original software. If you use this software - * in a product, an acknowledgment in the product documentation would be - * appreciated but is not required. - * 2. Altered source versions must be plainly marked as such, and must not be - * misrepresented as being the original software. - * 3. This notice may not be removed or altered from any source distribution. - * - * Version: $Id: amx_macro.h 821 2004-08-11 08:18:14Z dvander $ - */ - -#ifndef _INCLUDE_MACRO_H -#define _INCLUDE_MACRO_H - -class MacroList -{ -public: - class Macro - { - public: - ~Macro(); - std::vector::iterator arg; - std::vector argList; - std::string symbol; - std::string macro; - int argpos; - }; -public: - MacroList(); - MacroList(void *c); - ~MacroList(); - void Clear(); - MacroList::Macro *AddMacroBegin(std::string &symbol, std::string &mac); - void AddMacroArgument(MacroList::Macro *m, std::string &arg); - void AddMacroEnd(MacroList::Macro *m); - MacroList::Macro *FindMacro(std::string &sym); - std::string *BeginReplacement(MacroList::Macro *macro); - int ReplaceArgument(MacroList::Macro *m, std::string *macro, std::string &arg, int pos); - void EndReplacement(MacroList::Macro *m, std::string *macro); - void SearchAndReplace(std::string &text); -private: - std::vector List; - ErrorMngr *CError; - void *Cmp; -}; - -#endif //_INCLUDE_MACRO_H diff --git a/compiler/scasm/amx_nametable.h b/compiler/scasm/amx_nametable.h deleted file mode 100755 index 80df9f7c..00000000 --- a/compiler/scasm/amx_nametable.h +++ /dev/null @@ -1,41 +0,0 @@ -/* AMX Assembler - * Copyright (C)2004 David "BAILOPAN" Anderson - * - * This software is provided 'as-is', without any express or implied - * warranty. In no event will the authors be held liable for any damages - * arising from the use of this software. - * - * Permission is granted to anyone to use this software for any purpose, - * including commercial applications, and to alter it and redistribute it - * freely, subject to the following restrictions: - * - * 1. The origin of this software must not be misrepresented; you must not - * claim that you wrote the original software. If you use this software - * in a product, an acknowledgment in the product documentation would be - * appreciated but is not required. - * 2. Altered source versions must be plainly marked as such, and must not be - * misrepresented as being the original software. - * 3. This notice may not be removed or altered from any source distribution. - * - * Version: $Id: amx_nametable.h 826 2004-08-11 10:01:56Z dvander $ - */ - -#ifndef _INCLUDE_NAMETABLE_H -#define _INCLUDE_NAMETABLE_H - -class NameRecord -{ -public: - const char *Name; - int32_t offset; -}; - -class AddrTable -{ -public: - int32_t addr; - int32_t offset; -}; - -#endif //_INCLUDE_NAMETABLE_H - diff --git a/compiler/scasm/amx_natives.cpp b/compiler/scasm/amx_natives.cpp deleted file mode 100755 index 710e1129..00000000 --- a/compiler/scasm/amx_natives.cpp +++ /dev/null @@ -1,94 +0,0 @@ -/* AMX Assembler - * Copyright (C)2004 David "BAILOPAN" Anderson - * - * This software is provided 'as-is', without any express or implied - * warranty. In no event will the authors be held liable for any damages - * arising from the use of this software. - * - * Permission is granted to anyone to use this software for any purpose, - * including commercial applications, and to alter it and redistribute it - * freely, subject to the following restrictions: - * - * 1. The origin of this software must not be misrepresented; you must not - * claim that you wrote the original software. If you use this software - * in a product, an acknowledgment in the product documentation would be - * appreciated but is not required. - * 2. Altered source versions must be plainly marked as such, and must not be - * misrepresented as being the original software. - * 3. This notice may not be removed or altered from any source distribution. - * - * Version: $Id: amx_natives.cpp 826 2004-08-11 10:01:56Z dvander $ - */ - -#include "amxasm.h" - -NativeMngr::~NativeMngr() -{ - Clear(); -} - -void NativeMngr::Clear() -{ - std::vector::iterator i; - - for (i=List.begin(); i!=List.end(); i++) - { - if ( (*i) ) - delete (*i); - } - - List.clear(); -} - -void NativeMngr::AddNative(SymbolList::Symbol *S) -{ - NativeMngr::Native *N = new NativeMngr::Native; - - N->S = S; - N->used = false; - - List.push_back(N); -} - -int NativeMngr::GetNativeId(std::string &sym) -{ - int pos = 0; - std::vector::iterator i; - - for (i=List.begin(); i!=List.end(); i++) - { - if ( (*i)->S->IsEqual(sym) ) - { - return pos; - } - pos++; - } - - return ncip; -} - -NativeMngr::Native *NativeMngr::FindNative(std::string &sym) -{ - std::vector::iterator i; - - for (i=List.begin(); i!=List.end(); i++) - { - if ( (*i)->S->IsEqual(sym) ) - { - return (*i); - } - } - - return NULL; -} - -void NativeMngr::GetNatives(std::vector &nList) -{ - std::vector::iterator i; - - for (i=List.begin(); i!=List.end(); i++) - { - nList.push_back( (*i) ); - } -} - diff --git a/compiler/scasm/amx_natives.h b/compiler/scasm/amx_natives.h deleted file mode 100755 index d570ee1f..00000000 --- a/compiler/scasm/amx_natives.h +++ /dev/null @@ -1,49 +0,0 @@ -/* AMX Assembler - * Copyright (C)2004 David "BAILOPAN" Anderson - * - * This software is provided 'as-is', without any express or implied - * warranty. In no event will the authors be held liable for any damages - * arising from the use of this software. - * - * Permission is granted to anyone to use this software for any purpose, - * including commercial applications, and to alter it and redistribute it - * freely, subject to the following restrictions: - * - * 1. The origin of this software must not be misrepresented; you must not - * claim that you wrote the original software. If you use this software - * in a product, an acknowledgment in the product documentation would be - * appreciated but is not required. - * 2. Altered source versions must be plainly marked as such, and must not be - * misrepresented as being the original software. - * 3. This notice may not be removed or altered from any source distribution. - * - * Version: $Id: amx_natives.h 821 2004-08-11 08:18:14Z dvander $ - */ - -#ifndef _INCLUDE_NATIVES_H -#define _INCLUDE_NATIVES_H - -class NativeMngr -{ -public: - class Native - { - public: - Native() { used = false; S = NULL; } - SymbolList::Symbol *S; - bool used; - }; -public: - ~NativeMngr(); - void AddNative(SymbolList::Symbol *S); - void Clear(); - NativeMngr::Native *FindNative(std::string &sym); - int GetNativeId(std::string &sym); - void GetNatives(std::vector &nList); -public: - static const int ncip = -1; -private: - std::vector List; -}; - -#endif //_INCLUDE_NATIVES_H diff --git a/compiler/scasm/amx_parser.cpp b/compiler/scasm/amx_parser.cpp deleted file mode 100755 index 7ed81a96..00000000 --- a/compiler/scasm/amx_parser.cpp +++ /dev/null @@ -1,209 +0,0 @@ -/* AMX Assembler - * Copyright (C)2004 David "BAILOPAN" Anderson - * - * This software is provided 'as-is', without any express or implied - * warranty. In no event will the authors be held liable for any damages - * arising from the use of this software. - * - * Permission is granted to anyone to use this software for any purpose, - * including commercial applications, and to alter it and redistribute it - * freely, subject to the following restrictions: - * - * 1. The origin of this software must not be misrepresented; you must not - * claim that you wrote the original software. If you use this software - * in a product, an acknowledgment in the product documentation would be - * appreciated but is not required. - * 2. Altered source versions must be plainly marked as such, and must not be - * misrepresented as being the original software. - * 3. This notice may not be removed or altered from any source distribution. - * - * Version: $Id: amx_parser.cpp 826 2004-08-11 10:01:56Z dvander $ - */ - -#include "amxasm.h" - -char isletter(char c) -{ - if (c >= 65 && c <= 90) - return c; - if (c >= 97 && c <= 122) - return c; - if (c == '_') - return c; - return 0; -} - -char expr(char c) -{ - if (c == '(') - return ')'; - if (c == ')') - return '('; - return 0; -} - -char literal(char c) -{ - if (c == '"') - return '"'; - if (c == '\'') - return '\''; - return 0; -} - -void StripComments(std::string &text) -{ - size_t i = 0; - char c = 0, l = 0; - - for (i=0; i=0; i--) - { - if (!isspace(text[i]) - || (isspace(text[i]) && (i==0))) - { - text.erase(i+1, text.size()-1-i); - break; - } - } - } - - if (text.size() == 1) - { - if (isspace(text[0])) - { - text.clear(); - return; - } - } -} - -/* This is a very simple symbol searcher - * It only restricts the pattern location to outside of - * string literals and other symbols. - */ -int FindSymbol(std::string &text, const std::string &sym, int startPos = 0) -{ - unsigned int i = 0; - char c = 0, d = 0, l = 0; - - for (i=startPos; i text.size() - i) - break; - - /* Skip literal strings */ - if (l) - { - if (d == l) - l = 0; - c = d; - continue; - } else { - l = literal(d); - if (l) - { - c = d; - continue; - } - } - - /* If the last character was a letter, we're in a symbol already */ - if (isletter(c)) - { - c = d; - continue; - } - - /* If the current character is a letter, test for a symbol */ - if (text.compare(i, sym.size(), sym) == 0) - return i; - - c = d; - } - - return -1; -} - diff --git a/compiler/scasm/amx_parser.h b/compiler/scasm/amx_parser.h deleted file mode 100755 index 512e3e34..00000000 --- a/compiler/scasm/amx_parser.h +++ /dev/null @@ -1,36 +0,0 @@ -/* AMX Assembler - * Copyright (C)2004 David "BAILOPAN" Anderson - * - * This software is provided 'as-is', without any express or implied - * warranty. In no event will the authors be held liable for any damages - * arising from the use of this software. - * - * Permission is granted to anyone to use this software for any purpose, - * including commercial applications, and to alter it and redistribute it - * freely, subject to the following restrictions: - * - * 1. The origin of this software must not be misrepresented; you must not - * claim that you wrote the original software. If you use this software - * in a product, an acknowledgment in the product documentation would be - * appreciated but is not required. - * 2. Altered source versions must be plainly marked as such, and must not be - * misrepresented as being the original software. - * 3. This notice may not be removed or altered from any source distribution. - * - * Version: $Id: amx_parser.h 821 2004-08-11 08:18:14Z dvander $ - */ - -#ifndef _INCLUDE_PARSER_H -#define _INCLUDE_PARSER_H - -void StringBreak(std::string &Source, std::string &Left, std::string &Right); -int FindArguments(std::string &text, std::vector &List, int &end); -int FindSymbol(std::string &text, const std::string &sym, int startPos); -void ProcessDirective(std::string &text); -void StripComments(std::string &text); -void Strip(std::string &text); -char isletter(char c); -char literal(char c); -char expr(char c); - -#endif //_INCLUDE_PARSER_H diff --git a/compiler/scasm/amx_proc.cpp b/compiler/scasm/amx_proc.cpp deleted file mode 100755 index 6dfb1f73..00000000 --- a/compiler/scasm/amx_proc.cpp +++ /dev/null @@ -1,159 +0,0 @@ -/* AMX Assembler - * Copyright (C)2004 David "BAILOPAN" Anderson - * - * This software is provided 'as-is', without any express or implied - * warranty. In no event will the authors be held liable for any damages - * arising from the use of this software. - * - * Permission is granted to anyone to use this software for any purpose, - * including commercial applications, and to alter it and redistribute it - * freely, subject to the following restrictions: - * - * 1. The origin of this software must not be misrepresented; you must not - * claim that you wrote the original software. If you use this software - * in a product, an acknowledgment in the product documentation would be - * appreciated but is not required. - * 2. Altered source versions must be plainly marked as such, and must not be - * misrepresented as being the original software. - * 3. This notice may not be removed or altered from any source distribution. - * - * Version: $Id: amx_proc.cpp 926 2004-08-21 18:57:47Z dvander $ - */ - -#include "amxasm.h" - -ProcMngr::ProcMngr() -{ - CError = 0; - printf("Instantiated without a compiler!\n"); - assert(CError); -} - -ProcMngr::ProcMngr(ErrorMngr *e) -{ - CError = e; -} - -ProcMngr::~ProcMngr() -{ - Clear(); -} - -void ProcMngr::Clear() -{ - std::vector::iterator i; - - for (i=List.begin(); i!=List.end(); i++) - { - if ( (*i) ) - delete (*i); - } - - List.clear(); -} - -ProcMngr::AsmProc *ProcMngr::AddProc(SymbolList::Symbol *Symbol, Asm *ASM) -{ - ProcMngr::AsmProc *a = new ProcMngr::AsmProc; - - a->ASM = ASM; - a->Symbol = Symbol; - a->pb = false; - - List.push_back(a); - - return a; -} - -bool ProcMngr::SetPublic(std::string &sym) -{ - ProcMngr::AsmProc *a = NULL; - - a = FindProc(sym); - - if (a == NULL) - return false; - - a->pb = true; - - return true; -} - -void ProcMngr::GetPublics(std::vector &pbList) -{ - std::vector::reverse_iterator i; - - for (i=List.rbegin(); i!=List.rend(); i++) - { - if ((*i)->pb == true) - { - pbList.push_back( (*i) ); - } - } -} - -ProcMngr::AsmProc *ProcMngr::FindProc(std::string &sym) -{ - std::vector::iterator i; - - for (i = List.begin(); i != List.end(); i++) - { - if ( (*i)->Symbol->IsEqual(sym) ) - { - return (*i); - } - } - - return NULL; -} - -int ProcMngr::GetCip(std::string &sym) -{ - ProcMngr::AsmProc *p = NULL; - - p = FindProc(sym); - - if (p == NULL || p->ASM == NULL) - return ncip; - - return p->ASM->cip; -} - -void ProcMngr::QueueProc(std::string &sym, Asm *ASM) -{ - std::string d(sym); - PQ[d].push(ASM); -} - -void ProcMngr::CompleteQueue() -{ - std::map >::iterator i; - std::string search; - ProcMngr::AsmProc *p = 0; - std::stack *stk = 0; - - for (i=PQ.begin(); i!=PQ.end(); i++) - { - search.assign( (*i).first ); - p = FindProc(search); - stk = &((*i).second); - - if (p == NULL || p->ASM == NULL) - { - while (!stk->empty()) - { - CError->SetLine(stk->top()->line); - CError->ErrorMsg(Err_Invalid_Proc); - stk->pop(); - } - } else { - while (!stk->empty()) - { - stk->top()->cip = p->ASM->cip; - stk->top()->params[0] = p->ASM->cip; - stk->pop(); - } - } - } -} - diff --git a/compiler/scasm/amx_proc.h b/compiler/scasm/amx_proc.h deleted file mode 100755 index 4bf2a35a..00000000 --- a/compiler/scasm/amx_proc.h +++ /dev/null @@ -1,56 +0,0 @@ -/* AMX Assembler - * Copyright (C)2004 David "BAILOPAN" Anderson - * - * This software is provided 'as-is', without any express or implied - * warranty. In no event will the authors be held liable for any damages - * arising from the use of this software. - * - * Permission is granted to anyone to use this software for any purpose, - * including commercial applications, and to alter it and redistribute it - * freely, subject to the following restrictions: - * - * 1. The origin of this software must not be misrepresented; you must not - * claim that you wrote the original software. If you use this software - * in a product, an acknowledgment in the product documentation would be - * appreciated but is not required. - * 2. Altered source versions must be plainly marked as such, and must not be - * misrepresented as being the original software. - * 3. This notice may not be removed or altered from any source distribution. - * - * Version: $Id: amx_proc.h 835 2004-08-12 16:31:50Z dvander $ - */ - -#ifndef _INCLUDE_AMXPROC_H -#define _INCLUDE_AMXPROC_H - -class ProcMngr -{ -public: - class AsmProc - { - public: - SymbolList::Symbol *Symbol; - Asm *ASM; - bool pb; - }; -public: - ~ProcMngr(); - ProcMngr(); - ProcMngr(ErrorMngr *e); - ProcMngr::AsmProc *AddProc(SymbolList::Symbol *Symbol, Asm *ASM); - ProcMngr::AsmProc *FindProc(std::string &sym); - int GetCip(std::string &sym); - bool SetPublic(std::string &sym); - void GetPublics(std::vector &pbList); - void QueueProc(std::string &sym, Asm *ASM); - void CompleteQueue(); - void Clear(); -private: - std::vector List; - std::map > PQ; - ErrorMngr *CError; -public: - static const int ncip = -1; -}; - -#endif //_INCLUDE_AMXPROC_H diff --git a/compiler/scasm/amx_symbol.cpp b/compiler/scasm/amx_symbol.cpp deleted file mode 100755 index 871cbdba..00000000 --- a/compiler/scasm/amx_symbol.cpp +++ /dev/null @@ -1,140 +0,0 @@ -/* AMX Assembler - * Copyright (C)2004 David "BAILOPAN" Anderson - * - * This software is provided 'as-is', without any express or implied - * warranty. In no event will the authors be held liable for any damages - * arising from the use of this software. - * - * Permission is granted to anyone to use this software for any purpose, - * including commercial applications, and to alter it and redistribute it - * freely, subject to the following restrictions: - * - * 1. The origin of this software must not be misrepresented; you must not - * claim that you wrote the original software. If you use this software - * in a product, an acknowledgment in the product documentation would be - * appreciated but is not required. - * 2. Altered source versions must be plainly marked as such, and must not be - * misrepresented as being the original software. - * 3. This notice may not be removed or altered from any source distribution. - * - * Version: $Id: amx_symbol.cpp 835 2004-08-12 16:31:50Z dvander $ - */ - -#include "amxasm.h" - -bool is_valid_symbol_marker(char c) -{ - if (c >= '0' && c <= '9') - return true; - if (isletter(c)) - return true; - return false; -} - -bool IsValidSymbol(std::string &text) -{ - size_t i = 0; - - if (!text.size() || !isletter(text[0])) - { - return false; - } - - for (i=0; i::iterator i; - - for (i=List.begin(); i!=List.end(); i++) - { - if ( (*i) ) - delete (*i); - } - - List.clear(); -} - -SymbolList::~SymbolList() -{ - Clear(); -} - -bool SymbolList::Symbol::IsEqual(std::string &s) -{ - return (sym.compare(s)==0); -} - -SymbolList::Symbol* SymbolList::AddSymbol(const char *szSym, SymbolType type, int line) -{ - SymbolList::Symbol *S = new SymbolList::Symbol; - - S->line = line; - S->type = type; - S->sym.assign(szSym); - - List.push_back(S); - return S; -} - -SymbolList::Symbol *SymbolList::AddSymbol(std::string &sym, SymbolType type, int line) -{ - SymbolList::Symbol *S = new SymbolList::Symbol; - - S->line = line; - S->type = type; - S->sym.assign(sym); - - List.push_back(S); - return S; -} - -SymbolList::Symbol* SymbolList::FindSymbol(std::string &sym) -{ - std::list::iterator i; - for (i=List.begin(); i!=List.end(); i++) - { - if ((*i)->IsEqual(sym)) - return (*i); - } - - return NULL; -} - -void SymbolList::PrintTable() -{ - std::list::iterator i; - for (i=List.begin(); i!=List.end(); i++) - { - printf("Symbol \"%s\" defined on line %d\n", (*i)->sym.c_str(), (*i)->line); - } -} - -bool SymbolList::EraseSymbol(std::string &sym) -{ - std::list::iterator i; - SymbolList::Symbol *S = 0; - - for (i=List.begin(); i!=List.end(); i++) - { - S = (*i); - if ( S && S->IsEqual(sym) ) - { - delete S; - i = List.erase(i); - S = 0; - return true; - } - } - - return false; -} diff --git a/compiler/scasm/amx_symbol.h b/compiler/scasm/amx_symbol.h deleted file mode 100755 index caa6f206..00000000 --- a/compiler/scasm/amx_symbol.h +++ /dev/null @@ -1,65 +0,0 @@ -/* AMX Assembler - * Copyright (C)2004 David "BAILOPAN" Anderson - * - * This software is provided 'as-is', without any express or implied - * warranty. In no event will the authors be held liable for any damages - * arising from the use of this software. - * - * Permission is granted to anyone to use this software for any purpose, - * including commercial applications, and to alter it and redistribute it - * freely, subject to the following restrictions: - * - * 1. The origin of this software must not be misrepresented; you must not - * claim that you wrote the original software. If you use this software - * in a product, an acknowledgment in the product documentation would be - * appreciated but is not required. - * 2. Altered source versions must be plainly marked as such, and must not be - * misrepresented as being the original software. - * 3. This notice may not be removed or altered from any source distribution. - * - * Version: $Id: amx_symbol.h 835 2004-08-12 16:31:50Z dvander $ - */ - -#ifndef _INCLUDE_SYMBOL_H -#define _INCLUDE_SYMBOL_H - -bool IsValidSymbol(std::string &text); - -typedef enum -{ - Sym_None, - Sym_Define, - Sym_Macro, - Sym_Proc, - Sym_Dat, - Sym_Reserved, - Sym_Label, - Sym_Native, -} SymbolType; - -class SymbolList -{ -public: - class Symbol - { - public: - bool IsEqual(std::string &s); - SymbolType type; - std::string sym; - int line; - }; - -public: - ~SymbolList(); - SymbolList::Symbol* AddSymbol(std::string &sym, SymbolType type, int line); - SymbolList::Symbol* AddSymbol(const char *szSym, SymbolType type, int line); - SymbolList::Symbol* FindSymbol(std::string &sym); - bool EraseSymbol(std::string &sym); - void PrintTable(); - void Clear(); -private: - std::list List; -}; - - -#endif //_INCLUDE_SYMBOL_H diff --git a/compiler/scasm/amxasm.cpp b/compiler/scasm/amxasm.cpp deleted file mode 100755 index c1793406..00000000 --- a/compiler/scasm/amxasm.cpp +++ /dev/null @@ -1,143 +0,0 @@ -/* AMX Assembler - * Copyright (C)2004 David "BAILOPAN" Anderson - * - * This software is provided 'as-is', without any express or implied - * warranty. In no event will the authors be held liable for any damages - * arising from the use of this software. - * - * Permission is granted to anyone to use this software for any purpose, - * including commercial applications, and to alter it and redistribute it - * freely, subject to the following restrictions: - * - * 1. The origin of this software must not be misrepresented; you must not - * claim that you wrote the original software. If you use this software - * in a product, an acknowledgment in the product documentation would be - * appreciated but is not required. - * 2. Altered source versions must be plainly marked as such, and must not be - * misrepresented as being the original software. - * 3. This notice may not be removed or altered from any source distribution. - * - * Version: $Id: amxasm.cpp 921 2004-08-21 06:20:27Z dvander $ - */ - -#include "amxasm.h" - -std::string filename; -std::string output_name; -Compiler Program; - -int main(int argc, char **argv) -{ - get_options(argc, argv, Program); - - if (filename.size() < 1) - { - print_version(); - print_options(); - exit(0); - } - - Program.Load(filename); - if (Program.Parse()) - { - if (Program.Compile(output_name.size() ? output_name : filename)) - printf("Done.\n"); - else - printf("Compile build failed.\n"); - } else { - printf("Compile failed.\n"); - } - - exit(0); -} - -void get_options(int argc, char **argv, Compiler &Prog) -{ - int i = 0; /* index */ - char opt_flag = 0; /* flag for option detection */ - char *option = 0; /* option pointer */ - for (i=1; i 2) - { - output_name.assign(&(argv[i][2])); - } else { - opt_flag = 'o'; - } - break; - } - case 'c': - { - Program.SetPack(); - opt_flag = 0; - break; - } - case 'v': - { - opt_flag = 0; /* no options expected */ - print_version(); - exit(0); - break; - } /* case */ - case 'd': - { - opt_flag = 0; - Prog.SetDebug(); - break; - } - case 'h': - { - opt_flag = 0; - Prog.SetDOpt(); - break; - } - case 'f': - { - opt_flag = 0; - Prog.SetDOpt(); - Prog.SetPack(); - } - } /* switch */ - } else { /* - */ - if (!opt_flag) - { - filename.assign(argv[i]); - } else { - switch (opt_flag) - { - case 'o': - { - output_name.assign(argv[i]); - break; - } - } - } - } /* if */ - } -} - -void print_version() -{ - printf("Small/AMX Assembler 1.02\n"); - printf("(C)2004 David 'BAILOPAN' Anderson\n"); -} - -void print_options() -{ - printf("\nOptions:\n"); - printf("\t-d\t\t- Add debug opcodes (will double file size)\n"); - printf("\t-v\t\t- Output version and exit\n"); - printf("\t-o\t\t- Specify file to write\n"); - printf("\t-c\t\t- Enable compact encoding\n"); - printf("\t-h\t\t- Optimize DAT section\n"); - printf("\t-f\t\t- Optimal Build\n"); - printf("\n"); -} diff --git a/compiler/scasm/amxasm.h b/compiler/scasm/amxasm.h deleted file mode 100755 index 287a26f7..00000000 --- a/compiler/scasm/amxasm.h +++ /dev/null @@ -1,225 +0,0 @@ -/* AMX Assembler - * Copyright (C)2004 David "BAILOPAN" Anderson - * - * This software is provided 'as-is', without any express or implied - * warranty. In no event will the authors be held liable for any damages - * arising from the use of this software. - * - * Permission is granted to anyone to use this software for any purpose, - * including commercial applications, and to alter it and redistribute it - * freely, subject to the following restrictions: - * - * 1. The origin of this software must not be misrepresented; you must not - * claim that you wrote the original software. If you use this software - * in a product, an acknowledgment in the product documentation would be - * appreciated but is not required. - * 2. Altered source versions must be plainly marked as such, and must not be - * misrepresented as being the original software. - * 3. This notice may not be removed or altered from any source distribution. - * - * Version: $Id: amxasm.h 824 2004-08-11 09:32:24Z dvander $ - */ - -#ifndef _INCLUDE_AMXASM_H -#define _INCLUDE_AMXASM_H - -//C includes -#include -#include -#include -#include -#include -//C++ includes -#include -#include -#include -#include -#include -#include -#include - -class Asm -{ -public: - int op; - std::vector params; - int cip; - int line; -}; - -#include "amx.h" -#include "amx_error.h" -#include "cexpr.h" -#include "amx_parser.h" -#include "amx_symbol.h" -#include "amx_macro.h" -#include "amx_define.h" -#include "amx_data.h" -#include "amx_proc.h" -#include "amx_label.h" -#include "amx_natives.h" -#include "amx_nametable.h" -#include "amx_compiler.h" //This should be last! - -#define SMALL_CELL_SIZE 32 - -typedef enum -{ - Asm_Invalid = -1, - Asm_None, - Asm_Data, - Asm_Code, - Asm_Public, - Asm_Native, -} AsmSection; - -/* From amx.c */ -typedef enum { - OP_NONE, /* invalid opcode */ - OP_LOAD_PRI, - OP_LOAD_ALT, - OP_LOAD_S_PRI, - OP_LOAD_S_ALT, - OP_LREF_PRI, - OP_LREF_ALT, - OP_LREF_S_PRI, - OP_LREF_S_ALT, - OP_LOAD_I, - OP_LODB_I, - OP_CONST_PRI, - OP_CONST_ALT, - OP_ADDR_PRI, - OP_ADDR_ALT, - OP_STOR_PRI, - OP_STOR_ALT, - OP_STOR_S_PRI, - OP_STOR_S_ALT, - OP_SREF_PRI, - OP_SREF_ALT, - OP_SREF_S_PRI, - OP_SREF_S_ALT, - OP_STOR_I, - OP_STRB_I, - OP_LIDX, - OP_LIDX_B, - OP_IDXADDR, - OP_IDXADDR_B, - OP_ALIGN_PRI, - OP_ALIGN_ALT, - OP_LCTRL, - OP_SCTRL, - OP_MOVE_PRI, - OP_MOVE_ALT, - OP_XCHG, - OP_PUSH_PRI, - OP_PUSH_ALT, - OP_PUSH_R, - OP_PUSH_C, - OP_PUSH, - OP_PUSH_S, - OP_POP_PRI, - OP_POP_ALT, - OP_STACK, - OP_HEAP, - OP_PROC, - OP_RET, - OP_RETN, - OP_CALL, - OP_CALL_PRI, - OP_JUMP, - OP_JREL, - OP_JZER, - OP_JNZ, - OP_JEQ, - OP_JNEQ, - OP_JLESS, - OP_JLEQ, - OP_JGRTR, - OP_JGEQ, - OP_JSLESS, - OP_JSLEQ, - OP_JSGRTR, - OP_JSGEQ, - OP_SHL, - OP_SHR, - OP_SSHR, - OP_SHL_C_PRI, - OP_SHL_C_ALT, - OP_SHR_C_PRI, - OP_SHR_C_ALT, - OP_SMUL, - OP_SDIV, - OP_SDIV_ALT, - OP_UMUL, - OP_UDIV, - OP_UDIV_ALT, - OP_ADD, - OP_SUB, - OP_SUB_ALT, - OP_AND, - OP_OR, - OP_XOR, - OP_NOT, - OP_NEG, - OP_INVERT, - OP_ADD_C, - OP_SMUL_C, - OP_ZERO_PRI, - OP_ZERO_ALT, - OP_ZERO, - OP_ZERO_S, - OP_SIGN_PRI, - OP_SIGN_ALT, - OP_EQ, - OP_NEQ, - OP_LESS, - OP_LEQ, - OP_GRTR, - OP_GEQ, - OP_SLESS, - OP_SLEQ, - OP_SGRTR, - OP_SGEQ, - OP_EQ_C_PRI, - OP_EQ_C_ALT, - OP_INC_PRI, - OP_INC_ALT, - OP_INC, - OP_INC_S, - OP_INC_I, - OP_DEC_PRI, - OP_DEC_ALT, - OP_DEC, - OP_DEC_S, - OP_DEC_I, - OP_MOVS, - OP_CMPS, - OP_FILL, - OP_HALT, - OP_BOUNDS, - OP_SYSREQ_PRI, - OP_SYSREQ_C, - OP_FILE, - OP_LINE, - OP_SYMBOL, - OP_SRANGE, - OP_JUMP_PRI, - OP_SWITCH, - OP_CASETBL, - OP_SWAP_PRI, - OP_SWAP_ALT, - OP_PUSHADDR, - OP_NOP, - OP_SYSREQ_D, - OP_SYMTAG, - /* ----- */ - OP_NUM_OPCODES -} OPCODE; - -void get_options(int argc, char **argv, Compiler &Prog); -void InitOpcodes(); -void DestroyArgList(std::vector &List); -void print_version(); -void print_options(); - -#endif //_INCLUDE_AMXASM_H diff --git a/compiler/scasm/assembler.sln b/compiler/scasm/assembler.sln deleted file mode 100644 index 8eb48566..00000000 --- a/compiler/scasm/assembler.sln +++ /dev/null @@ -1,20 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 11.00 -# Visual Studio 2010 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "assembler", "assembler.vcxproj", "{FFFC86BE-94E7-458A-A61B-4D0F3B45658B}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Release|Win32 = Release|Win32 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {FFFC86BE-94E7-458A-A61B-4D0F3B45658B}.Debug|Win32.ActiveCfg = Debug|Win32 - {FFFC86BE-94E7-458A-A61B-4D0F3B45658B}.Debug|Win32.Build.0 = Debug|Win32 - {FFFC86BE-94E7-458A-A61B-4D0F3B45658B}.Release|Win32.ActiveCfg = Release|Win32 - {FFFC86BE-94E7-458A-A61B-4D0F3B45658B}.Release|Win32.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/compiler/scasm/assembler.vcxproj b/compiler/scasm/assembler.vcxproj deleted file mode 100644 index e2fe94b7..00000000 --- a/compiler/scasm/assembler.vcxproj +++ /dev/null @@ -1,123 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - - {FFFC86BE-94E7-458A-A61B-4D0F3B45658B} - assembler - Win32Proj - - - - Application - MultiByte - - - Application - MultiByte - - - - - - - - - - - - - - - <_ProjectFileVersion>10.0.40219.1 - true - false - AllRules.ruleset - - - AllRules.ruleset - - - sasm - sasm - - - - Disabled - WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_DEPRECATE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebug - false - - - Level3 - EditAndContinue - - - true - $(OutDir)assembler.pdb - Console - MachineX86 - - - - - WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_DEPRECATE;%(PreprocessorDefinitions) - MultiThreaded - false - - - Level3 - ProgramDatabase - - - true - Console - true - true - MachineX86 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/compiler/scasm/assembler.vcxproj.filters b/compiler/scasm/assembler.vcxproj.filters deleted file mode 100644 index 570fae74..00000000 --- a/compiler/scasm/assembler.vcxproj.filters +++ /dev/null @@ -1,95 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hpp;hxx;hm;inl;inc;xsd - - - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - \ No newline at end of file diff --git a/compiler/scasm/cexpr.cpp b/compiler/scasm/cexpr.cpp deleted file mode 100755 index 5a3efaab..00000000 --- a/compiler/scasm/cexpr.cpp +++ /dev/null @@ -1,545 +0,0 @@ -/* AMX Assembler - * Copyright (C)2004 David "BAILOPAN" Anderson - * - * This software is provided 'as-is', without any express or implied - * warranty. In no event will the authors be held liable for any damages - * arising from the use of this software. - * - * Permission is granted to anyone to use this software for any purpose, - * including commercial applications, and to alter it and redistribute it - * freely, subject to the following restrictions: - * - * 1. The origin of this software must not be misrepresented; you must not - * claim that you wrote the original software. If you use this software - * in a product, an acknowledgment in the product documentation would be - * appreciated but is not required. - * 2. Altered source versions must be plainly marked as such, and must not be - * misrepresented as being the original software. - * 3. This notice may not be removed or altered from any source distribution. - * - * Version: $Id: cexpr.cpp 921 2004-08-21 06:20:27Z dvander $ - */ - -#include -#include "amxasm.h" - -CExpr::CExpr() -{ - numVal = 0; - type = Val_None; - block = 0; - bDone = false; - CError = NULL; -} - -CExpr::CExpr(ErrorMngr *e) -{ - numVal = 0; - type = Val_None; - block = 0; - bDone = false; - CError = e; -} - -CExpr::CExpr(ErrorMngr *e, std::string &text) -{ - numVal = 0; - type = Val_None; - block = 0; - CError = e; - bDone = false; - data.assign(text); -} - -void CExpr::Clear() -{ - if (type == Val_Block && block) - delete [] block; - numVal = 0; - type = Val_None; - block = 0; -} - -CExpr::~CExpr() -{ - if (block && type == Val_Block) - delete [] block; -} - -char CExpr::IsLiteral(char c) -{ - if (c == '"') - return '"'; - if (c == '\'') - return '\''; - return 0; -} - -char CExpr::IsHex(char c) -{ - if (c >= '0' && c <= '9') - return c; - if (c >= 'A' && c <= 'F') - return c; - if (c >= 'a' && c <= 'f') - return c; - return 0; -} - -cExprType CExpr::GetType() -{ - return type; -} - -void CExpr::Set(std::string &text) -{ - data.assign(text); -} - -int CExpr::DeHex(std::string blk) -{ - size_t pos = 0, xc = 0, xpos = 0, ms = 0; - /* run through the characters */ - for (pos = 0; pos < blk.size(); pos++) - { - if (blk[pos] == 'x') - { - xc++; - if (xc > 1) - break; - xpos = pos; - } else if (blk[pos] == '-') { - if (pos != 0) - ms = 1; - } else if (blk[pos] != ' ' - && (blk[pos] < '0' || blk[pos] > '9') - && (!xc || (xc && !IsHex(blk[pos])))) { - CError->ErrorMsg(Err_Unexpected_Char, blk[pos]); - return 0; - } - } - if (xc > 1) - { - CError->ErrorMsg(Err_Unexpected_Char, 'x'); - return 0; - } - if (ms) - { - CError->ErrorMsg(Err_Unexpected_Char, '-'); - return 0; - } - if (xc) - { - if (xpos == 0 || blk[xpos-1] != '0') - { - if (CError) - CError->ErrorMsg(Warning_Hex_Start); - } - blk.erase(0, xpos+1); - pos = 0; - int j = 0; - while (blk[pos]) - { - blk[pos] -= 48; - if (blk[pos] > 16) - blk[pos] -= 7; - if (blk[pos] >= 16) - blk[pos] -= 32; - if (blk[pos] >= 16 || blk[pos] < 0) - { - if (CError) - { - CError->ErrorMsg(Err_Unexpected_Char, blk[pos]); - } - return 0; - } - j *= 16; - j += blk[pos]; - pos++; - } - - return j; - } - - return atoi(blk.c_str()); -} - -int CExpr::Size() -{ - if (type == Val_String || type == Val_Block) - return numVal; - if (type == Val_Number) - return (SMALL_CELL_SIZE/8); - return 0; -} - -const char *CExpr::GetString(int *d) -{ - const char *ret = 0; - - if (type == Val_String) - { - ret = data.c_str(); - if (d != NULL) - *d = numVal; - } else if (type == Val_Block) { - ret = block; - if (d != NULL) - *d = numVal; - } - - return ret; -} - -int CExpr::GetNumber() -{ - if (type == Val_Float) - { - memcpy((void*)&numVal, (void*)&fData, sizeof(float)); - } - return numVal; -} - -/* Returns true if the expr can be evaluated */ -int CExpr::Analyze() -{ - size_t pos = 0, xc = 0, xpos = 0, fd = 0; - /* run through the characters */ - if (data.compare("$") == 0) - { - return 1; - } - for (pos = 0; pos < data.size(); pos++) - { - if (data[pos] == '.') - { - fd++; - if (fd > 1 || xc) - return 0; - } else if (data[pos] == 'x') { - xc++; - if (xc > 1 || fd) - return 0; - xpos = pos; - } else if (data[pos] != ' ' - && (data[pos] < '0' || data[pos] > '9') - && (!xc || (xc && !IsHex(data[pos])))) { - return 0; - } - } - - return 1; -} - -cExprType CExpr::Evaluate(int symNum) -{ - size_t i = 0; - char litc = 0, c = 0; - cExprType t = Val_None; - std::string num; - - block = new char[2]; - bDone = true; - - if (data.compare("$") == 0) - { - type = Val_Number; - numVal = CError->CurCip(); - Update(); - return t; - } else { - if (CError->IsSymbol(data) - || (IsValidSymbol(data) && symNum == Sym_Label || symNum == Sym_Proc)) - { - type = Val_Number; - numVal = CError->DerefSymbol(data, symNum); - Update(); - return t; - } - } - - if (data.find('\'', 0) != std::string::npos || data.find('"', 0) != std::string::npos) - { - /* STRESS TEST */ - for (i=0; iErrorMsg(Err_String_Terminate); - t = Val_Error; - } else { - char cp = data[i+1]; - char *nc = 0; - if (cp == 't') - nc = "\t"; - else if (cp == 'n') - nc = "\n"; - else if (cp == '\\') - nc = "\\"; - else if (cp == '"') - nc = "\""; - else if (cp == '\'') - nc = "'"; - if (nc) - { - data.replace(i, 2, nc); - continue; - } - } - } - if (IsLiteral(c) != 0) - { - if (litc == IsLiteral(c)) - { - litc = 0; - /* The literal has terminated. Expect no more. */ - if (i != data.size() - 1) - { - t = Val_Error; - if (CError) - CError->ErrorMsg(Err_String_Extra, data[i+1]); - } else { - /* STRING DISCOVERED */ - t = Val_String; - /* Erase literals */ - data.erase(0, 1); - data.erase(data.size()-1, 1); - numVal = (int)(data.size()+1); - break; - } - } else { - litc = IsLiteral(c); - } - } - } - } else if (data.find(' ', 0) != std::string::npos) { - /* Build a mem block from values, store length in numVal */ - t = Val_Block; - size_t pos = 0, npos = 0; - numVal = 0; - pos = data.find(' ', 0); - block[numVal++] = DeHex(data.substr(0, pos)); - while ((pos = data.find(' ', pos)) != std::string::npos) - { - npos = data.find(' ', pos+1); - block = (char *)realloc(block, numVal+2); - if (npos != std::string::npos) - { - block[numVal] = (char)DeHex(data.substr(pos, npos-pos)); - } else { - block[numVal] = (char)DeHex(data.substr(pos)); - } - pos++; - numVal++; - } - } else { - if (data.find('.', 0) != std::string::npos) - { - /* Get as a float */ - fData = (float)atof(data.c_str()); - t = Val_Float; - memcpy((void*)&numVal, (void*)&fData, sizeof(float)); - } else { - /* Just get the number */ - t = Val_Number; - numVal = DeHex(data); - char buf[32]; - sprintf(buf, "%d", numVal); - data.assign(buf); - } - } - - if (litc) - { - if (CError) - CError->ErrorMsg(Err_String_Terminate); - } - - type = t; - - return t; -} - -void CExpr::Not() -{ - if (type != Val_Number) - { - if (CError) - CError->ErrorMsg(Err_Bad_Not); - } - numVal = ~numVal; -} - -void CExpr::Oper(OpToken op, CExpr &e) -{ - switch (op) - { - case Token_Xor: - { - if (e.GetType() != Val_Number) - { - if (CError) - CError->ErrorMsg(Err_Invalid_Operator); - } - numVal = numVal ^ e.GetNumber(); - break; - } - case Token_Shr: - { - if (e.GetType() != Val_Number) - { - if (CError) - CError->ErrorMsg(Err_Invalid_Operator); - } - numVal >>= e.GetNumber(); - break; - } - case Token_Sub: - { - if (GetType() == Val_Number) - { - if (e.GetType() == Val_Number) - { - numVal -= e.GetNumber(); - } else if (e.GetType() == Val_Float) { - numVal -= (int)e.GetFloat(); - } - } else if (GetType() == Val_Float) { - if (e.GetType() == Val_Number) - { - fData -= (float)e.GetNumber(); - } else if (e.GetType() == Val_Float) { - fData -= e.GetFloat(); - } - } - break; - } - case Token_Mod: - { - if (e.GetType() != Val_Number) - { - if (CError) - CError->ErrorMsg(Err_Invalid_Operator); - } - numVal = numVal % e.GetNumber(); - break; - } - case Token_Mul: - { - if (GetType() == Val_Number) - { - if (e.GetType() == Val_Number) - { - numVal *= e.GetNumber(); - } else if (e.GetType() == Val_Float) { - numVal *= (int)e.GetFloat(); - } - } else if (GetType() == Val_Float) { - if (e.GetType() == Val_Number) - { - fData *= (float)e.GetNumber(); - } else if (e.GetType() == Val_Float) { - fData *= e.GetFloat(); - } - } - break; - } - case Token_Div: - { - if (GetType() == Val_Number) - { - if (e.GetType() == Val_Number) - { - numVal /= e.GetNumber(); - } else if (e.GetType() == Val_Float) { - numVal /= (int)e.GetFloat(); - } - } else if (GetType() == Val_Float) { - if (e.GetType() == Val_Number) - { - fData /= (float)e.GetNumber(); - } else if (e.GetType() == Val_Float) { - fData /= e.GetFloat(); - } - } - break; - } - case Token_Shl: - { - if (e.GetType() != Val_Number) - { - if (CError) - CError->ErrorMsg(Err_Invalid_Operator); - } - numVal <<= e.GetNumber(); - break; - } - case Token_And: - { - if (e.GetType() != Val_Number) - { - if (CError) - CError->ErrorMsg(Err_Invalid_Operator); - } - numVal &= e.GetNumber(); - break; - } - case Token_Or: - { - if (e.GetType() != Val_Number) - { - if (CError) - CError->ErrorMsg(Err_Invalid_Operator); - } - numVal |= e.GetNumber(); - break; - } - case Token_Add: - { - if (GetType() == Val_Number) - { - if (e.GetType() == Val_Number) - { - numVal += e.GetNumber(); - } else if (e.GetType() == Val_Float) { - numVal += (int)e.GetFloat(); - } - } else if (GetType() == Val_Float) { - if (e.GetType() == Val_Number) - { - fData += (float)e.GetNumber(); - } else if (e.GetType() == Val_Float) { - fData += e.GetFloat(); - } - } - break; - } - default: - { - numVal = 0; - break; - } - } - - Update(); -} - -void CExpr::Update() -{ - if (type == Val_Float) - { - numVal = (int)fData; - } else if (type == Val_Number) { - fData = (float)numVal; - } - if (type != Val_String && type != Val_Block) - { - char buf[24]; - sprintf(buf, "%d", numVal); - data.assign(buf); - } -} diff --git a/compiler/scasm/cexpr.h b/compiler/scasm/cexpr.h deleted file mode 100755 index 97047513..00000000 --- a/compiler/scasm/cexpr.h +++ /dev/null @@ -1,96 +0,0 @@ -/* AMX Assembler - * Copyright (C)2004 David "BAILOPAN" Anderson - * - * This software is provided 'as-is', without any express or implied - * warranty. In no event will the authors be held liable for any damages - * arising from the use of this software. - * - * Permission is granted to anyone to use this software for any purpose, - * including commercial applications, and to alter it and redistribute it - * freely, subject to the following restrictions: - * - * 1. The origin of this software must not be misrepresented; you must not - * claim that you wrote the original software. If you use this software - * in a product, an acknowledgment in the product documentation would be - * appreciated but is not required. - * 2. Altered source versions must be plainly marked as such, and must not be - * misrepresented as being the original software. - * 3. This notice may not be removed or altered from any source distribution. - * - * Version: $Id: cexpr.h 821 2004-08-11 08:18:14Z dvander $ - */ - -#ifndef _INCLUDE_CEXPR_H -#define _INCLUDE_CEXPR_H - -/* This class is used for a single expression element - * It reads in a symbol and evaluates it. - */ - -typedef enum -{ - Token_None, - Token_Or, - Token_Xor, - Token_And, - Token_Shr, - Token_Shl, - Token_Mod, - Token_Div, - Token_Mul, - Token_Sub, - Token_Add, - Token_Not, - /* End */ - Tokens_Total, -} OpToken; - -typedef enum -{ - Val_None, - Val_Error, - Val_String, - Val_String_Hex, - Val_String_Number, - Val_Number_Hex, - Val_Number, - Val_Block, - Val_Hex, - Val_Float, -} cExprType; - -class CExpr -{ -public: - CExpr(); - CExpr(ErrorMngr *e); - CExpr(ErrorMngr *e, std::string &text); - void Set(std::string &text); - const char *GetString(int *d=NULL); - int Analyze(); - cExprType Evaluate(int symNum = 0); - cExprType GetType(); - int GetNumber(); - float GetFloat() { return fData; } - int Size(); - void Clear(); - void Not(); - void Oper(OpToken op, CExpr &e); - ~CExpr(); -private: - void Update(); - char IsHex(char c); - char IsLiteral(char c); - int DeHex(std::string blk); -private: - char *block; - std::string data; - cExprType type; - float fData; - int numVal; - bool bDone; -private: - ErrorMngr *CError; -}; - -#endif //_INCLUDE_CEXPR_H diff --git a/compiler/scasm/plugin.asm b/compiler/scasm/plugin.asm deleted file mode 100755 index d5c50d9d..00000000 --- a/compiler/scasm/plugin.asm +++ /dev/null @@ -1,80 +0,0 @@ -;(C)2004 David "BAILOPAN" Anderson -; Demonstration of AMX Mod X plugin writing in assembly. -#define VERSION "1.00" -#define AUTHOR "BAILOPAN" -#define PLUGIN "Asm Test" -#define CELL 4 -#macro ARGN(argc) (12+(argc*CELL)) - -.CODE - halt 0 ;Return point for end - -.NATIVE - get_user_name ;id, buffer[], maxLen - register_plugin ;name[], version[], author[] - register_concmd ;cmd[], callback[], access, descr[] - server_print ;fmt[], ... - -.DATA -Plugin db PLUGIN -Version db VERSION -Author db AUTHOR -Cmd db "amx_asmtest" -Callback db "cmdCallback" -Descr db "Test" - -.DATA -HELLO db "Hello, %s!" - -.CODE -PROC cmdCallback - stack -128*CELL - zero.pri - addr.alt -128*CELL - fill 128*CELL - push.c 127 - pushaddr -128*CELL - push.s ARG(0) - push.c CELL*3 - sysreq.c get_user_name - stack CELL*4 - pushaddr -128*CELL - push.c HELLO - push.c CELL*2 - sysreq.c server_print - stack CELL*3 - stack 128*CELL - zero.pri - retn -ENDP - -.CODE -;Technically PROC could simply be "proc" -; this is more for reasons of readability. -; feel free to use "proc" and omit ENDP -; if you would like to code one huge list of instructions. -PROC plugin_init - push.c Author ;push the plugin name - push.c Version ;push the plugin version - push.c Plugin ;push the plugin author - push.c CELL*3 ;push 3 arguments - sysreq.c register_plugin ;call register_plugin - stack CELL*4 ;clean up the stack - push.c Callback ;push string - push.c CELL ;push one argument - sysreq.c server_print ;call server_print - stack CELL*2 ;clean up the stack - push.c Descr ;push the description - push.c 0 ;push the access level - push.c Callback ;push callback - push.c Cmd ;push the command - push.c CELL*4 ;push 4 arguments - sysreq.c register_concmd ;call register_concmd - stack CELL*5 ;cleanup - zero.pri ;zero pri - retn ;return + cleanup -ENDP - -.PUBLIC - plugin_init - cmdCallback \ No newline at end of file diff --git a/compiler/scasm/sasm b/compiler/scasm/sasm deleted file mode 100755 index 4bcc84d8..00000000 Binary files a/compiler/scasm/sasm and /dev/null differ diff --git a/compiler/scasm/sasm.exe b/compiler/scasm/sasm.exe deleted file mode 100755 index 9f924120..00000000 Binary files a/compiler/scasm/sasm.exe and /dev/null differ diff --git a/installer/builder/CoreMod.cs b/installer/builder/CoreMod.cs index f247facd..9eaad1b5 100755 --- a/installer/builder/CoreMod.cs +++ b/installer/builder/CoreMod.cs @@ -40,9 +40,6 @@ public override sealed bool ExcludeCopy(string file) return true; if ( (file.IndexOf("dlsym")!=-1) && Releaser.IsWindows ) return true; - if ( ((ABuilder.GetFileName(file).CompareTo("sasm")) == 0) - && Releaser.IsWindows ) - return true; if (ABuilder.GetFileName(file).CompareTo("svn_version.tpl") == 0) { return true; diff --git a/plugins/sasm b/plugins/sasm deleted file mode 100755 index 4bcc84d8..00000000 Binary files a/plugins/sasm and /dev/null differ diff --git a/plugins/sasm.exe b/plugins/sasm.exe deleted file mode 100755 index 9f924120..00000000 Binary files a/plugins/sasm.exe and /dev/null differ