]> granicus.if.org Git - yasm/commitdiff
Change mem (other sized memory reference) to cause operand size mismatch error
authorPeter Johnson <peter@tortall.net>
Wed, 4 Jul 2001 20:53:21 +0000 (20:53 -0000)
committerPeter Johnson <peter@tortall.net>
Wed, 4 Jul 2001 20:53:21 +0000 (20:53 -0000)
if a size is specified.

svn path=/trunk/yasm/; revision=87

include/errwarn.h
libyasm/errwarn.c
libyasm/errwarn.h
modules/parsers/nasm/bison.y.in
modules/parsers/nasm/nasm-bison.y
src/bison.y.in
src/errwarn.c
src/errwarn.h
src/parsers/nasm/bison.y.in
src/parsers/nasm/nasm-bison.y

index 0d8d3c8f53a193d625c992cf457a43e727862446..6ef8e0132db86ff186859e4ac4705b86d9732560 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: errwarn.h,v 1.7 2001/06/28 21:22:01 peter Exp $
+/* $Id: errwarn.h,v 1.8 2001/07/04 20:53:21 peter Exp $
  * Error and warning reporting and related functions header file.
  *
  *  Copyright (C) 2001  Peter Johnson
@@ -40,7 +40,8 @@ typedef enum {
     ERR_INVALID_EA,
     ERR_INVALID_LINE,
     ERR_EXP_SYNTAX,
-    ERR_DUPLICATE_DEF
+    ERR_DUPLICATE_DEF,
+    ERR_OP_SIZE_MISMATCH
 } err_num;
 
 void Error(err_num, char *, ...);
index d072d584559bc4f08da2f0c63276b942c8fdcb9a..d76a97488d6df36dfc2f1f95d06b20bd2482e9af 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: errwarn.c,v 1.12 2001/06/29 02:12:15 peter Exp $
+/* $Id: errwarn.c,v 1.13 2001/07/04 20:53:21 peter Exp $
  * Error and warning reporting and related functions.
  *
  *  Copyright (C) 2001  Peter Johnson
@@ -55,7 +55,8 @@ static char *err_msgs[] = {
     "invalid effective address",
     "label or instruction expected at start of line",
     "expression syntax error",
-    "duplicate definition of `%s'; previously defined line %d"
+    "duplicate definition of `%s'; previously defined line %d",
+    "mismatch in operand sizes"
 };
 
 static char *warn_msgs[] = {
index 0d8d3c8f53a193d625c992cf457a43e727862446..6ef8e0132db86ff186859e4ac4705b86d9732560 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: errwarn.h,v 1.7 2001/06/28 21:22:01 peter Exp $
+/* $Id: errwarn.h,v 1.8 2001/07/04 20:53:21 peter Exp $
  * Error and warning reporting and related functions header file.
  *
  *  Copyright (C) 2001  Peter Johnson
@@ -40,7 +40,8 @@ typedef enum {
     ERR_INVALID_EA,
     ERR_INVALID_LINE,
     ERR_EXP_SYNTAX,
-    ERR_DUPLICATE_DEF
+    ERR_DUPLICATE_DEF,
+    ERR_OP_SIZE_MISMATCH
 } err_num;
 
 void Error(err_num, char *, ...);
index 28831536e8832f26d0ef57e10cdde9c151e1a2bb..f1d87fbaf69d327a76e43cb63def62829f3bb333 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: bison.y.in,v 1.11 2001/07/04 04:24:52 peter Exp $
+/* $Id: bison.y.in,v 1.12 2001/07/04 20:53:21 peter Exp $
  * Main bison parser
  *
  *  Copyright (C) 2001  Peter Johnson, Michael Urman
@@ -194,45 +194,55 @@ memaddr: memexp                   { $$ = $1; $$.segment = 0; }
     | DWORD memaddr            { $$ = $2; SetEALen(&$$, 4); }
 ;
 
-mem: '[' memaddr ']' { $$ = $2; }
+memref: '[' memaddr ']' { $$ = $2; }
 ;
 
 /* explicit memory */
