From: Peter Johnson Date: Wed, 4 Jul 2001 20:53:21 +0000 (-0000) Subject: Change mem (other sized memory reference) to cause operand size mismatch error X-Git-Tag: v0.1.0~424 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=619381bdb9cc1972ba35f05adbc863da6c667144;p=yasm Change mem (other sized memory reference) to cause operand size mismatch error if a size is specified. svn path=/trunk/yasm/; revision=87 --- diff --git a/include/errwarn.h b/include/errwarn.h index 0d8d3c8f..6ef8e013 100644 --- a/include/errwarn.h +++ b/include/errwarn.h @@ -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 *, ...); diff --git a/libyasm/errwarn.c b/libyasm/errwarn.c index d072d584..d76a9748 100644 --- a/libyasm/errwarn.c +++ b/libyasm/errwarn.c @@ -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[] = { diff --git a/libyasm/errwarn.h b/libyasm/errwarn.h index 0d8d3c8f..6ef8e013 100644 --- a/libyasm/errwarn.h +++ b/libyasm/errwarn.h @@ -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 *, ...); diff --git a/modules/parsers/nasm/bison.y.in b/modules/parsers/nasm/bison.y.in index 28831536..f1d87fba 100644 --- a/modules/parsers/nasm/bison.y.in +++ b/modules/parsers/nasm/bison.y.in @@ -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 ; diff --git a/modules/parsers/nasm/nasm-bison.y b/modules/parsers/nasm/nasm-bison.y index b676c4ca..1452b2d8 100644 --- a/modules/parsers/nasm/nasm-bison.y +++ b/modules/parsers/nasm/nasm-bison.y @@ -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 ; diff --git a/src/bison.y.in b/src/bison.y.in index 28831536..f1d87fba 100644 --- a/src/bison.y.in +++ b/src/bison.y.in @@ -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 ; diff --git a/src/errwarn.c b/src/errwarn.c index d072d584..d76a9748 100644 --- a/src/errwarn.c +++ b/src/errwarn.c @@ -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[] = { diff --git a/src/errwarn.h b/src/errwarn.h index 0d8d3c8f..6ef8e013 100644 --- a/src/errwarn.h +++ b/src/errwarn.h @@ -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 *, ...); diff --git a/src/parsers/nasm/bison.y.in b/src/parsers/nasm/bison.y.in index 28831536..f1d87fba 100644 --- a/src/parsers/nasm/bison.y.in +++ b/src/parsers/nasm/bison.y.in @@ -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 ; diff --git a/src/parsers/nasm/nasm-bison.y b/src/parsers/nasm/nasm-bison.y index b676c4ca..1452b2d8 100644 --- a/src/parsers/nasm/nasm-bison.y +++ b/src/parsers/nasm/nasm-bison.y @@ -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 ;