Sigrid Haflínudóttirto utf858f72106 years agoHistory
19726 lines · 697.1 KB · C
RawDownload
#define PROGRAM_NAME      "RASM"#define PROGRAM_VERSION   "1.3 nightly"#define PROGRAM_DATE      "xx/07/2020"#define PROGRAM_COPYRIGHT "© 2017 BERGE Edouard / roudoudou from Resistance" #define RASM_VERSION PROGRAM_NAME" v"PROGRAM_VERSION" (build "PROGRAM_DATE")"#define RASM_SNAP_VERSION PROGRAM_NAME" v"PROGRAM_VERSION #define TRACE_GENERALE 0#define TRACE_PREPRO 0#define TRACE_ASSEMBLE 0#define TRACE_COMPUTE_EXPRESSION 0#define TRACE_HEXBIN 0#define TRACE_MAKEAMSDOSREAL 0#define TRACE_STRUCT 0#define TRACE_EDSK 0#define TRACE_LABEL 0   /***Rasm (roudoudou assembler) Z80 assembler doc & latest official release at: https://github.com/EdouardBERGE/rasm You may send requests/bugs in the same topic -----------------------------------------------------------------------------------------------------This software is using MIT "expat" license « Copyright © BERGE Edouard (roudoudou) Permission  is  hereby  granted,  free  of charge,to any person obtaining a copy  of  this  softwareand  associated  documentation/source   files   of RASM, to deal in the Software without restriction,including without limitation the  rights  to  use, copy,   modify,   merge,   publish,    distribute,sublicense,  and/or  sell  copies of the Software, and  to  permit  persons  to  whom the Software isfurnished  to  do  so,  subject  to  the following conditions: The above copyright  notice  and  this  permission notice   shall   be  included  in  all  copies  orsubstantial portions of the Software.The   Software   is   provided  "as is",   without warranty   of   any   kind,  express  or  implied,including  but  not  limited  to the warranties of merchantability,   fitness   for   a    particularpurpose  and  noninfringement.  In  no event shall the  authors  or  copyright  holders be liable forany  claim, damages  or other  liability,  whether in  an  action  of  contract, tort  or  otherwise,arising from,  out of  or in connection  with  the software  or  the  use  or  other  dealings in theSoftware. »-----------------------------------------------------------------------------------------------------Linux compilation with GCC or Clang:cc rasm.c -O2 -lm -lrt -march=native -o rasmstrip rasm Windows compilation with Visual studio:cl.exe rasm.c -O2 -Ob3 pure MS-DOS 32 bits compilation with Watcom without native support of AP-Ultra:wcl386 rasm.c -6r -6s -fp6 -d0 -k4000000 -ox /bt=DOS /l=dos4g -DOS_WIN=1 -DNOAPLIB=1 MorphOS compilation (ixemul):gcc -noixemul -O2 -c -o rasm rasm.cstrip rasm MacOS compilation:cc rasm.c -O2 -lm -march=native -o rasm */ #ifdef __WATCOMC__#define OS_WIN 1#endif #ifdef _WIN32#define OS_WIN 1#endif #ifdef _WIN64#define OS_WIN 1#endif #ifndef RDD	/* public lib */	#include"minilib.h"#else	/* private dev lib wont be published */	#include"../tools/library.h"	#define TxtSplitWithChar _internal_TxtSplitWithChar#endif #ifndef NO_3RD_PARTIES#define __FILENAME__ "3rd parties"/* 3rd parties compression */#include"zx7.h"#include"lz4.h"#include"exomizer.h"/* too much trouble with old DOS compiler */ #ifndef NOAPULTRA  #include"apultra.h" #endif#endif #ifdef __MORPHOS__/* Add standard version string to executable */const char __attribute__((section(".text"))) ver_version[]={ "\0$VER: "PROGRAM_NAME" "PROGRAM_VERSION" ("PROGRAM_DATE") "PROGRAM_COPYRIGHT"" };#endif #undef __FILENAME__#define __FILENAME__ "rasm.c" #ifndef OS_WIN#define KNORMAL  "\x1B[0m"#define KERROR   "\x1B[31m"#define KAYGREEN "\x1B[32m"#define KWARNING "\x1B[33m"#define KBLUE    "\x1B[34m"#define KVERBOSE "\x1B[36m"#define KIO      "\x1B[97m"#else#define KNORMAL  ""#define KERROR   "Error: "#define KAYGREEN ""#define KWARNING "Warning: "#define KBLUE    ""#define KVERBOSE ""#define KIO      ""#endif /*******************************************************************         c o m m a n d    l i n e    p a r a m e t e r s *******************************************************************/enum e_dependencies_type {E_DEPENDENCIES_NO=0,E_DEPENDENCIES_LIST,E_DEPENDENCIES_MAKE}; struct s_parameter {	char **labelfilename;	char *filename;	char *outputfilename;	int automatic_radix;	int export_local;	int export_var;	int export_equ;	int export_sym;	int export_multisym;	int export_tape;	char *flexible_export;	int export_sna;	int export_snabrk;	int export_brk;	int nowarning;	int erronwarn;	int checkmode;	int dependencies;	int maxerr;	int macrovoid;	int extended_error;	int display_stats;	int edskoverwrite;	float rough;	int as80,dams,pasmo;	int v2;	int warn_unused;	char *symbol_name;	char *binary_name;	char *cartridge_name;	char *snapshot_name;	char *rom_name;	char *tape_name;	char *breakpoint_name;	char **symboldef;	int nsymb,msymb;	char **pathdef;	int npath,mpath;	int noampersand;};   /******************************************************************* c o m p u t e   o p e r a t i o n s   f o r   c a l c u l a t o r*******************************************************************/ enum e_compute_operation_type {E_COMPUTE_OPERATION_PUSH_DATASTC=0,E_COMPUTE_OPERATION_OPEN=1,E_COMPUTE_OPERATION_CLOSE=2,E_COMPUTE_OPERATION_ADD=3,E_COMPUTE_OPERATION_SUB=4,E_COMPUTE_OPERATION_DIV=5,E_COMPUTE_OPERATION_MUL=6,E_COMPUTE_OPERATION_AND=7,E_COMPUTE_OPERATION_OR=8,E_COMPUTE_OPERATION_MOD=9,E_COMPUTE_OPERATION_XOR=10,E_COMPUTE_OPERATION_NOT=11,E_COMPUTE_OPERATION_SHL=12,E_COMPUTE_OPERATION_SHR=13,E_COMPUTE_OPERATION_BAND=14,E_COMPUTE_OPERATION_BOR=15,E_COMPUTE_OPERATION_LOWER=16,E_COMPUTE_OPERATION_GREATER=17,E_COMPUTE_OPERATION_EQUAL=18,E_COMPUTE_OPERATION_NOTEQUAL=19,E_COMPUTE_OPERATION_LOWEREQ=20,E_COMPUTE_OPERATION_GREATEREQ=21,/* math functions */E_COMPUTE_OPERATION_SIN=22,E_COMPUTE_OPERATION_COS=23,E_COMPUTE_OPERATION_INT=24,E_COMPUTE_OPERATION_FLOOR=25,E_COMPUTE_OPERATION_ABS=26,E_COMPUTE_OPERATION_LN=27,E_COMPUTE_OPERATION_LOG10=28,E_COMPUTE_OPERATION_SQRT=29,E_COMPUTE_OPERATION_ASIN=30,E_COMPUTE_OPERATION_ACOS=31,E_COMPUTE_OPERATION_ATAN=32,E_COMPUTE_OPERATION_EXP=33,E_COMPUTE_OPERATION_LOW=34,E_COMPUTE_OPERATION_HIGH=35,E_COMPUTE_OPERATION_PSG=36,E_COMPUTE_OPERATION_RND=37,E_COMPUTE_OPERATION_FRAC=38,E_COMPUTE_OPERATION_CEIL=39,E_COMPUTE_OPERATION_GET_R=40,E_COMPUTE_OPERATION_GET_V=41,E_COMPUTE_OPERATION_GET_B=42,E_COMPUTE_OPERATION_SET_R=43,E_COMPUTE_OPERATION_SET_V=44,E_COMPUTE_OPERATION_SET_B=45,E_COMPUTE_OPERATION_SOFT2HARD=46,E_COMPUTE_OPERATION_HARD2SOFT=47,/* string functions */E_COMPUTE_OPERATION_GETNOP=48,E_COMPUTE_OPERATION_GETTICK=49,E_COMPUTE_OPERATION_DURATION=50,E_COMPUTE_OPERATION_END=51}; struct s_compute_element {enum e_compute_operation_type operator;double value;int priority;char *string;}; struct s_compute_core_data {	/* evaluator v3 may be recursive */	char *varbuffer;	int maxivar;	struct s_compute_element *tokenstack;	int maxtokenstack;	struct s_compute_element *operatorstack;	int maxoperatorstack;}; /***********************************************************  w a v   h e a d e r    f o r    a u d i o    i m p o r t***********************************************************/struct s_wav_header {unsigned char ChunkID[4];unsigned char ChunkSize[4];unsigned char Format[4];unsigned char SubChunk1ID[4];unsigned char SubChunk1Size[4];unsigned char AudioFormat[2];unsigned char NumChannels[2];unsigned char SampleRate[4];unsigned char ByteRate[4];unsigned char BlockAlign[2];unsigned char BitsPerSample[2];unsigned char SubChunk2ID[4];unsigned char SubChunk2Size[4];}; enum e_audio_sample_type {AUDIOSAMPLE_SMP,AUDIOSAMPLE_SM2,AUDIOSAMPLE_SM4,AUDIOSAMPLE_DMA,AUDIOSAMPLE_END}; /***********************************************************************  e x p r e s s i o n   t y p e s   f o r   d e l a y e d   w r i t e***********************************************************************/enum e_expression {	E_EXPRESSION_J8,     /* relative 8bits jump */	E_EXPRESSION_0V8,    /* 8 bits value to current adress */	E_EXPRESSION_V8,     /* 8 bits value to current adress+1 */	E_EXPRESSION_V16,    /* 16 bits value to current adress+1 */	E_EXPRESSION_V16C,   /* 16 bits value to current adress+1 */	E_EXPRESSION_0V16,   /* 16 bits value to current adress */	E_EXPRESSION_0V32,   /* 32 bits value to current adress */	E_EXPRESSION_0VR,    /* AMSDOS real value (5 bytes) to current adress */	E_EXPRESSION_0VRMike,/* Microsoft IEEE-754 real value (5 bytes) to current adress */	E_EXPRESSION_IV8,    /* 8 bits value to current adress+2 */	E_EXPRESSION_IV81,   /* 8 bits value+1 to current adress+2 */	E_EXPRESSION_3V8,    /* 8 bits value to current adress+3 used with LD (IX+n),n */	E_EXPRESSION_IV16,   /* 16 bits value to current adress+2 */	E_EXPRESSION_RST,    /* the offset of RST is translated to the opcode */	E_EXPRESSION_IM,     /* the interrupt mode is translated to the opcode */	E_EXPRESSION_RUN,    /* delayed RUN value */	E_EXPRESSION_ZXRUN,  /* delayed RUN value for ZX snapshot */	E_EXPRESSION_ZXSTACK,/* delayed STACK value for ZX snapshot */	E_EXPRESSION_BRS     /* delayed shifting for BIT, RES, SET */}; struct s_expression {		char *reference;          /* backup when used inside loop (or macro?) */	int iw;                   /* word index in the main wordlist */	int o;                    /* offset de depart 0, 1 ou 3 selon l'opcode */	int ptr;                  /* offset courant pour calculs relatifs */	int wptr;                 /* where to write the result  */	enum e_expression zetype; /* type of delayed write */	int lz;                   /* lz zone */	int ibank;                /* ibank of expression */	int iorgzone;             /* org of expression */	char *module;}; struct s_expr_dico {	char *name;	int crc;	int autorise_export;	double v;	int used;	int iw;}; struct s_label {	char *name;   /* is alloced for local repeat or struct OR generated global -> in this case iw=-1 */	int iw;       /* index of the word of label name */	int crc;      /* crc of the label name */	int ptr;      /* "physical" adress */	int lz;       /* is the label in a crunched section (or after)? */	int iorgzone; /* org of label */	int ibank;    /* current CPR bank / always zero in classic mode */	int local;	/* errmsg */	int fileidx;	int fileline;	int autorise_export,backidx;	int used;}; struct s_alias {	char *alias;	char *translation;	int crc,len,autorise_export;	int iw;	int used;}; struct s_ticker {	char *varname;	int crc;	long nopstart;	long tickerstart;}; /***********************************************************************   m e r k e l    t r e e s    f o r    l a b e l,  v a r,  a l i a s***********************************************************************/struct s_crclabel_tree {	struct s_crclabel_tree *radix[256];	struct s_label *label;	int nlabel,mlabel;};struct s_crcdico_tree {	struct s_crcdico_tree *radix[256];	struct s_expr_dico *dico;	int ndico,mdico;};struct s_crcused_tree {	struct s_crcused_tree *radix[256];	char **used;	int nused,mused;};struct s_crcstring_tree {	struct s_crcstring_tree *radix[256];	char **text;	int ntext,mtext;	char **replace;	int nreplace,mreplace;};/*************************************************          m e m o r y    s e c t i o n*************************************************/struct s_lz_section {	int iw;	int memstart,memend;	int lzversion; /* 0 -> NO CRUNCH but must be delayed / 4 -> LZ4 / 7 -> ZX7 / 48 -> LZ48 / 49 -> LZ49 / 8 -> Exomizer */	int iorgzone;	int ibank;	/* idx backup */	int iexpr;	int ilabel;}; struct s_orgzone {	int ibank,protect;	int memstart,memend;	int ifile,iline;	int nocode;	int inplace;}; /**************************************************         i n c b i n     s t o r a g e**************************************************/struct s_hexbin {	unsigned char *data;	int datalen,rawlen;	char *filename;	int crunch;}; /**************************************************          e d s k    m a n a g e m e n t        **************************************************/struct s_edsk_sector_global_struct {unsigned char track;unsigned char side;unsigned char id;unsigned char size;unsigned char st1;unsigned char st2;unsigned short int length;unsigned char *data;}; struct s_edsk_track_global_struct  {int sectornumber;/* information purpose */int sectorsize;int gap3length;int fillerbyte;int datarate;int recordingmode;struct s_edsk_sector_global_struct *sector;}; struct s_edsk_global_struct {int tracknumber;int sidenumber;int tracksize; /* DSK legacy */struct s_edsk_track_global_struct *track;}; struct s_edsk_wrapper_entry {unsigned char user;unsigned char filename[11];unsigned char subcpt;unsigned char extendcounter;unsigned char reserved;unsigned char rc;unsigned char blocks[16];}; struct s_edsk_wrapper {char *edsk_filename;struct s_edsk_wrapper_entry entry[64];int nbentry;unsigned char blocks[178][1024]; /* DATA format */int face;}; struct s_save {	int ibank;	int ioffset;	int isize;	int iw,irun;	int amsdos,hobeta;	int tape,dsk,face,iwdskname;};  /********************      L O O P S********************/ enum e_loop_style {E_LOOPSTYLE_REPEATN,E_LOOPSTYLE_REPEATUNTIL,E_LOOPSTYLE_WHILE}; struct s_repeat {	int start;	int cpt;	int value;	int maxim;	int repeat_counter;	char *repeatvar;	int repeatcrc;}; struct s_whilewend {	int start;

Lines 1–500 of 19726.

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t