Skip to content

Commit 3b5241e

Browse files
committed
open-watcom: Open Watcom fix switch handling for 64-bit argument
1 parent 0a1a978 commit 3b5241e

File tree

3 files changed

+43
-39
lines changed

3 files changed

+43
-39
lines changed

asm/assemble.c

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3103,19 +3103,20 @@ static enum match_result matches(const struct itemplate * const itemp,
31033103
* If this is an *explicitly* sized immediate,
31043104
* allow it to match an extending pattern.
31053105
*/
3106-
switch (isize[i]) {
3107-
case BITS8:
3106+
/*
3107+
* The if() is a hack to deal with compilers which
3108+
* don't handle switch() statements with 64-bit
3109+
* expressions.
3110+
*/
3111+
if (isize[i] == BITS8) {
31083112
if (ttype & BYTEEXTMASK) {
31093113
isize[i] = tsize[i];
31103114
itype[i] |= BYTEEXTMASK;
31113115
}
3112-
break;
3113-
case BITS32:
3114-
if (ttype & DWORDEXTMASK)
3116+
} else if (isize[i] == BITS32) {
3117+
if (ttype & DWORDEXTMASK) {
31153118
isize[i] = tsize[i];
3116-
break;
3117-
default:
3118-
break;
3119+
}
31193120
}
31203121

31213122
/*

disasm/disasm.c

Lines changed: 29 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -113,32 +113,35 @@ static enum reg_enum whichreg(opflags_t regflags, int regval, uint32_t rex)
113113
*/
114114
static enum reg_enum implicit_reg(opflags_t regflags)
115115
{
116-
switch (regflags) {
117-
case REG_AL: return R_AL;
118-
case REG_AX: return R_AX;
119-
case REG_EAX: return R_EAX;
120-
case REG_RAX: return R_RAX;
121-
case REG_DL: return R_DL;
122-
case REG_DX: return R_DX;
123-
case REG_EDX: return R_EDX;
124-
case REG_RDX: return R_RDX;
125-
case REG_CL: return R_CL;
126-
case REG_CX: return R_CX;
127-
case REG_ECX: return R_ECX;
128-
case REG_RCX: return R_RCX;
129-
case FPU0: return R_ST0;
130-
case XMM0: return R_XMM0;
131-
case YMM0: return R_YMM0;
132-
case ZMM0: return R_ZMM0;
133-
case REG_ES: return R_ES;
134-
case REG_CS: return R_CS;
135-
case REG_SS: return R_SS;
136-
case REG_DS: return R_DS;
137-
case REG_FS: return R_FS;
138-
case REG_GS: return R_GS;
139-
case OPMASK0: return R_K0;
140-
default: return 0;
141-
}
116+
/*
117+
* The if() is a hack to deal with compilers which
118+
* don't handle switch() statements with 64-bit
119+
* expressions.
120+
*/
121+
if (regflags == REG_AL) return R_AL;
122+
else if (regflags == REG_AX) return R_AX;
123+
else if (regflags == REG_EAX) return R_EAX;
124+
else if (regflags == REG_RAX) return R_RAX;
125+
else if (regflags == REG_DL) return R_DL;
126+
else if (regflags == REG_DX) return R_DX;
127+
else if (regflags == REG_EDX) return R_EDX;
128+
else if (regflags == REG_RDX) return R_RDX;
129+
else if (regflags == REG_CL) return R_CL;
130+
else if (regflags == REG_CX) return R_CX;
131+
else if (regflags == REG_ECX) return R_ECX;
132+
else if (regflags == REG_RCX) return R_RCX;
133+
else if (regflags == FPU0) return R_ST0;
134+
else if (regflags == XMM0) return R_XMM0;
135+
else if (regflags == YMM0) return R_YMM0;
136+
else if (regflags == ZMM0) return R_ZMM0;
137+
else if (regflags == REG_ES) return R_ES;
138+
else if (regflags == REG_CS) return R_CS;
139+
else if (regflags == REG_SS) return R_SS;
140+
else if (regflags == REG_DS) return R_DS;
141+
else if (regflags == REG_FS) return R_FS;
142+
else if (regflags == REG_GS) return R_GS;
143+
else if (regflags == OPMASK0) return R_K0;
144+
else return 0;
142145
}
143146

144147
/*

output/outelf.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1131,12 +1131,12 @@ static void elf32_out(const struct out_data *out)
11311131
nasm_nonfatal("ELF format does not support"
11321132
" segment base references");
11331133
} else {
1134+
/*
1135+
* The if() is a hack to deal with compilers which
1136+
* don't handle switch() statements with 64-bit
1137+
* expressions.
1138+
*/
11341139
if (wrt == NO_SEG) {
1135-
/*
1136-
* The if() is a hack to deal with compilers which
1137-
* don't handle switch() statements with 64-bit
1138-
* expressions.
1139-
*/
11401140
switch (asize) {
11411141
case 1:
11421142
elf_add_reloc(s, segment, 0, R_386_8);

0 commit comments

Comments
 (0)