aicasm_gram.y (79873) | aicasm_gram.y (95376) |
---|---|
1%{ 2/* 3 * Parser for the Aic7xxx SCSI Host adapter sequencer assembler. 4 * 5 * Copyright (c) 1997, 1998, 2000 Justin T. Gibbs. | 1%{ 2/* 3 * Parser for the Aic7xxx SCSI Host adapter sequencer assembler. 4 * 5 * Copyright (c) 1997, 1998, 2000 Justin T. Gibbs. |
6 * Copyright (c) 2001 Adaptec Inc. |
|
6 * All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without 9 * modification, are permitted provided that the following conditions 10 * are met: 11 * 1. Redistributions of source code must retain the above copyright 12 * notice, this list of conditions, and the following disclaimer, 13 * without modification. | 7 * All rights reserved. 8 * 9 * Redistribution and use in source and binary forms, with or without 10 * modification, are permitted provided that the following conditions 11 * are met: 12 * 1. Redistributions of source code must retain the above copyright 13 * notice, this list of conditions, and the following disclaimer, 14 * without modification. |
14 * 2. The name of the author may not be used to endorse or promote products 15 * derived from this software without specific prior written permission. | 15 * 2. Redistributions in binary form must reproduce at minimum a disclaimer 16 * substantially similar to the "NO WARRANTY" disclaimer below 17 * ("Disclaimer") and any redistribution must be conditioned upon 18 * including a substantially similar Disclaimer requirement for further 19 * binary redistribution. 20 * 3. Neither the names of the above-listed copyright holders nor the names 21 * of any contributors may be used to endorse or promote products derived 22 * from this software without specific prior written permission. |
16 * 17 * Alternatively, this software may be distributed under the terms of the | 23 * 24 * Alternatively, this software may be distributed under the terms of the |
18 * GNU Public License ("GPL"). | 25 * GNU General Public License ("GPL") version 2 as published by the Free 26 * Software Foundation. |
19 * | 27 * |
20 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 21 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR 24 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | 28 * NO WARRANTY 29 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 30 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 31 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR 32 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 33 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
25 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 26 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | 34 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 35 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30 * SUCH DAMAGE. | 36 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 37 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 38 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 39 * POSSIBILITY OF SUCH DAMAGES. |
31 * | 40 * |
32 * $Id: //depot/src/aic7xxx/aicasm/aicasm_gram.y#7 $ | 41 * $Id: //depot/aic7xxx/aic7xxx/aicasm/aicasm_gram.y#14 $ |
33 * | 42 * |
34 * $FreeBSD: head/sys/dev/aic7xxx/aicasm/aicasm_gram.y 79873 2001-07-18 21:03:32Z gibbs $ | 43 * $FreeBSD: head/sys/dev/aic7xxx/aicasm/aicasm_gram.y 95376 2002-04-24 16:24:43Z gibbs $ |
35 */ 36 | 44 */ 45 |
46#include <sys/types.h> 47 |
|
37#include <inttypes.h> | 48#include <inttypes.h> |
49#include <regex.h> |
|
38#include <stdio.h> 39#include <stdlib.h> 40#include <string.h> 41#include <sysexits.h> 42 | 50#include <stdio.h> 51#include <stdlib.h> 52#include <string.h> 53#include <sysexits.h> 54 |
43#include <sys/types.h> | |
44#ifdef __linux__ 45#include "../queue.h" 46#else 47#include <sys/queue.h> 48#endif 49 50#include "aicasm.h" 51#include "aicasm_symbol.h" 52#include "aicasm_insformat.h" 53 54int yylineno; 55char *yyfilename; | 55#ifdef __linux__ 56#include "../queue.h" 57#else 58#include <sys/queue.h> 59#endif 60 61#include "aicasm.h" 62#include "aicasm_symbol.h" 63#include "aicasm_insformat.h" 64 65int yylineno; 66char *yyfilename; |
67char *patch_arg_list; |
|
56char *versions; | 68char *versions; |
69static char errbuf[255]; 70static char regex_pattern[255]; |
|
57static symbol_t *cur_symbol; | 71static symbol_t *cur_symbol; |
72static symbol_t *scb_or_sram_symbol; |
|
58static symtype cur_symtype; | 73static symtype cur_symtype; |
59static symbol_t *accumulator; | 74static symbol_ref_t accumulator; 75static symbol_ref_t mode_ptr; |
60static symbol_ref_t allones; 61static symbol_ref_t allzeros; 62static symbol_ref_t none; 63static symbol_ref_t sindex; 64static int instruction_ptr; | 76static symbol_ref_t allones; 77static symbol_ref_t allzeros; 78static symbol_ref_t none; 79static symbol_ref_t sindex; 80static int instruction_ptr; |
81static int num_srams; |
|
65static int sram_or_scb_offset; 66static int download_constant_count; 67static int in_critical_section; 68 69static void process_bitmask(int mask_type, symbol_t *sym, int mask); 70static void initialize_symbol(symbol_t *symbol); | 82static int sram_or_scb_offset; 83static int download_constant_count; 84static int in_critical_section; 85 86static void process_bitmask(int mask_type, symbol_t *sym, int mask); 87static void initialize_symbol(symbol_t *symbol); |
88static void add_macro_arg(const char *argtext, int position); 89static void add_macro_body(const char *bodytext); |
|
71static void process_register(symbol_t **p_symbol); 72static void format_1_instr(int opcode, symbol_ref_t *dest, 73 expression_t *immed, symbol_ref_t *src, int ret); 74static void format_2_instr(int opcode, symbol_ref_t *dest, 75 expression_t *places, symbol_ref_t *src, int ret); 76static void format_3_instr(int opcode, symbol_ref_t *src, 77 expression_t *immed, symbol_ref_t *address); 78static void test_readable_symbol(symbol_t *symbol); 79static void test_writable_symbol(symbol_t *symbol); 80static void type_check(symbol_t *symbol, expression_t *expression, int and_op); 81static void make_expression(expression_t *immed, int value); 82static void add_conditional(symbol_t *symbol); 83static void add_version(const char *verstring); 84static int is_download_const(expression_t *immed); 85 | 90static void process_register(symbol_t **p_symbol); 91static void format_1_instr(int opcode, symbol_ref_t *dest, 92 expression_t *immed, symbol_ref_t *src, int ret); 93static void format_2_instr(int opcode, symbol_ref_t *dest, 94 expression_t *places, symbol_ref_t *src, int ret); 95static void format_3_instr(int opcode, symbol_ref_t *src, 96 expression_t *immed, symbol_ref_t *address); 97static void test_readable_symbol(symbol_t *symbol); 98static void test_writable_symbol(symbol_t *symbol); 99static void type_check(symbol_t *symbol, expression_t *expression, int and_op); 100static void make_expression(expression_t *immed, int value); 101static void add_conditional(symbol_t *symbol); 102static void add_version(const char *verstring); 103static int is_download_const(expression_t *immed); 104 |
86#define YYDEBUG 1 | |
87#define SRAM_SYMNAME "SRAM_BASE" 88#define SCB_SYMNAME "SCB_BASE" 89%} 90 91%union { | 105#define SRAM_SYMNAME "SRAM_BASE" 106#define SCB_SYMNAME "SCB_BASE" 107%} 108 109%union { |
92 int value; | 110 u_int value; |
93 char *str; 94 symbol_t *sym; 95 symbol_ref_t sym_ref; 96 expression_t expression; 97} 98 99%token T_REGISTER 100 101%token <value> T_CONST 102 | 111 char *str; 112 symbol_t *sym; 113 symbol_ref_t sym_ref; 114 expression_t expression; 115} 116 117%token T_REGISTER 118 119%token <value> T_CONST 120 |
121%token T_EXPORT 122 |
|
103%token T_DOWNLOAD 104 105%token T_SCB 106 107%token T_SRAM 108 109%token T_ALIAS 110 111%token T_SIZE 112 | 123%token T_DOWNLOAD 124 125%token T_SCB 126 127%token T_SRAM 128 129%token T_ALIAS 130 131%token T_SIZE 132 |
133%token T_EXPR_LSHIFT 134 135%token T_EXPR_RSHIFT 136 |
|
113%token <value> T_ADDRESS 114 115%token T_ACCESS_MODE 116 | 137%token <value> T_ADDRESS 138 139%token T_ACCESS_MODE 140 |
141%token T_MODES 142 143%token T_DEFINE 144 145%token T_SET_SRC_MODE 146 147%token T_SET_DST_MODE 148 |
|
117%token <value> T_MODE 118 119%token T_BEGIN_CS 120 121%token T_END_CS 122 123%token T_BIT 124 125%token T_MASK 126 127%token <value> T_NUMBER 128 | 149%token <value> T_MODE 150 151%token T_BEGIN_CS 152 153%token T_END_CS 154 155%token T_BIT 156 157%token T_MASK 158 159%token <value> T_NUMBER 160 |
129%token | 161%token <str> T_PATH T_STRING T_ARG T_MACROBODY |
130 131%token <sym> T_CEXPR 132 | 162 163%token <sym> T_CEXPR 164 |
133%token T_EOF T_INCLUDE T_VERSION | 165%token T_EOF T_INCLUDE T_VERSION T_PATCH_ARG_LIST |
134 135%token <value> T_SHR T_SHL T_ROR T_ROL 136 137%token <value> T_MVI T_MOV T_CLR T_BMOV 138 139%token <value> T_JMP T_JC T_JNC T_JE T_JNE T_JNZ T_JZ T_CALL 140 141%token <value> T_ADD T_ADC --- 7 unchanged lines hidden (view full) --- 149%token <value> T_TEST T_AND 150 151%token <value> T_OR 152 153%token T_RET 154 155%token T_NOP 156 | 166 167%token <value> T_SHR T_SHL T_ROR T_ROL 168 169%token <value> T_MVI T_MOV T_CLR T_BMOV 170 171%token <value> T_JMP T_JC T_JNC T_JE T_JNE T_JNZ T_JZ T_CALL 172 173%token <value> T_ADD T_ADC --- 7 unchanged lines hidden (view full) --- 181%token <value> T_TEST T_AND 182 183%token <value> T_OR 184 185%token T_RET 186 187%token T_NOP 188 |
157%token T_ACCUM T_ALLONES T_ALLZEROS T_NONE T_SINDEX | 189%token T_ACCUM T_ALLONES T_ALLZEROS T_NONE T_SINDEX T_MODE_PTR |
158 159%token T_A 160 161%token <sym> T_SYMBOL 162 163%token T_NL 164 165%token T_IF T_ELSE T_ELSE_IF T_ENDIF 166 167%type <sym_ref> reg_symbol address destination source opt_source 168 169%type <expression> expression immediate immediate_or_a 170 | 190 191%token T_A 192 193%token <sym> T_SYMBOL 194 195%token T_NL 196 197%token T_IF T_ELSE T_ELSE_IF T_ENDIF 198 199%type <sym_ref> reg_symbol address destination source opt_source 200 201%type <expression> expression immediate immediate_or_a 202 |
171%type | 203%type <value> export ret f1_opcode f2_opcode jmp_jc_jnc_call jz_jnz je_jne |
172 | 204 |
173%type | 205%type <value> numerical_value mode_value mode_list macro_arglist |
174 175%left '|' 176%left '&' | 206 207%left '|' 208%left '&' |
209%left T_EXPR_LSHIFT T_EXPR_RSHIFT |
|
177%left '+' '-' | 210%left '+' '-' |
211%left '*' '/' |
|
178%right '~' 179%nonassoc UMINUS 180%% 181 182program: 183 include 184| program include | 212%right '~' 213%nonassoc UMINUS 214%% 215 216program: 217 include 218| program include |
219| patch_arg_list 220| program patch_arg_list |
|
185| version 186| program version 187| register 188| program register 189| constant 190| program constant | 221| version 222| program version 223| register 224| program register 225| constant 226| program constant |
227| macrodefn 228| program macrodefn |
|
191| scratch_ram 192| program scratch_ram 193| scb 194| program scb 195| label 196| program label | 229| scratch_ram 230| program scratch_ram 231| scb 232| program scb 233| label 234| program label |
235| set_src_mode 236| program set_src_mode 237| set_dst_mode 238| program set_dst_mode |
|
197| critical_section_start 198| program critical_section_start 199| critical_section_end 200| program critical_section_end 201| conditional 202| program conditional 203| code 204| program code --- 5 unchanged lines hidden (view full) --- 210 include_file($3, BRACKETED_INCLUDE); 211 } 212| T_INCLUDE '"' T_PATH '"' 213 { 214 include_file($3, QUOTED_INCLUDE); 215 } 216; 217 | 239| critical_section_start 240| program critical_section_start 241| critical_section_end 242| program critical_section_end 243| conditional 244| program conditional 245| code 246| program code --- 5 unchanged lines hidden (view full) --- 252 include_file($3, BRACKETED_INCLUDE); 253 } 254| T_INCLUDE '"' T_PATH '"' 255 { 256 include_file($3, QUOTED_INCLUDE); 257 } 258; 259 |
260patch_arg_list: 261 T_PATCH_ARG_LIST '=' T_STRING 262 { 263 if (patch_arg_list != NULL) 264 stop("Patch argument list multiply defined", 265 EX_DATAERR); 266 patch_arg_list = strdup($3); 267 if (patch_arg_list == NULL) 268 stop("Unable to record patch arg list", EX_SOFTWARE); 269 } 270; 271 |
|
218version: 219 T_VERSION '=' T_STRING 220 { add_version($3); } 221; 222 223register: 224 T_REGISTER { cur_symtype = REGISTER; } reg_definition 225; --- 40 unchanged lines hidden (view full) --- 266 reg_attribute 267| reg_attribute_list reg_attribute 268; 269 270reg_attribute: 271 reg_address 272| size 273| access_mode | 272version: 273 T_VERSION '=' T_STRING 274 { add_version($3); } 275; 276 277register: 278 T_REGISTER { cur_symtype = REGISTER; } reg_definition 279; --- 40 unchanged lines hidden (view full) --- 320 reg_attribute 321| reg_attribute_list reg_attribute 322; 323 324reg_attribute: 325 reg_address 326| size 327| access_mode |
328| modes |
|
274| bit_defn 275| mask_defn 276| alias 277| accumulator | 329| bit_defn 330| mask_defn 331| alias 332| accumulator |
333| mode_pointer |
|
278| allones 279| allzeros 280| none 281| sindex 282; 283 284reg_address: 285 T_ADDRESS T_NUMBER 286 { 287 cur_symbol->info.rinfo->address = $2; 288 } 289; 290 291size: 292 T_SIZE T_NUMBER 293 { 294 cur_symbol->info.rinfo->size = $2; | 334| allones 335| allzeros 336| none 337| sindex 338; 339 340reg_address: 341 T_ADDRESS T_NUMBER 342 { 343 cur_symbol->info.rinfo->address = $2; 344 } 345; 346 347size: 348 T_SIZE T_NUMBER 349 { 350 cur_symbol->info.rinfo->size = $2; |
351 if (scb_or_sram_symbol != NULL) { 352 u_int max_addr; 353 u_int sym_max_addr; 354 355 max_addr = scb_or_sram_symbol->info.rinfo->address 356 + scb_or_sram_symbol->info.rinfo->size; 357 sym_max_addr = cur_symbol->info.rinfo->address 358 + cur_symbol->info.rinfo->size; 359 360 if (sym_max_addr > max_addr) 361 stop("SCB or SRAM space exhausted", EX_DATAERR); 362 } |
|
295 } 296; 297 298access_mode: 299 T_ACCESS_MODE T_MODE 300 { 301 cur_symbol->info.rinfo->mode = $2; 302 } 303; 304 | 363 } 364; 365 366access_mode: 367 T_ACCESS_MODE T_MODE 368 { 369 cur_symbol->info.rinfo->mode = $2; 370 } 371; 372 |
373modes: 374 T_MODES mode_list 375 { 376 cur_symbol->info.rinfo->modes = $2; 377 } 378; 379 380mode_list: 381 mode_value 382 { 383 $$ = $1; 384 } 385| mode_list ',' mode_value 386 { 387 $$ = $1 | $3; 388 } 389; 390 391mode_value: 392 T_NUMBER 393 { 394 if ($1 > 4) { 395 stop("Valid register modes range between 0 and 4.", 396 EX_DATAERR); 397 /* NOTREACHED */ 398 } 399 400 $$ = (0x1 << $1); 401 } 402| T_SYMBOL 403 { 404 symbol_t *symbol; 405 406 symbol = $1; 407 if (symbol->type != CONST) { 408 stop("Only \"const\" symbols allowed in " 409 "mode definitions.", EX_DATAERR); 410 /* NOTREACHED */ 411 } 412 if (symbol->info.cinfo->value > 4) { 413 stop("Valid register modes range between 0 and 4.", 414 EX_DATAERR); 415 /* NOTREACHED */ 416 } 417 $$ = (0x1 << symbol->info.cinfo->value); 418 } 419; 420 |
|
305bit_defn: 306 T_BIT T_SYMBOL T_NUMBER 307 { 308 process_bitmask(BIT, $2, $3); 309 } 310; 311 312mask_defn: --- 15 unchanged lines hidden (view full) --- 328 initialize_symbol($2); 329 $2->info.ainfo->parent = cur_symbol; 330 } 331; 332 333accumulator: 334 T_ACCUM 335 { | 421bit_defn: 422 T_BIT T_SYMBOL T_NUMBER 423 { 424 process_bitmask(BIT, $2, $3); 425 } 426; 427 428mask_defn: --- 15 unchanged lines hidden (view full) --- 444 initialize_symbol($2); 445 $2->info.ainfo->parent = cur_symbol; 446 } 447; 448 449accumulator: 450 T_ACCUM 451 { |
336 if (accumulator != NULL) { | 452 if (accumulator.symbol != NULL) { |
337 stop("Only one accumulator definition allowed", 338 EX_DATAERR); 339 /* NOTREACHED */ 340 } | 453 stop("Only one accumulator definition allowed", 454 EX_DATAERR); 455 /* NOTREACHED */ 456 } |
341 accumulator = cur_symbol; | 457 accumulator.symbol = cur_symbol; |
342 } 343; 344 | 458 } 459; 460 |
461mode_pointer: 462 T_MODE_PTR 463 { 464 if (mode_ptr.symbol != NULL) { 465 stop("Only one mode pointer definition allowed", 466 EX_DATAERR); 467 /* NOTREACHED */ 468 } 469 mode_ptr.symbol = cur_symbol; 470 } 471; 472 |
|
345allones: 346 T_ALLONES 347 { 348 if (allones.symbol != NULL) { 349 stop("Only one definition of allones allowed", 350 EX_DATAERR); 351 /* NOTREACHED */ 352 } --- 61 unchanged lines hidden (view full) --- 414 } 415| expression '-' expression 416 { 417 $$.value = $1.value - $3.value; 418 symlist_merge(&($$.referenced_syms), 419 &($1.referenced_syms), 420 &($3.referenced_syms)); 421 } | 473allones: 474 T_ALLONES 475 { 476 if (allones.symbol != NULL) { 477 stop("Only one definition of allones allowed", 478 EX_DATAERR); 479 /* NOTREACHED */ 480 } --- 61 unchanged lines hidden (view full) --- 542 } 543| expression '-' expression 544 { 545 $$.value = $1.value - $3.value; 546 symlist_merge(&($$.referenced_syms), 547 &($1.referenced_syms), 548 &($3.referenced_syms)); 549 } |
550| expression '*' expression 551 { 552 $$.value = $1.value * $3.value; 553 symlist_merge(&($$.referenced_syms), 554 &($1.referenced_syms), 555 &($3.referenced_syms)); 556 } 557| expression '/' expression 558 { 559 $$.value = $1.value / $3.value; 560 symlist_merge(&($$.referenced_syms), 561 &($1.referenced_syms), 562 &($3.referenced_syms)); 563 } 564| expression T_EXPR_LSHIFT expression 565 { 566 $$.value = $1.value << $3.value; 567 symlist_merge(&$$.referenced_syms, 568 &$1.referenced_syms, 569 &$3.referenced_syms); 570 } 571| expression T_EXPR_RSHIFT expression 572 { 573 $$.value = $1.value >> $3.value; 574 symlist_merge(&$$.referenced_syms, 575 &$1.referenced_syms, 576 &$3.referenced_syms); 577 } |
|
422| '(' expression ')' 423 { 424 $$ = $2; 425 } 426| '~' expression 427 { 428 $$ = $2; 429 $$.value = (~$$.value) & 0xFF; --- 27 unchanged lines hidden (view full) --- 457 break; 458 case DOWNLOAD_CONST: 459 case CONST: 460 $$.value = symbol->info.cinfo->value; 461 break; 462 case UNINITIALIZED: 463 default: 464 { | 578| '(' expression ')' 579 { 580 $$ = $2; 581 } 582| '~' expression 583 { 584 $$ = $2; 585 $$.value = (~$$.value) & 0xFF; --- 27 unchanged lines hidden (view full) --- 613 break; 614 case DOWNLOAD_CONST: 615 case CONST: 616 $$.value = symbol->info.cinfo->value; 617 break; 618 case UNINITIALIZED: 619 default: 620 { |
465 char buf[255]; 466 467 snprintf(buf, sizeof(buf), | 621 snprintf(errbuf, sizeof(errbuf), |
468 "Undefined symbol %s referenced", 469 symbol->name); | 622 "Undefined symbol %s referenced", 623 symbol->name); |
470 stop(buf, EX_DATAERR); | 624 stop(errbuf, EX_DATAERR); |
471 /* NOTREACHED */ 472 break; 473 } 474 } 475 SLIST_INIT(&$$.referenced_syms); 476 symlist_add(&$$.referenced_syms, symbol, SYMLIST_INSERT_HEAD); 477 } 478; --- 4 unchanged lines hidden (view full) --- 483 if ($2->type != UNINITIALIZED) { 484 stop("Re-definition of symbol as a constant", 485 EX_DATAERR); 486 /* NOTREACHED */ 487 } 488 $2->type = CONST; 489 initialize_symbol($2); 490 $2->info.cinfo->value = $3; | 625 /* NOTREACHED */ 626 break; 627 } 628 } 629 SLIST_INIT(&$$.referenced_syms); 630 symlist_add(&$$.referenced_syms, symbol, SYMLIST_INSERT_HEAD); 631 } 632; --- 4 unchanged lines hidden (view full) --- 637 if ($2->type != UNINITIALIZED) { 638 stop("Re-definition of symbol as a constant", 639 EX_DATAERR); 640 /* NOTREACHED */ 641 } 642 $2->type = CONST; 643 initialize_symbol($2); 644 $2->info.cinfo->value = $3; |
491 $2->info.cinfo->define = $1; | |
492 } 493| T_CONST T_SYMBOL T_DOWNLOAD 494 { 495 if ($1) { 496 stop("Invalid downloaded constant declaration", 497 EX_DATAERR); 498 /* NOTREACHED */ 499 } 500 if ($2->type != UNINITIALIZED) { 501 stop("Re-definition of symbol as a downloaded constant", 502 EX_DATAERR); 503 /* NOTREACHED */ 504 } 505 $2->type = DOWNLOAD_CONST; 506 initialize_symbol($2); 507 $2->info.cinfo->value = download_constant_count++; | 645 } 646| T_CONST T_SYMBOL T_DOWNLOAD 647 { 648 if ($1) { 649 stop("Invalid downloaded constant declaration", 650 EX_DATAERR); 651 /* NOTREACHED */ 652 } 653 if ($2->type != UNINITIALIZED) { 654 stop("Re-definition of symbol as a downloaded constant", 655 EX_DATAERR); 656 /* NOTREACHED */ 657 } 658 $2->type = DOWNLOAD_CONST; 659 initialize_symbol($2); 660 $2->info.cinfo->value = download_constant_count++; |
508 $2->info.cinfo->define = FALSE; | |
509 } 510; 511 | 661 } 662; 663 |
664macrodefn_prologue: 665 T_DEFINE T_SYMBOL 666 { 667 if ($2->type != UNINITIALIZED) { 668 stop("Re-definition of symbol as a macro", 669 EX_DATAERR); 670 /* NOTREACHED */ 671 } 672 cur_symbol = $2; 673 cur_symbol->type = MACRO; 674 initialize_symbol(cur_symbol); 675 } 676; 677 678macrodefn: 679 macrodefn_prologue T_MACROBODY 680 { 681 add_macro_body($2); 682 } 683| macrodefn_prologue '(' macro_arglist ')' T_MACROBODY 684 { 685 add_macro_body($5); 686 cur_symbol->info.macroinfo->narg = $3; 687 } 688; 689 690macro_arglist: 691 { 692 /* Macros can take no arguments */ 693 $$ = 0; 694 } 695| T_ARG 696 { 697 $$ = 1; 698 add_macro_arg($1, 0); 699 } 700| macro_arglist ',' T_ARG 701 { 702 if ($1 == 0) { 703 stop("Comma without preceeding argument in arg list", 704 EX_DATAERR); 705 /* NOTREACHED */ 706 } 707 $$ = $1 + 1; 708 add_macro_arg($3, $1); 709 } 710; 711 |
|
512numerical_value: 513 T_NUMBER 514 { 515 $$ = $1; 516 } 517| '-' T_NUMBER 518 { 519 $$ = -$2; 520 } 521; 522 523scratch_ram: 524 T_SRAM '{' 525 { | 712numerical_value: 713 T_NUMBER 714 { 715 $$ = $1; 716 } 717| '-' T_NUMBER 718 { 719 $$ = -$2; 720 } 721; 722 723scratch_ram: 724 T_SRAM '{' 725 { |
726 snprintf(errbuf, sizeof(errbuf), "%s%d", SRAM_SYMNAME, 727 num_srams); |
|
526 cur_symbol = symtable_get(SRAM_SYMNAME); 527 cur_symtype = SRAMLOC; | 728 cur_symbol = symtable_get(SRAM_SYMNAME); 729 cur_symtype = SRAMLOC; |
528 if (cur_symbol->type != UNINITIALIZED) { 529 stop("Only one SRAM definition allowed", 530 EX_DATAERR); 531 /* NOTREACHED */ 532 } | |
533 cur_symbol->type = SRAMLOC; 534 initialize_symbol(cur_symbol); 535 } 536 reg_address 537 { 538 sram_or_scb_offset = cur_symbol->info.rinfo->address; 539 } | 730 cur_symbol->type = SRAMLOC; 731 initialize_symbol(cur_symbol); 732 } 733 reg_address 734 { 735 sram_or_scb_offset = cur_symbol->info.rinfo->address; 736 } |
540 scb_or_sram_reg_list | 737 size 738 { 739 scb_or_sram_symbol = cur_symbol; 740 } 741 scb_or_sram_attributes |
541 '}' 542 { 543 cur_symbol = NULL; | 742 '}' 743 { 744 cur_symbol = NULL; |
745 scb_or_sram_symbol = NULL; |
|
544 } 545; 546 547scb: 548 T_SCB '{' 549 { 550 cur_symbol = symtable_get(SCB_SYMNAME); 551 cur_symtype = SCBLOC; --- 6 unchanged lines hidden (view full) --- 558 initialize_symbol(cur_symbol); 559 /* 64 bytes of SCB space */ 560 cur_symbol->info.rinfo->size = 64; 561 } 562 reg_address 563 { 564 sram_or_scb_offset = cur_symbol->info.rinfo->address; 565 } | 746 } 747; 748 749scb: 750 T_SCB '{' 751 { 752 cur_symbol = symtable_get(SCB_SYMNAME); 753 cur_symtype = SCBLOC; --- 6 unchanged lines hidden (view full) --- 760 initialize_symbol(cur_symbol); 761 /* 64 bytes of SCB space */ 762 cur_symbol->info.rinfo->size = 64; 763 } 764 reg_address 765 { 766 sram_or_scb_offset = cur_symbol->info.rinfo->address; 767 } |
566 scb_or_sram_reg_list | 768 size 769 { 770 scb_or_sram_symbol = cur_symbol; 771 } 772 scb_or_sram_attributes |
567 '}' 568 { 569 cur_symbol = NULL; | 773 '}' 774 { 775 cur_symbol = NULL; |
776 scb_or_sram_symbol = NULL; |
|
570 } 571; 572 | 777 } 778; 779 |
780scb_or_sram_attributes: 781 /* NULL definition is okay */ 782| modes 783| scb_or_sram_reg_list 784| modes scb_or_sram_reg_list 785; 786 |
|
573scb_or_sram_reg_list: 574 reg_definition 575| scb_or_sram_reg_list reg_definition 576; 577 578reg_symbol: 579 T_SYMBOL 580 { --- 24 unchanged lines hidden (view full) --- 605 EX_DATAERR); 606 /* NOTREACHED */ 607 } 608 $$.symbol = $1; 609 $$.offset = $3; 610 } 611| T_A 612 { | 787scb_or_sram_reg_list: 788 reg_definition 789| scb_or_sram_reg_list reg_definition 790; 791 792reg_symbol: 793 T_SYMBOL 794 { --- 24 unchanged lines hidden (view full) --- 819 EX_DATAERR); 820 /* NOTREACHED */ 821 } 822 $$.symbol = $1; 823 $$.offset = $3; 824 } 825| T_A 826 { |
613 if (accumulator == NULL) { | 827 if (accumulator.symbol == NULL) { |
614 stop("No accumulator has been defined", EX_DATAERR); 615 /* NOTREACHED */ 616 } | 828 stop("No accumulator has been defined", EX_DATAERR); 829 /* NOTREACHED */ 830 } |
617 $$.symbol = accumulator; | 831 $$.symbol = accumulator.symbol; |
618 $$.offset = 0; 619 } 620; 621 622destination: 623 reg_symbol 624 { 625 test_writable_symbol($1.symbol); --- 4 unchanged lines hidden (view full) --- 630immediate: 631 expression 632 { $$ = $1; } 633; 634 635immediate_or_a: 636 expression 637 { | 832 $$.offset = 0; 833 } 834; 835 836destination: 837 reg_symbol 838 { 839 test_writable_symbol($1.symbol); --- 4 unchanged lines hidden (view full) --- 844immediate: 845 expression 846 { $$ = $1; } 847; 848 849immediate_or_a: 850 expression 851 { |
852 if ($1.value == 0 && is_download_const(&$1) == 0) { 853 snprintf(errbuf, sizeof(errbuf), 854 "\nExpression evaluates to 0 and thus " 855 "references the accumulator.\n " 856 "If this is the desired effect, use 'A' " 857 "instead.\n"); 858 stop(errbuf, EX_DATAERR); 859 } |
|
638 $$ = $1; 639 } 640| T_A 641 { 642 SLIST_INIT(&$$.referenced_syms); 643 $$.value = 0; 644 } 645; --- 16 unchanged lines hidden (view full) --- 662; 663 664ret: 665 { $$ = 0; } 666| T_RET 667 { $$ = 1; } 668; 669 | 860 $$ = $1; 861 } 862| T_A 863 { 864 SLIST_INIT(&$$.referenced_syms); 865 $$.value = 0; 866 } 867; --- 16 unchanged lines hidden (view full) --- 884; 885 886ret: 887 { $$ = 0; } 888| T_RET 889 { $$ = 1; } 890; 891 |
892set_src_mode: 893 T_SET_SRC_MODE T_NUMBER ';' 894 { 895 src_mode = $2; 896 } 897; 898 899set_dst_mode: 900 T_SET_DST_MODE T_NUMBER ';' 901 { 902 dst_mode = $2; 903 } 904; 905 |
|
670critical_section_start: | 906critical_section_start: |
671 T_BEGIN_CS | 907 T_BEGIN_CS ';' |
672 { 673 critical_section_t *cs; 674 675 if (in_critical_section != FALSE) { 676 stop("Critical Section within Critical Section", 677 EX_DATAERR); 678 /* NOTREACHED */ 679 } 680 cs = cs_alloc(); 681 cs->begin_addr = instruction_ptr; 682 in_critical_section = TRUE; 683 } 684 685critical_section_end: | 908 { 909 critical_section_t *cs; 910 911 if (in_critical_section != FALSE) { 912 stop("Critical Section within Critical Section", 913 EX_DATAERR); 914 /* NOTREACHED */ 915 } 916 cs = cs_alloc(); 917 cs->begin_addr = instruction_ptr; 918 in_critical_section = TRUE; 919 } 920 921critical_section_end: |
686 T_END_CS | 922 T_END_CS ';' |
687 { 688 critical_section_t *cs; 689 690 if (in_critical_section == FALSE) { 691 stop("Unballanced 'end_cs'", EX_DATAERR); 692 /* NOTREACHED */ 693 } 694 cs = TAILQ_LAST(&cs_tailq, cs_tailq); 695 cs->end_addr = instruction_ptr; 696 in_critical_section = FALSE; 697 } 698 | 923 { 924 critical_section_t *cs; 925 926 if (in_critical_section == FALSE) { 927 stop("Unballanced 'end_cs'", EX_DATAERR); 928 /* NOTREACHED */ 929 } 930 cs = TAILQ_LAST(&cs_tailq, cs_tailq); 931 cs->end_addr = instruction_ptr; 932 in_critical_section = FALSE; 933 } 934 |
935export: 936 { $$ = 0; } 937| T_EXPORT 938 { $$ = 1; } 939; 940 |
|
699label: | 941label: |
700 T_SYMBOL ':' | 942 export T_SYMBOL ':' |
701 { | 943 { |
702 if ($1->type != UNINITIALIZED) { | 944 if ($2->type != UNINITIALIZED) { |
703 stop("Program label multiply defined", EX_DATAERR); 704 /* NOTREACHED */ 705 } | 945 stop("Program label multiply defined", EX_DATAERR); 946 /* NOTREACHED */ 947 } |
706 $1->type = LABEL; 707 initialize_symbol($1); 708 $1->info.linfo->address = instruction_ptr; | 948 $2->type = LABEL; 949 initialize_symbol($2); 950 $2->info.linfo->address = instruction_ptr; 951 $2->info.linfo->exported = $1; |
709 } 710; 711 712address: 713 T_SYMBOL 714 { 715 $$.symbol = $1; 716 $$.offset = 0; --- 397 unchanged lines hidden (view full) --- 1114 symbol->info.rinfo = 1115 (struct reg_info *)malloc(sizeof(struct reg_info)); 1116 if (symbol->info.rinfo == NULL) { 1117 stop("Can't create register info", EX_SOFTWARE); 1118 /* NOTREACHED */ 1119 } 1120 memset(symbol->info.rinfo, 0, 1121 sizeof(struct reg_info)); | 952 } 953; 954 955address: 956 T_SYMBOL 957 { 958 $$.symbol = $1; 959 $$.offset = 0; --- 397 unchanged lines hidden (view full) --- 1357 symbol->info.rinfo = 1358 (struct reg_info *)malloc(sizeof(struct reg_info)); 1359 if (symbol->info.rinfo == NULL) { 1360 stop("Can't create register info", EX_SOFTWARE); 1361 /* NOTREACHED */ 1362 } 1363 memset(symbol->info.rinfo, 0, 1364 sizeof(struct reg_info)); |
1365 /* 1366 * Default to allowing access in all register modes 1367 * or to the mode specified by the SCB or SRAM space 1368 * we are in. 1369 */ 1370 if (scb_or_sram_symbol != NULL) 1371 symbol->info.rinfo->modes = 1372 scb_or_sram_symbol->info.rinfo->modes; 1373 else 1374 symbol->info.rinfo->modes = ~0; |
|
1122 break; 1123 case ALIAS: 1124 symbol->info.ainfo = 1125 (struct alias_info *)malloc(sizeof(struct alias_info)); 1126 if (symbol->info.ainfo == NULL) { 1127 stop("Can't create alias info", EX_SOFTWARE); 1128 /* NOTREACHED */ 1129 } --- 37 unchanged lines hidden (view full) --- 1167 (struct cond_info *)malloc(sizeof(struct cond_info)); 1168 if (symbol->info.condinfo == NULL) { 1169 stop("Can't create conditional info", EX_SOFTWARE); 1170 /* NOTREACHED */ 1171 } 1172 memset(symbol->info.condinfo, 0, 1173 sizeof(struct cond_info)); 1174 break; | 1375 break; 1376 case ALIAS: 1377 symbol->info.ainfo = 1378 (struct alias_info *)malloc(sizeof(struct alias_info)); 1379 if (symbol->info.ainfo == NULL) { 1380 stop("Can't create alias info", EX_SOFTWARE); 1381 /* NOTREACHED */ 1382 } --- 37 unchanged lines hidden (view full) --- 1420 (struct cond_info *)malloc(sizeof(struct cond_info)); 1421 if (symbol->info.condinfo == NULL) { 1422 stop("Can't create conditional info", EX_SOFTWARE); 1423 /* NOTREACHED */ 1424 } 1425 memset(symbol->info.condinfo, 0, 1426 sizeof(struct cond_info)); 1427 break; |
1428 case MACRO: 1429 symbol->info.macroinfo = 1430 (struct macro_info *)malloc(sizeof(struct macro_info)); 1431 if (symbol->info.macroinfo == NULL) { 1432 stop("Can't create macro info", EX_SOFTWARE); 1433 /* NOTREACHED */ 1434 } 1435 memset(symbol->info.macroinfo, 0, 1436 sizeof(struct macro_info)); 1437 STAILQ_INIT(&symbol->info.macroinfo->args); 1438 break; |
|
1175 default: 1176 stop("Call to initialize_symbol with invalid symbol type", 1177 EX_SOFTWARE); 1178 /* NOTREACHED */ 1179 break; 1180 } 1181} 1182 1183static void | 1439 default: 1440 stop("Call to initialize_symbol with invalid symbol type", 1441 EX_SOFTWARE); 1442 /* NOTREACHED */ 1443 break; 1444 } 1445} 1446 1447static void |
1448add_macro_arg(const char *argtext, int argnum) 1449{ 1450 struct macro_arg *marg; 1451 int i; 1452 int retval; 1453 1454 1455 if (cur_symbol == NULL || cur_symbol->type != MACRO) { 1456 stop("Invalid current symbol for adding macro arg", 1457 EX_SOFTWARE); 1458 /* NOTREACHED */ 1459 } 1460 1461 marg = (struct macro_arg *)malloc(sizeof(*marg)); 1462 if (marg == NULL) { 1463 stop("Can't create macro_arg structure", EX_SOFTWARE); 1464 /* NOTREACHED */ 1465 } 1466 marg->replacement_text = NULL; 1467 retval = snprintf(regex_pattern, sizeof(regex_pattern), 1468 "[^-/A-Za-z0-9_](%s)([^-/A-Za-z0-9_]|$)", 1469 argtext); 1470 if (retval >= sizeof(regex_pattern)) { 1471 stop("Regex text buffer too small for arg", 1472 EX_SOFTWARE); 1473 /* NOTREACHED */ 1474 } 1475 retval = regcomp(&marg->arg_regex, regex_pattern, REG_EXTENDED); 1476 if (retval != 0) { 1477 stop("Regex compilation failed", EX_SOFTWARE); 1478 /* NOTREACHED */ 1479 } 1480 STAILQ_INSERT_TAIL(&cur_symbol->info.macroinfo->args, marg, links); 1481} 1482 1483static void 1484add_macro_body(const char *bodytext) 1485{ 1486 if (cur_symbol == NULL || cur_symbol->type != MACRO) { 1487 stop("Invalid current symbol for adding macro arg", 1488 EX_SOFTWARE); 1489 /* NOTREACHED */ 1490 } 1491 cur_symbol->info.macroinfo->body = strdup(bodytext); 1492 if (cur_symbol->info.macroinfo->body == NULL) { 1493 stop("Can't duplicate macro body text", EX_SOFTWARE); 1494 /* NOTREACHED */ 1495 } 1496} 1497 1498static void |
|
1184process_register(symbol_t **p_symbol) 1185{ | 1499process_register(symbol_t **p_symbol) 1500{ |
1186 char buf[255]; | |
1187 symbol_t *symbol = *p_symbol; 1188 1189 if (symbol->type == UNINITIALIZED) { | 1501 symbol_t *symbol = *p_symbol; 1502 1503 if (symbol->type == UNINITIALIZED) { |
1190 snprintf(buf, sizeof(buf), "Undefined register %s", | 1504 snprintf(errbuf, sizeof(errbuf), "Undefined register %s", |
1191 symbol->name); | 1505 symbol->name); |
1192 stop(buf, EX_DATAERR); | 1506 stop(errbuf, EX_DATAERR); |
1193 /* NOTREACHED */ 1194 } else if (symbol->type == ALIAS) { 1195 *p_symbol = symbol->info.ainfo->parent; 1196 } else if ((symbol->type != REGISTER) 1197 && (symbol->type != SCBLOC) 1198 && (symbol->type != SRAMLOC)) { | 1507 /* NOTREACHED */ 1508 } else if (symbol->type == ALIAS) { 1509 *p_symbol = symbol->info.ainfo->parent; 1510 } else if ((symbol->type != REGISTER) 1511 && (symbol->type != SCBLOC) 1512 && (symbol->type != SRAMLOC)) { |
1199 snprintf(buf, sizeof(buf), | 1513 snprintf(errbuf, sizeof(errbuf), |
1200 "Specified symbol %s is not a register", 1201 symbol->name); | 1514 "Specified symbol %s is not a register", 1515 symbol->name); |
1202 stop(buf, EX_DATAERR); | 1516 stop(errbuf, EX_DATAERR); |
1203 } 1204} 1205 1206static void 1207format_1_instr(int opcode, symbol_ref_t *dest, expression_t *immed, 1208 symbol_ref_t *src, int ret) 1209{ 1210 struct instruction *instr; --- 17 unchanged lines hidden (view full) --- 1228 f1_instr->destination = dest->symbol->info.rinfo->address 1229 + dest->offset; 1230 f1_instr->source = src->symbol->info.rinfo->address 1231 + src->offset; 1232 f1_instr->immediate = immed->value; 1233 1234 if (is_download_const(immed)) 1235 f1_instr->parity = 1; | 1517 } 1518} 1519 1520static void 1521format_1_instr(int opcode, symbol_ref_t *dest, expression_t *immed, 1522 symbol_ref_t *src, int ret) 1523{ 1524 struct instruction *instr; --- 17 unchanged lines hidden (view full) --- 1542 f1_instr->destination = dest->symbol->info.rinfo->address 1543 + dest->offset; 1544 f1_instr->source = src->symbol->info.rinfo->address 1545 + src->offset; 1546 f1_instr->immediate = immed->value; 1547 1548 if (is_download_const(immed)) 1549 f1_instr->parity = 1; |
1550 else if (dest->symbol == mode_ptr.symbol) { 1551 u_int src_value; 1552 u_int dst_value; |
|
1236 | 1553 |
1554 /* 1555 * Attempt to update mode information if 1556 * we are operating on the mode register. 1557 */ 1558 if (src->symbol == allones.symbol) 1559 src_value = 0xFF; 1560 else if (src->symbol == allzeros.symbol) 1561 src_value = 0; 1562 else if (src->symbol == mode_ptr.symbol) 1563 src_value = (dst_mode << 4) | src_mode; 1564 else 1565 goto cant_update; 1566 1567 switch (opcode) { 1568 case AIC_OP_AND: 1569 dst_value = src_value & immed->value; 1570 break; 1571 case AIC_OP_XOR: 1572 dst_value = src_value ^ immed->value; 1573 break; 1574 case AIC_OP_ADD: 1575 dst_value = (src_value + immed->value) & 0xFF; 1576 break; 1577 case AIC_OP_OR: 1578 dst_value = src_value | immed->value; 1579 break; 1580 break; 1581 case AIC_OP_BMOV: 1582 dst_value = src_value; 1583 break; 1584 default: 1585 goto cant_update; 1586 } 1587 src_mode = dst_value & 0xF; 1588 dst_mode = (dst_value >> 4) & 0xF; 1589cant_update: 1590 } 1591 |
|
1237 symlist_free(&immed->referenced_syms); 1238 instruction_ptr++; 1239} 1240 1241static void 1242format_2_instr(int opcode, symbol_ref_t *dest, expression_t *places, 1243 symbol_ref_t *src, int ret) 1244{ --- 91 unchanged lines hidden (view full) --- 1336 1337 symlist_free(&immed->referenced_syms); 1338 instruction_ptr++; 1339} 1340 1341static void 1342test_readable_symbol(symbol_t *symbol) 1343{ | 1592 symlist_free(&immed->referenced_syms); 1593 instruction_ptr++; 1594} 1595 1596static void 1597format_2_instr(int opcode, symbol_ref_t *dest, expression_t *places, 1598 symbol_ref_t *src, int ret) 1599{ --- 91 unchanged lines hidden (view full) --- 1691 1692 symlist_free(&immed->referenced_syms); 1693 instruction_ptr++; 1694} 1695 1696static void 1697test_readable_symbol(symbol_t *symbol) 1698{ |
1699 1700 if ((symbol->info.rinfo->modes & (0x1 << src_mode)) == 0) { 1701 snprintf(errbuf, sizeof(errbuf), 1702 "Register %s unavailable in source reg mode %d", 1703 symbol->name, src_mode); 1704 stop(errbuf, EX_DATAERR); 1705 } 1706 |
|
1344 if (symbol->info.rinfo->mode == WO) { 1345 stop("Write Only register specified as source", 1346 EX_DATAERR); 1347 /* NOTREACHED */ 1348 } 1349} 1350 1351static void 1352test_writable_symbol(symbol_t *symbol) 1353{ | 1707 if (symbol->info.rinfo->mode == WO) { 1708 stop("Write Only register specified as source", 1709 EX_DATAERR); 1710 /* NOTREACHED */ 1711 } 1712} 1713 1714static void 1715test_writable_symbol(symbol_t *symbol) 1716{ |
1717 1718 if ((symbol->info.rinfo->modes & (0x1 << dst_mode)) == 0) { 1719 snprintf(errbuf, sizeof(errbuf), 1720 "Register %s unavailable in destination reg mode %d", 1721 symbol->name, dst_mode); 1722 stop(errbuf, EX_DATAERR); 1723 } 1724 |
|
1354 if (symbol->info.rinfo->mode == RO) { 1355 stop("Read Only register specified as destination", 1356 EX_DATAERR); 1357 /* NOTREACHED */ 1358 } 1359} 1360 1361static void 1362type_check(symbol_t *symbol, expression_t *expression, int opcode) 1363{ 1364 symbol_node_t *node; 1365 int and_op; | 1725 if (symbol->info.rinfo->mode == RO) { 1726 stop("Read Only register specified as destination", 1727 EX_DATAERR); 1728 /* NOTREACHED */ 1729 } 1730} 1731 1732static void 1733type_check(symbol_t *symbol, expression_t *expression, int opcode) 1734{ 1735 symbol_node_t *node; 1736 int and_op; |
1366 char buf[255]; | |
1367 1368 and_op = FALSE; 1369 if (opcode == AIC_OP_AND || opcode == AIC_OP_JNZ || AIC_OP_JZ) 1370 and_op = TRUE; 1371 1372 /* 1373 * Make sure that we aren't attempting to write something 1374 * that hasn't been defined. If this is an and operation, 1375 * this is a mask, so "undefined" bits are okay. 1376 */ 1377 if (and_op == FALSE 1378 && (expression->value & ~symbol->info.rinfo->valid_bitmask) != 0) { | 1737 1738 and_op = FALSE; 1739 if (opcode == AIC_OP_AND || opcode == AIC_OP_JNZ || AIC_OP_JZ) 1740 and_op = TRUE; 1741 1742 /* 1743 * Make sure that we aren't attempting to write something 1744 * that hasn't been defined. If this is an and operation, 1745 * this is a mask, so "undefined" bits are okay. 1746 */ 1747 if (and_op == FALSE 1748 && (expression->value & ~symbol->info.rinfo->valid_bitmask) != 0) { |
1379 snprintf(buf, sizeof(buf), | 1749 snprintf(errbuf, sizeof(errbuf), |
1380 "Invalid bit(s) 0x%x in immediate written to %s", 1381 expression->value & ~symbol->info.rinfo->valid_bitmask, 1382 symbol->name); | 1750 "Invalid bit(s) 0x%x in immediate written to %s", 1751 expression->value & ~symbol->info.rinfo->valid_bitmask, 1752 symbol->name); |
1383 stop(buf, EX_DATAERR); | 1753 stop(errbuf, EX_DATAERR); |
1384 /* NOTREACHED */ 1385 } 1386 1387 /* 1388 * Now make sure that all of the symbols referenced by the 1389 * expression are defined for this register. 1390 */ | 1754 /* NOTREACHED */ 1755 } 1756 1757 /* 1758 * Now make sure that all of the symbols referenced by the 1759 * expression are defined for this register. 1760 */ |
1391 if(symbol->info.rinfo->typecheck_masks != FALSE) { | 1761 if (symbol->info.rinfo->typecheck_masks != FALSE) { |
1392 for(node = expression->referenced_syms.slh_first; 1393 node != NULL; 1394 node = node->links.sle_next) { 1395 if ((node->symbol->type == MASK 1396 || node->symbol->type == BIT) 1397 && symlist_search(&node->symbol->info.minfo->symrefs, 1398 symbol->name) == NULL) { | 1762 for(node = expression->referenced_syms.slh_first; 1763 node != NULL; 1764 node = node->links.sle_next) { 1765 if ((node->symbol->type == MASK 1766 || node->symbol->type == BIT) 1767 && symlist_search(&node->symbol->info.minfo->symrefs, 1768 symbol->name) == NULL) { |
1399 snprintf(buf, sizeof(buf), | 1769 snprintf(errbuf, sizeof(errbuf), |
1400 "Invalid bit or mask %s " 1401 "for register %s", 1402 node->symbol->name, symbol->name); | 1770 "Invalid bit or mask %s " 1771 "for register %s", 1772 node->symbol->name, symbol->name); |
1403 stop(buf, EX_DATAERR); | 1773 stop(errbuf, EX_DATAERR); |
1404 /* NOTREACHED */ 1405 } 1406 } 1407 } 1408} 1409 1410static void 1411make_expression(expression_t *immed, int value) --- 77 unchanged lines hidden --- | 1774 /* NOTREACHED */ 1775 } 1776 } 1777 } 1778} 1779 1780static void 1781make_expression(expression_t *immed, int value) --- 77 unchanged lines hidden --- |