Formatting Hex Output

Discussion in 'C' started by mvtaylor, Sep 5, 2010.

  1. mvtaylor

    mvtaylor New Member

    Joined:
    Sep 5, 2010
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    I'm trying to build a simple assembler and have now managed to get everything working except something rather trivial... the correct output format...

    The format must be:

    Address followed by a space followed by Operand and Opcode.

    These must be two 32 bit values (as 8 hex characters). For the Operand/Opcode the first six bits are the Operand and the final two bits are the Opcode. EG:

    00000001 0009D0A1

    To generate this I am using:
    Code:
    printf ("%8.8X %6.6X%2.2X\n", printout, operand, opcode);

    Which is all fine and lovely until the operand is a negative value at which point it will promptly ignore any attempts at following the format and print out 8 characters such as:

    00000001 FFFFFFFF00

    Any idea as for how to fix this?
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice