Niotso  git revision 558726a9f13d7c3423a683dd2f4323589b66c310
The New Implementation of The Sims Online
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Classes | Macros | Enumerations | Functions | Variables
hitasm.c File Reference
#include <stdarg.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <stdint.h>
#include <errno.h>
#include "hitutils.h"

Classes

struct  ByteWriterContext
 
struct  ParserContext
 

Macros

#define HITASM_HEADERS
 

Enumerations

enum  { txt, out, filecount }
 
enum  { TK_CROSSLINES = 1, CN_LABELONLY = 1 }
 
enum  Sections {
  Text, SymbolTable, StringTable, RelocationTable,
  SectionCount
}
 

Functions

static void bw_expand (ByteWriterContext *bwc)
 
static void bw_write32 (ByteWriterContext *bwc, uint32_t value)
 
static void bw_write8 (ByteWriterContext *bwc, uint8_t value)
 
static void bw_write_memory (ByteWriterContext *bwc, const uint8_t *ptr, size_t size)
 
static void bw_write_string (ByteWriterContext *bwc, const char *string)
 
static uint8_t * add_symbol (const char *Name)
 
static uint8_t * find_symbol_by_name (const char *Name, uint32_t *SymbolIndex)
 
static __inline int whitespace (const uint8_t *Data)
 
static __inline int comment (const uint8_t *Data)
 
static int parser_next_token (ParserContext *pc, int CrossLines)
 
static __inline void verify_eol (ParserContext *pc)
 
static void verify_name (const ParserContext *pc, const char *thistoken, const char *nexttoken)
 
static __inline void parser_add_symbol (const ParserContext *pc)
 
static __inline void parser_add_reference (const ParserContext *pc)
 
static uint32_t read_integer (const ParserContext *pc, uint32_t maxval)
 
static uint32_t read_constant (ParserContext *pc, int Type, uint32_t maxval)
 
static __inline uint8_t read_instruction (const ParserContext *pc, uint32_t *operands)
 
static __inline uint8_t read_variable (const ParserContext *pc, const variable_t *Variables, size_t VariableCount)
 
static void Shutdown ()
 
int main (int argc, char *argv[])
 

Variables

static uint8_t ObjectHeader []
 
static FILE * hFile = NULL
 
static char * path [filecount] = {NULL}
 
static uint8_t * data [filecount] = {NULL}
 
static ByteWriterContext Section []
 

Macro Definition Documentation

#define HITASM_HEADERS

Enumeration Type Documentation

anonymous enum
Enumerator
txt 
out 
filecount 
anonymous enum
Enumerator
TK_CROSSLINES 
CN_LABELONLY 
enum Sections
Enumerator
Text 
SymbolTable 
StringTable 
RelocationTable 
SectionCount 

Function Documentation

static uint8_t* add_symbol ( const char *  Name)
static
static void bw_expand ( ByteWriterContext bwc)
static
static void bw_write32 ( ByteWriterContext bwc,
uint32_t  value 
)
static
static void bw_write8 ( ByteWriterContext bwc,
uint8_t  value 
)
static
static void bw_write_memory ( ByteWriterContext bwc,
const uint8_t *  ptr,
size_t  size 
)
static
static void bw_write_string ( ByteWriterContext bwc,
const char *  string 
)
static
static __inline int comment ( const uint8_t *  Data)
static
static uint8_t* find_symbol_by_name ( const char *  Name,
uint32_t *  SymbolIndex 
)
static
int main ( int  argc,
char *  argv[] 
)
static __inline void parser_add_reference ( const ParserContext pc)
static
static __inline void parser_add_symbol ( const ParserContext pc)
static
static int parser_next_token ( ParserContext pc,
int  CrossLines 
)
static
static uint32_t read_constant ( ParserContext pc,
int  Type,
uint32_t  maxval 
)
static
static __inline uint8_t read_instruction ( const ParserContext pc,
uint32_t *  operands 
)
static
static uint32_t read_integer ( const ParserContext pc,
uint32_t  maxval 
)
static
static __inline uint8_t read_variable ( const ParserContext pc,
const variable_t Variables,
size_t  VariableCount 
)
static
static void Shutdown ( )
static
static __inline void verify_eol ( ParserContext pc)
static
static void verify_name ( const ParserContext pc,
const char *  thistoken,
const char *  nexttoken 
)
static
static __inline int whitespace ( const uint8_t *  Data)
static

Variable Documentation

uint8_t* data[filecount] = {NULL}
static
FILE* hFile = NULL
static
uint8_t ObjectHeader[]
static
Initial value:
= {
0x7F, 0x45, 0x4C, 0x46, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x00, 0x00, 0x00, 0x28, 0x00,
0x06, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x07, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
0x19, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00
}
char* path[filecount] = {NULL}
static
ByteWriterContext Section[]
static
Initial value:
= {
{0,0,1024,"text"},
{0,0,1024,"symtab"},
{0,0,1024,"strtab"},
{0,0,1024,".rel.text"}
}