summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2007-09-18 17:49:09 -0700
committerH. Peter Anvin <hpa@zytor.com>2007-09-18 17:49:09 -0700
commitcfbe7c3cc2dbdfe1268e2d0a19fc59b52cbcfcc5 (patch)
tree19d40b3af07da3dea56a24d29c06b604c5da099c
parent141d7cf68d60f6c77c078fea7ff85526db668c6f (diff)
downloadnasm-cfbe7c3cc2dbdfe1268e2d0a19fc59b52cbcfcc5.tar.gz
Fix handling of DO; support unary + for floating-point numbers
Floating-point users generally expect to be able to use a unary plus. Fix support for the DO instruction in several places.
-rw-r--r--assemble.c13
-rw-r--r--parser.c18
2 files changed, 20 insertions, 11 deletions
diff --git a/assemble.c b/assemble.c
index e5384548..efb02207 100644
--- a/assemble.c
+++ b/assemble.c
@@ -250,6 +250,9 @@ int32_t assemble(int32_t segment, int32_t offset, int bits, uint32_t cp,
case I_DT:
wsize = 10;
break;
+ case I_DO:
+ wsize = 16;
+ break;
default:
break;
}
@@ -564,10 +567,9 @@ int32_t insn_size(int32_t segment, int32_t offset, int bits, uint32_t cp,
if (instruction->opcode == -1)
return 0;
- if (instruction->opcode == I_DB ||
- instruction->opcode == I_DW ||
- instruction->opcode == I_DD ||
- instruction->opcode == I_DQ || instruction->opcode == I_DT) {
+ if (instruction->opcode == I_DB || instruction->opcode == I_DW ||
+ instruction->opcode == I_DD || instruction->opcode == I_DQ ||
+ instruction->opcode == I_DT || instruction->opcode == I_DO) {
extop *e;
int32_t isize, osize, wsize = 0; /* placate gcc */
@@ -588,6 +590,9 @@ int32_t insn_size(int32_t segment, int32_t offset, int bits, uint32_t cp,
case I_DT:
wsize = 10;
break;
+ case I_DO:
+ wsize = 16;
+ break;
default:
break;
}
diff --git a/parser.c b/parser.c
index 69ae3790..31c3612a 100644
--- a/parser.c
+++ b/parser.c
@@ -214,16 +214,18 @@ insn *parse_line(int pass, char *buffer, insn * result,
continue;
}
- if ((i == TOKEN_FLOAT && is_comma_next()) || i == '-') {
- int32_t sign = +1L;
+ if ((i == TOKEN_FLOAT && is_comma_next())
+ || i == '-' || i == '+') {
+ int32_t sign = +1;
- if (i == '-') {
+ if (i == '+' || i == '-') {
char *save = stdscan_bufptr;
+ int token = i;
+ sign = (i == '-') ? -1 : 1;
i = stdscan(NULL, &tokval);
- sign = -1L;
if (i != TOKEN_FLOAT || !is_comma_next()) {
stdscan_bufptr = save;
- i = tokval.t_type = '-';
+ i = tokval.t_type = token;
}
}
@@ -243,10 +245,12 @@ insn *parse_line(int pass, char *buffer, insn * result,
case I_DT:
eop->stringlen = 10;
break;
+ case I_DO:
+ eop->stringlen = 16;
+ break;
default:
error(ERR_NONFATAL, "floating-point constant"
- " encountered in `d%c' instruction"
- ? (result->opcode == I_DO) ? 'o' : 'b');
+ " encountered in `db' instruction");
/*
* fix suggested by Pedro Gimeno... original line
* was: