0

Can someone here explain me, how the TC17** assembler works out the "movh.a and lea" addressing (hex), and how i can calculate them for myself if i have an configuration value like shown in my picture, which is defined as a "constant" or a "global".

What i want to do is, creating/assemble this 32-bit instruction for myself, but i do not make any proccess the last days. Sure, i know how to assemble with Eclipse Toolchain, but i cant use this toolchain in my programm. I am programming with PHP but this doesnt really matter, if i know how to work out this.

As example, here is a picture with the IDApro View of the commands i have to assembly:

screenshot of IDA-Pro

As 32-Bit Hex instruction it looks like this:

ASM: movh.a    a15, #@HIS(configuration_value_1)
HEX: 91 70 01 F8

ASM: lea   a15, [a15]@LOS(configuration_value_1)
HEX: D9 FF E4 67

What i want to do now is to work out that HEX-assembler instructions, with the right addressing to my variable. In this case its located at: "0x80177DA4".

In the instruction set, its explained like this:

Screenshot: movh.a command
Screenshot: lea + long offset addressing mode

C.E.
  • 664
  • 2
  • 5
  • 21

1 Answers1

1

What's causing you problem? Everything is shown in your pictures, it's just a simple matter of extracting bits.

It's easier if you reassemble the words from the little endian form. Thus:

movh.a = F8017091. You can see the constant is actually 8017 (no surprise there). lea = 67E4FFD9 This is a little bit trickier due to the silly encoding, so let's convert the top 16 bits to binary: 0110 0111 1110 0100. Now rearrange them to get 011111 0110 100100, then back to hex: 7DA4

So the full address is 80177DA4.

Jester
  • 56,577
  • 4
  • 81
  • 125
  • Thanks for your fast answer. After i posted this, i viewed again at the hex-values and i found out how to figure out the movh.a problem. Maybe i thought a little bit too complicated because i worked 2 days at the load byte command: http://www.bilder-upload.eu/upload/ee9540-1506994269.png But, this doesnt matter - as sayd i already figured out the ld.bu and the movh.a thing. But as you sayd the lea command is a bit more tricky for me. I dont know, how i have to rearrange the bits to get the values i need, i am very dumb in bitwise operations - i work at the "try and fail" principe.. – C.E. Oct 03 '17 at 01:34
  • Btw, checked the hex/address again. So the hex i gaved above, definitly points to 0x80177DA4, i compiled it again and load the .elf again to IDA and it's pointing to 0x80177DA4, with the HEX-instruction D9 FF E4 67 Br – C.E. Oct 03 '17 at 01:43
  • Yeah I made the mistake, `E` is of course `1110` not `1100`. – Jester Oct 03 '17 at 13:32