-mem8x: BYTE mem                { $$ = $2; }
+mem8x: BYTE memref     { $$ = $2; }
 ;
-mem16x: WORD mem       { $$ = $2; }
+mem16x: WORD memref    { $$ = $2; }
 ;
-mem32x: DWORD mem      { $$ = $2; }
+mem32x: DWORD memref   { $$ = $2; }
 ;
-mem64x: QWORD mem      { $$ = $2; }
+mem64x: QWORD memref   { $$ = $2; }
 ;
-mem80x: TWORD mem      { $$ = $2; }
+mem80x: TWORD memref   { $$ = $2; }
 ;
-mem128x: DQWORD mem    { $$ = $2; }
+mem128x: DQWORD memref { $$ = $2; }
+;
+
+/* other sized memory reference - no explicit size allowed */
+mem: memref            { $$ = $1; }
+    | mem8x            { $$ = $1; Error(ERR_OP_SIZE_MISMATCH, (char *)NULL); }
+    | mem16x           { $$ = $1; Error(ERR_OP_SIZE_MISMATCH, (char *)NULL); }
+    | mem32x           { $$ = $1; Error(ERR_OP_SIZE_MISMATCH, (char *)NULL); }
+    | mem64x           { $$ = $1; Error(ERR_OP_SIZE_MISMATCH, (char *)NULL); }
+    | mem80x           { $$ = $1; Error(ERR_OP_SIZE_MISMATCH, (char *)NULL); }
+    | mem128x          { $$ = $1; Error(ERR_OP_SIZE_MISMATCH, (char *)NULL); }
 ;
 
 /* implicit memory */
-mem8: mem
+mem8: memref
     | mem8x
 ;
-mem16: mem
+mem16: memref
     | mem16x
 ;
-mem32: mem
+mem32: memref
     | mem32x
 ;
-mem64: mem
+mem64: memref
     | mem64x
 ;
-mem80: mem
+mem80: memref
     | mem80x
 ;
-mem128: mem
+mem128: memref
     | mem128x
 ;
 
 /* both 16 and 32 bit memory */
-mem1632: mem
+mem1632: memref
     | mem16x
     | mem32x
 ;
index b676c4ca2b94c90ed11dae1b25ac7baf9e8da875..1452b2d8df36b9ab704fe40844bb5234111fd9cd 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: nasm-bison.y,v 1.11 2001/07/04 04:24:52 peter Exp $
+/* $Id: nasm-bison.y,v 1.12 2001/07/04 20:53:21 peter Exp $
  * Main bison parser
  *
  *  Copyright (C) 2001  Peter Johnson, Michael Urman
@@ -194,45 +194,55 @@ memaddr: memexp                   { $$ = $1; $$.segment = 0; }
     | DWORD memaddr            { $$ = $2; SetEALen(&$$, 4); }
 ;
 
-mem: '[' memaddr ']' { $$ = $2; }
+memref: '[' memaddr ']' { $$ = $2; }
 ;
 
 /* explicit memory */
-mem8x: BYTE mem                { $$ = $2; }
+mem8x: BYTE memref     { $$ = $2; }
 ;
-mem16x: WORD mem       { $$ = $2; }
+mem16x: WORD memref    { $$ = $2; }
 ;
-mem32x: DWORD mem      { $$ = $2; }
+mem32x: DWORD memref   { $$ = $2; }
 ;
-mem64x: QWORD mem      { $$ = $2; }
+mem64x: QWORD memref   { $$ = $2; }
 ;
-mem80x: TWORD mem      { $$ = $2; }
+mem80x: TWORD memref   { $$ = $2; }
 ;
-mem128x: DQWORD mem    { $$ = $2; }
+mem128x: DQWORD memref { $$ = $2; }
+;
+
+/* other sized memory reference - no explicit size allowed */
+mem: memref            { $$ = $1; }
+    | mem8x            { $$ = $1; Error(ERR_OP_SIZE_MISMATCH, (char *)NULL); }
+    | mem16x           { $$ = $1; Error(ERR_OP_SIZE_MISMATCH, (char *)NULL); }
+    | mem32x           { $$ = $1; Error(ERR_OP_SIZE_MISMATCH, (char *)NULL); }
+    | mem64x           { $$ = $1; Error(ERR_OP_SIZE_MISMATCH, (char *)NULL); }
+    | mem80x           { $$ = $1; Error(ERR_OP_SIZE_MISMATCH, (char *)NULL); }
+    | mem128x          { $$ = $1; Error(ERR_OP_SIZE_MISMATCH, (char *)NULL); }
 ;
 
 /* implicit memory */
-mem8: mem
+mem8: memref
     | mem8x
 ;
-mem16: mem
+mem16: memref
     | mem16x
 ;
-mem32: mem
+mem32: memref
     | mem32x
 ;
-mem64: mem
+mem64: memref
     | mem64x
 ;
-mem80: mem
+mem80: memref
     | mem80x
 ;
-mem128: mem
+mem128: memref
     | mem128x
 ;
 
 /* both 16 and 32 bit memory */
-mem1632: mem
+mem1632: memref
     | mem16x
     | mem32x
 ;
index 28831536e8832f26d0ef57e10cdde9c151e1a2bb..f1d87fbaf69d327a76e43cb63def62829f3bb333 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: bison.y.in,v 1.11 2001/07/04 04:24:52 peter Exp $
+/* $Id: bison.y.in,v 1.12 2001/07/04 20:53:21 peter Exp $
  * Main bison parser
  *
  *  Copyright (C) 2001  Peter Johnson, Michael Urman
@@ -194,45 +194,55 @@ memaddr: memexp                   { $$ = $1; $$.segment = 0; }
     | DWORD memaddr            { $$ = $2; SetEALen(&$$, 4); }
 ;
 
-mem: '[' memaddr ']' { $$ = $2; }
+memref: '[' memaddr ']' { $$ = $2; }
 ;
 
 /* explicit memory */
-mem8x: BYTE mem                { $$ = $2; }
+mem8x: BYTE memref     { $$ = $2; }
 ;
-mem16x: WORD mem       { $$ = $2; }
+mem16x: WORD memref    { $$ = $2; }
 ;
-mem32x: DWORD mem      { $$ = $2; }
+mem32x: DWORD memref   { $$ = $2; }
 ;
-mem64x: QWORD mem      { $$ = $2; }
+mem64x: QWORD memref   { $$ = $2; }
 ;
-mem80x: TWORD mem      { $$ = $2; }
+mem80x: TWORD memref   { $$ = $2; }
 ;
-mem128x: DQWORD mem    { $$ = $2; }
+mem128x: DQWORD memref { $$ = $2; }
+;
+
+/* other sized memory reference - no explicit size allowed */
+mem: memref            { $$ = $1; }
+    | mem8x            { $$ = $1; Error(ERR_OP_SIZE_MISMATCH, (char *)NULL); }
+    | mem16x           { $$ = $1; Error(ERR_OP_SIZE_MISMATCH, (char *)NULL); }
+    | mem32x           { $$ = $1; Error(ERR_OP_SIZE_MISMATCH, (char *)NULL); }
+    | mem64x           { $$ = $1; Error(ERR_OP_SIZE_MISMATCH, (char *)NULL); }
+    | mem80x           { $$ = $1; Error(ERR_OP_SIZE_MISMATCH, (char *)NULL); }
+    | mem128x          { $$ = $1; Error(ERR_OP_SIZE_MISMATCH, (char *)NULL); }
 ;
 
 /* implicit memory */
-mem8: mem
+mem8: memref
     | mem8x
 ;
-mem16: mem
+mem16: memref
     | mem16x
 ;
-mem32: mem
+mem32: memref
     | mem32x
 ;
