1
Index: libyasm/bytecode.c
2
===================================================================
3
--- old/libyasm/bytecode.c (r�vision 2128)
4
+++ new/libyasm/bytecode.c (copie de travail)
9
+yasm_bc_elem_size(yasm_bytecode *bc)
11
+ if (!bc->callback) {
12
+ yasm_internal_error(N_("got empty bytecode in yasm_bc_elem_size"));
14
+ } else if (!bc->callback->elem_size)
17
+ return bc->callback->elem_size(bc);
21
yasm_bc_calc_len(yasm_bytecode *bc, yasm_bc_add_span_func add_span,
24
Index: libyasm/symrec.c
25
===================================================================
26
--- old/libyasm/symrec.c (r�vision 2128)
27
+++ new/libyasm/symrec.c (copie de travail)
29
/*@unused@*/ RCSID("$Id$");
34
#include "libyasm-stdint.h"
37
/* bytecode immediately preceding a label */
38
/*@dependent@*/ yasm_bytecode *precbc;
40
+ unsigned int size; /* 0 if not user-defined */
41
+ const char *segment; /* for segmented systems like DOS */
43
/* associated data; NULL if none */
44
/*@null@*/ /*@only@*/ yasm__assoc_data *assoc_data;
46
/*@only@*/ HAMT *sym_table;
47
/* Symbols not in the table */
48
SLIST_HEAD(nontablesymhead_s, non_table_symrec_s) non_table_syms;
55
yasm_symtab *symtab = yasm_xmalloc(sizeof(yasm_symtab));
56
symtab->sym_table = HAMT_create(0, yasm_internal_error_);
57
SLIST_INIT(&symtab->non_table_syms);
58
+ symtab->case_sensitive = 1;
63
+yasm_symtab_set_case_sensitive(yasm_symtab *symtab, int sensitive)
65
+ symtab->case_sensitive = sensitive;
69
symrec_destroy_one(/*@only@*/ void *d)
74
static /*@partial@*/ yasm_symrec *
75
-symrec_new_common(/*@keep@*/ char *name)
76
+symrec_new_common(/*@keep@*/ char *name, int case_sensitive)
78
yasm_symrec *rec = yasm_xmalloc(sizeof(yasm_symrec));
80
+ if (!case_sensitive) {
82
+ for (c=name; *c; c++)
87
rec->type = SYM_UNKNOWN;
91
rec->visibility = YASM_SYM_LOCAL;
93
+ rec->segment = NULL;
94
rec->assoc_data = NULL;
98
static /*@partial@*/ /*@dependent@*/ yasm_symrec *
99
symtab_get_or_new_in_table(yasm_symtab *symtab, /*@only@*/ char *name)
101
- yasm_symrec *rec = symrec_new_common(name);
102
+ yasm_symrec *rec = symrec_new_common(name, symtab->case_sensitive);
105
rec->status = YASM_SYM_NOSTATUS;
107
+ if (!symtab->case_sensitive) {
109
+ for (c=name; *c; c++)
113
return HAMT_insert(symtab->sym_table, name, rec, &replace,
117
symtab_get_or_new_not_in_table(yasm_symtab *symtab, /*@only@*/ char *name)
119
non_table_symrec *sym = yasm_xmalloc(sizeof(non_table_symrec));
120
- sym->rec = symrec_new_common(name);
121
+ sym->rec = symrec_new_common(name, symtab->case_sensitive);
123
sym->rec->status = YASM_SYM_NOTINTABLE;
127
yasm_symtab_get(yasm_symtab *symtab, const char *name)
129
- return HAMT_search(symtab->sym_table, name);
130
+ if (!symtab->case_sensitive) {
131
+ char *_name = yasm__xstrdup(name);
134
+ for (c=_name; *c; c++)
136
+ ret = HAMT_search(symtab->sym_table, _name);
140
+ return HAMT_search(symtab->sym_table, name);
143
static /*@dependent@*/ yasm_symrec *
145
rec->def_line = line; /* set line number of definition */
147
rec->status |= YASM_SYM_DEFINED;
149
+ rec->segment = NULL;
158
+yasm_symrec_set_size(yasm_symrec *sym, int size)
164
+yasm_symrec_get_size(const yasm_symrec *sym)
170
+yasm_symrec_set_segment(yasm_symrec *sym, const char *segment)
172
+ sym->segment = segment;
176
+yasm_symrec_get_segment(const yasm_symrec *sym)
178
+ return sym->segment;
182
yasm_symrec_is_abs(const yasm_symrec *sym)
184
return (sym->def_line == 0 && sym->type == SYM_EQU &&
185
Index: libyasm/bytecode.h
186
===================================================================
187
--- old/libyasm/bytecode.h (r�vision 2128)
188
+++ new/libyasm/bytecode.h (copie de travail)
191
void (*finalize) (yasm_bytecode *bc, yasm_bytecode *prev_bc);
193
+ /** Return elements size of a data bytecode.
194
+ * This function should return the size of each elements of a data
195
+ * bytecode, for proper dereference of symbols attached to it.
196
+ * \param bc bytecode
197
+ * \return 0 if element size is unknown.
199
+ int (*elem_size) (yasm_bytecode *bc);
201
/** Calculates the minimum size of a bytecode.
202
* Called from yasm_bc_calc_len().
203
* A generic fill-in for this is yasm_bc_calc_len_common(), but as this
206
unsigned long yasm_bc_next_offset(yasm_bytecode *precbc);
208
+/** Return elemens size of a data bytecode.
209
+ * Returns the size of each elements of a data bytecode, for proper dereference
210
+ * of symbols attached to it.
211
+ * \param bc bytecode
212
+ * \return 0 if element size is unknown
214
+int yasm_bc_elem_size(yasm_bytecode *bc);
216
/** Resolve EQUs in a bytecode and calculate its minimum size.
217
* Generates dependent bytecode spans for cases where, if the length spanned
218
* increases, it could cause the bytecode size to increase.
219
@@ -548,11 +565,31 @@
220
yasm_dataval *yasm_dv_create_raw(/*@keep@*/ unsigned char *contents,
223
+/** Create a new uninitialized data value.
224
+ * \return Newly allocated data value.
226
+yasm_dataval *yasm_dv_create_reserve(void);
229
#define yasm_dv_create_string(s, l) yasm_dv_create_raw((unsigned char *)(s), \
233
+/** Set multiple field of a data value.
234
+ * A data value can be repeated a number of times when output. This function
235
+ * sets that multiple.
236
+ * \param dv data value
237
+ * \param e multiple (kept, do not free)
239
+void yasm_dv_set_multiple(yasm_dataval *dv, /*@keep@*/ yasm_expr *e);
241
+/** Get the data value multiple value as an unsigned long integer.
242
+ * \param dv data value
243
+ * \param multiple multiple value (output)
244
+ * \return 1 on error (set with yasm_error_set), 0 on success.
246
+int yasm_dv_get_multiple(yasm_dataval *dv, /*@out@*/ unsigned long *multiple);
248
/** Initialize a list of data values.
249
* \param headp list of data values
251
Index: libyasm/symrec.h
252
===================================================================
253
--- old/libyasm/symrec.h (r�vision 2128)
254
+++ new/libyasm/symrec.h (copie de travail)
257
void yasm_symtab_destroy(/*@only@*/ yasm_symtab *symtab);
259
+/** Set the symbol table to be case sensitive or not.
260
+ * Should be called before adding any symbol.
261
+ * \param symtab symbol table
262
+ * \param sensitive whether the symbol table should be case sensitive.
264
+void yasm_symtab_set_case_sensitive(yasm_symtab *symtab, int sensitive);
266
/** Get a reference to the symbol table's "absolute" symbol. This is
267
* essentially an EQU with no name and value 0, and is used for relocating
268
* absolute current-position-relative values.
270
int yasm_symrec_get_label(const yasm_symrec *sym,
271
/*@out@*/ yasm_symrec_get_label_bytecodep *precbc);
273
+/** Set the size of a symbol.
274
+ * \param sym symbol
275
+ * \param size size to be set
277
+void yasm_symrec_set_size(yasm_symrec *sym, int size);
279
+/** Get the size of a symbol.
280
+ * \param sym symbol
281
+ * \return size of the symbol, 0 if none specified by the user.
283
+int yasm_symrec_get_size(const yasm_symrec *sym);
285
+/** Set the segment of a symbol.
286
+ * \param sym symbol
287
+ * \param segment segment to be set
289
+void yasm_symrec_set_segment(yasm_symrec *sym, const char *segment);
291
+/** Get the segment of a symbol.
292
+ * \param sym symbol
293
+ * \return segment of the symbol, NULL if none specified by the user.
295
+const char *yasm_symrec_get_segment(const yasm_symrec *sym);
297
/** Determine if symbol is the "absolute" symbol created by
298
* yasm_symtab_abs_sym().
300
Index: libyasm/insn.c
301
===================================================================
302
--- old/libyasm/insn.c (r�vision 2128)
303
+++ new/libyasm/insn.c (copie de travail)
308
+ retval->size = ea->data_len * 8;
312
Index: libyasm/insn.h
313
===================================================================
314
--- old/libyasm/insn.h (r�vision 2128)
315
+++ new/libyasm/insn.h (copie de travail)
318
/** 1 if effective address is forced non-PC-relative. */
319
unsigned int not_pc_rel:1;
321
+ /** length of pointed data (in bytes), 0 if unknown. */
322
+ unsigned int data_len;
325
/** An instruction operand (opaque type). */
326
Index: libyasm/bc-align.c
327
===================================================================
328
--- old/libyasm/bc-align.c (r�vision 2128)
329
+++ new/libyasm/bc-align.c (copie de travail)
338
Index: libyasm/bc-reserve.c
339
===================================================================
340
--- old/libyasm/bc-reserve.c (r�vision 2128)
341
+++ new/libyasm/bc-reserve.c (copie de travail)
343
static void bc_reserve_destroy(void *contents);
344
static void bc_reserve_print(const void *contents, FILE *f, int indent_level);
345
static void bc_reserve_finalize(yasm_bytecode *bc, yasm_bytecode *prev_bc);
346
+static int bc_reserve_elem_size(yasm_bytecode *bc);
347
static int bc_reserve_calc_len(yasm_bytecode *bc,
348
yasm_bc_add_span_func add_span,
349
void *add_span_data);
354
+ bc_reserve_elem_size,
356
yasm_bc_expand_common,
362
+bc_reserve_elem_size(yasm_bytecode *bc)
364
+ bytecode_reserve *reserve = (bytecode_reserve *)bc->contents;
365
+ return reserve->itemsize;
369
bc_reserve_calc_len(yasm_bytecode *bc, yasm_bc_add_span_func add_span,
372
Index: libyasm/bc-org.c
373
===================================================================
374
--- old/libyasm/bc-org.c (r�vision 2128)
375
+++ new/libyasm/bc-org.c (copie de travail)
384
Index: libyasm/intnum.c
385
===================================================================
386
--- old/libyasm/intnum.c (r�vision 2128)
387
+++ new/libyasm/intnum.c (copie de travail)
388
@@ -244,17 +244,65 @@
392
- /* >32 bit conversion */
393
+ /* >=32 bit conversion */
395
BitVector_Move_Left(conv_bv, 8);
396
BitVector_Chunk_Store(conv_bv, 8, 0,
397
- (unsigned long)str[--len]);
398
+ ((unsigned long)str[--len]) & 0xff);
400
intn->val.bv = BitVector_Clone(conv_bv);
407
+yasm_intnum_create_charconst_tasm(const char *str)
409
+ yasm_intnum *intn = yasm_xmalloc(sizeof(yasm_intnum));
410
+ size_t len = strlen(str);
413
+ if(len*8 > BITVECT_NATIVE_SIZE)
414
+ yasm_error_set(YASM_ERROR_OVERFLOW,
415
+ N_("Character constant too large for internal format"));
417
+ /* be conservative in choosing bitvect in case MSB is set */
419
+ BitVector_Empty(conv_bv);
420
+ intn->type = INTNUM_BV;
423
+ intn->type = INTNUM_L;
426
+ /* tasm uses big endian notation */
430
+ intn->val.l |= ((unsigned long)str[i++]) & 0xff;
434
+ intn->val.l |= ((unsigned long)str[i++]) & 0xff;
438
+ intn->val.l |= ((unsigned long)str[i++]) & 0xff;
442
+ /* >=32 bit conversion */
444
+ BitVector_Chunk_Store(conv_bv, 8, (len-i-1)*8,
445
+ ((unsigned long)str[i]) & 0xff);
448
+ intn->val.bv = BitVector_Clone(conv_bv);
453
/*@=usedef =compdef =uniondef@*/
456
Index: libyasm/expr.c
457
===================================================================
458
--- old/libyasm/expr.c (r�vision 2128)
459
+++ new/libyasm/expr.c (copie de travail)
460
@@ -1444,3 +1444,73 @@
461
fprintf(f, "%s", opstr);
466
+yasm_expr_size(const yasm_expr *e)
470
+ unsigned int size = 0, newsize;
472
+ if (e->op == YASM_EXPR_IDENT) {
473
+ if (e->terms[0].type == YASM_EXPR_SYM)
474
+ return yasm_symrec_get_size(e->terms[0].data.sym);
477
+ if (e->op != YASM_EXPR_ADD && e->op != YASM_EXPR_SUB)
480
+ for (i=0; i<e->numterms; i++) {
482
+ switch (e->terms[i].type) {
483
+ case YASM_EXPR_EXPR:
484
+ newsize = yasm_expr_size(e->terms[i].data.expn);
486
+ case YASM_EXPR_SYM:
487
+ newsize = yasm_symrec_get_size(e->terms[i].data.sym);
495
+ /* either sum of idents (?!) or substract of idents */
500
+ /* exactly one offset */
505
+yasm_expr_segment(const yasm_expr *e)
509
+ const char *segment = NULL;
511
+ if (e->op == YASM_EXPR_IDENT) {
512
+ if (e->terms[0].type == YASM_EXPR_SYM)
513
+ return yasm_symrec_get_segment(e->terms[0].data.sym);
516
+ if (e->op != YASM_EXPR_ADD && e->op != YASM_EXPR_SUB)
519
+ for (i=0; i<e->numterms; i++) {
520
+ if ((e->op == YASM_EXPR_ADD || !i) &&
521
+ e->terms[i].type == YASM_EXPR_EXPR) {
522
+ if ((segment = yasm_expr_segment(e->terms[i].data.expn))) {
524
+ /* either sum of idents (?!) or substract of idents */
531
+ /* exactly one offset */
534
Index: libyasm/intnum.h
535
===================================================================
536
--- old/libyasm/intnum.h (r�vision 2128)
537
+++ new/libyasm/intnum.h (copie de travail)
540
/** Convert character constant to integer value, using NASM rules. NASM syntax
541
* supports automatic conversion from strings such as 'abcd' to a 32-bit
542
- * integer value. This function performs those conversions.
543
+ * integer value (little endian order). This function performs those conversions.
544
* \param str character constant string
545
* \return Newly allocated intnum.
547
/*@only@*/ yasm_intnum *yasm_intnum_create_charconst_nasm(const char *str);
549
+/** Convert character constant to integer value, using TASM rules. TASM syntax
550
+ * supports automatic conversion from strings such as 'abcd' to a 32-bit
551
+ * integer value (big endian order). This function performs those conversions.
552
+ * \param str character constant string
553
+ * \return Newly allocated intnum.
555
+/*@only@*/ yasm_intnum *yasm_intnum_create_charconst_tasm(const char *str);
557
/** Create a new intnum from an unsigned integer value.
558
* \param i unsigned integer value
559
* \return Newly allocated intnum.
560
Index: libyasm/errwarn.c
561
===================================================================
562
--- old/libyasm/errwarn.c (r�vision 2128)
563
+++ new/libyasm/errwarn.c (copie de travail)
566
(1UL<<YASM_WARN_GENERAL) | (1UL<<YASM_WARN_UNREC_CHAR) |
567
(1UL<<YASM_WARN_PREPROC) | (0UL<<YASM_WARN_ORPHAN_LABEL) |
568
- (1UL<<YASM_WARN_UNINIT_CONTENTS);
569
+ (1UL<<YASM_WARN_UNINIT_CONTENTS) | (0UL<<YASM_WARN_SIZE_OVERRIDE) |
570
+ (1UL<<YASM_WARN_IMPLICIT_SIZE_OVERRIDE);
572
yasm_eclass = YASM_ERROR_NONE;
574
Index: libyasm/expr.h
575
===================================================================
576
--- old/libyasm/expr.h (r�vision 2128)
577
+++ new/libyasm/expr.h (copie de travail)
580
void yasm_expr_print(/*@null@*/ const yasm_expr *e, FILE *f);
582
+/** Return the size of an expression, if the user provided it
583
+ * \param e expression
585
+unsigned int yasm_expr_size(const yasm_expr *e);
587
+/** Return the segment of an expression, if the user provided it
588
+ * \param e expression
590
+const char *yasm_expr_segment(const yasm_expr *e);
592
/** Traverse over expression tree in order (const version).
593
* Calls func for each leaf (non-operation).
594
* \param e expression
595
Index: libyasm/bc-incbin.c
596
===================================================================
597
--- old/libyasm/bc-incbin.c (r�vision 2128)
598
+++ new/libyasm/bc-incbin.c (copie de travail)
605
yasm_bc_expand_common,
607
Index: libyasm/errwarn.h
608
===================================================================
609
--- old/libyasm/errwarn.h (r�vision 2128)
610
+++ new/libyasm/errwarn.h (copie de travail)
612
YASM_WARN_PREPROC, /**< Preprocessor warnings */
613
YASM_WARN_ORPHAN_LABEL, /**< Label alone on a line without a colon */
614
YASM_WARN_UNINIT_CONTENTS, /**< Uninitialized space in code/data section */
615
- YASM_WARN_SIZE_OVERRIDE /**< Double size override */
616
+ YASM_WARN_SIZE_OVERRIDE,/**< Double size override */
617
+ YASM_WARN_IMPLICIT_SIZE_OVERRIDE /**< Implicit size override */
620
/** Error classes. Bitmask-based to support limited subclassing. */
621
Index: libyasm/bc-data.c
622
===================================================================
623
--- old/libyasm/bc-data.c (r�vision 2128)
624
+++ new/libyasm/bc-data.c (copie de travail)
626
struct yasm_dataval {
627
/*@reldef@*/ STAILQ_ENTRY(yasm_dataval) link;
629
- enum { DV_EMPTY, DV_VALUE, DV_RAW, DV_ULEB128, DV_SLEB128 } type;
630
+ enum { DV_EMPTY, DV_VALUE, DV_RAW, DV_ULEB128, DV_SLEB128, DV_RESERVE }
640
+ /* number of times data is repeated, NULL=1. */
641
+ /*@only@*/ /*@null@*/ yasm_expr *multiple;
644
typedef struct bytecode_data {
645
/* converted data (linked list) */
646
yasm_datavalhead datahead;
651
static void bc_data_destroy(void *contents);
652
static void bc_data_print(const void *contents, FILE *f, int indent_level);
653
static void bc_data_finalize(yasm_bytecode *bc, yasm_bytecode *prev_bc);
654
+static int bc_data_item_size(yasm_bytecode *bc);
655
static int bc_data_calc_len(yasm_bytecode *bc, yasm_bc_add_span_func add_span,
656
void *add_span_data);
657
static int bc_data_tobytes(yasm_bytecode *bc, unsigned char **bufp, void *d,
664
yasm_bc_expand_common,
666
@@ -131,37 +139,64 @@
670
+ if (dv->multiple) {
672
+ if (yasm_value_finalize_expr(&val, dv->multiple, prev_bc, 0))
673
+ yasm_error_set(YASM_ERROR_TOO_COMPLEX,
674
+ N_("multiple expression too complex"));
676
+ yasm_error_set(YASM_ERROR_NOT_ABSOLUTE,
677
+ N_("multiple expression not absolute"));
678
+ dv->multiple = val.abs;
684
+bc_data_item_size(yasm_bytecode *bc)
686
+ bytecode_data *bc_data = (bytecode_data *)bc->contents;
687
+ return bc_data->item_size;
691
bc_data_calc_len(yasm_bytecode *bc, yasm_bc_add_span_func add_span,
694
bytecode_data *bc_data = (bytecode_data *)bc->contents;
698
+ unsigned long multiple;
700
/* Count up element sizes, rounding up string length. */
701
STAILQ_FOREACH(dv, &bc_data->datahead, link) {
707
- bc->len += dv->data.val.size/8;
708
+ len = dv->data.val.size/8;
711
- bc->len += dv->data.raw.len;
712
+ len = dv->data.raw.len;
716
intn = yasm_expr_get_intnum(&dv->data.val.abs, 0);
718
yasm_internal_error(N_("non-constant in data_tobytes"));
720
- yasm_intnum_size_leb128(intn, dv->type == DV_SLEB128);
721
+ len = yasm_intnum_size_leb128(intn, dv->type == DV_SLEB128);
724
+ len = dv->data.val.size/8;
728
+ if (!yasm_dv_get_multiple(dv, &multiple))
735
@@ -177,29 +212,47 @@
736
unsigned char *bufp_orig = *bufp;
738
unsigned int val_len;
739
+ unsigned long multiple, i;
741
STAILQ_FOREACH(dv, &bc_data->datahead, link) {
742
+ if (yasm_dv_get_multiple(dv, &multiple) || multiple == 0)
748
val_len = dv->data.val.size/8;
749
- if (output_value(&dv->data.val, *bufp, val_len,
750
- (unsigned long)(*bufp-bufp_orig), bc, 1, d))
753
+ for (i=0; i<multiple; i++) {
754
+ if (output_value(&dv->data.val, *bufp, val_len,
755
+ (unsigned long)(*bufp-bufp_orig), bc, 1,
762
- memcpy(*bufp, dv->data.raw.contents, dv->data.raw.len);
763
- *bufp += dv->data.raw.len;
764
+ for (i=0; i<multiple; i++) {
765
+ memcpy(*bufp, dv->data.raw.contents, dv->data.raw.len);
766
+ *bufp += dv->data.raw.len;
771
intn = yasm_expr_get_intnum(&dv->data.val.abs, 234);
773
yasm_internal_error(N_("non-constant in data_tobytes"));
775
- yasm_intnum_get_leb128(intn, *bufp, dv->type == DV_SLEB128);
776
+ for (i=0; i<multiple; i++) {
778
+ yasm_intnum_get_leb128(intn, *bufp,
779
+ dv->type == DV_SLEB128);
782
+ val_len = dv->data.val.size/8;
783
+ for (i=0; i<multiple; i++) {
784
+ memset(*bufp, 0, val_len);
791
@@ -218,11 +271,18 @@
794
yasm_dvs_initialize(&data->datahead);
795
+ data->item_size = size;
797
/* Prescan input data for length, etc. Careful: this needs to be
798
* precisely paired with the second loop.
800
STAILQ_FOREACH(dv, datahead, link) {
801
+ if (dv->multiple && dv->type != DV_EMPTY && len > 0) {
802
+ /* Flush previous data */
803
+ dvo = yasm_dv_create_raw(yasm_xmalloc(len), len);
804
+ STAILQ_INSERT_TAIL(&data->datahead, dvo, link);
811
/* Create bytecode for this value */
812
dvo = yasm_xmalloc(sizeof(yasm_dataval));
813
STAILQ_INSERT_TAIL(&data->datahead, dvo, link);
814
+ dvo->multiple = dv->multiple;
819
rlen = (rlen + size - 1) / size;
827
+ if (dv->multiple && dv->type != DV_EMPTY && len > 0) {
828
+ /* Flush this data */
829
+ dvo = yasm_dv_create_raw(yasm_xmalloc(len), len);
830
+ STAILQ_INSERT_TAIL(&data->datahead, dvo, link);
831
+ dvo->multiple = dv->multiple;
839
dvo = STAILQ_FIRST(&data->datahead);
842
+ if (dv->multiple && dv->type != DV_EMPTY && len > 0) {
843
+ dvo = STAILQ_NEXT(dvo, link);
850
dvo->data.raw.contents[len++] = 0;
854
+ memset(&dvo->data.raw.contents[len], 0, size);
859
+ if (dv->multiple && dv->type != DV_EMPTY && len > 0) {
860
+ dvo = STAILQ_NEXT(dvo, link);
865
dvo->data.raw.contents[len++] = 0;
866
dv2 = STAILQ_NEXT(dv, link);
869
retval->type = DV_VALUE;
870
yasm_value_initialize(&retval->data.val, e, 0);
871
+ retval->multiple = NULL;
875
@@ -376,11 +464,55 @@
876
retval->type = DV_RAW;
877
retval->data.raw.contents = contents;
878
retval->data.raw.len = len;
879
+ retval->multiple = NULL;
885
+yasm_dv_create_reserve(void)
887
+ yasm_dataval *retval = yasm_xmalloc(sizeof(yasm_dataval));
889
+ retval->type = DV_RESERVE;
890
+ retval->multiple = NULL;
896
+yasm_dv_set_multiple(yasm_dataval *dv, yasm_expr *e)
899
+ dv->multiple = yasm_expr_create_tree( dv->multiple, YASM_EXPR_MUL, e,
906
+yasm_dv_get_multiple(yasm_dataval *dv, unsigned long *multiple)
908
+ /*@dependent@*/ /*@null@*/ const yasm_intnum *num;
911
+ if (dv->multiple) {
912
+ num = yasm_expr_get_intnum(&dv->multiple, 0);
914
+ yasm_error_set(YASM_ERROR_VALUE,
915
+ N_("could not determine multiple"));
918
+ if (yasm_intnum_sign(num) < 0) {
919
+ yasm_error_set(YASM_ERROR_VALUE, N_("multiple is negative"));
922
+ *multiple = yasm_intnum_get_uint(num);
928
yasm_dvs_delete(yasm_datavalhead *headp)
930
yasm_dataval *cur, *next;
936
+ yasm_expr_destroy(cur->multiple);
943
STAILQ_FOREACH(cur, head, link) {
944
+ fprintf(f, "%*sMultiple=", indent_level, "");
945
+ if (!cur->multiple)
946
+ fprintf(f, "nil (1)");
948
+ yasm_expr_print(cur->multiple, f);
951
fprintf(f, "%*sEmpty\n", indent_level, "");
953
fprintf(f, "%*sSLEB128 value:\n", indent_level, "");
954
yasm_value_print(&cur->data.val, f, indent_level+1);
957
+ fprintf(f, "%*sReserved\n", indent_level, "");
962
Index: modules/parsers/tasm/tests/lidt.hex
963
===================================================================
964
--- old/modules/parsers/tasm/tests/lidt.hex (r�vision 0)
965
+++ new/modules/parsers/tasm/tests/lidt.hex (r�vision 0)
978
Index: modules/parsers/tasm/tests/macro.asm
979
===================================================================
980
--- old/modules/parsers/tasm/tests/macro.asm (r�vision 0)
981
+++ new/modules/parsers/tasm/tests/macro.asm (r�vision 0)
989
Index: modules/parsers/tasm/tests/segment.asm
990
===================================================================
991
--- old/modules/parsers/tasm/tests/segment.asm (r�vision 0)
992
+++ new/modules/parsers/tasm/tests/segment.asm (r�vision 0)
1000
+ mov byte ptr [a],1
1002
Index: modules/parsers/tasm/tests/exe/exe.asm
1003
===================================================================
1004
--- old/modules/parsers/tasm/tests/exe/exe.asm (r�vision 0)
1005
+++ new/modules/parsers/tasm/tests/exe/exe.asm (r�vision 0)
1011
Index: modules/parsers/tasm/tests/exe/exe.hex
1012
===================================================================
1013
--- old/modules/parsers/tasm/tests/exe/exe.hex (r�vision 0)
1014
+++ new/modules/parsers/tasm/tests/exe/exe.hex (r�vision 0)
1531
Index: modules/parsers/tasm/tests/exe/tasm_exe_test.sh
1532
===================================================================
1533
--- old/modules/parsers/tasm/tests/exe/tasm_exe_test.sh (r�vision 0)
1534
+++ new/modules/parsers/tasm/tests/exe/tasm_exe_test.sh (r�vision 0)
1537
+# $Id: tasm_test.sh 1137 2004-09-04 01:24:57Z peter $
1538
+${srcdir}/out_test.sh tasm_test modules/parsers/tasm/tests/exe "tasm-compat parser" "-f dosexe -p tasm" ""
1541
Modification de propri�t�s sur modules/parsers/tasm/tests/exe/tasm_exe_test.sh
1542
___________________________________________________________________
1543
Ajout� : svn:mergeinfo
1545
Index: modules/parsers/tasm/tests/macro.hex
1546
===================================================================
1547
--- old/modules/parsers/tasm/tests/macro.hex (r�vision 0)
1548
+++ new/modules/parsers/tasm/tests/macro.hex (r�vision 0)
1556
Index: modules/parsers/tasm/tests/segment.hex
1557
===================================================================
1558
--- old/modules/parsers/tasm/tests/segment.hex (r�vision 0)
1559
+++ new/modules/parsers/tasm/tests/segment.hex (r�vision 0)
1568
Index: modules/parsers/tasm/tests/charstr.asm
1569
===================================================================
1570
--- old/modules/parsers/tasm/tests/charstr.asm (r�vision 0)
1571
+++ new/modules/parsers/tasm/tests/charstr.asm (r�vision 0)
1574
Index: modules/parsers/tasm/tests/charstr.hex
1575
===================================================================
1576
--- old/modules/parsers/tasm/tests/charstr.hex (r�vision 0)
1577
+++ new/modules/parsers/tasm/tests/charstr.hex (r�vision 0)
1585
Index: modules/parsers/tasm/tests/array.asm
1586
===================================================================
1587
--- old/modules/parsers/tasm/tests/array.asm (r�vision 0)
1588
+++ new/modules/parsers/tasm/tests/array.asm (r�vision 0)
1592
Index: modules/parsers/tasm/tests/label.asm
1593
===================================================================
1594
--- old/modules/parsers/tasm/tests/label.asm (r�vision 0)
1595
+++ new/modules/parsers/tasm/tests/label.asm (r�vision 0)
1599
Index: modules/parsers/tasm/tests/array.hex
1600
===================================================================
1601
--- old/modules/parsers/tasm/tests/array.hex (r�vision 0)
1602
+++ new/modules/parsers/tasm/tests/array.hex (r�vision 0)
1610
Index: modules/parsers/tasm/tests/label.hex
1611
===================================================================
1612
--- old/modules/parsers/tasm/tests/label.hex (r�vision 0)
1613
+++ new/modules/parsers/tasm/tests/label.hex (r�vision 0)
1618
Index: modules/parsers/tasm/tests/offset.asm
1619
===================================================================
1620
--- old/modules/parsers/tasm/tests/offset.asm (r�vision 0)
1621
+++ new/modules/parsers/tasm/tests/offset.asm (r�vision 0)
1626
Index: modules/parsers/tasm/tests/offset.hex
1627
===================================================================
1628
--- old/modules/parsers/tasm/tests/offset.hex (r�vision 0)
1629
+++ new/modules/parsers/tasm/tests/offset.hex (r�vision 0)
1638
Index: modules/parsers/tasm/tests/irp.asm
1639
===================================================================
1640
--- old/modules/parsers/tasm/tests/irp.asm (r�vision 0)
1641
+++ new/modules/parsers/tasm/tests/irp.asm (r�vision 0)
1646
Index: modules/parsers/tasm/tests/quote.asm
1647
===================================================================
1648
--- old/modules/parsers/tasm/tests/quote.asm (r�vision 0)
1649
+++ new/modules/parsers/tasm/tests/quote.asm (r�vision 0)
1653
Index: modules/parsers/tasm/tests/tasm_test.sh
1654
===================================================================
1655
--- old/modules/parsers/tasm/tests/tasm_test.sh (r�vision 0)
1656
+++ new/modules/parsers/tasm/tests/tasm_test.sh (r�vision 0)
1659
+# $Id: tasm_test.sh 1137 2004-09-04 01:24:57Z peter $
1660
+${srcdir}/out_test.sh tasm_test modules/parsers/tasm/tests "tasm-compat parser" "-f bin -p tasm" ""
1661
+${srcdir}/out_test.sh tasm_test modules/parsers/tasm/tests/exe "tasm-compat parser" "-f dosexe -p tasm" ""
1664
Modification de propri�t�s sur modules/parsers/tasm/tests/tasm_test.sh
1665
___________________________________________________________________
1666
Ajout� : svn:executable
1669
Index: modules/parsers/tasm/tests/irp.hex
1670
===================================================================
1671
--- old/modules/parsers/tasm/tests/irp.hex (r�vision 0)
1672
+++ new/modules/parsers/tasm/tests/irp.hex (r�vision 0)
1683
Index: modules/parsers/tasm/tests/struc.asm
1684
===================================================================
1685
--- old/modules/parsers/tasm/tests/struc.asm (r�vision 0)
1686
+++ new/modules/parsers/tasm/tests/struc.asm (r�vision 0)
1696
Index: modules/parsers/tasm/tests/struc.errwarn
1697
===================================================================
1698
--- old/modules/parsers/tasm/tests/struc.errwarn (r�vision 0)
1699
+++ new/modules/parsers/tasm/tests/struc.errwarn (r�vision 0)
1701
+-:6: warning: uninitialized space declared in code/data section: zeroing
1702
Index: modules/parsers/tasm/tests/quote.hex
1703
===================================================================
1704
--- old/modules/parsers/tasm/tests/quote.hex (r�vision 0)
1705
+++ new/modules/parsers/tasm/tests/quote.hex (r�vision 0)
1713
Index: modules/parsers/tasm/tests/struc.hex
1714
===================================================================
1715
--- old/modules/parsers/tasm/tests/struc.hex (r�vision 0)
1716
+++ new/modules/parsers/tasm/tests/struc.hex (r�vision 0)
1723
Index: modules/parsers/tasm/tests/equal.asm
1724
===================================================================
1725
--- old/modules/parsers/tasm/tests/equal.asm (r�vision 0)
1726
+++ new/modules/parsers/tasm/tests/equal.asm (r�vision 0)
1729
Index: modules/parsers/tasm/tests/size.asm
1730
===================================================================
1731
--- old/modules/parsers/tasm/tests/size.asm (r�vision 0)
1732
+++ new/modules/parsers/tasm/tests/size.asm (r�vision 0)
1736
Index: modules/parsers/tasm/tests/equal.hex
1737
===================================================================
1738
Index: modules/parsers/tasm/tests/case.asm
1739
===================================================================
1740
--- old/modules/parsers/tasm/tests/case.asm (r�vision 0)
1741
+++ new/modules/parsers/tasm/tests/case.asm (r�vision 0)
1746
Index: modules/parsers/tasm/tests/size.hex
1747
===================================================================
1748
--- old/modules/parsers/tasm/tests/size.hex (r�vision 0)
1749
+++ new/modules/parsers/tasm/tests/size.hex (r�vision 0)
1757
Index: modules/parsers/tasm/tests/expr.asm
1758
===================================================================
1759
--- old/modules/parsers/tasm/tests/expr.asm (r�vision 0)
1760
+++ new/modules/parsers/tasm/tests/expr.asm (r�vision 0)
1762
+a db low ((1 shl 2) and (16 shr 2) or (high 0x5034))
1763
Index: modules/parsers/tasm/tests/case.hex
1764
===================================================================
1765
--- old/modules/parsers/tasm/tests/case.hex (r�vision 0)
1766
+++ new/modules/parsers/tasm/tests/case.hex (r�vision 0)
1773
Index: modules/parsers/tasm/tests/expr.hex
1774
===================================================================
1775
--- old/modules/parsers/tasm/tests/expr.hex (r�vision 0)
1776
+++ new/modules/parsers/tasm/tests/expr.hex (r�vision 0)
1779
Index: modules/parsers/tasm/tests/les.asm
1780
===================================================================
1781
--- old/modules/parsers/tasm/tests/les.asm (r�vision 0)
1782
+++ new/modules/parsers/tasm/tests/les.asm (r�vision 0)
1786
Index: modules/parsers/tasm/tests/les.hex
1787
===================================================================
1788
--- old/modules/parsers/tasm/tests/les.hex (r�vision 0)
1789
+++ new/modules/parsers/tasm/tests/les.hex (r�vision 0)
1796
Index: modules/parsers/tasm/tests/dup.asm
1797
===================================================================
1798
--- old/modules/parsers/tasm/tests/dup.asm (r�vision 0)
1799
+++ new/modules/parsers/tasm/tests/dup.asm (r�vision 0)
1802
Index: modules/parsers/tasm/tests/res.errwarn
1803
===================================================================
1804
--- old/modules/parsers/tasm/tests/res.errwarn (r�vision 0)
1805
+++ new/modules/parsers/tasm/tests/res.errwarn (r�vision 0)
1807
+-:1: warning: uninitialized space declared in code/data section: zeroing
1808
+-:2: warning: uninitialized space declared in code/data section: zeroing
1809
Index: modules/parsers/tasm/tests/res.asm
1810
===================================================================
1811
--- old/modules/parsers/tasm/tests/res.asm (r�vision 0)
1812
+++ new/modules/parsers/tasm/tests/res.asm (r�vision 0)
1816
Index: modules/parsers/tasm/tests/lidt.asm
1817
===================================================================
1818
--- old/modules/parsers/tasm/tests/lidt.asm (r�vision 0)
1819
+++ new/modules/parsers/tasm/tests/lidt.asm (r�vision 0)
1823
+lidt fword ptr idtr
1824
Index: modules/parsers/tasm/tests/dup.hex
1825
===================================================================
1826
--- old/modules/parsers/tasm/tests/dup.hex (r�vision 0)
1827
+++ new/modules/parsers/tasm/tests/dup.hex (r�vision 0)
1839
Index: modules/parsers/tasm/tests/res.hex
1840
===================================================================
1841
--- old/modules/parsers/tasm/tests/res.hex (r�vision 0)
1842
+++ new/modules/parsers/tasm/tests/res.hex (r�vision 0)
1847
Index: modules/parsers/nasm/nasm-token.re
1848
===================================================================
1849
--- old/modules/parsers/nasm/nasm-token.re (r�vision 2128)
1850
+++ new/modules/parsers/nasm/nasm-token.re (copie de travail)
1852
#include <libyasm.h>
1854
#include "modules/parsers/nasm/nasm-parser.h"
1855
+#include "modules/preprocs/nasm/nasm.h"
1858
#define YYCURSOR cursor
1861
/* check for special non-local labels like ..start */
1862
if (tok[zeropos+1] == '.') {
1863
- lvalp->str_val = yasm__xstrndup(tok+zeropos, toklen-zeropos);
1864
+ lvalp->str_val = yasm__xstrndup(tok+zeropos+(parser_nasm->tasm?2:0),
1865
+ toklen-zeropos-(parser_nasm->tasm?2:0));
1866
/* check for special non-local ..@label */
1867
if (lvalp->str_val[zeropos+2] == '@')
1872
+ if (parser_nasm->tasm && (!tasm_locals ||
1873
+ (tok[zeropos] == '.' &&
1874
+ tok[zeropos+1] != '@' && tok[zeropos+2] != '@'))) {
1875
+ /* no locals on Tasm without the 'locals' directive */
1876
+ /* .foo is never local either, but .@@foo may be (local structure
1878
+ lvalp->str_val = yasm__xstrndup(tok + zeropos, toklen - zeropos);
1879
+ return SPECIAL_ID;
1881
if (!parser_nasm->locallabel_base) {
1882
lvalp->str_val = yasm__xstrndup(tok+zeropos, toklen-zeropos);
1883
yasm_warn_set(YASM_WARN_GENERAL,
1884
@@ -242,65 +252,95 @@
1887
/* pseudo-instructions */
1888
- 'db' { lvalp->int_info = 8; RETURN(DECLARE_DATA); }
1890
+ lvalp->int_info = 8;
1891
+ parser_nasm->state = INSTRUCTION;
1892
+ RETURN(DECLARE_DATA);
1895
lvalp->int_info = yasm_arch_wordsize(p_object->arch)/2;
1896
+ parser_nasm->state = INSTRUCTION;
1897
RETURN(DECLARE_DATA);
1900
lvalp->int_info = yasm_arch_wordsize(p_object->arch);
1901
+ parser_nasm->state = INSTRUCTION;
1902
RETURN(DECLARE_DATA);
1905
lvalp->int_info = yasm_arch_wordsize(p_object->arch)*2;
1906
+ parser_nasm->state = INSTRUCTION;
1907
RETURN(DECLARE_DATA);
1910
lvalp->int_info = yasm_arch_wordsize(p_object->arch)*4;
1911
+ parser_nasm->state = INSTRUCTION;
1912
RETURN(DECLARE_DATA);
1914
- 'dt' { lvalp->int_info = 80; RETURN(DECLARE_DATA); }
1916
+ lvalp->int_info = 80;
1917
+ parser_nasm->state = INSTRUCTION;
1918
+ RETURN(DECLARE_DATA);
1921
lvalp->int_info = yasm_arch_wordsize(p_object->arch)*8;
1922
+ parser_nasm->state = INSTRUCTION;
1923
RETURN(DECLARE_DATA);
1926
lvalp->int_info = yasm_arch_wordsize(p_object->arch)*8;
1927
+ parser_nasm->state = INSTRUCTION;
1928
RETURN(DECLARE_DATA);
1931
lvalp->int_info = 256;
1932
+ parser_nasm->state = INSTRUCTION;
1933
RETURN(DECLARE_DATA);
1936
- 'resb' { lvalp->int_info = 8; RETURN(RESERVE_SPACE); }
1938
+ lvalp->int_info = 8;
1939
+ parser_nasm->state = INSTRUCTION;
1940
+ RETURN(RESERVE_SPACE);
1943
lvalp->int_info = yasm_arch_wordsize(p_object->arch)/2;
1944
+ parser_nasm->state = INSTRUCTION;
1945
RETURN(RESERVE_SPACE);
1948
lvalp->int_info = yasm_arch_wordsize(p_object->arch);
1949
+ parser_nasm->state = INSTRUCTION;
1950
RETURN(RESERVE_SPACE);
1953
lvalp->int_info = yasm_arch_wordsize(p_object->arch)*2;
1954
+ parser_nasm->state = INSTRUCTION;
1955
RETURN(RESERVE_SPACE);
1958
lvalp->int_info = yasm_arch_wordsize(p_object->arch)*4;
1959
+ parser_nasm->state = INSTRUCTION;
1960
RETURN(RESERVE_SPACE);
1962
- 'rest' { lvalp->int_info = 80; RETURN(RESERVE_SPACE); }
1964
+ lvalp->int_info = 80;
1965
+ parser_nasm->state = INSTRUCTION;
1966
+ RETURN(RESERVE_SPACE);
1969
lvalp->int_info = yasm_arch_wordsize(p_object->arch)*8;
1970
+ parser_nasm->state = INSTRUCTION;
1971
RETURN(RESERVE_SPACE);
1974
lvalp->int_info = yasm_arch_wordsize(p_object->arch)*8;
1975
+ parser_nasm->state = INSTRUCTION;
1976
RETURN(RESERVE_SPACE);
1979
lvalp->int_info = 256;
1980
+ parser_nasm->state = INSTRUCTION;
1981
RETURN(RESERVE_SPACE);
1984
@@ -325,17 +365,18 @@
1985
"//" { RETURN(SIGNDIV); }
1986
"%%" { RETURN(SIGNMOD); }
1987
"$$" { RETURN(START_SECTION_ID); }
1988
- [-+|^*&/%~$():=,\[] { RETURN(s->tok[0]); }
1989
+ [-+|^*&/%~$():=,\[?] { RETURN(s->tok[0]); }
1990
"]" { RETURN(s->tok[0]); }
1992
/* local label (.label) */
1993
- "." [a-zA-Z0-9_$#@~.?]+ {
1994
+ ("." | "@@") [a-zA-Z0-9_$#@~.?]+ {
1995
RETURN(handle_dot_label(lvalp, TOK, TOKLEN, 0, parser_nasm));
1998
/* forced identifier */
1999
"$" [a-zA-Z0-9_$#@~.?]+ {
2000
- if (TOK[1] == '.') {
2001
+ if (TOK[1] == '.' ||
2002
+ (parser_nasm->tasm && TOK[1] == '@' && TOK[2] == '@')) {
2003
/* handle like .label */
2004
RETURN(handle_dot_label(lvalp, TOK, TOKLEN, 1, parser_nasm));
2006
@@ -376,11 +417,61 @@
2007
s->tok[TOKLEN] = savech;
2012
+ if (parser_nasm->tasm) {
2013
+ if (!strcasecmp(TOK, "shl")) {
2014
s->tok[TOKLEN] = savech;
2017
+ if (!strcasecmp(TOK, "shr")) {
2018
+ s->tok[TOKLEN] = savech;
2021
+ if (!strcasecmp(TOK, "and")) {
2022
+ s->tok[TOKLEN] = savech;
2025
+ if (!strcasecmp(TOK, "or")) {
2026
+ s->tok[TOKLEN] = savech;
2029
+ if (!strcasecmp(TOK, "low")) {
2030
+ s->tok[TOKLEN] = savech;
2033
+ if (!strcasecmp(TOK, "high")) {
2034
+ s->tok[TOKLEN] = savech;
2037
+ if (!strcasecmp(TOK, "offset")) {
2038
+ s->tok[TOKLEN] = savech;
2041
+ if (!strcasecmp(TOK, "fword")) {
2042
+ s->tok[TOKLEN] = savech;
2043
+ lvalp->int_info = yasm_arch_wordsize(p_object->arch)*2;
2044
+ RETURN(SIZE_OVERRIDE);
2046
+ if (!strcasecmp(TOK, "df")) {
2047
+ s->tok[TOKLEN] = savech;
2048
+ lvalp->int_info = yasm_arch_wordsize(p_object->arch)*3;
2049
+ parser_nasm->state = INSTRUCTION;
2050
+ RETURN(DECLARE_DATA);
2052
+ if (!strcasecmp(TOK, "label")) {
2053
+ s->tok[TOKLEN] = savech;
2056
+ if (!strcasecmp(TOK, "dup")) {
2057
+ s->tok[TOKLEN] = savech;
2061
/* Propagate errors in case we got a warning from the arch */
2062
yasm_errwarn_propagate(parser_nasm->errwarns, cur_line);
2063
/* Just an identifier, return as such. */
2064
+ s->tok[TOKLEN] = savech;
2065
lvalp->str_val = yasm__xstrndup(TOK, TOKLEN);
2068
@@ -656,6 +747,29 @@
2073
+ if (endch != s->tok[0]) {
2074
+ strbuf[count++] = s->tok[0];
2075
+ if (count >= strbuf_size) {
2076
+ strbuf = yasm_xrealloc(strbuf,
2077
+ strbuf_size + STRBUF_ALLOC_SIZE);
2078
+ strbuf_size += STRBUF_ALLOC_SIZE;
2080
+ } else if (!parser_nasm->tasm) {
2082
+ strbuf[count] = '\0';
2083
+ lvalp->str.contents = (char *)strbuf;
2084
+ lvalp->str.len = count;
2087
+ strbuf[count++] = s->tok[0];
2088
+ if (count >= strbuf_size) {
2089
+ strbuf = yasm_xrealloc(strbuf, strbuf_size + STRBUF_ALLOC_SIZE);
2090
+ strbuf_size += STRBUF_ALLOC_SIZE;
2092
+ goto stringconst_scan;
2096
if (s->tok[0] == endch) {
2097
strbuf[count] = '\0';
2098
Index: modules/parsers/nasm/nasm-parse.c
2099
===================================================================
2100
--- old/modules/parsers/nasm/nasm-parse.c (r�vision 2128)
2101
+++ new/modules/parsers/nasm/nasm-parse.c (copie de travail)
2105
#include "modules/parsers/nasm/nasm-parser.h"
2106
+#include "modules/preprocs/nasm/nasm.h"
2111
/*@null@*/ yasm_valparamhead *valparams,
2112
/*@null@*/ yasm_valparamhead *objext_valparams);
2113
static void define_label(yasm_parser_nasm *parser_nasm, /*@only@*/ char *name,
2115
+ unsigned int size, int local);
2117
+static void yasm_ea_set_implicit_size_segment(yasm_parser_nasm *parser_nasm,
2118
+ yasm_effaddr *ea, yasm_expr *e)
2120
+ if (parser_nasm->tasm) {
2121
+ const char *segment = yasm_expr_segment(e);
2122
+ ea->data_len = yasm_expr_size(e);
2124
+ const char *segreg = tasm_get_segment_register(segment);
2126
+ yasm_arch_parse_check_regtmod(p_object->arch, segreg,
2127
+ strlen(segreg), &ea->segreg);
2133
#define is_eol_tok(tok) ((tok) == 0)
2134
#define is_eol() is_eol_tok(curtok)
2136
@@ -242,11 +259,12 @@
2137
yasm_bc_destroy(bc);
2142
temp_bc = yasm_section_bcs_append(cursect, bc);
2144
parser_nasm->prev_bc = temp_bc;
2148
yasm_errwarn_propagate(parser_nasm->errwarns, cur_line);
2150
if (parser_nasm->save_input)
2151
@@ -355,23 +373,33 @@
2154
char *name = ID_val;
2155
- int local = (curtok != ID);
2156
+ int local = parser_nasm->tasm
2157
+ ? (curtok == ID || curtok == LOCAL_ID ||
2158
+ (curtok == SPECIAL_ID && name[0] == '@'))
2160
+ unsigned int size = 0;
2164
/* label alone on the line */
2165
yasm_warn_set(YASM_WARN_ORPHAN_LABEL,
2166
N_("label alone on a line without a colon might be in error"));
2167
- define_label(parser_nasm, name, local);
2168
+ define_label(parser_nasm, name, 0, local);
2174
- if (curtok == EQU) {
2175
+ if (curtok == EQU || (parser_nasm->tasm && curtok == '=')) {
2176
/* label EQU expr */
2180
+ if (parser_nasm->tasm && curtok == SIZE_OVERRIDE) {
2181
+ size = SIZE_OVERRIDE_val;
2185
e = parse_expr(parser_nasm, NORM_EXPR);
2187
yasm_error_set(YASM_ERROR_SYNTAX,
2188
@@ -384,17 +412,30 @@
2192
- define_label(parser_nasm, name, local);
2194
+ if (parser_nasm->tasm && curtok == LABEL)
2197
+ if (parser_nasm->tasm && curtok == SIZE_OVERRIDE) {
2198
+ size = SIZE_OVERRIDE_val;
2203
+ define_label(parser_nasm, name, size, local);
2206
if (curtok == TIMES) {
2207
+ define_label(parser_nasm, name, size, local);
2209
return parse_times(parser_nasm);
2211
bc = parse_exp(parser_nasm);
2213
+ if (!parser_nasm->tasm && !bc)
2214
yasm_error_set(YASM_ERROR_SYNTAX,
2215
N_("instruction expected after label"));
2216
+ if (parser_nasm->tasm && bc && !size)
2217
+ size = yasm_bc_elem_size(bc);
2218
+ define_label(parser_nasm, name, size, local);
2223
unsigned int size = DECLARE_DATA_val/8;
2224
yasm_datavalhead dvs;
2227
+ yasm_expr *e, *e2;
2231
@@ -529,14 +570,68 @@
2235
- if ((e = parse_bexpr(parser_nasm, DV_EXPR)))
2236
- dv = yasm_dv_create_expr(e);
2238
+ if (curtok == '?') {
2239
+ yasm_dvs_delete(&dvs);
2241
+ if (! is_eol_tok(curtok)) {
2242
+ yasm_error_set(YASM_ERROR_SYNTAX,
2243
+ N_("can not handle more than one '?'"));
2246
+ return yasm_bc_create_reserve(
2247
+ p_expr_new_ident(yasm_expr_int(
2248
+ yasm_intnum_create_uint(1))),
2251
+ if (!(e = parse_bexpr(parser_nasm, DV_EXPR))) {
2252
yasm_error_set(YASM_ERROR_SYNTAX,
2253
N_("expression or string expected"));
2254
yasm_dvs_delete(&dvs);
2257
+ if (curtok == DUP) {
2259
+ if (curtok != '(') {
2260
+ yasm_error_set(YASM_ERROR_SYNTAX,
2261
+ N_("expected ( after DUP"));
2265
+ if (curtok == '?') {
2267
+ if (curtok != ')') {
2268
+ yasm_error_set(YASM_ERROR_SYNTAX,
2269
+ N_("expected ) after DUPlicated expression"));
2273
+ if (! is_eol_tok(curtok)) {
2274
+ yasm_error_set(YASM_ERROR_SYNTAX,
2275
+ N_("can not handle more than one '?'"));
2278
+ yasm_dvs_delete(&dvs);
2279
+ return yasm_bc_create_reserve(e, size, cur_line);
2280
+ } else if ((e2 = parse_bexpr(parser_nasm, DV_EXPR))) {
2281
+ if (curtok != ')') {
2282
+ yasm_expr_destroy(e2);
2283
+ yasm_error_set(YASM_ERROR_SYNTAX,
2284
+ N_("expected ) after DUPlicated expression"));
2288
+ dv = yasm_dv_create_expr(e2);
2289
+ yasm_dv_set_multiple(dv, e);
2291
+ yasm_error_set(YASM_ERROR_SYNTAX,
2292
+ N_("expression or string expected"));
2294
+ yasm_expr_destroy(e);
2295
+ yasm_dvs_delete(&dvs);
2299
+ dv = yasm_dv_create_expr(e);
2301
yasm_dvs_append(&dvs, dv);
2303
@@ -699,12 +794,106 @@
2304
N_("memory address expected"));
2308
+ if (parser_nasm->tasm && !is_eol() && curtok != ',') {
2309
+ yasm_expr *e = NULL, *f;
2312
+ switch (op->type) {
2313
+ case YASM_INSN__OPERAND_IMM:
2316
+ case YASM_INSN__OPERAND_MEMORY:
2317
+ if (op->data.ea->disp.rel) {
2318
+ yasm_error_set(YASM_ERROR_SYNTAX,
2319
+ N_("relative adressing not supported\n"));
2322
+ e = yasm_expr_copy(op->data.ea->disp.abs);
2323
+ yasm_arch_ea_destroy(p_object->arch, op->data.ea);
2325
+ case YASM_INSN__OPERAND_REG:
2326
+ case YASM_INSN__OPERAND_SEGREG:
2327
+ yasm_error_set(YASM_ERROR_SYNTAX,
2328
+ N_("register adressing not supported\n"));
2332
+ f = parse_bexpr(parser_nasm, NORM_EXPR);
2334
+ yasm_expr_destroy(e);
2335
+ yasm_error_set(YASM_ERROR_SYNTAX,
2336
+ N_("expected expression after ]"));
2339
+ e = p_expr_new_tree(e, YASM_EXPR_ADD, f);
2340
+ ea = yasm_arch_ea_create(p_object->arch, e);
2341
+ yasm_ea_set_implicit_size_segment(parser_nasm, ea, e);
2342
+ op = yasm_operand_create_mem(ea);
2348
+ yasm_insn_operand *op2;
2350
+ op = parse_operand(parser_nasm);
2352
+ yasm_error_set(YASM_ERROR_SYNTAX,
2353
+ N_("memory address expected"));
2356
+ if (op->type == YASM_INSN__OPERAND_IMM)
2358
+ if (op->type != YASM_INSN__OPERAND_MEMORY) {
2359
+ yasm_error_set(YASM_ERROR_SYNTAX,
2360
+ N_("OFFSET applied to non-memory operand"));
2363
+ if (op->data.ea->disp.rel) {
2364
+ yasm_error_set(YASM_ERROR_SYNTAX,
2365
+ N_("OFFSET applied to non-absolute memory operand"));
2368
+ if (op->data.ea->disp.abs)
2369
+ op2 = yasm_operand_create_imm(op->data.ea->disp.abs);
2371
+ op2 = yasm_operand_create_imm(p_expr_new_ident(
2372
+ yasm_expr_int(yasm_intnum_create_uint(0))));
2377
- op = yasm_operand_create_segreg(SEGREG_val);
2379
+ uintptr_t segreg = SEGREG_val;
2381
+ if (parser_nasm->tasm && curtok == ':') {
2383
+ op = parse_operand(parser_nasm);
2386
+ if (op->type == YASM_INSN__OPERAND_IMM) {
2387
+ yasm_effaddr *ea = yasm_arch_ea_create(p_object->arch,
2389
+ yasm_insn_operand *op2;
2390
+ yasm_ea_set_implicit_size_segment(parser_nasm, ea,
2392
+ op2 = yasm_operand_create_mem(ea);
2393
+ op2->size = op->size;
2397
+ if (op->type != YASM_INSN__OPERAND_MEMORY) {
2398
+ yasm_error_set(YASM_ERROR_SYNTAX,
2399
+ N_("segment applied to non-memory operand"));
2402
+ yasm_ea_set_segreg(op->data.ea, segreg);
2405
+ op = yasm_operand_create_segreg(segreg);
2409
op = yasm_operand_create_reg(REG_val);
2411
@@ -756,13 +945,51 @@
2412
op->targetmod = tmod;
2418
+ if (parser_nasm->tasm) {
2419
+ get_peek_token(parser_nasm);
2420
+ if (parser_nasm->peek_token == '[') {
2421
+ yasm_symrec *sym = yasm_symtab_use(p_symtab, ID_val,
2423
+ yasm_expr *e = p_expr_new_ident(yasm_expr_sym(sym)), *f;
2425
+ yasm_xfree(ID_val);
2428
+ f = parse_bexpr(parser_nasm, NORM_EXPR);
2430
+ yasm_error_set(YASM_ERROR_SYNTAX,
2431
+ N_("expected expression after ["));
2434
+ e = p_expr_new_tree(e, YASM_EXPR_ADD, f);
2435
+ if (!expect(']')) {
2436
+ yasm_error_set(YASM_ERROR_SYNTAX, N_("missing closing bracket"));
2440
+ ea = yasm_arch_ea_create(p_object->arch, e);
2441
+ yasm_ea_set_implicit_size_segment(parser_nasm, ea, e);
2442
+ op = yasm_operand_create_mem(ea);
2449
yasm_expr *e = parse_bexpr(parser_nasm, NORM_EXPR);
2453
- return yasm_operand_create_imm(e);
2454
+ if (parser_nasm->tasm && yasm_expr_size(e)) {
2455
+ yasm_effaddr *ea = yasm_arch_ea_create(p_object->arch, e);
2456
+ yasm_ea_set_implicit_size_segment(parser_nasm, ea, e);
2457
+ op = yasm_operand_create_mem(ea);
2460
+ return yasm_operand_create_imm(e);
2464
@@ -836,10 +1061,12 @@
2465
yasm_expr *e = parse_bexpr(parser_nasm, NORM_EXPR);
2468
- if (curtok != ':')
2469
- return yasm_operand_create_mem(
2470
- yasm_arch_ea_create(p_object->arch, e));
2472
+ if (curtok != ':') {
2473
+ yasm_effaddr *ea = yasm_arch_ea_create(p_object->arch, e);
2474
+ yasm_ea_set_implicit_size_segment(parser_nasm, ea, e);
2475
+ return yasm_operand_create_mem(ea);
2480
off = parse_bexpr(parser_nasm, NORM_EXPR);
2481
@@ -847,8 +1074,9 @@
2482
yasm_expr_destroy(e);
2485
- op = yasm_operand_create_mem(
2486
- yasm_arch_ea_create(p_object->arch, off));
2487
+ ea = yasm_arch_ea_create(p_object->arch, off);
2488
+ yasm_ea_set_implicit_size_segment(parser_nasm, ea, off);
2489
+ op = yasm_operand_create_mem(ea);
2493
@@ -1094,6 +1322,30 @@
2496
return p_expr_new_branch(YASM_EXPR_NOT, e);
2499
+ e = parse_expr6(parser_nasm, type);
2501
+ yasm_error_set(YASM_ERROR_SYNTAX,
2502
+ N_("expected expression after %s"), "LOW");
2505
+ return p_expr_new_tree(e, YASM_EXPR_AND,
2506
+ p_expr_new_ident(yasm_expr_int(yasm_intnum_create_uint(0xff))));
2509
+ e = parse_expr6(parser_nasm, type);
2511
+ yasm_error_set(YASM_ERROR_SYNTAX,
2512
+ N_("expected expression after %s"), "HIGH");
2515
+ return p_expr_new_tree(
2516
+ p_expr_new_tree(e, YASM_EXPR_SHR,
2517
+ p_expr_new_ident(yasm_expr_int(
2518
+ yasm_intnum_create_uint(8)))),
2520
+ p_expr_new_ident(yasm_expr_int(yasm_intnum_create_uint(0xff))));
2523
e = parse_expr6(parser_nasm, type);
2524
@@ -1132,10 +1384,16 @@
2525
e = p_expr_new_ident(yasm_expr_reg(REG_val));
2528
- e = p_expr_new_ident(yasm_expr_int(
2529
- yasm_intnum_create_charconst_nasm(STRING_val.contents)));
2531
+ yasm_intnum *intn;
2532
+ if (parser_nasm->tasm)
2533
+ intn = yasm_intnum_create_charconst_tasm(STRING_val.contents);
2535
+ intn = yasm_intnum_create_charconst_nasm(STRING_val.contents);
2536
+ e = p_expr_new_ident(yasm_expr_int(intn));
2537
yasm_xfree(STRING_val.contents);
2541
sym = yasm_objfmt_get_special_sym(p_object, ID_val+2, "nasm");
2543
@@ -1179,9 +1437,12 @@
2547
-define_label(yasm_parser_nasm *parser_nasm, char *name, int local)
2548
+define_label(yasm_parser_nasm *parser_nasm, char *name, unsigned int size,
2552
+ yasm_symrec *symrec;
2554
+ if ((!parser_nasm->tasm || tasm_locals) && !local) {
2555
if (parser_nasm->locallabel_base)
2556
yasm_xfree(parser_nasm->locallabel_base);
2557
parser_nasm->locallabel_base_len = strlen(name);
2558
@@ -1191,11 +1452,16 @@
2561
if (parser_nasm->abspos)
2562
- yasm_symtab_define_equ(p_symtab, name,
2563
- yasm_expr_copy(parser_nasm->abspos), cur_line);
2564
+ symrec = yasm_symtab_define_equ(p_symtab, name,
2565
+ yasm_expr_copy(parser_nasm->abspos),
2568
- yasm_symtab_define_label(p_symtab, name, parser_nasm->prev_bc, 1,
2570
+ symrec = yasm_symtab_define_label(p_symtab, name, parser_nasm->prev_bc,
2573
+ yasm_symrec_set_size(symrec, size);
2574
+ yasm_symrec_set_segment(symrec, tasm_segment);
2579
Index: modules/parsers/nasm/nasm-parser.c
2580
===================================================================
2581
--- old/modules/parsers/nasm/nasm-parser.c (r�vision 2129)
2582
+++ new/modules/parsers/nasm/nasm-parser.c (r�vision 2137)
2587
-nasm_parser_do_parse(yasm_object *object, yasm_preproc *pp,
2588
- int save_input, yasm_linemap *linemap,
2589
- yasm_errwarns *errwarns)
2590
+nasm_do_parse(yasm_object *object, yasm_preproc *pp, int save_input,
2591
+ yasm_linemap *linemap, yasm_errwarns *errwarns, int tasm)
2593
yasm_parser_nasm parser_nasm;
2595
+ parser_nasm.tasm = tasm;
2597
parser_nasm.object = object;
2598
parser_nasm.linemap = linemap;
2601
yasm_symtab_parser_finalize(object->symtab, 0, errwarns);
2605
+nasm_parser_do_parse(yasm_object *object, yasm_preproc *pp,
2606
+ int save_input, yasm_linemap *linemap,
2607
+ yasm_errwarns *errwarns)
2609
+ nasm_do_parse(object, pp, save_input, linemap, errwarns, 0);
2612
/* Define valid preprocessors to use with this parser */
2613
static const char *nasm_parser_preproc_keywords[] = {
2615
@@ -100,3 +109,29 @@
2616
nasm_parser_stdmacs,
2617
nasm_parser_do_parse
2621
+tasm_parser_do_parse(yasm_object *object, yasm_preproc *pp,
2622
+ int save_input, yasm_linemap *linemap,
2623
+ yasm_errwarns *errwarns)
2625
+ yasm_symtab_set_case_sensitive(object->symtab, 0);
2626
+ yasm_warn_disable(YASM_WARN_IMPLICIT_SIZE_OVERRIDE);
2627
+ nasm_do_parse(object, pp, save_input, linemap, errwarns, 1);
2630
+/* Define valid preprocessors to use with this parser */
2631
+static const char *tasm_parser_preproc_keywords[] = {
2637
+/* Define parser structure -- see parser.h for details */
2638
+yasm_parser_module yasm_tasm_LTX_parser = {
2639
+ "TASM-compatible parser",
2641
+ tasm_parser_preproc_keywords,
2643
+ tasm_parser_do_parse
2645
Index: modules/parsers/nasm/nasm-parser.h
2646
===================================================================
2647
--- old/modules/parsers/nasm/nasm-parser.h (r�vision 2128)
2648
+++ new/modules/parsers/nasm/nasm-parser.h (copie de travail)
2674
#define YYSTYPE yystype
2676
typedef struct yasm_parser_nasm {
2681
/*@only@*/ yasm_object *object;
2682
Index: modules/objfmts/win64/tests/win64-dataref.hex
2683
===================================================================
2684
--- old/modules/objfmts/win64/tests/win64-dataref.hex (r�vision 2128)
2685
+++ new/modules/objfmts/win64/tests/win64-dataref.hex (copie de travail)
2686
@@ -1364,7 +1364,7 @@
2695
@@ -1374,7 +1374,7 @@
2704
@@ -1999,39 +1999,39 @@
2752
Index: modules/objfmts/bin/bin-objfmt.c
2753
===================================================================
2754
--- old/modules/objfmts/bin/bin-objfmt.c (r�vision 2128)
2755
+++ new/modules/objfmts/bin/bin-objfmt.c (copie de travail)
2758
/*@unused@*/ RCSID("$Id$");
2760
+#ifdef HAVE_UNISTD_H
2761
+#include <unistd.h>
2763
#include <libyasm.h>
2766
@@ -1071,7 +1072,8 @@
2767
yasm_errwarn_propagate(info->errwarns, 0);
2770
- if (fseek(info->f, yasm_intnum_get_int(info->tmp_intn), SEEK_SET) < 0)
2771
+ if (fseek(info->f, yasm_intnum_get_int(info->tmp_intn) + info->start,
2773
yasm__fatal(N_("could not seek on output file"));
2774
yasm_section_bcs_traverse(sect, info->errwarns,
2775
info, bin_objfmt_output_bytecode);
2776
@@ -1106,6 +1107,8 @@
2777
yasm_intnum *start, *last, *vdelta;
2778
bin_groups unsorted_groups, bss_groups;
2780
+ info.start = ftell(f);
2782
/* Set ORG to 0 unless otherwise specified */
2783
if (objfmt_bin->org) {
2784
info.origin = yasm_expr_get_intnum(&objfmt_bin->org, 0);
2785
@@ -1802,3 +1806,153 @@
2786
bin_objfmt_section_switch,
2787
bin_objfmt_get_special_sym
2790
+#define EXE_HEADER_SIZE 0x200
2792
+/* DOS .EXE binaries are just raw binaries with a header */
2793
+yasm_objfmt_module yasm_dosexe_LTX_objfmt;
2795
+static yasm_objfmt *
2796
+dosexe_objfmt_create(yasm_object *object)
2798
+ yasm_objfmt_bin *objfmt_bin = (yasm_objfmt_bin *) bin_objfmt_create(object);
2799
+ objfmt_bin->objfmt.module = &yasm_dosexe_LTX_objfmt;
2800
+ return (yasm_objfmt *)objfmt_bin;
2803
+static unsigned long
2804
+get_sym(yasm_object *object, const char *name) {
2805
+ yasm_symrec *symrec = yasm_symtab_get(object->symtab, name);
2806
+ yasm_bytecode *prevbc;
2809
+ if (!yasm_symrec_get_label(symrec, &prevbc))
2811
+ return prevbc->offset + prevbc->len;
2815
+dosexe_objfmt_output(yasm_object *object, FILE *f, /*@unused@*/ int all_syms,
2816
+ yasm_errwarns *errwarns)
2818
+ unsigned long tot_size, size, bss_size;
2819
+ unsigned long start, bss;
2822
+ fseek(f, EXE_HEADER_SIZE, SEEK_SET);
2824
+ bin_objfmt_output(object, f, all_syms, errwarns);
2826
+ tot_size = ftell(f);
2828
+ /* if there is a __bss_start symbol, data after it is 0, no need to write
2830
+ bss = get_sym(object, "__bss_start");
2835
+ bss_size = tot_size - size;
2836
+#ifdef HAVE_FTRUNCATE
2837
+ if (size != tot_size)
2838
+ ftruncate(fileno(f), EXE_HEADER_SIZE + size);
2840
+ fseek(f, 0, SEEK_SET);
2843
+ fwrite("MZ", 1, 2, f);
2847
+ fwrite(&c, 1, 1, f);
2848
+ c = !!(size & 0x100);
2849
+ fwrite(&c, 1, 1, f);
2850
+ c = ((size + 511) >> 9) & 0xff;
2851
+ fwrite(&c, 1, 1, f);
2852
+ c = ((size + 511) >> 17) & 0xff;
2853
+ fwrite(&c, 1, 1, f);
2855
+ /* relocation # */
2857
+ fwrite(&c, 1, 1, f);
2858
+ fwrite(&c, 1, 1, f);
2861
+ c = EXE_HEADER_SIZE / 16;
2862
+ fwrite(&c, 1, 1, f);
2864
+ fwrite(&c, 1, 1, f);
2866
+ /* minimum paragraph # */
2867
+ bss_size = (bss_size + 15) >> 4;
2868
+ c = bss_size & 0xff;
2869
+ fwrite(&c, 1, 1, f);
2870
+ c = (bss_size >> 8) & 0xff;
2871
+ fwrite(&c, 1, 1, f);
2873
+ /* maximum paragraph # */
2875
+ fwrite(&c, 1, 1, f);
2876
+ fwrite(&c, 1, 1, f);
2878
+ /* relative value of stack segment */
2880
+ fwrite(&c, 1, 1, f);
2881
+ fwrite(&c, 1, 1, f);
2885
+ fwrite(&c, 1, 1, f);
2886
+ fwrite(&c, 1, 1, f);
2888
+ /* header checksum */
2890
+ fwrite(&c, 1, 1, f);
2891
+ fwrite(&c, 1, 1, f);
2894
+ start = get_sym(object, "start");
2896
+ yasm_error_set(YASM_ERROR_GENERAL,
2897
+ N_("%s: could not find symbol `start'"));
2901
+ fwrite(&c, 1, 1, f);
2902
+ c = (start >> 8) & 0xff;
2903
+ fwrite(&c, 1, 1, f);
2907
+ fwrite(&c, 1, 1, f);
2908
+ fwrite(&c, 1, 1, f);
2912
+ fwrite(&c, 1, 1, f);
2914
+ fwrite(&c, 1, 1, f);
2916
+ /* Overlay number */
2918
+ fwrite(&c, 1, 1, f);
2919
+ fwrite(&c, 1, 1, f);
2923
+/* Define objfmt structure -- see objfmt.h for details */
2924
+yasm_objfmt_module yasm_dosexe_LTX_objfmt = {
2925
+ "DOS .EXE format binary",
2929
+ bin_objfmt_dbgfmt_keywords,
2931
+ bin_objfmt_directives,
2932
+ dosexe_objfmt_create,
2933
+ dosexe_objfmt_output,
2934
+ bin_objfmt_destroy,
2935
+ bin_objfmt_add_default_section,
2936
+ bin_objfmt_section_switch,
2937
+ bin_objfmt_get_special_sym
2939
Index: modules/objfmts/coff/coff-objfmt.c
2940
===================================================================
2941
--- old/modules/objfmts/coff/coff-objfmt.c (r�vision 2128)
2942
+++ new/modules/objfmts/coff/coff-objfmt.c (copie de travail)
2944
win32_sxdata_bc_destroy,
2945
win32_sxdata_bc_print,
2946
yasm_bc_finalize_common,
2948
win32_sxdata_bc_calc_len,
2949
yasm_bc_expand_common,
2950
win32_sxdata_bc_tobytes,
2951
Index: modules/objfmts/coff/win64-except.c
2952
===================================================================
2953
--- old/modules/objfmts/coff/win64-except.c (r�vision 2128)
2954
+++ new/modules/objfmts/coff/win64-except.c (copie de travail)
2956
win64_uwinfo_bc_destroy,
2957
win64_uwinfo_bc_print,
2958
win64_uwinfo_bc_finalize,
2960
win64_uwinfo_bc_calc_len,
2961
win64_uwinfo_bc_expand,
2962
win64_uwinfo_bc_tobytes,
2964
win64_uwcode_bc_destroy,
2965
win64_uwcode_bc_print,
2966
win64_uwcode_bc_finalize,
2968
win64_uwcode_bc_calc_len,
2969
win64_uwcode_bc_expand,
2970
win64_uwcode_bc_tobytes,
2971
Index: modules/dbgfmts/codeview/cv-symline.c
2972
===================================================================
2973
--- old/modules/dbgfmts/codeview/cv-symline.c (r�vision 2128)
2974
+++ new/modules/dbgfmts/codeview/cv-symline.c (copie de travail)
2976
cv8_symhead_bc_destroy,
2977
cv8_symhead_bc_print,
2978
yasm_bc_finalize_common,
2980
cv8_symhead_bc_calc_len,
2981
yasm_bc_expand_common,
2982
cv8_symhead_bc_tobytes,
2984
cv8_fileinfo_bc_destroy,
2985
cv8_fileinfo_bc_print,
2986
yasm_bc_finalize_common,
2988
cv8_fileinfo_bc_calc_len,
2989
yasm_bc_expand_common,
2990
cv8_fileinfo_bc_tobytes,
2992
cv8_lineinfo_bc_destroy,
2993
cv8_lineinfo_bc_print,
2994
yasm_bc_finalize_common,
2996
cv8_lineinfo_bc_calc_len,
2997
yasm_bc_expand_common,
2998
cv8_lineinfo_bc_tobytes,
3002
yasm_bc_finalize_common,
3005
yasm_bc_expand_common,
3007
Index: modules/dbgfmts/codeview/cv-type.c
3008
===================================================================
3009
--- old/modules/dbgfmts/codeview/cv-type.c (r�vision 2128)
3010
+++ new/modules/dbgfmts/codeview/cv-type.c (copie de travail)
3014
yasm_bc_finalize_common,
3016
cv_type_bc_calc_len,
3017
yasm_bc_expand_common,
3019
Index: modules/dbgfmts/dwarf2/dwarf2-info.c
3020
===================================================================
3021
--- old/modules/dbgfmts/dwarf2/dwarf2-info.c (r�vision 2128)
3022
+++ new/modules/dbgfmts/dwarf2/dwarf2-info.c (copie de travail)
3024
dwarf2_abbrev_bc_destroy,
3025
dwarf2_abbrev_bc_print,
3026
yasm_bc_finalize_common,
3028
dwarf2_abbrev_bc_calc_len,
3029
yasm_bc_expand_common,
3030
dwarf2_abbrev_bc_tobytes,
3031
Index: modules/dbgfmts/dwarf2/dwarf2-dbgfmt.c
3032
===================================================================
3033
--- old/modules/dbgfmts/dwarf2/dwarf2-dbgfmt.c (r�vision 2128)
3034
+++ new/modules/dbgfmts/dwarf2/dwarf2-dbgfmt.c (copie de travail)
3036
dwarf2_head_bc_destroy,
3037
dwarf2_head_bc_print,
3038
yasm_bc_finalize_common,
3040
dwarf2_head_bc_calc_len,
3041
yasm_bc_expand_common,
3042
dwarf2_head_bc_tobytes,
3043
Index: modules/dbgfmts/dwarf2/dwarf2-line.c
3044
===================================================================
3045
--- old/modules/dbgfmts/dwarf2/dwarf2-line.c (r�vision 2128)
3046
+++ new/modules/dbgfmts/dwarf2/dwarf2-line.c (copie de travail)
3048
dwarf2_spp_bc_destroy,
3049
dwarf2_spp_bc_print,
3050
yasm_bc_finalize_common,
3052
dwarf2_spp_bc_calc_len,
3053
yasm_bc_expand_common,
3054
dwarf2_spp_bc_tobytes,
3056
dwarf2_line_op_bc_destroy,
3057
dwarf2_line_op_bc_print,
3058
yasm_bc_finalize_common,
3060
dwarf2_line_op_bc_calc_len,
3061
yasm_bc_expand_common,
3062
dwarf2_line_op_bc_tobytes,
3063
Index: modules/dbgfmts/stabs/stabs-dbgfmt.c
3064
===================================================================
3065
--- old/modules/dbgfmts/stabs/stabs-dbgfmt.c (r�vision 2128)
3066
+++ new/modules/dbgfmts/stabs/stabs-dbgfmt.c (copie de travail)
3068
stabs_bc_str_destroy,
3070
yasm_bc_finalize_common,
3072
stabs_bc_str_calc_len,
3073
yasm_bc_expand_common,
3074
stabs_bc_str_tobytes,
3076
stabs_bc_stab_destroy,
3077
stabs_bc_stab_print,
3078
yasm_bc_finalize_common,
3080
stabs_bc_stab_calc_len,
3081
yasm_bc_expand_common,
3082
stabs_bc_stab_tobytes,
3083
Index: modules/arch/lc3b/lc3bid.re
3084
===================================================================
3085
--- old/modules/arch/lc3b/lc3bid.re (r�vision 2128)
3086
+++ new/modules/arch/lc3b/lc3bid.re (copie de travail)
3088
lc3b_id_insn_destroy,
3090
lc3b_id_insn_finalize,
3092
yasm_bc_calc_len_common,
3093
yasm_bc_expand_common,
3094
yasm_bc_tobytes_common,
3095
Index: modules/arch/lc3b/lc3bbc.c
3096
===================================================================
3097
--- old/modules/arch/lc3b/lc3bbc.c (r�vision 2128)
3098
+++ new/modules/arch/lc3b/lc3bbc.c (copie de travail)
3100
lc3b_bc_insn_destroy,
3102
yasm_bc_finalize_common,
3104
lc3b_bc_insn_calc_len,
3105
lc3b_bc_insn_expand,
3106
lc3b_bc_insn_tobytes,
3107
Index: modules/arch/x86/tests/lds-err.errwarn
3108
===================================================================
3109
--- old/modules/arch/x86/tests/lds-err.errwarn (r�vision 2129)
3110
+++ new/modules/arch/x86/tests/lds-err.errwarn (r�vision 2137)
3112
--:2: error: invalid size for operand 2
3113
--:3: error: invalid size for operand 2
3114
--:5: error: invalid size for operand 2
3115
--:6: error: invalid size for operand 2
3116
Index: modules/arch/x86/tests/lds-err.asm
3117
===================================================================
3118
--- old/modules/arch/x86/tests/lds-err.asm (r�vision 2129)
3119
+++ new/modules/arch/x86/tests/lds-err.asm (r�vision 2137)
3127
Index: modules/arch/x86/tests/lds.asm
3128
===================================================================
3129
--- old/modules/arch/x86/tests/lds.asm (r�vision 0)
3130
+++ new/modules/arch/x86/tests/lds.asm (r�vision 2137)
3138
Index: modules/arch/x86/tests/lds.hex
3139
===================================================================
3140
--- old/modules/arch/x86/tests/lds.hex (r�vision 0)
3141
+++ new/modules/arch/x86/tests/lds.hex (r�vision 2137)
3170
Index: modules/arch/x86/x86id.c
3171
===================================================================
3172
--- old/modules/arch/x86/x86id.c (r�vision 2128)
3173
+++ new/modules/arch/x86/x86id.c (copie de travail)
3175
x86_id_insn_destroy,
3177
x86_id_insn_finalize,
3179
yasm_bc_calc_len_common,
3180
yasm_bc_expand_common,
3181
yasm_bc_tobytes_common,
3182
@@ -1733,6 +1734,9 @@
3183
case X86_PARSER_NASM:
3184
pdata = insnprefix_nasm_find(lcaseid, id_len);
3186
+ case X86_PARSER_TASM:
3187
+ pdata = insnprefix_nasm_find(lcaseid, id_len);
3189
case X86_PARSER_GAS:
3190
pdata = insnprefix_gas_find(lcaseid, id_len);
3192
Index: modules/arch/x86/x86arch.c
3193
===================================================================
3194
--- old/modules/arch/x86/x86arch.c (r�vision 2128)
3195
+++ new/modules/arch/x86/x86arch.c (copie de travail)
3198
if (yasm__strcasecmp(parser, "nasm") == 0)
3199
arch_x86->parser = X86_PARSER_NASM;
3200
+ else if (yasm__strcasecmp(parser, "tasm") == 0)
3201
+ arch_x86->parser = X86_PARSER_TASM;
3202
else if (yasm__strcasecmp(parser, "gas") == 0
3203
|| yasm__strcasecmp(parser, "gnu") == 0)
3204
arch_x86->parser = X86_PARSER_GAS;
3205
Index: modules/arch/x86/x86expr.c
3206
===================================================================
3207
--- old/modules/arch/x86/x86expr.c (r�vision 2128)
3208
+++ new/modules/arch/x86/x86expr.c (copie de travail)
3210
* EA. With no registers, we must have a 16/32 value.
3213
- yasm_warn_set(YASM_WARN_GENERAL,
3214
+ yasm_warn_set(YASM_WARN_IMPLICIT_SIZE_OVERRIDE,
3215
N_("invalid displacement size; fixed"));
3216
x86_ea->ea.disp.size = wordsize;
3218
Index: modules/arch/x86/x86arch.h
3219
===================================================================
3220
--- old/modules/arch/x86/x86arch.h (r�vision 2128)
3221
+++ new/modules/arch/x86/x86arch.h (copie de travail)
3223
unsigned int amd64_machine;
3225
X86_PARSER_NASM = 0,
3226
- X86_PARSER_GAS = 1
3227
+ X86_PARSER_TASM = 1,
3228
+ X86_PARSER_GAS = 2
3230
unsigned int mode_bits;
3231
unsigned int force_strict;
3232
Index: modules/arch/x86/x86bc.c
3233
===================================================================
3234
--- old/modules/arch/x86/x86bc.c (r�vision 2128)
3235
+++ new/modules/arch/x86/x86bc.c (copie de travail)
3237
x86_bc_insn_destroy,
3239
yasm_bc_finalize_common,
3241
x86_bc_insn_calc_len,
3243
x86_bc_insn_tobytes,
3247
yasm_bc_finalize_common,
3249
x86_bc_jmp_calc_len,
3253
x86_bc_jmpfar_destroy,
3254
x86_bc_jmpfar_print,
3255
yasm_bc_finalize_common,
3257
x86_bc_jmpfar_calc_len,
3258
yasm_bc_expand_common,
3259
x86_bc_jmpfar_tobytes,
3261
x86_ea->ea.segreg = 0;
3262
x86_ea->ea.pc_rel = 0;
3263
x86_ea->ea.not_pc_rel = 0;
3264
+ x86_ea->ea.data_len = 0;
3266
x86_ea->valid_modrm = 0;
3267
x86_ea->need_modrm = 0;
3270
x86_ea->need_sib = 0xff;
3272
+ x86_ea->ea.data_len = 0;
3274
return (yasm_effaddr *)x86_ea;
3277
Index: modules/arch/x86/gen_x86_insn.py
3278
===================================================================
3279
--- old/modules/arch/x86/gen_x86_insn.py (r�vision 2128)
3280
+++ new/modules/arch/x86/gen_x86_insn.py (copie de travail)
3282
modifiers=["SpAdd", "Op0Add", "Op1Add"],
3283
opcode=[0x00, 0x00],
3285
- operands=[Operand(type="Mem", dest="EA")])
3286
+ operands=[Operand(type="Mem", relaxed=True, dest="EA")])
3290
@@ -1666,7 +1666,7 @@
3293
operands=[Operand(type="Reg", size=sz, dest="Spare"),
3294
- Operand(type="Mem", size=sz, relaxed=True, dest="EA")])
3295
+ Operand(type="Mem", relaxed=True, dest="EA")])
3297
add_insn("lea", "lea")
3299
@@ -1681,7 +1681,7 @@
3302
operands=[Operand(type="Reg", size=sz, dest="Spare"),
3303
- Operand(type="Mem", dest="EA")])
3304
+ Operand(type="Mem", relaxed=True, dest="EA")])
3306
add_insn("lds", "ldes", modifiers=[0xC5])
3307
add_insn("les", "ldes", modifiers=[0xC4])
3308
@@ -1694,7 +1694,7 @@
3310
opcode=[0x0F, 0x00],
3311
operands=[Operand(type="Reg", size=sz, dest="Spare"),
3312
- Operand(type="Mem", dest="EA")])
3313
+ Operand(type="Mem", relaxed=True, dest="EA")])
3315
add_insn("lfs", "lfgss", modifiers=[0xB4])
3316
add_insn("lgs", "lfgss", modifiers=[0xB5])
3317
Index: modules/preprocs/nasm/nasm.h
3318
===================================================================
3319
--- old/modules/preprocs/nasm/nasm.h (r�vision 2128)
3320
+++ new/modules/preprocs/nasm/nasm.h (copie de travail)
3322
#define elements(x) ( sizeof(x) / sizeof(*(x)) )
3324
extern int tasm_compatible_mode;
3325
+extern int tasm_locals;
3326
+extern const char *tasm_segment;
3327
+const char *tasm_get_segment_register(const char *segment);
3330
Index: modules/preprocs/nasm/nasm-preproc.c
3331
===================================================================
3332
--- old/modules/preprocs/nasm/nasm-preproc.c (r�vision 2128)
3333
+++ new/modules/preprocs/nasm/nasm-preproc.c (copie de travail)
3335
static yasm_linemap *cur_lm;
3336
static yasm_errwarns *cur_errwarns;
3337
int tasm_compatible_mode = 0;
3339
+const char *tasm_segment;
3341
#include "nasm-version.c"
3343
@@ -314,3 +316,24 @@
3344
nasm_preproc_define_builtin,
3345
nasm_preproc_add_standard
3348
+static yasm_preproc *
3349
+tasm_preproc_create(const char *in_filename, yasm_symtab *symtab,
3350
+ yasm_linemap *lm, yasm_errwarns *errwarns)
3352
+ tasm_compatible_mode = 1;
3353
+ return nasm_preproc_create(in_filename, symtab, lm, errwarns);
3356
+yasm_preproc_module yasm_tasm_LTX_preproc = {
3357
+ "Real TASM Preprocessor",
3359
+ tasm_preproc_create,
3360
+ nasm_preproc_destroy,
3361
+ nasm_preproc_get_line,
3362
+ nasm_preproc_get_included_file,
3363
+ nasm_preproc_add_include_file,
3364
+ nasm_preproc_predefine_macro,
3365
+ nasm_preproc_undefine_macro,
3366
+ nasm_preproc_define_builtin,
3369
Modification de propri�t�s sur modules/preprocs/nasm/nasmlib.h
3370
___________________________________________________________________
3371
Ajout� : svn:mergeinfo
3373
Index: modules/preprocs/nasm/nasm-pp.c
3374
===================================================================
3375
--- old/modules/preprocs/nasm/nasm-pp.c (r�vision 2128)
3376
+++ new/modules/preprocs/nasm/nasm-pp.c (copie de travail)
3380
TM_ARG, TM_ELIF, TM_ELSE, TM_ENDIF, TM_IF, TM_IFDEF, TM_IFDIFI,
3381
- TM_IFNDEF, TM_INCLUDE, TM_LOCAL
3382
+ TM_IFNDEF, TM_INCLUDE, TM_LOCAL,
3383
+ TM_REPT, TM_IRP, TM_MACRO,
3384
+ TM_STRUC, TM_SEGMENT
3387
static const char *tasm_directives[] = {
3389
static Token *new_Token(Token * next, int type, const char *text,
3391
static Token *delete_Token(Token * t);
3392
+static Token *tokenise(char *line);
3395
* Macros for safe checking of token pointers, avoid *(NULL)
3396
@@ -442,69 +488,555 @@
3397
* place to do it for the moment, and it is a hack (ideally it would
3398
* be nice to be able to use the NASM pre-processor to do it).
3401
+typedef struct TMEndItem {
3404
+ struct TMEndItem *next;
3407
+static TMEndItem *EndmStack = NULL, *EndsStack = NULL;
3409
+char **TMParameters;
3411
+struct TStrucField {
3414
+ struct TStrucField *next;
3418
+ struct TStrucField *fields, *lastField;
3419
+ struct TStruc *next;
3421
+static struct TStruc *TStrucs = NULL;
3422
+static int inTstruc = 0;
3424
+struct TSegmentAssume {
3428
+struct TSegmentAssume *TAssumes;
3430
+const char *tasm_get_segment_register(const char *segment)
3432
+ struct TSegmentAssume *assume;
3435
+ for (assume = TAssumes; assume->segreg; assume++) {
3436
+ if (!strcmp(assume->segment, segment))
3439
+ return assume->segreg;
3443
check_tasm_directive(char *line)
3447
- char *p = line, *oldline, oldchar;
3449
+ char *p, *oldline, oldchar, *q, oldchar2;
3452
+ if ((p = strchr(line, ';')))
3457
/* Skip whitespace */
3458
while (isspace(*p) && *p != 0)
3461
+ /* Ignore nasm directives */
3465
/* Binary search for the directive name */
3467
- j = elements(tasm_directives);
3469
while (!isspace(p[len]) && p[len] != 0)
3478
+ j = elements(tasm_directives);
3485
+ m = nasm_stricmp(p, tasm_directives[k]);
3489
- m = nasm_stricmp(p, tasm_directives[k]);
3491
+ /* We have found a directive, so jam a % in front of it
3492
+ * so that NASM will then recognise it as one if it's own.
3497
+ if (k == TM_IFDIFI)
3499
- /* We have found a directive, so jam a % in front of it
3500
- * so that NASM will then recognise it as one if it's own.
3501
+ /* NASM does not recognise IFDIFI, so we convert it to
3502
+ * %ifdef BOGUS. This is not used in NASM comaptible
3503
+ * code, but does need to parse for the TASM macro
3507
+ line = nasm_malloc(13);
3508
+ strcpy(line, "%ifdef BOGUS");
3510
+ else if (k == TM_INCLUDE)
3512
+ /* add double quotes around file name */
3514
+ while (isspace(*p) && *p)
3518
+ line = nasm_malloc(1 + 7 + 1 + 1 + len + 1 + 1);
3519
+ sprintf(line, "%%include \"%s\"", p);
3523
line = nasm_malloc(len + 2);
3525
- if (k == TM_IFDIFI)
3527
- /* NASM does not recognise IFDIFI, so we convert it to
3528
- * %ifdef BOGUS. This is not used in NASM comaptible
3529
- * code, but does need to parse for the TASM macro
3532
- strcpy(line + 1, "ifdef BOGUS");
3533
+ memcpy(line + 1, p, len + 1);
3535
+ nasm_free(oldline);
3546
+ /* Not a simple directive */
3548
+ if (!nasm_stricmp(p, "endm")) {
3549
+ /* handle end of endm directive */
3552
+ /* undef parameters */
3554
+ error(ERR_FATAL, "ENDM: not in an endm context");
3557
+ EndmStack = EndmStack->next;
3559
+ switch (end->type) {
3562
+ for (parameter = end->data; *parameter; parameter++)
3563
+ len += 6 + 1 + strlen(*parameter) + 1;
3565
+ line = nasm_malloc(len);
3567
+ for (parameter = end->data; *parameter; parameter++) {
3568
+ p += sprintf(p, "%%undef %s\n", *parameter);
3569
+ nasm_free(*parameter);
3571
+ nasm_free(end->data);
3573
+ sprintf(p, "%%endm");
3577
+ return nasm_strdup("%endrep");
3580
+ const char *irp_format =
3588
+ line = nasm_malloc(strlen(irp_format) - 4 + strlen(data[0])
3589
+ + strlen(data[1]));
3590
+ sprintf(line, irp_format, data[0], data[1]);
3591
+ nasm_free(data[0]);
3592
+ nasm_free(data[1]);
3597
+ error(ERR_FATAL, "ENDM: bogus endm context type %d\n",end->type);
3600
+ } else if (!nasm_stricmp(p, "end")) {
3602
+ return strdup("");
3603
+ } else if (!nasm_stricmp(p, "rept")) {
3604
+ /* handle repeat directive */
3605
+ end = nasm_malloc(sizeof(*end));
3606
+ end->type = TM_REPT;
3607
+ end->next = EndmStack;
3609
+ memcpy(p, "%rep", 4);
3612
+ } else if (!nasm_stricmp(p, "locals")) {
3615
+ return strdup("");
3621
+ /* handle two-words directives */
3623
+ /* Skip whitespaces */
3624
+ while (isspace(*q) && *q)
3628
+ while (!isspace(q[len2]) && q[len2]!=',' && q[len2] != 0)
3630
+ oldchar2 = q[len2];
3633
+ if (!nasm_stricmp(p, "irp")) {
3634
+ /* handle indefinite repeat directive */
3635
+ const char *irp_format =
3636
+ "%%imacro irp 0-*\n"
3638
+ "%%define %s %%1\n";
3641
+ data = malloc(2*sizeof(char*));
3643
+ line = nasm_malloc(strlen(irp_format) - 2 + len2 + 1);
3644
+ sprintf(line,irp_format,q);
3645
+ data[0] = nasm_strdup(q);
3648
+ error(ERR_FATAL, "%s: expected <values>", q + len2);
3649
+ p = strchr(q + len2 + 1, '<');
3651
+ error(ERR_FATAL, "%s: expected <values>", q + len2);
3653
+ q = strchr(p, '>');
3654
+ data[1] = nasm_strndup(p, q - p);
3656
+ end = nasm_malloc(sizeof(*end));
3657
+ end->type = TM_IRP;
3658
+ end->next = EndmStack;
3662
+ nasm_free(oldline);
3664
+ } else if (!nasm_stricmp(q, "macro")) {
3666
+ /* handle MACRO */
3667
+ /* count parameters */
3670
+ TMParameters = nasm_malloc(j*sizeof(*TMParameters));
3673
+ /* Skip whitespaces */
3674
+ while (isspace(*p) && *p)
3677
+ /* Get parameter name */
3678
+ for (q = p; !isspace(*q) && *q != ',' && *q; q++);
3681
+ error(ERR_FATAL, "'%s': expected parameter name", p);
3682
+ TMParameters[i] = nasm_malloc(len2 + 1);
3683
+ memcpy(TMParameters[i], p, len2);
3684
+ TMParameters[i][len2] = '\0';
3689
+ TMParameters = nasm_realloc(TMParameters,
3690
+ j*sizeof(*TMParameters));
3693
+ error(ERR_FATAL, "too many parameters for macro %s", name);
3695
+ while (isspace(*p) && *p)
3700
+ error(ERR_FATAL, "expected comma");
3702
+ while (isspace(*p) && *p)
3705
+ TMParameters[i] = NULL;
3706
+ TMParameters = nasm_realloc(TMParameters,
3707
+ (i+1)*sizeof(*TMParameters));
3708
+ len += 1 + 6 + 1 + strlen(name) + 1 + 3; /* macro definition */
3709
+ len += i * (1 + 9 + 1 + 1 + 1 + 3 + 2); /* macro parameter definition */
3711
+ p = line = nasm_malloc(len + 1);
3712
+ p += sprintf(p, "%%imacro %s 0-*", name);
3713
+ nasm_free(oldline);
3714
+ for (j = 0; TMParameters[j]; j++) {
3715
+ p += sprintf(p, "\n%%idefine %s %%{%-u}", TMParameters[j], j + 1);
3717
+ end = nasm_malloc(sizeof(*end));
3718
+ end->type = TM_MACRO;
3719
+ end->next = EndmStack;
3720
+ end->data = TMParameters;
3723
+ } else if (!nasm_stricmp(q, "proc")) {
3726
+ line = nasm_malloc(2 + len + 1);
3727
+ sprintf(line, "..%s",p);
3728
+ nasm_free(oldline);
3730
+ } else if (!nasm_stricmp(q, "struc")) {
3731
+ /* handle struc */
3732
+ struct TStruc *struc;
3734
+ error(ERR_FATAL, "STRUC: already in a struc context");
3738
+ line = nasm_malloc(5 + 1 + len + 1);
3739
+ sprintf(line, "struc %s", p);
3740
+ struc = malloc(sizeof(*struc));
3741
+ struc->name = strdup(p);
3742
+ struc->fields = NULL;
3743
+ struc->lastField = NULL;
3744
+ struc->next = TStrucs;
3747
+ nasm_free(oldline);
3748
+ end = nasm_malloc(sizeof(*end));
3749
+ end->type = TM_STRUC;
3750
+ end->next = EndsStack;
3753
+ } else if (!nasm_stricmp(q, "segment")) {
3754
+ /* handle SEGMENT */
3756
+ line = strdup(oldchar2?q+len2+1:"");
3757
+ if (tasm_segment) {
3758
+ error(ERR_FATAL, "SEGMENT: already in a segment context");
3761
+ tasm_segment = strdup(p);
3762
+ nasm_free(oldline);
3763
+ end = nasm_malloc(sizeof(*end));
3764
+ end->type = TM_SEGMENT;
3765
+ end->next = EndsStack;
3768
+ } else if (!nasm_stricmp(p, "ends") || !nasm_stricmp(q, "ends")) {
3769
+ /* handle end of ends directive */
3771
+ /* undef parameters */
3773
+ error(ERR_FATAL, "ENDS: not in an ends context");
3776
+ EndsStack = EndsStack->next;
3778
+ switch (end->type) {
3781
+ return strdup("endstruc");
3783
+ /* XXX: yes, we leak memory here, but that permits labels
3784
+ * to avoid strduping... */
3785
+ tasm_segment = NULL;
3786
+ return strdup("");
3788
+ error(ERR_FATAL, "ENDS: bogus ends context type %d",end->type);
3791
+ } else if (!nasm_stricmp(p, "endp") || !nasm_stricmp(q, "endp")) {
3793
+ return strdup("");
3794
+ } else if (!nasm_stricmp(p, "assume")) {
3795
+ struct TSegmentAssume *assume;
3796
+ /* handle ASSUME */
3798
+ TAssumes = nasm_malloc(sizeof(*TAssumes));
3799
+ TAssumes[0].segreg = NULL;
3802
+ q[len2] = oldchar2;
3803
+ /* Skip whitespaces */
3804
+ while (isspace(*q) && *q)
3808
+ for (; *q && *q != ':' && !isspace(*q); q++);
3811
+ /* segment register name */
3812
+ for (assume = TAssumes; assume->segreg; assume++)
3813
+ if (strlen(assume->segreg) == (size_t)(q-p) &&
3814
+ !strncasecmp(assume->segreg, p, q-p))
3816
+ if (!assume->segreg) {
3817
+ i = assume - TAssumes + 1;
3818
+ TAssumes = nasm_realloc(TAssumes, (i+1)*sizeof(*TAssumes));
3819
+ assume = TAssumes + i - 1;
3820
+ assume->segreg = nasm_strndup(p, q-p);
3821
+ assume[1].segreg = NULL;
3823
+ for (; *q && *q != ':' && isspace(*q); q++);
3825
+ error(ERR_FATAL, "expected `:' instead of `%c'", *q);
3826
+ for (q++; *q && isspace(*q); q++);
3828
+ /* segment name */
3830
+ for (; *q && *q != ',' && !isspace(*q); q++);
3831
+ assume->segment = nasm_strndup(p, q-p);
3832
+ for (; *q && isspace(*q); q++);
3833
+ if (*q && *q != ',')
3834
+ error(ERR_FATAL, "expected `,' instead of `%c'", *q);
3836
+ for (q++; *q && isspace(*q); q++);
3838
+ TAssumes[i].segreg = NULL;
3839
+ TAssumes = nasm_realloc(TAssumes, (i+1)*sizeof(*TAssumes));
3841
+ return strdup("");
3842
+ } else if (inTstruc) {
3843
+ struct TStrucField *field;
3844
+ /* TODO: handle unnamed data */
3845
+ field = nasm_malloc(sizeof(*field));
3846
+ field->name = strdup(p);
3847
+ /* TODO: type struc ! */
3848
+ field->type = strdup(q);
3849
+ field->next = NULL;
3850
+ if (!TStrucs->fields)
3851
+ TStrucs->fields = field;
3852
+ else if (TStrucs->lastField)
3853
+ TStrucs->lastField->next = field;
3854
+ TStrucs->lastField = field;
3856
+ error(ERR_FATAL, "Expected struc field initializer after %s %s", p, q);
3860
+ line = nasm_malloc(1 + len + 1 + len2 + 1 + strlen(q+len2+1) + 1);
3861
+ sprintf(line, ".%s %s %s", p, q, q+len2+1);
3862
+ nasm_free(oldline);
3866
+ struct TStruc *struc;
3867
+ for (struc = TStrucs; struc; struc = struc->next) {
3868
+ if (!strcasecmp(q, struc->name)) {
3869
+ char *r = q + len2 + 1, *s, *t, tasm_param[6];
3870
+ struct TStrucField *field = struc->fields;
3873
+ error(ERR_FATAL, "Expected struc field initializer after %s %s", p, q);
3878
- memcpy(line + 1, p, len + 1);
3879
+ r = strchr(r, '<');
3881
+ error(ERR_FATAL, "Expected < for struc field initializer in %s %s %s", p, q, r);
3884
+ t = strchr(r + 1, '>');
3886
+ error(ERR_FATAL, "Expected > for struc field initializer in %s %s %s", p, q, r);
3891
+ size = len + len2 + 128;
3892
+ line = nasm_malloc(size);
3894
+ for (n=0;TMParameters[n];n++)
3895
+ if (!strcmp(TMParameters[n],p)) {
3896
+ sprintf(tasm_param,"%%{%d}",n+1);
3900
+ n = sprintf(line, "%s: istruc %s\n", p, q);
3901
+ /* use initialisers */
3902
+ while ((s = strchr(r + 1, ','))) {
3904
+ error(ERR_FATAL, "Too many initializers in structure %s %s", p, q);
3909
+ m = snprintf(line + n, size - n, "%s.%s: at .%s, %s %s\n", p, field->name, field->name, field->type, r + 1);
3910
+ if (m + 1 <= size - n)
3913
+ line = nasm_realloc(line, size);
3917
+ field = field->next;
3919
+ /* complete with last initializer and '?' */
3922
+ m = snprintf(line + n, size - n, "%s.%s: at .%s, %s %s\n", p, field->name, field->name, field->type, r ? r + 1: "?");
3923
+ if (m + 1 <= size - n)
3926
+ line = nasm_realloc(line, size);
3930
+ field = field->next;
3932
+ line = nasm_realloc(line, n + 5);
3933
+ sprintf(line + n, "iend");
3947
+ q[len2] = oldchar2;
3953
+static Token * tasm_join_tokens(Token *tline)
3955
+ Token *t, *prev, *next;
3956
+ for (prev = NULL, t = tline; t; prev = t, t = next) {
3958
+ if (t->type == TOK_OTHER && !strcmp(t->text,"&")) {
3960
+ error(ERR_FATAL, "no token before &");
3962
+ error(ERR_FATAL, "no token after &");
3963
+ else if (prev->type != next->type)
3964
+ error(ERR_FATAL, "can't handle different types of token around &");
3965
+ else if (!prev->text || !next->text)
3966
+ error(ERR_FATAL, "can't handle empty token around &");
3968
+ int lenp = strlen(prev->text);
3969
+ int lenn = strlen(next->text);
3970
+ prev->text = nasm_realloc(prev->text, lenp + lenn + 1);
3971
+ strncpy(prev->text + lenp, next->text, lenn + 1);
3972
+ (void) delete_Token(t);
3973
+ prev->next = delete_Token(next);
3983
* The pre-preprocessing stage... This function translates line
3984
* number indications as they emerge from GNU cpp (`# lineno "file"
3985
@@ -517,6 +1049,8 @@
3988
char *fname, *oldline;
3989
+ char *c, *d, *ret;
3992
if (line[0] == '#' && line[1] == ' ')
3994
@@ -532,8 +1066,30 @@
3997
if (tasm_compatible_mode)
3998
- return check_tasm_directive(line);
4000
+ line = check_tasm_directive(line);
4002
+ if (!(c = strchr(line, '\n')))
4005
+ /* Turn multiline macros into several lines */
4007
+ ret = nasm_strdup(line);
4009
+ lp = &istk->expansion;
4011
+ d = strchr(c+1, '\n');
4014
+ l = malloc(sizeof(*l));
4015
+ l -> first = tokenise(c+1);
4016
+ l -> finishes = NULL;
4027
@@ -1231,7 +1787,7 @@
4028
inc_fopen(char *file, char **newname)
4031
- char *combine = NULL;
4032
+ char *combine = NULL, *c;
4033
char *pb, *p1, *p2, *file2 = NULL;
4035
/* Try to expand all %ENVVAR% in filename. Warn, and leave %string%
4036
@@ -1281,6 +1837,27 @@
4038
fp = yasm_fopen_include(file2 ? file2 : file, nasm_src_get_fname(), "r",
4040
+ if (!fp && tasm_compatible_mode)
4042
+ char *thefile = file2 ? file2 : file;
4043
+ /* try a few case combinations */
4045
+ for (c = thefile; *c; c++)
4047
+ fp = yasm_fopen_include(thefile, nasm_src_get_fname(), "r", &combine);
4049
+ *thefile = tolower(*thefile);
4050
+ fp = yasm_fopen_include(thefile, nasm_src_get_fname(), "r", &combine);
4052
+ for (c = thefile; *c; c++)
4054
+ fp = yasm_fopen_include(thefile, nasm_src_get_fname(), "r", &combine);
4056
+ *thefile = toupper(*thefile);
4057
+ fp = yasm_fopen_include(thefile, nasm_src_get_fname(), "r", &combine);
4062
error(ERR_FATAL, "unable to open include file `%s'",
4063
file2 ? file2 : file);
4064
@@ -4420,6 +4997,9 @@
4066
* De-tokenise the line again, and emit it.
4068
+ if (tasm_compatible_mode)
4069
+ tline = tasm_join_tokens(tline);
4071
line = detoken(tline, TRUE);
4074
Index: frontends/tasm/tasm-options.h
4075
===================================================================
4076
--- old/frontends/tasm/tasm-options.h (r�vision 0)
4077
+++ new/frontends/tasm/tasm-options.h (r�vision 0)
4079
+/* $Id: tasm-options.h 1137 2004-09-04 01:24:57Z peter $
4080
+ * Generic Options Support Header File
4082
+ * Copyright (c) 2001 Stanislav Karchebny <berk@madfire.net>
4084
+ * Redistribution and use in source and binary forms, with or without
4085
+ * modification, are permitted provided that the following conditions
4087
+ * 1. Redistributions of source code must retain the above copyright
4088
+ * notice, this list of conditions and the following disclaimer.
4089
+ * 2. Redistributions in binary form must reproduce the above copyright
4090
+ * notice, this list of conditions and the following disclaimer in the
4091
+ * documentation and/or other materials provided with the distribution.
4093
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND OTHER CONTRIBUTORS ``AS IS''
4094
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
4095
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
4096
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR OTHER CONTRIBUTORS BE
4097
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
4098
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
4099
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
4100
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
4101
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
4102
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
4103
+ * POSSIBILITY OF SUCH DAMAGE.
4105
+#ifndef TASM_OPTIONS_H
4106
+#define TASM_OPTIONS_H
4108
+/* an option structure
4109
+ * operate on either -sopt, --lopt, -sopt <val> or --lopt=<val>
4111
+typedef struct opt_option_s
4116
+ /* !=0 if option requires parameter, 0 if not */
4119
+ int (*handler) (char *cmd, /*@null@*/ char *param, int extra);
4120
+ int extra; /* extra value for handler */
4122
+ /* description to use in help_msg() */
4123
+ /*@observer@*/ const char *description;
4125
+ /* optional description for the param taken (NULL if not present) */
4126
+ /* (short - will be printed after option sopt/lopt) */
4127
+ /*@observer@*/ /*@null@*/ const char *param_desc;
4130
+/* handle everything that is not an option */
4131
+int not_an_option_handler(char *param);
4133
+/* parse command line calling handlers when appropriate
4134
+ * argc, argv - pass directly from main(argc,argv)
4135
+ * options - array of options
4136
+ * nopts - options count
4138
+int parse_cmdline(int argc, char **argv, opt_option *options, size_t nopts,
4139
+ void (*print_error) (const char *fmt, ...));
4141
+/* display help message msg followed by list of options in options and followed
4144
+void help_msg(const char *msg, const char *tail, opt_option *options,
4148
Index: frontends/tasm/tasm.c
4149
===================================================================
4150
--- old/frontends/tasm/tasm.c (r�vision 0)
4151
+++ new/frontends/tasm/tasm.c (r�vision 0)
4154
+ * Program entry point, command line parsing
4156
+ * Copyright (C) 2001-2008 Peter Johnson
4157
+ * Copyright (C) 2007-2008 Samuel Thibault
4159
+ * Redistribution and use in source and binary forms, with or without
4160
+ * modification, are permitted provided that the following conditions
4162
+ * 1. Redistributions of source code must retain the above copyright
4163
+ * notice, this list of conditions and the following disclaimer.
4164
+ * 2. Redistributions in binary form must reproduce the above copyright
4165
+ * notice, this list of conditions and the following disclaimer in the
4166
+ * documentation and/or other materials provided with the distribution.
4168
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND OTHER CONTRIBUTORS ``AS IS''
4169
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
4170
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
4171
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR OTHER CONTRIBUTORS BE
4172
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
4173
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
4174
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
4175
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
4176
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
4177
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
4178
+ * POSSIBILITY OF SUCH DAMAGE.
4181
+/*@unused@*/ RCSID("$Id: tasm.c 1523 2006-05-06 16:11:56Z peter $");
4184
+#include <unistd.h>
4185
+#include <libyasm/compat-queue.h>
4186
+#include <libyasm/bitvect.h>
4187
+#include <libyasm.h>
4189
+#ifdef HAVE_LIBGEN_H
4190
+#include <libgen.h>
4193
+#include "tasm-options.h"
4196
+#include "yasm-plugin.h"
4199
+#include "license.c"
4201
+#define DEFAULT_OBJFMT_MODULE "bin"
4203
+/*@null@*/ /*@only@*/ static char *obj_filename = NULL, *in_filename = NULL;
4204
+/*@null@*/ /*@only@*/ static char *list_filename = NULL, *xref_filename = NULL;
4205
+/*@null@*/ /*@only@*/ static char *machine_name = NULL;
4206
+static int special_options = 0;
4207
+static int segment_ordering = 0;
4208
+static int cross_reference = 0;
4209
+static int floating_point = 0;
4210
+static int listing = 0;
4211
+static int expanded_listing = 0;
4212
+static int case_sensitivity = 0;
4213
+static int valid_length = -1;
4214
+/*@null@*/ /*@dependent@*/ static yasm_arch *cur_arch = NULL;
4215
+/*@null@*/ /*@dependent@*/ static const yasm_arch_module *
4216
+ cur_arch_module = NULL;
4217
+/*@null@*/ /*@dependent@*/ static const yasm_parser_module *
4218
+ cur_parser_module = NULL;
4219
+/*@null@*/ /*@dependent@*/ static yasm_preproc *cur_preproc = NULL;
4220
+/*@null@*/ /*@dependent@*/ static const yasm_preproc_module *
4221
+ cur_preproc_module = NULL;
4222
+/*@null@*/ static char *objfmt_keyword = NULL;
4223
+/*@null@*/ /*@dependent@*/ static const yasm_objfmt_module *
4224
+ cur_objfmt_module = NULL;
4225
+/*@null@*/ /*@dependent@*/ static const yasm_dbgfmt_module *
4226
+ cur_dbgfmt_module = NULL;
4227
+/*@null@*/ /*@dependent@*/ static yasm_listfmt *cur_listfmt = NULL;
4228
+/*@null@*/ /*@dependent@*/ static const yasm_listfmt_module *
4229
+ cur_listfmt_module = NULL;
4230
+static int warning_error = 0; /* warnings being treated as errors */
4231
+static FILE *errfile;
4232
+/*@null@*/ /*@only@*/ static char *error_filename = NULL;
4234
+/*@null@*/ /*@dependent@*/ static FILE *open_file(const char *filename,
4235
+ const char *mode);
4236
+static void check_errors(/*@only@*/ yasm_errwarns *errwarns,
4237
+ /*@only@*/ yasm_object *object,
4238
+ /*@only@*/ yasm_linemap *linemap);
4239
+static void cleanup(/*@null@*/ /*@only@*/ yasm_object *object);
4241
+/* Forward declarations: cmd line parser handlers */
4242
+static int opt_special_handler(char *cmd, /*@null@*/ char *param, int extra);
4243
+static int opt_segment_ordering_handler(char *cmd, /*@null@*/ char *param, int extra);
4244
+static int opt_cross_reference_handler(char *cmd, /*@null@*/ char *param, int extra);
4245
+static int opt_floating_point_handler(char *cmd, /*@null@*/ char *param, int extra);
4246
+static int opt_ignore(char *cmd, /*@null@*/ char *param, int extra);
4247
+static int opt_listing_handler(char *cmd, /*@null@*/ char *param, int extra);
4248
+static int opt_case_handler(char *cmd, /*@null@*/ char *param, int extra);
4249
+static int opt_valid_length_handler(char *cmd, /*@null@*/ char *param, int extra);
4251
+static int opt_warning_handler(char *cmd, /*@null@*/ char *param, int extra);
4252
+static int opt_preproc_option(char *cmd, /*@null@*/ char *param, int extra);
4253
+static int opt_exe_handler(char *cmd, /*@null@*/ char *param, int extra);
4255
+static /*@only@*/ char *replace_extension(const char *orig, /*@null@*/
4256
+ const char *ext, const char *def);
4257
+static void print_error(const char *fmt, ...);
4259
+static /*@exits@*/ void handle_yasm_int_error(const char *file,
4260
+ unsigned int line,
4261
+ const char *message);
4262
+static /*@exits@*/ void handle_yasm_fatal(const char *message, va_list va);
4263
+static const char *handle_yasm_gettext(const char *msgid);
4264
+static void print_yasm_error(const char *filename, unsigned long line,
4265
+ const char *msg, /*@null@*/ const char *xref_fn,
4266
+ unsigned long xref_line,
4267
+ /*@null@*/ const char *xref_msg);
4268
+static void print_yasm_warning(const char *filename, unsigned long line,
4271
+static void apply_preproc_builtins(void);
4272
+static void apply_preproc_standard_macros(const yasm_stdmac *stdmacs);
4273
+static void apply_preproc_saved_options(void);
4274
+static void print_list_keyword_desc(const char *name, const char *keyword);
4276
+/* values for special_options */
4277
+#define SPECIAL_SHOW_HELP 0x01
4278
+#define SPECIAL_SHOW_VERSION 0x02
4279
+#define SPECIAL_SHOW_LICENSE 0x04
4281
+#define SEGMENT_ORDERING_ALPHABETIC 0x01
4282
+#define SEGMENT_ORDERING_SOURCE 0x02
4284
+#define FP_EMULATED 0x01
4285
+#define FP_REAL 0x02
4287
+#define CASE_ALL 0x01
4288
+#define CASE_GLOBALS 0x02
4289
+#define CASE_NONE 0x04
4291
+#define DEBUG_FULL 0x01
4292
+#define DEBUG_LINES 0x02
4293
+#define DEBUG_NONE 0x04
4295
+/* command line options */
4296
+static opt_option options[] =
4298
+ { "version", 0, opt_special_handler, SPECIAL_SHOW_VERSION,
4299
+ N_("show version text"), NULL },
4300
+ { "license", 0, opt_special_handler, SPECIAL_SHOW_LICENSE,
4301
+ N_("show license text"), NULL },
4302
+ { "a", 0, opt_segment_ordering_handler, SEGMENT_ORDERING_ALPHABETIC,
4303
+ N_("Alphabetic segment ordering"), NULL },
4304
+ { "s", 0, opt_segment_ordering_handler, SEGMENT_ORDERING_SOURCE,
4305
+ N_("Source segment ordering"), NULL },
4307
+ { "c", 0, opt_cross_reference_handler, 0,
4308
+ N_("Generate cross-reference in listing"), NULL },
4310
+ { "d", 1, opt_preproc_option, 2,
4311
+ N_("pre-define a macro, optionally to value"), N_("macro[=value]") },
4313
+ { "e", 0, opt_floating_point_handler, FP_EMULATED,
4314
+ N_("Emulated floating-point instructions (not supported)"), NULL },
4315
+ { "r", 0, opt_floating_point_handler, FP_REAL,
4316
+ N_("Real floating-point instructions"), NULL },
4318
+ { "h", 0, opt_special_handler, SPECIAL_SHOW_HELP,
4319
+ N_("show help text"), NULL },
4320
+ { "?", 0, opt_special_handler, SPECIAL_SHOW_HELP,
4321
+ N_("show help text"), NULL },
4323
+ { "i", 1, opt_preproc_option, 0,
4324
+ N_("add include path"), N_("path") },
4326
+ { "j", 1, opt_ignore, 0,
4327
+ N_("Jam in an assemble directive CMD (eg. /jIDEAL) (not supported)"), NULL },
4329
+ { "k", 1, opt_ignore, 0,
4330
+ N_("Hash table capacity (ignored)"), N_("# symbols") },
4332
+ { "l", 0, opt_listing_handler, 0,
4333
+ N_("Generate listing"), N_("l=normal listing, la=expanded listing") },
4335
+ { "ml", 0, opt_case_handler, CASE_ALL,
4336
+ N_("Case sensitivity on all symbols"), NULL },
4337
+ { "mx", 0, opt_case_handler, CASE_GLOBALS,
4338
+ N_("Case sensitivity on global symbols"), NULL },
4339
+ { "mu", 0, opt_case_handler, CASE_NONE,
4340
+ N_("No case sensitivity on symbols"), NULL },
4341
+ { "mv", 0, opt_valid_length_handler, 0,
4342
+ N_("Set maximum valid length for symbols"), N_("length") },
4344
+ { "m", 1, opt_ignore, 0,
4345
+ N_("Allow multiple passes to resolve forward reference (ignored)"), N_("number of passes") },
4347
+ { "n", 0, opt_ignore, 0,
4348
+ N_("Suppress symbol tables in listing"), NULL },
4350
+ { "o", 0, opt_ignore, 0,
4351
+ N_("Object code"), N_("os: standard, o: standard w/overlays, op: Phar Lap, oi: IBM") },
4353
+ { "p", 0, opt_ignore, 0,
4354
+ N_("Check for code segment overrides in protected mode"), NULL },
4355
+ { "q", 0, opt_ignore, 0,
4356
+ N_("Suppress OBJ records not needed for linking (ignored)"), NULL },
4357
+ { "t", 0, opt_ignore, 0,
4358
+ N_("Suppress messages if successful assembly"), NULL },
4359
+ { "u", 0, opt_ignore, 0,
4360
+ N_("Set version emulation"), N_("Version") },
4361
+ { "w", 1, opt_warning_handler, 0,
4362
+ N_("Set warning level"), N_("w0=none, w1=w2=warnings on, w-xxx/w+xxx=disable/enable warning xxx") },
4363
+ { "x", 0, opt_ignore, 0,
4364
+ N_("Include false conditionals in listing"), NULL },
4365
+ { "zi", 0, opt_ignore, DEBUG_FULL,
4366
+ N_("Full debug info"), NULL },
4367
+ { "zd", 0, opt_ignore, DEBUG_LINES,
4368
+ N_("Line numbers debug info"), NULL },
4369
+ { "zn", 0, opt_ignore, DEBUG_NONE,
4370
+ N_("No debug info"), NULL },
4371
+ { "z", 0, opt_ignore, 0,
4372
+ N_("Display source line with error message (ignored)"), NULL },
4374
+ { "b", 0, opt_exe_handler, 0,
4375
+ N_("Build a (very) basic .exe file"), NULL },
4378
+/* version message */
4379
+/*@observer@*/ static const char *version_msg[] = {
4380
+ PACKAGE_NAME " " PACKAGE_INTVER "." PACKAGE_BUILD,
4381
+ "Compiled on " __DATE__ ".",
4382
+ "Copyright (c) 2001-2008 Peter Johnson and other Yasm developers.",
4383
+ "Run yasm --license for licensing overview and summary."
4386
+/* help messages */
4387
+/*@observer@*/ static const char *help_head = N_(
4388
+ "usage: tasm [option]* source [,object] [,listing] [,xref] \n"
4390
+/*@observer@*/ static const char *help_tail = N_(
4392
+ "source is asm source to be assembled.\n"
4394
+ "Sample invocation:\n"
4395
+ " tasm /zi source.asm\n"
4397
+ "Report bugs to bug-yasm@tortall.net\n");
4399
+/* parsed command line storage until appropriate modules have been loaded */
4400
+typedef STAILQ_HEAD(constcharparam_head, constcharparam) constcharparam_head;
4402
+typedef struct constcharparam {
4403
+ STAILQ_ENTRY(constcharparam) link;
4404
+ const char *param;
4408
+static constcharparam_head preproc_options;
4413
+ yasm_object *object;
4414
+ const char *base_filename;
4415
+ /*@null@*/ FILE *obj = NULL;
4416
+ yasm_arch_create_error arch_error;
4417
+ yasm_linemap *linemap;
4418
+ yasm_errwarns *errwarns = yasm_errwarns_create();
4421
+ /* Initialize line map */
4422
+ linemap = yasm_linemap_create();
4423
+ yasm_linemap_set(linemap, in_filename, 1, 1);
4425
+ /* determine the object filename if not specified */
4426
+ if (!obj_filename) {
4427
+ if (in_filename == NULL)
4428
+ /* Default to yasm.out if no obj filename specified */
4429
+ obj_filename = yasm__xstrdup("yasm.out");
4431
+ /* replace (or add) extension to base filename */
4432
+ yasm__splitpath(in_filename, &base_filename);
4433
+ if (base_filename[0] == '\0')
4434
+ obj_filename = yasm__xstrdup("yasm.out");
4436
+ obj_filename = replace_extension(base_filename,
4442
+ cur_arch = yasm_arch_create(cur_arch_module, machine_name,
4443
+ cur_parser_module->keyword, &arch_error);
4445
+ switch (arch_error) {
4446
+ case YASM_ARCH_CREATE_BAD_MACHINE:
4447
+ print_error(_("%s: `%s' is not a valid %s for %s `%s'"),
4448
+ _("FATAL"), machine_name, _("machine"),
4449
+ _("architecture"), cur_arch_module->keyword);
4451
+ case YASM_ARCH_CREATE_BAD_PARSER:
4452
+ print_error(_("%s: `%s' is not a valid %s for %s `%s'"),
4453
+ _("FATAL"), cur_parser_module->keyword,
4454
+ _("parser"), _("architecture"),
4455
+ cur_arch_module->keyword);
4458
+ print_error(_("%s: unknown architecture error"), _("FATAL"));
4461
+ return EXIT_FAILURE;
4464
+ /* Create object */
4465
+ object = yasm_object_create(in_filename, obj_filename, cur_arch,
4466
+ cur_objfmt_module, cur_dbgfmt_module);
4468
+ yasm_error_class eclass;
4469
+ unsigned long xrefline;
4470
+ /*@only@*/ /*@null@*/ char *estr, *xrefstr;
4472
+ yasm_error_fetch(&eclass, &estr, &xrefline, &xrefstr);
4473
+ print_error("%s: %s", _("FATAL"), estr);
4475
+ yasm_xfree(xrefstr);
4478
+ return EXIT_FAILURE;
4481
+ /* Get a fresh copy of objfmt_module as it may have changed. */
4482
+ cur_objfmt_module = ((yasm_objfmt_base *)object->objfmt)->module;
4484
+ /* Check to see if the requested preprocessor is in the allowed list
4485
+ * for the active parser.
4488
+ for (i=0; cur_parser_module->preproc_keywords[i]; i++)
4489
+ if (yasm__strcasecmp(cur_parser_module->preproc_keywords[i],
4490
+ cur_preproc_module->keyword) == 0)
4493
+ print_error(_("%s: `%s' is not a valid %s for %s `%s'"), _("FATAL"),
4494
+ cur_preproc_module->keyword, _("preprocessor"),
4495
+ _("parser"), cur_parser_module->keyword);
4497
+ return EXIT_FAILURE;
4500
+ cur_preproc = yasm_preproc_create(cur_preproc_module, in_filename,
4501
+ object->symtab, linemap, errwarns);
4503
+ apply_preproc_builtins();
4504
+ apply_preproc_standard_macros(cur_parser_module->stdmacs);
4505
+ apply_preproc_standard_macros(cur_objfmt_module->stdmacs);
4506
+ apply_preproc_saved_options();
4508
+ /* Get initial x86 BITS setting from object format */
4509
+ if (strcmp(cur_arch_module->keyword, "x86") == 0) {
4510
+ yasm_arch_set_var(cur_arch, "mode_bits",
4511
+ cur_objfmt_module->default_x86_mode_bits);
4515
+ cur_parser_module->do_parse(object, cur_preproc, list_filename != NULL,
4516
+ linemap, errwarns);
4518
+ check_errors(errwarns, object, linemap);
4520
+ /* Finalize parse */
4521
+ yasm_object_finalize(object, errwarns);
4522
+ check_errors(errwarns, object, linemap);
4525
+ yasm_object_optimize(object, errwarns);
4526
+ check_errors(errwarns, object, linemap);
4528
+ /* generate any debugging information */
4529
+ yasm_dbgfmt_generate(object, linemap, errwarns);
4530
+ check_errors(errwarns, object, linemap);
4532
+ /* open the object file for output (if not already opened by dbg objfmt) */
4533
+ if (!obj && strcmp(cur_objfmt_module->keyword, "dbg") != 0) {
4534
+ obj = open_file(obj_filename, "wb");
4537
+ return EXIT_FAILURE;
4541
+ /* Write the object file */
4542
+ yasm_objfmt_output(object, obj?obj:stderr,
4543
+ strcmp(cur_dbgfmt_module->keyword, "null"), errwarns);
4545
+ /* Close object file */
4549
+ /* If we had an error at this point, we also need to delete the output
4550
+ * object file (to make sure it's not left newer than the source).
4552
+ if (yasm_errwarns_num_errors(errwarns, warning_error) > 0)
4553
+ remove(obj_filename);
4554
+ check_errors(errwarns, object, linemap);
4556
+ /* Open and write the list file */
4557
+ if (list_filename) {
4558
+ FILE *list = open_file(list_filename, "wt");
4561
+ return EXIT_FAILURE;
4563
+ /* Initialize the list format */
4564
+ cur_listfmt = yasm_listfmt_create(cur_listfmt_module, in_filename,
4566
+ yasm_listfmt_output(cur_listfmt, list, linemap, cur_arch);
4570
+ yasm_errwarns_output_all(errwarns, linemap, warning_error,
4571
+ print_yasm_error, print_yasm_warning);
4573
+ yasm_linemap_destroy(linemap);
4574
+ yasm_errwarns_destroy(errwarns);
4576
+ return EXIT_SUCCESS;
4579
+/* main function */
4580
+/*@-globstate -unrecog@*/
4582
+main(int argc, char *argv[])
4588
+#if defined(HAVE_SETLOCALE) && defined(HAVE_LC_MESSAGES)
4589
+ setlocale(LC_MESSAGES, "");
4591
+#if defined(LOCALEDIR)
4592
+ bindtextdomain(PACKAGE, LOCALEDIR);
4594
+ textdomain(PACKAGE);
4596
+ /* Initialize errwarn handling */
4597
+ yasm_internal_error_ = handle_yasm_int_error;
4598
+ yasm_fatal = handle_yasm_fatal;
4599
+ yasm_gettext_hook = handle_yasm_gettext;
4600
+ yasm_errwarn_initialize();
4602
+ /* Initialize BitVector (needed for intnum/floatnum). */
4603
+ if (BitVector_Boot() != ErrCode_Ok) {
4604
+ print_error(_("%s: could not initialize BitVector"), _("FATAL"));
4605
+ return EXIT_FAILURE;
4608
+ /* Initialize intnum and floatnum */
4609
+ yasm_intnum_initialize();
4610
+ yasm_floatnum_initialize();
4613
+ /* Load standard modules */
4614
+ if (!load_plugin("yasmstd")) {
4615
+ print_error(_("%s: could not load standard modules"), _("FATAL"));
4616
+ return EXIT_FAILURE;
4620
+ /* Initialize parameter storage */
4621
+ STAILQ_INIT(&preproc_options);
4623
+ if (parse_cmdline(argc, argv, options, NELEMS(options), print_error))
4624
+ return EXIT_FAILURE;
4626
+ switch (special_options) {
4627
+ case SPECIAL_SHOW_HELP:
4628
+ /* Does gettext calls internally */
4629
+ help_msg(help_head, help_tail, options, NELEMS(options));
4630
+ return EXIT_SUCCESS;
4631
+ case SPECIAL_SHOW_VERSION:
4632
+ for (i=0; i<NELEMS(version_msg); i++)
4633
+ printf("%s\n", version_msg[i]);
4634
+ return EXIT_SUCCESS;
4635
+ case SPECIAL_SHOW_LICENSE:
4636
+ for (i=0; i<NELEMS(license_msg); i++)
4637
+ printf("%s\n", license_msg[i]);
4638
+ return EXIT_SUCCESS;
4641
+ /* Open error file if specified. */
4642
+ if (error_filename) {
4643
+ errfile = open_file(error_filename, "wt");
4645
+ return EXIT_FAILURE;
4648
+ /* If not already specified, default to bin as the object format. */
4649
+ if (!cur_objfmt_module) {
4650
+ if (!objfmt_keyword)
4651
+ objfmt_keyword = yasm__xstrdup(DEFAULT_OBJFMT_MODULE);
4652
+ cur_objfmt_module = yasm_load_objfmt(objfmt_keyword);
4653
+ if (!cur_objfmt_module) {
4654
+ print_error(_("%s: could not load default %s"), _("FATAL"),
4655
+ _("object format"));
4656
+ return EXIT_FAILURE;
4660
+ /* TASM's architecture is x86 */
4661
+ cur_arch_module = yasm_load_arch("x86");
4662
+ if (!cur_arch_module) {
4663
+ print_error(_("%s: could not load %s"), _("FATAL"),
4664
+ _("architecture"));
4665
+ return EXIT_FAILURE;
4668
+ yasm__xstrdup(cur_arch_module->default_machine_keyword);
4670
+ /* Check for arch help */
4671
+ if (machine_name && strcmp(machine_name, "help") == 0) {
4672
+ const yasm_arch_machine *m = cur_arch_module->machines;
4673
+ printf(_("Available %s for %s `%s':\n"), _("machines"),
4674
+ _("architecture"), cur_arch_module->keyword);
4675
+ while (m->keyword && m->name) {
4676
+ print_list_keyword_desc(m->name, m->keyword);
4679
+ return EXIT_SUCCESS;
4682
+ cur_parser_module = yasm_load_parser("tasm");
4683
+ if (!cur_parser_module) {
4684
+ print_error(_("%s: could not load %s"), _("FATAL"),
4687
+ return EXIT_FAILURE;
4690
+ /* If not already specified, default to the parser's default preproc. */
4691
+ if (!cur_preproc_module) {
4692
+ cur_preproc_module =
4693
+ yasm_load_preproc(cur_parser_module->default_preproc_keyword);
4694
+ if (!cur_preproc_module) {
4695
+ print_error(_("%s: could not load default %s"), _("FATAL"),
4696
+ _("preprocessor"));
4698
+ return EXIT_FAILURE;
4702
+ /* Determine input filename and open input file. */
4703
+ if (!in_filename) {
4704
+ print_error(_("No input files specified"));
4705
+ return EXIT_FAILURE;
4708
+ /* If list file enabled, make sure we have a list format loaded. */
4709
+ if (list_filename) {
4710
+ /* use nasm as the list format. */
4711
+ cur_listfmt_module = yasm_load_listfmt("nasm");
4714
+ /* If not already specified, default to null as the debug format. */
4715
+ if (!cur_dbgfmt_module) {
4716
+ cur_dbgfmt_module = yasm_load_dbgfmt("null");
4717
+ if (!cur_dbgfmt_module) {
4718
+ print_error(_("%s: could not load default %s"), _("FATAL"),
4719
+ _("debug format"));
4720
+ return EXIT_FAILURE;
4724
+ return do_assemble();
4726
+/*@=globstate =unrecog@*/
4728
+/* Open the object file. Returns 0 on failure. */
4730
+open_file(const char *filename, const char *mode)
4734
+ f = fopen(filename, mode);
4736
+ print_error(_("could not open file `%s'"), filename);
4741
+check_errors(yasm_errwarns *errwarns, yasm_object *object,
4742
+ yasm_linemap *linemap)
4744
+ if (yasm_errwarns_num_errors(errwarns, warning_error) > 0) {
4745
+ yasm_errwarns_output_all(errwarns, linemap, warning_error,
4746
+ print_yasm_error, print_yasm_warning);
4747
+ yasm_linemap_destroy(linemap);
4748
+ yasm_errwarns_destroy(errwarns);
4750
+ exit(EXIT_FAILURE);
4754
+/* Define DO_FREE to 1 to enable deallocation of all data structures.
4755
+ * Useful for detecting memory leaks, but slows down execution unnecessarily
4756
+ * (as the OS will free everything we miss here).
4760
+/* Cleans up all allocated structures. */
4762
+cleanup(yasm_object *object)
4766
+ yasm_listfmt_destroy(cur_listfmt);
4768
+ yasm_preproc_destroy(cur_preproc);
4770
+ yasm_object_destroy(object);
4772
+ yasm_floatnum_cleanup();
4773
+ yasm_intnum_cleanup();
4775
+ yasm_errwarn_cleanup();
4777
+ BitVector_Shutdown();
4782
+ yasm_xfree(in_filename);
4784
+ yasm_xfree(obj_filename);
4785
+ if (list_filename)
4786
+ yasm_xfree(list_filename);
4787
+ if (xref_filename)
4788
+ yasm_xfree(xref_filename);
4790
+ yasm_xfree(machine_name);
4791
+ if (objfmt_keyword)
4792
+ yasm_xfree(objfmt_keyword);
4795
+ if (errfile != stderr && errfile != stdout)
4803
+ * Command line options handlers
4805
+static char ** const filenames[] = {
4806
+ &in_filename, &obj_filename, &list_filename, &xref_filename, NULL
4807
+}, ** const * cur_filename = &filenames[0];
4809
+static int filename_handler(char *param) {
4810
+ if (!*cur_filename) {
4811
+ print_error(_("error: too many files on command line."));
4816
+ **cur_filename = yasm__xstrdup(param);
4821
+not_an_option_handler(char *param) {
4822
+ char *c, *d = param;
4824
+ while ((c = strchr(d, ','))) {
4826
+ if (filename_handler(d))
4831
+ filename_handler(d);
4836
+opt_special_handler(/*@unused@*/ char *cmd, /*@unused@*/ char *param, int extra)
4838
+ if (special_options == 0)
4839
+ special_options = extra;
4844
+opt_segment_ordering_handler(/*@unused@*/ char *cmd, /*@unused@*/ char *param, int extra)
4846
+ segment_ordering = extra;
4851
+opt_cross_reference_handler(/*@unused@*/ char *cmd, /*@unused@*/ char *param, int extra)
4853
+ cross_reference = 1;
4858
+opt_floating_point_handler(/*@unused@*/ char *cmd, /*@unused@*/ char *param, int extra)
4860
+ floating_point = extra;
4865
+opt_ignore(/*@unused@*/ char *cmd, /*@unused@*/ char *param, int extra)
4871
+opt_listing_handler(/*@unused@*/ char *cmd, /*@unused@*/ char *param, int extra)
4873
+ if (param && param[0]) {
4874
+ if (param[0] != 'a')
4876
+ expanded_listing = 1;
4883
+opt_case_handler(/*@unused@*/ char *cmd, /*@unused@*/ char *param, int extra)
4885
+ case_sensitivity = extra;
4890
+opt_valid_length_handler(/*@unused@*/ char *cmd, /*@unused@*/ char *param, int extra)
4892
+ valid_length = atoi(param);
4897
+opt_warning_handler(char *cmd, /*@unused@*/ char *param, int extra)
4899
+ /* is it disabling the warning instead of enabling? */
4900
+ void (*action)(yasm_warn_class wclass) = NULL;
4902
+ if (cmd[0] == '0') {
4903
+ /* /w0, disable warnings */
4904
+ yasm_warn_disable_all();
4908
+ if (cmd[0] == '1' || cmd[0] == '2') {
4909
+ /* /w[12], enable warnings */
4910
+ yasm_warn_enable(YASM_WARN_UNREC_CHAR);
4911
+ yasm_warn_enable(YASM_WARN_ORPHAN_LABEL);
4912
+ yasm_warn_enable(YASM_WARN_UNINIT_CONTENTS);
4916
+ /* detect no- prefix to disable the warning */
4917
+ if (cmd[0] == '-') {
4918
+ action = yasm_warn_disable;
4919
+ } else if (cmd[0] == '+') {
4920
+ action = yasm_warn_enable;
4923
+ /* skip past '+/-' */
4926
+ if (cmd[0] == '\0')
4927
+ /* just /w- or /w+, so definitely not valid */
4929
+ else if (strcmp(cmd, "error") == 0)
4930
+ warning_error = (action == yasm_warn_enable);
4931
+ else if (strcmp(cmd, "unrecognized-char") == 0)
4932
+ action(YASM_WARN_UNREC_CHAR);
4933
+ else if (strcmp(cmd, "orphan-labels") == 0)
4934
+ action(YASM_WARN_ORPHAN_LABEL);
4935
+ else if (strcmp(cmd, "uninit-contents") == 0)
4936
+ action(YASM_WARN_UNINIT_CONTENTS);
4937
+ else if (strcmp(cmd, "size-override") == 0)
4938
+ action(YASM_WARN_SIZE_OVERRIDE);
4946
+opt_preproc_option(/*@unused@*/ char *cmd, char *param, int extra)
4948
+ constcharparam *cp;
4949
+ cp = yasm_xmalloc(sizeof(constcharparam));
4950
+ cp->param = param;
4952
+ STAILQ_INSERT_TAIL(&preproc_options, cp, link);
4957
+opt_exe_handler(char *cmd, /*@unused@*/ char *param, int extra)
4959
+ objfmt_keyword = yasm__xstrdup("dosexe");
4964
+apply_preproc_builtins()
4968
+ if (!objfmt_keyword)
4969
+ objfmt_keyword = yasm__xstrdup(DEFAULT_OBJFMT_MODULE);
4971
+ /* Define standard YASM assembly-time macro constants */
4972
+ predef = yasm_xmalloc(strlen("__YASM_OBJFMT__=")
4973
+ + strlen(objfmt_keyword) + 1);
4974
+ strcpy(predef, "__YASM_OBJFMT__=");
4975
+ strcat(predef, objfmt_keyword);
4976
+ yasm_preproc_define_builtin(cur_preproc, predef);
4977
+ yasm_xfree(predef);
4981
+apply_preproc_standard_macros(const yasm_stdmac *stdmacs)
4989
+ for (i=0; stdmacs[i].parser; i++)
4990
+ if (yasm__strcasecmp(stdmacs[i].parser,
4991
+ cur_parser_module->keyword) == 0 &&
4992
+ yasm__strcasecmp(stdmacs[i].preproc,
4993
+ cur_preproc_module->keyword) == 0)
4995
+ if (matched >= 0 && stdmacs[matched].macros)
4996
+ yasm_preproc_add_standard(cur_preproc, stdmacs[matched].macros);
5000
+apply_preproc_saved_options()
5002
+ constcharparam *cp, *cpnext;
5004
+ void (*funcs[3])(yasm_preproc *, const char *);
5005
+ funcs[0] = cur_preproc_module->add_include_file;
5006
+ funcs[1] = cur_preproc_module->predefine_macro;
5007
+ funcs[2] = cur_preproc_module->undefine_macro;
5009
+ STAILQ_FOREACH(cp, &preproc_options, link) {
5010
+ if (0 <= cp->id && cp->id < 3 && funcs[cp->id])
5011
+ funcs[cp->id](cur_preproc, cp->param);
5014
+ cp = STAILQ_FIRST(&preproc_options);
5015
+ while (cp != NULL) {
5016
+ cpnext = STAILQ_NEXT(cp, link);
5020
+ STAILQ_INIT(&preproc_options);
5023
+/* Replace extension on a filename (or append one if none is present).
5024
+ * If output filename would be identical to input (same extension out as in),
5025
+ * returns (copy of) def.
5026
+ * A NULL ext means the trailing '.' should NOT be included, whereas a "" ext
5027
+ * means the trailing '.' should be included.
5030
+replace_extension(const char *orig, /*@null@*/ const char *ext,
5033
+ char *out, *outext;
5034
+ size_t deflen, outlen;
5036
+ /* allocate enough space for full existing name + extension */
5037
+ outlen = strlen(orig) + 2;
5039
+ outlen += strlen(ext) + 1;
5040
+ deflen = strlen(def) + 1;
5041
+ if (outlen < deflen)
5043
+ out = yasm_xmalloc(outlen);
5045
+ strcpy(out, orig);
5046
+ outext = strrchr(out, '.');
5048
+ /* Existing extension: make sure it's not the same as the replacement
5049
+ * (as we don't want to overwrite the source file).
5051
+ outext++; /* advance past '.' */
5052
+ if (ext && strcmp(outext, ext) == 0) {
5053
+ outext = NULL; /* indicate default should be used */
5055
+ _("file name already ends in `.%s': output will be in `%s'"),
5059
+ /* No extension: make sure the output extension is not empty
5060
+ * (again, we don't want to overwrite the source file).
5064
+ _("file name already has no extension: output will be in `%s'"),
5067
+ outext = strrchr(out, '\0'); /* point to end of the string */
5068
+ *outext++ = '.'; /* append '.' */
5072
+ /* replace extension or use default name */
5075
+ /* Back up and replace '.' with string terminator */
5079
+ strcpy(outext, ext);
5087
+print_list_keyword_desc(const char *name, const char *keyword)
5089
+ printf("%4s%-12s%s\n", "", keyword, name);
5093
+print_error(const char *fmt, ...)
5096
+ fprintf(errfile, "tasm: ");
5097
+ va_start(va, fmt);
5098
+ vfprintf(errfile, fmt, va);
5100
+ fputc('\n', errfile);
5103
+static /*@exits@*/ void
5104
+handle_yasm_int_error(const char *file, unsigned int line, const char *message)
5106
+ fprintf(stderr, _("INTERNAL ERROR at %s, line %u: %s\n"), file, line,
5107
+ gettext(message));
5111
+ exit(EXIT_FAILURE);
5115
+static /*@exits@*/ void
5116
+handle_yasm_fatal(const char *fmt, va_list va)
5118
+ fprintf(errfile, "**%s**: ", _("Fatal"));
5119
+ vfprintf(errfile, gettext(fmt), va);
5120
+ fputc('\n', errfile);
5121
+ exit(EXIT_FAILURE);
5124
+static const char *
5125
+handle_yasm_gettext(const char *msgid)
5127
+ return gettext(msgid);
5131
+print_yasm_error(const char *filename, unsigned long line, const char *msg,
5132
+ const char *xref_fn, unsigned long xref_line,
5133
+ const char *xref_msg)
5136
+ fprintf(errfile, "**%s** %s(%lu) %s\n", _("Error"), filename, line, msg);
5138
+ fprintf(errfile, "**%s** %s %s\n", _("Error"), filename, msg);
5140
+ if (/* xref_fn && */ xref_msg) {
5142
+ fprintf(errfile, "**%s** %s(%lu) %s\n", _("Error"), filename, xref_line, xref_msg);
5144
+ fprintf(errfile, "**%s** %s %s\n", _("Error"), filename, xref_msg);
5149
+print_yasm_warning(const char *filename, unsigned long line, const char *msg)
5152
+ fprintf(errfile, "*%s* %s(%lu) %s\n", _("Warning"), filename, line, msg);
5154
+ fprintf(errfile, "*%s* %s %s\n", _("Warning"), filename, msg);
5156
Index: frontends/tasm/tasm-options.c
5157
===================================================================
5158
--- old/frontends/tasm/tasm-options.c (r�vision 0)
5159
+++ new/frontends/tasm/tasm-options.c (r�vision 2137)
5162
+ * Generic Options Support Header File
5164
+ * Copyright (c) 2001 Stanislav Karchebny <berk@madfire.net>
5166
+ * Redistribution and use in source and binary forms, with or without
5167
+ * modification, are permitted provided that the following conditions
5169
+ * 1. Redistributions of source code must retain the above copyright
5170
+ * notice, this list of conditions and the following disclaimer.
5171
+ * 2. Redistributions in binary form must reproduce the above copyright
5172
+ * notice, this list of conditions and the following disclaimer in the
5173
+ * documentation and/or other materials provided with the distribution.
5174
+ * 3. Neither the name of the author nor the names of other contributors
5175
+ * may be used to endorse or promote products derived from this
5176
+ * software without specific prior written permission.
5178
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND OTHER CONTRIBUTORS ``AS IS''
5179
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
5180
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
5181
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR OTHER CONTRIBUTORS BE
5182
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
5183
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
5184
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
5185
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
5186
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
5187
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
5188
+ * POSSIBILITY OF SUCH DAMAGE.
5192
+/*@unused@*/ RCSID("$Id: tasm-options.c 1197 2005-01-24 06:44:25Z peter $");
5194
+#include "tasm-options.h"
5198
+#define DEBUG(x) fprintf ## x ;
5204
+/* Options Parser */
5206
+parse_cmdline(int argc, char **argv, opt_option *options, size_t nopts,
5207
+ void (*print_error) (const char *fmt, ...))
5209
+ int errors = 0, warnings = 0;
5213
+ DEBUG((stderr, "parse_cmdline: entered\n"));
5219
+ if (argv[0][0] == '/' && argv[0][1]) { /* opt */
5221
+ for (i = 0; i < nopts; i++) {
5222
+ char *cmd = &argv[0][1];
5223
+ size_t len = strlen(options[i].opt);
5224
+ if (yasm__strncasecmp(cmd, options[i].opt, len) == 0) {
5227
+ param = &argv[0][1+len];
5228
+ if (options[i].takes_param) {
5229
+ if (param[0] == '\0') {
5231
+ _("option `-%c' needs an argument!"),
5242
+ if (!options[i].handler(cmd, param, options[i].extra))
5248
+ print_error(_("warning: unrecognized option `%s'"),
5252
+ } else { /* not an option, then it should be a file or something */
5254
+ if (not_an_option_handler(argv[0]))
5259
+ DEBUG((stderr, "parse_cmdline: finished\n"));
5264
+help_msg(const char *msg, const char *tail, opt_option *options, size_t nopts)
5266
+ char optbuf[100], optopt[100];
5269
+ printf("%s", gettext(msg));
5271
+ for (i = 0; i < nopts; i++) {
5275
+ if (options[i].takes_param) {
5276
+ if (options[i].opt)
5277
+ sprintf(optbuf, "/%s <%s>", options[i].opt,
5278
+ options[i].param_desc ? options[i].
5279
+ param_desc : _("param"));
5281
+ if (options[i].opt)
5282
+ sprintf(optbuf, "/%s", options[i].opt);
5285
+ printf(" %-22s %s\n", optbuf, gettext(options[i].description));
5288
+ printf("%s", gettext(tail));
5290
--- old/modules/preprocs/nasm/standard.mac 2008-04-16 05:29:59.000000000 +0200
5291
+++ new/modules/preprocs/nasm/standard.mac 2008-10-06 19:21:36.000000000 +0200
5300
+ %idefine P8086 CPU 8086
5301
+ %idefine P186 CPU 186
5302
+ %idefine P286 CPU 286
5303
+ %idefine P286N CPU 286
5304
+ %idefine P286P CPU 286 Priv
5305
+ %idefine P386 CPU 386
5306
+ %idefine P386N CPU 386
5307
+ %idefine P386P CPU 386 Priv
5308
+ %idefine P486 CPU 486
5309
+ %idefine P586 CPU 586
5310
+ %idefine .8086 CPU 8086
5311
+ %idefine .186 CPU 186
5312
+ %idefine .286 CPU 286
5313
+ %idefine .286C CPU 286
5314
+ %idefine .286P CPU 286
5315
+ %idefine .386 CPU 386
5316
+ %idefine .386C CPU 386
5317
+ %idefine .386P CPU 386
5318
+ %idefine .486 CPU 486
5319
+ %idefine .486C CPU 486
5320
+ %idefine .486P CPU 486
5321
+ %idefine .586 CPU 586
5322
+ %idefine .586C CPU 586
5323
+ %idefine .586P CPU 586
5330
+ %imacro EXTRN 1-*.nolist
5337
+ %imacro PUBLIC 1-*.nolist
5344
+ ; this is not needed
5347
; This is a magic token which indicates the end of the TASM macros