1

I am trying to reverse a simple code that gets a string and calculates it's checksum. I've been trying to understand every instruction, but they look different from what is said in arm documentation. Here's the full code(Using no$gba debugger) Pink signals the checksum code

I've reached the code knowing that once the checksum has been calculated it is stored in the r0 register. Docs specify that EOR receives 2 args, while here is taking 4. eor r3,r3,r0,asr 8h I've figured out that this will be something like r3 = (r3^r0)>>8 but I'm not really sure. In addition, C/C++ doesn't specify if the >> operator performs arithmetical or logical shifts (asr)

Same confusion is created with the mov's instructions. The sub inst. would be reversed in something like r2--; or r2=r2-1;

Thanks for your time.

EDIT: The checksum is 2 bytes long, and I am giving some examples:

String: AAAAAAB -- Checksum: 0xB649 (While debugging, write in little endian)

String: AAAAAAA -- Checksum: 0x68BC (NOTE: Checksum can't be worked out by performing operations with different checksum samples)

3
  • 1
    How exactly do these instructions look different from the ones in your documentation? "They are all lowercase"?
    – Jongware
    Jun 24, 2016 at 11:40
  • @RadLexus ... " Docs specify that EOR receives 2 args, while here is taking 4. eor r3,r3,r0,asr 8h " From the ARM documentation: Syntax eor Rd, Rm Rd->destination Rm->Second operand
    – 78dtat78da
    Jun 24, 2016 at 11:44
  • 4
    You are looking at the Thumb documentation, but this code is in the regular mode (you can see that because the opcodes are 4 bytes long)
    – Jongware
    Jun 24, 2016 at 12:41

1 Answer 1

0

A disassembler and decompiler like Ghidra can be used to obtain a C equivalent code.

Also, as specified by @RadLexus, the ARM documentation can be found here: http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0068b/BABGIEBE.html

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.