Subject: pkg/34538: TME sun3 emulator incorrectly calculates EA with immediate mode instructions with PC indirect 16-bit displacement addressing
To: None <pkg-manager@netbsd.org, gnats-admin@netbsd.org,>
From: None <sigmfsk@aol.com>
List: pkgsrc-bugs
Date: 09/15/2006 19:30:00
>Number:         34538
>Category:       pkg
>Synopsis:       TME sun3 emulator incorrectly calculates EA with immediate mode instructions with PC indirect 16-bit displacement addressing
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    pkg-manager
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Sep 15 19:30:00 +0000 2006
>Originator:     Arthur Townsend
>Release:        3.0
>Organization:
>Environment:
3.0 for i386
>Description:
When calculating the effective address for program counter indirect 16 bit displacement addressing, TME calculates incorrectly when the instruction contains an immediate mode instruction.
>How-To-Repeat:
Using gcc-3.2.3 (and likely others) inside the emulator running SunOS 4.1.1, the following test gcc-3.2.3 test cases fail due to the above bug, but work on a real sun3:

20010325-1.c
991227-1.c
string-opt-8.c
widechar-2.c
lexstrng.c


>Fix:
The following differences to m68k-execute.c in ic/m68k directory fixes the bug, allows the above test cases to work identically as on a real-sun3, and produces no new failures in the remaining 18,000 test cases.

209d208
< 
595,606d593
< 
<           /* if instruction has immediate, then we need to add either
<              2 bytes (for byte or word) or
<              4 bytes (for lword) to get the effective address
<           */ 
<           if (TME_M68K_OPCODE_HAS_IMM(params)) {
<             if (TME_FIELD_EXTRACTU(TME_M68K_INSN_OPCODE,6,2) == 2)
<               ea_address = ea_address + 4;
<             else
<               ea_address = ea_address + 2;
<           }
<