This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

problems with hexidecimal values

Greetings, a rookie here!

I'm hoping that my problem will be borderline moronic, such that the problem will be easily solved and all I'll need is a hit over the head! I'm rather new at encountering some of these problems!

I am trying to set up descriptor tables for a USB firmware project. Nothing special, simply loading my ROM with data. When attempting to compile/build, it chokes on only certain lines with Hexidecimal values. The only way to properly explain is through example:

db 12h ;Descriptor Length
db 01h ;Descriptor Type
db 00h ;USB Spec Ver. 1.00 (L)
db 01h ;USB Spec Ver. 1.00 (H)
*db FFh ;Device Class
db 255 ;Device Sub-Class
db 255 ;Device Protocol

The line with the asterisk is where the error "UNDEFINED SYMBOL" came up. Note that the two lines following are in decimal form. They ALSO were errors when in hexidecimal format, but changing them to decimal allowed me to compile.

Throughout the table, similar errors cropped up, but disappeared when I changed to decimal from hexidecimal. Although this DOES fix the problem, do you know what is causing this? It seems that the values that had problems all contained a digit with A-F in it, while the problem free values had digits only from 0-9.

I am using Keil's uVision2 Eval version.

  • An excerpt from page 84 of "Macro Assembler and Utilities -- User's Guide 02.2001" (A51.pdf) which is "Chapter 3. Writing Assembly Programs" / "Expressions and Operators" / "Numbers":

    "The first character of a number must be a digit between 0 and 9. Hexadecimal numbers which do not have a digit as the first character should be prefixed with a 0. The Ax51 assembler supports also hex numbers written in C notation."

    So, in the example you flagged with the asterisk, you would change that to:

    " db 0FFh ;Device Class"
    and do likewise for other hexadecimal values where its required and other hexadecimal values where its not required, but it suits your desire for consistency.

  • My humble and profound apologies, as my posts continue to be an embarrassment...

    In the last sentence of my previous post, please read "its" as "it's".

  • THANK YOU DAN!! I KNEW it had to be an easy fix, but unless you happen onto one of these 'easy solutions', the problems can sure be vexxing! As for embarrassing posts, we've all had our share! Never to worry!

    Much gratitude,
    Chad

  • my posts continue to be an embarrassment... please read "its" as "it's".

    Well, at least that goes to show that you do actually know the difference! ;-)

  • Dan,

    I don't think I can forgive such an egregious error.

    - Mark

    <joking of course>