SOLVED - Sort of, see edit
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);
-----------
Solution involved a slightly roundabout and less than ideal way of doing it but am now using:
Code:
char test[7];
sprintf(test, "%X",-1);
printf ("%c%c%c%c%c%c\n",test[2],test[3],test[4],test[5],test[6],test[7]);
Which works fine. Will simply do a check to see if operand < 0 and if so use this style.
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?