reko
reko copied to clipboard
Bug: Switch statements cannot find switch variable
Minor bug but one I've noticed consistently.
All switch statements in my code are switch(bx) even when the switch statement is the first thing in the function.
Also I'm not sure if it's fully implemented / recognising the jump table (see the image at the end).
void Mech_Mission_0629(Eq_15063 wArg04) <---unsigned char
{
word16 Eq_15065::* fp;
struct Eq_15065 * ss;
word16 bx;
Eq_21 ds;
ci16 wLoc16;
Eq_15069 wLoc24;
byte bLoc1A;
Eq_15071 wLoc06;
word16 wLoc26;
word16 wLoc10_1048 = 0x00;
word16 wLoc04_1027 = 0x00;
if (wArg04 <= 0x09)
{
byte ah_132 = SLICE(bx, byte, 8);
switch (bx) <--- bx. Should be wArg04
{
case 0x00:
struct Eq_15088 * es_226 = *((word32) ds + 21616);
bLoc1A = es_226->b200A;
es_226->b200A = 0x00;
wLoc16 = 0x00;
goto l0FDC_066A;
ASM:
0FDC:0629 55 push bp
0FDC:062A 8B EC mov bp,sp
0FDC:062C B8 24 00 mov ax,24h
0FDC:062F 9A DC 2F 7F 20 call far 207Fh:2FDCh
0FDC:0634 56 push si
0FDC:0635 2B C0 sub ax,ax
0FDC:0637 89 46 F2 mov [bp-0Eh],ax
0FDC:063A 89 46 FE mov [bp-2h],ax
0FDC:063D 8B 46 06 mov ax,[bp+6h]
0FDC:0640 3D 09 00 cmp ax,9h <---- (wArg04 <= 0x09)
0FDC:0643 76 03 jbe 0648h
0FDC:0645 E9 3B 02 jmp 0883h
0FDC:0648 03 C0 add ax,ax
0FDC:064A 93 xchg bx,ax
0FDC:064B 2E FF A7 6F 08 jmp word ptr cs:[bx+86Fh] <--- Jump table
0FDC:0650 8E 06 70 54 mov es,[5470h]
0FDC:0654 26 A0 0A 20 mov al,es:[200Ah]
0FDC:0658 98 cbw
0FDC:0659 89 46 E8 mov [bp-18h],ax
0FDC:065C 26 C6 06 0A 20 00 mov byte ptr es:[200Ah],0h
0FDC:0662 2B C0 sub ax,ax
0FDC:0664 89 46 FE mov [bp-2h],ax
0FDC:0667 89 46 EC mov [bp-14h],ax
Here's an image of the reko display of the jump table location:
