amxmodx/compiler/scasm/amxasm.h
2004-08-08 10:15:08 +00:00

223 lines
3.7 KiB
C++
Executable File

/* 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$
*/
#ifndef _INCLUDE_AMXASM_H
#define _INCLUDE_AMXASM_H
//C includes
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#include <assert.h>
//C++ includes
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <stack>
#include <list>
#include <map>
class Asm
{
public:
int op;
std::vector<int> params;
int cip;
};
#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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