WinAsm Studio, The Assembly IDE - Free Downloads, Source Code
Forum
   Search    Users    Calendar    Board Help  

  Reply to this topicStart new topicStart Poll

Hex numbers representation in Assembly, hexadecimal numbers should be prefixed with a 0 if they start with a digit not in the decimal range 0-9 .

GdS
Posted: Nov 20 2007, 02:31 PM
Quote Post


New Member
*

Group: Members
Posts: 4
Member No.: 5685
Joined: 17-November 07


Hi,

I'm having an error on this sentence:

.data

myconst dd C0C0C000h ;<= error
myconst dd 0C0C0C00h ;<= works fine

Had to replace the first one by this:

myconst db 192, 192, 192, 0 ;<= works fine

It seems perfectly valid hex numbers starting with a letter produces an error.

Maybe I'm missing something obvious here, if so please delete.

Rgds, GdS

PMEmail Poster
Top
samael
Posted: Nov 20 2007, 02:51 PM
Quote Post


Typo-lord
******

Group: Admins
Posts: 299
Member No.: 5187
Joined: 10-June 07


It's the way the MASM pre-compiler handles numbers.

It treats as numbers only the sequences beginning with a decimal digit, even if it's zero.

So, if you have a hexadecimal number, starting with a digit that is not in the decimal range (0-9), you must prefix it with 0, so that the pre-compiler will treat it as a number.
Prefixing the number with zero does not have any impact on the compiled code:

C0C0C0C0h == 0C0C0C0C0h

the same way as

010 = 10

E.G.

CODE
dwNumber1 dd FFh; this will be treated as error
dwNumber2 dd 0FFh; this will not be treated as error, although it's the same number as above
PM
Top
GdS
Posted: Nov 20 2007, 11:45 PM
Quote Post


New Member
*

Group: Members
Posts: 4
Member No.: 5685
Joined: 17-November 07



Thanks for your answer Samael, I do appreciate it.

Rgds, GdS
PMEmail Poster
Top
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

Topic Options Reply to this topicStart new topicStart Poll