0

I've been reversing some assembly code from a game in an ARM platform, and I've found a cmp r2,0h instruction. While looking online for the cmp instruction, I've noticed that it actually would compare the value in r2 with 0 (pseudo-C will be r2==0, right?) So I was wondering if 0h has the same meaning? Does 0h equal 0 (unsigned int)?

In general, I find the 'h' after addresses offsets and also after values, so I think it's some kind of flag or something? For example, after the cmp instruction there's a sub r2,r2,1h

Thanks a lot.

PS: I'm using no$gba debugger if that matters

user1354557
  • 2,413
  • 19
  • 29
78dtat78da
  • 112
  • 1
  • 9
  • 3
    It's certainly not the architectural syntax for a constant, but ultimately disassemblers are free to display things however they want to. I don't recall having ever looked at no$gba specifically, but I'd be incredibly surprised if it meant anything other than a hex value (e.g. 10h == 0x10 == 16). – Notlikethat Jun 23 '16 at 16:40
  • @Notlikethat you mean 'h' would mean something like 'hex' right? so 1h would be 1 in hex which is 0x1. Therefore, 0h == 0x0 == 0 right? Seems to be the solution. – 78dtat78da Jun 23 '16 at 16:53
  • 2
    http://www.keil.com/support/man/docs/uv4/uv4_db_exp_constants.htm – Jose Manuel Abarca Rodríguez Jun 23 '16 at 17:04
  • when you assembled it and then disassembled it did you see a difference? – old_timer Jun 23 '16 at 17:15
  • A way to answer this is to look at the binary of the instruction and see if it bit for bit identical to `cmp r2,#0`. It is in the ARM manuals and you can create binaries constants with many tools (including the assembler with constants and then disassemble the constant). – artless noise Jun 24 '16 at 13:30

1 Answers1

0

As explained by @Notlikethat , the h suffix seems to stand for 'hex' (hexadecimal). Addresses (i.e. 02035000h would be 0x02035000) and values (10h would be 0x10) in no$gba use this suffix.

78dtat78da
  • 112
  • 1
  • 9
  • 1
    DOS/Windows x86 assemblers (like MASM/TASM), [only support the `h` suffix](http://stackoverflow.com/a/37152498/224132) for hex constants, not `0xDEADBEEF` (supported by portable x86 assemblers). So presumably this choice was made by someone who thought it would be more familiar to asm programmers used to DOS/Windows tools. – Peter Cordes Jun 23 '16 at 20:59