0

I/n the below snippet, what does the 018H mean (specifically the 0 and H), and what does the cH mean?

_i DD 018H
_s1 DW 0cH

I get that what it's essentially doing is defining a variable, but I can't seem to find anywhere what those specifically mean/stand for.

On that note, if anyone has a resource, such as a reference, where terminology like that can be found that would be very helpful as well, as I am unable to find anything good online.

phuclv
  • 37,963
  • 15
  • 156
  • 475
swimmingpoole
  • 67
  • 1
  • 2
  • 7
  • 1
    Which assembler? For which CPU? Just a guess: It's probably the notation for [hexadecimal](https://en.wikipedia.org/wiki/Hexadecimal) numbers. – Scheff's Cat Feb 15 '18 at 14:53
  • Without specifying particular assembler, it can mean pretty much anything. "assembly" is not some kind of standardized single language, but each CPU, assembler and platform have their own dialect. Just check syntax documentation of your assembler. (anyway, these are obviously numerical values, but you will probably soon encounter things where the meaning between different assemblers is completely different, even when the text is same). – Ped7g Feb 15 '18 at 14:53
  • 1
    @Ped7g: that's just being pedantic. Any assembler which accepts H suffixes will treat is as meaning hex. DOS / Windows assemblers have been using this convention for decades. I doubt anyone would design a syntax where it means something else (even for a different ISA). – Peter Cordes Feb 16 '18 at 04:52
  • [How to represent hex value such as FFFFFFBB in x86 assembly programming?](https://stackoverflow.com/q/11733731) – Peter Cordes Oct 28 '18 at 15:52

1 Answers1

3

It means the literal is in hexadecimal.

So 18h is 16 + 8 = 24 in decimal, and 0ch is 12 in decimal.

The notation used is often a platform and/or operating system convention, so tools generally use what is conventionally used for the target.

unwind
  • 391,730
  • 64
  • 469
  • 606
  • That makes a lot of sense (and now I feel like that should of been obvious..hah) thanks! – swimmingpoole Feb 15 '18 at 14:52
  • The leading zero on the 0ch is so that the assembler doesnt see that as a label ch. beefh would be a label 0beefh would be a number. other assembly languages (instruction sets) may require/support $c, and some support C syntax of 0xC. The leading zero shouldnt be required, note in C syntax the leading zero makes it octal so you have to be careful with leading zeros. – old_timer Feb 15 '18 at 15:31
  • @old_timer: Actually `ch` is an x86 register name: the 2nd byte of `ecx`, the partner of `cl`. This is another reason that `0deadbeefH` notation sucks compared to `0xdeadbeef`: single-digit hex constants assemble *and link* without errors (no missing symbol definition) if you forget the leading zero. – Peter Cordes Feb 16 '18 at 04:52
  • LOL, yes ch is a register name, thats funny I didnt think down that path, was focused on the leading zero being important. (I learned ch was the upper half of cx before ecx existed or %ecx or whatever the popular assemblers syntax is today). This was before it was determined that C was going going to take off like it did, so back then $abcd would have been the more popular or X'abcd' (to programmers with compiler access). And you did see assembly languages that used $1A vs 1ah or 0x1a, etc...I learned the 0abcdh first, before 0xabcd so am comfortable with either. – old_timer Feb 16 '18 at 12:28