diff options
author | H. Peter Anvin <hpa@zytor.com> | 2017-02-20 00:35:58 -0800 |
---|---|---|
committer | H. Peter Anvin <hpa@zytor.com> | 2017-02-20 00:35:58 -0800 |
commit | 2902fbc1d8d084f10bfee4d18a01b90266c6adae (patch) | |
tree | 737d905e3fdccfc9663a96eef1a8f894a8049978 | |
parent | 3ebed50146d28ec0ae1eeb16fb951bf75d11b3bd (diff) | |
download | nasm-2902fbc1d8d084f10bfee4d18a01b90266c6adae.tar.gz |
assemble.c: don't use a case for get_broadcast_num()
Instead of using a case, use a conditional shift.
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
-rw-r--r-- | asm/assemble.c | 20 |
1 files changed, 7 insertions, 13 deletions
diff --git a/asm/assemble.c b/asm/assemble.c index a4f8c883..10011c99 100644 --- a/asm/assemble.c +++ b/asm/assemble.c @@ -2092,25 +2092,19 @@ done: static uint8_t get_broadcast_num(opflags_t opflags, opflags_t brsize) { - opflags_t opsize = opflags & SIZE_MASK; + unsigned int opsize = (opflags & SIZE_MASK) >> SIZE_SHIFT; uint8_t brcast_num; - /* - * Due to discontinuity between BITS64 and BITS128 (BITS80), - * this cannot be a simple arithmetic calculation. - */ if (brsize > BITS64) nasm_error(ERR_FATAL, "size of broadcasting element is greater than 64 bits"); - switch (opsize) { - case BITS64: - brcast_num = BITS64 / brsize; - break; - default: - brcast_num = (opsize / BITS128) * (BITS64 / brsize) * 2; - break; - } + /* + * The shift term is to take care of the extra BITS80 inserted + * between BITS64 and BITS128. + */ + brcast_num = ((opsize / (BITS64 >> SIZE_SHIFT)) * (BITS64 / brsize)) + >> (opsize > (BITS64 >> SIZE_SHIFT)); return brcast_num; } |