dirkwhoffmann / Moira

A Motorola 68000 emulator written in C++
https://dirkwhoffmann.github.io/Moira
Other
109 stars 13 forks source link

Moira Dasm: word size interpreted as negative #18

Closed elmerucr closed 1 year ago

elmerucr commented 2 years ago

Hello Dirk, I noticed the disassembler considers a word of the signed type, see first line from the screenshot. Is there a possibility to force the output all in unsigned type? See the second line of the screenshot what I mean.

Thanks for maybe considering this :-)

Screenshot 2022-10-11 at 23 21 48
dirkwhoffmann commented 2 years ago

There is no such option, because some values only make sense if they are displayed as signed values (e.g. displacements). When I wrote the disassembler, I noticed that Musashi sometimes prints signed numbers whereas binutils prints the same numbers unsigned. There is a certain inconsistency between disassemblers. Overall, I think it's best to decide the value type on a cases-by-case basis. E.g., in the case of the move.w instruction, I think the preferred output should be unsigned.

dirkwhoffmann commented 1 year ago

With the latest checkin, this code

template <Mode M, Size S> StrWriter&
StrWriter::operator<<(Im<M, S> wrapper)
{
    auto &ea = wrapper.ea;

    switch (style) {

        case DASM_MOIRA_MOT:
        case DASM_MOIRA_MIT:
        case DASM_GNU:
        case DASM_GNU_MIT:

            *this << Ims<S>(ea.ext1);
            break;

        case DASM_MUSASHI:

            *this << Imu(ea.ext1);
            break;
    }

    return *this;
}

has been replaced by:

template <Mode M, Size S> StrWriter&
StrWriter::operator<<(Im<M, S> wrapper)
{
    auto &ea = wrapper.ea;

    switch (style.syntax) {

        case DASM_GNU:
        case DASM_GNU_MIT:

            *this << Ims<S>(ea.ext1);
            break;

        default:

            *this << Imu(ea.ext1);
            break;
    }

    return *this;
}

This means that style MOIRA and MOIRA_MIT will print all intermediate operands as unsigned numbers now.