Instruction's binary encoding

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Instruction's binary encoding

634 Views
himanshudoshi
Contributor III

Hello,

Does anyone have an idea about the instruction's hex value, from which we can grab the binary value which is going to feed? Since, I am new to this field, I don't have much idea and the documentation related to these were bit confusing.

Since, I am working on LPCXpresso IDE. I was looking at the instruction's hex value through the disassembly file. But, I didn't understand the places filled by the assembler. Because, the information in internet is not so convincing. It will be great help, if someone can just explain me the significance of 32 bits in binary.

Image has been inserted for better understanding of my doubt.

Thanks a lot in advance,

Regards,

Himanshu

BINARY_ENCODING.png

Labels (4)
0 Kudos
4 Replies

439 Views
converse
Senior Contributor V

You need to read the ARM Architecture Reference Manual for the processor family, which I think is ARM V7 M. You can find it here, after you have registered 

ARM Information Center 

0 Kudos

439 Views
himanshudoshi
Contributor III

Hello Con Verse,

Thank you very much for your reply. I have gone through it and got some information. But still I am stuck, as shown in the below picture, I didn't understand: "i","S" and "imm3" and also, how it's converting the more than 8 bit immediate data. 

I mean, for example: ADD R6,R5,#0x100 or ADD R6,R5,#0F000000. If you can help me out will be a great help.

Capture.PNG

0 Kudos

439 Views
soledad
NXP Employee
NXP Employee

Please check the below threads, I hope this helps!!

arm - The questions about ADR.W instruction - Reverse Engineering Stack Exchange 

assembly - how does arm movw instruction map to machine code? - Stack Overflow 


Have a great day,
Soledad

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos

439 Views
himanshudoshi
Contributor III

Hello Soledad,

Thank you very much for your reply. As per your suggestion, I have gone through the link. But in my case, I don't know the actual significance or in other words how does the assembler is computing it.

For eg.           ADD R6,R5,#00000100 , assembler shows   F505 7680       (12 bit immediate data)

whereas for   ADD R6,R5,#00000200 , it shows                   F505 7600       (12 bit immediate data)

again for        ADD R6,R5,#00000300 , it shows                   F505 7640       (12 bit immediate data)

and for          ADD R6,R5,#00000400 , it shows                    F505 6680       (12 bit immediate data)

and for          ADD R6,R5,#00000500 , it shows                    F505 66A0       (12 bit immediate data)

this was one set but for other set like,

                    ADD R6,R5,#00000001 ,  assembler shows      F105 0601       (4 bit immediate data)

                    ADD R6,R5,#00000002 , assembler shows       F105 0602       (4 bit immediate data)

                    ADD R6,R5,#00000010 , assembler shows       F105 0610       (8 bit immediate data)

                    ADD R6,R5,#00000020, assembler shows        F105 0620       (8 bit immediate data)

So, why the 7th byte is chaning from 1 to 5??

why 2nd byte is changing randomly, for more than 8-bit immediate data?

why 4th byte has value change from 0 to 7 again 7 to 6?? and also it changes for any other value like,

 ADD R6,R5,#00001000 , it shows                    F505 5680       (16 bit immediate data)

 ADD R6,R5,#00002000 , it shows                    F505 5600       (16 bit immediate data)

 ADD R6,R5,#00003000 , it shows                    F505 5640       (16 bit immediate data)

 ADD R6,R5,#00004000 , it shows                    F505 4680       (16 bit immediate data)

 ADD R6,R5,#00005000 , it shows                    F505 46A0      (16 bit immediate data)

If anyone can help me out with these questions, will be a great help. As, I didn't find any solution in internet.

Thank you once again,

Regards,

Himanshu 

0 Kudos