Hello everyone.....i have to write a program to create a pseudo assembler.....i have as yet recognized the value of the registers and the type of assembly instruction input.....but i can't get the conversion of decimal to binary correct....the output has to be 32 bits...and i am not being able to convert the numbers correctly..for example..the source register is R5...but in binary what i am getting is 101 using the itoa function..what i need is 00101...then concatenate the binary of destination register to it and so on ....can anyone please tell me how do i get the zero padding done..i am not very used to C++ functions so please help me..
Start with a C string containing 32 zeroes. Until the input value is zero, left-shift it (x<<=1). If bit 31 is set, which you can check by bitwise-ANDing the value (x&0x80000000), set the corresponding character in the string to '1'.