Moira icon indicating copy to clipboard operation
Moira copied to clipboard

Moira Dasm: word size interpreted as negative

Open elmerucr opened this issue 3 years ago • 1 comments

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

elmerucr avatar Oct 11 '22 21:10 elmerucr

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 avatar Oct 13 '22 15:10 dirkwhoffmann

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.

dirkwhoffmann avatar Nov 11 '22 15:11 dirkwhoffmann