-mem64: mem
+mem64: memref
     | mem64x
 ;
-mem80: mem
+mem80: memref
     | mem80x
 ;
-mem128: mem
+mem128: memref
     | mem128x
 ;
 
 /* both 16 and 32 bit memory */
-mem1632: mem
+mem1632: memref
     | mem16x
     | mem32x
 ;
index d072d584559bc4f08da2f0c63276b942c8fdcb9a..d76a97488d6df36dfc2f1f95d06b20bd2482e9af 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: errwarn.c,v 1.12 2001/06/29 02:12:15 peter Exp $
+/* $Id: errwarn.c,v 1.13 2001/07/04 20:53:21 peter Exp $
  * Error and warning reporting and related functions.
  *
  *  Copyright (C) 2001  Peter Johnson
@@ -55,7 +55,8 @@ static char *err_msgs[] = {
     "invalid effective address",
     "label or instruction expected at start of line",
     "expression syntax error",
-    "duplicate definition of `%s'; previously defined line %d"
+    "duplicate definition of `%s'; previously defined line %d",
+    "mismatch in operand sizes"
 };
 
 static char *warn_msgs[] = {
index 0d8d3c8f53a193d625c992cf457a43e727862446..6ef8e0132db86ff186859e4ac4705b86d9732560 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: errwarn.h,v 1.7 2001/06/28 21:22:01 peter Exp $
+/* $Id: errwarn.h,v 1.8 2001/07/04 20:53:21 peter Exp $
  * Error and warning reporting and related functions header file.
  *
  *  Copyright (C) 2001  Peter Johnson
@@ -40,7 +40,8 @@ typedef enum {
     ERR_INVALID_EA,
     ERR_INVALID_LINE,
     ERR_EXP_SYNTAX,
-    ERR_DUPLICATE_DEF
+    ERR_DUPLICATE_DEF,
+    ERR_OP_SIZE_MISMATCH
 } err_num;
 
 void Error(err_num, char *, ...);
index 28831536e8832f26d0ef57e10cdde9c151e1a2bb..f1d87fbaf69d327a76e43cb63def62829f3bb333 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: bison.y.in,v 1.11 2001/07/04 04:24:52 peter Exp $
+/* $Id: bison.y.in,v 1.12 2001/07/04 20:53:21 peter Exp $
  * Main bison parser
  *
  *  Copyright (C) 2001  Peter Johnson, Michael Urman
@@ -194,45 +194,55 @@ memaddr: memexp                   { $$ = $1; $$.segment = 0; }
     | DWORD memaddr            { $$ = $2; SetEALen(&$$, 4); }
 ;
 
-mem: '[' memaddr ']' { $$ = $2; }
+memref: '[' memaddr ']' { $$ = $2; }
 ;
 
 /* explicit memory */
-mem8x: BYTE mem                { $$ = $2; }
+mem8x: BYTE memref     { $$ = $2; }
 ;
-mem16x: WORD mem       { $$ = $2; }
+mem16x: WORD memref    { $$ = $2; }
 ;
-mem32x: DWORD mem      { $$ = $2; }
+mem32x: DWORD memref   { $$ = $2; }
 ;
-mem64x: QWORD mem      { $$ = $2; }
+mem64x: QWORD memref   { $$ = $2; }
 ;
-mem80x: TWORD mem      { $$ = $2; }
+mem80x: TWORD memref   { $$ = $2; }
 ;
-mem128x: DQWORD mem    { $$ = $2; }
+mem128x: DQWORD memref { $$ = $2; }
+;
+
+/* other sized memory reference - no explicit size allowed */
+mem: memref            { $$ = $1; }
+    | mem8x            { $$ = $1; Error(ERR_OP_SIZE_MISMATCH, (char *)NULL); }
+    | mem16x           { $$ = $1; Error(ERR_OP_SIZE_MISMATCH, (char *)NULL); }
+    | mem32x           { $$ = $1; Error(ERR_OP_SIZE_MISMATCH, (char *)NULL); }
+    | mem64x           { $$ = $1; Error(ERR_OP_SIZE_MISMATCH, (char *)NULL); }
+    | mem80x           { $$ = $1; Error(ERR_OP_SIZE_MISMATCH, (char *)NULL); }
+    | mem128x          { $$ = $1; Error(ERR_OP_SIZE_MISMATCH, (char *)NULL); }
 ;
 
 /* implicit memory */
-mem8: mem
+mem8: memref
     | mem8x
 ;
-mem16: mem
+mem16: memref
     | mem16x
 ;
-mem32: mem
+mem32: memref
     | mem32x
 ;
-mem64: mem
+mem64: memref
     | mem64x
 ;
-mem80: mem
+mem80: memref
     | mem80x
 ;
-mem128: mem
+mem128: memref
     | mem128x
 ;
 
 /* both 16 and 32 bit memory */
-mem1632: mem
+mem1632: memref
     | mem16x
     | mem32x
 ;
index b676c4ca2b94c90ed11dae1b25ac7baf9e8da875..1452b2d8df36b9ab704fe40844bb5234111fd9cd 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: nasm-bison.y,v 1.11 2001/07/04 04:24:52 peter Exp $
+/* $Id: nasm-bison.y,v 1.12 2001/07/04 20:53:21 peter Exp $
  * Main bison parser
  *
  *  Copyright (C) 2001  Peter Johnson, Michael Urman
@@ -194,45 +194,55 @@ memaddr: memexp                   { $$ = $1; $$.segment = 0; }
     | DWORD memaddr            { $$ = $2; SetEALen(&$$, 4); }
 ;
 
-mem: '[' memaddr ']' { $$ = $2; }
+memref: '[' memaddr ']' { $$ = $2; }
 ;
 
 /* explicit memory */
-mem8x: BYTE mem                { $$ = $2; }
+mem8x: BYTE memref     { $$ = $2; }
 ;
-mem16x: WORD mem       { $$ = $2; }
+mem16x: WORD memref    { $$ = $2; }
 ;
-mem32x: DWORD mem      { $$ = $2; }
+mem32x: DWORD memref   { $$ = $2; }
 ;
-mem64x: QWORD mem      { $$ = $2; }
+mem64x: QWORD memref   { $$ = $2; }
 ;
-mem80x: TWORD mem      { $$ = $2; }
+mem80x: TWORD memref   { $$ = $2; }
 ;
-mem128x: DQWORD mem    { $$ = $2; }
+mem128x: DQWORD memref { $$ = $2; }
+;
+
+/* other sized memory reference - no explicit size allowed */
+mem: memref            { $$ = $1; }
+    | mem8x            { $$ = $1; Error(ERR_OP_SIZE_MISMATCH, (char *)NULL); }
+    | mem16x           { $$ = $1; Error(ERR_OP_SIZE_MISMATCH, (char *)NULL); }
+    | mem32x           { $$ = $1; Error(ERR_OP_SIZE_MISMATCH, (char *)NULL); }
+    | mem64x           { $$ = $1; Error(ERR_OP_SIZE_MISMATCH, (char *)NULL); }
+    | mem80x           { $$ = $1; Error(ERR_OP_SIZE_MISMATCH, (char *)NULL); }
+    | mem128x          { $$ = $1; Error(ERR_OP_SIZE_MISMATCH, (char *)NULL); }
 ;
 
 /* implicit memory */
-mem8: mem
+mem8: memref
     | mem8x
 ;
-mem16: mem
+mem16: memref
     | mem16x
 ;
-mem32: mem
+mem32: memref
     | mem32x
 ;
-mem64: mem
+mem64: memref
     | mem64x
 ;
-mem80: mem
+mem80: memref
     | mem80x
 ;
-mem128: mem
+mem128: memref
     | mem128x
 ;
 
 /* both 16 and 32 bit memory */
-mem1632: mem
+mem1632: memref
     | mem16x
     | mem32x
 ;