flat assembler
Message board for the users of flat assembler.

Index > Main > Undefined symbol hex

Goto page 1, 2  Next
Author
Thread Post new topic Reply to topic
donn



Joined: 05 Mar 2010
Posts: 321
donn 05 Oct 2017, 15:19
Hi, I don't use hexadecimal much (I usually convert constants when referencing c headers, for example), but received this:

Error: undefined symbol 'FFFFFFFFh'.

upon compilation.


Code:
mov rcx, FFFFFFFFh    


Did a quick search on the forums, but did not see any relevant posts. Tried lowercase also, same thing. 0xffffffff works fine, so have a workaround and was just curious.

Quote:
The numbers in the expression are by default treated as a decimal, binary numbers should have the b letter attached at the end, octal number should end with o letter, hexadecimal numbers should begin with 0x characters (like in C language) or with the $ character (like in Pascal language) or they should end with h letter. Also quoted string, when encountered in expression, will be converted into number - the first character will become the least significant byte of number.
from the docs, so they seem interchangeable?
Post 05 Oct 2017, 15:19
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20306
Location: In your JS exploiting you and your system
revolution 05 Oct 2017, 15:41
All numbers must start with a digit, (0-9) only. So you need 0FFFFFFFFh

But also note that you can't encode this number for RCX. Instead you can sign extend it to 0FFFFFFFFFFFFFFFFh, or perhaps more simply -1.
Post 05 Oct 2017, 15:41
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8351
Location: Kraków, Poland
Tomasz Grysztar 05 Oct 2017, 15:52
It seems that manual for fasm 1 has this detail not clarified. The fasmg manual does it a bit better:
Fundamental syntax rules wrote:
Numbers are distinguished from names by the fact that they either begin with a decimal digit, or with the "$" character followed by any hexadecimal digit. This means that a token can be considered numeric even when it is not a valid number. To be a correct one it must be one of the following: a decimal number (optionally with the letter "d" attached at the end), a binary number followed by the letter "b", an octal number followed by the letter "o" or "q", or a hexadecimal number either prepended with "$" or "0x", or followed by the character "h". Because the first digit of a hexadecimal number can be a letter, it may be needed to prepend it with the digit zero in order to make it recognizable as a number. For example, "0Ah" is a valid number, while "Ah" is a name.

revolution wrote:
But also note that you can't encode this number for RCX. Instead you can sign extend it to 0FFFFFFFFFFFFFFFFh, or perhaps more simply -1.
MOV to register has an encoding with 64-bit immediate field, so it is possible in this specific case.
Post 05 Oct 2017, 15:52
View user's profile Send private message Visit poster's website Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20306
Location: In your JS exploiting you and your system
revolution 05 Oct 2017, 16:11
Tomasz Grysztar wrote:
revolution wrote:
But also note that you can't encode this number for RCX. Instead you can sign extend it to 0FFFFFFFFFFFFFFFFh, or perhaps more simply -1.
MOV to register has an encoding with 64-bit immediate field, so it is possible in this specific case.
Embarassed Yes, you are right. Embarassed
Post 05 Oct 2017, 16:11
View user's profile Send private message Visit poster's website Reply with quote
Furs



Joined: 04 Mar 2016
Posts: 2493
Furs 06 Oct 2017, 10:57
Just use 0xFFFFFFFF, problem solved. Superior notation anyway.
Post 06 Oct 2017, 10:57
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20306
Location: In your JS exploiting you and your system
revolution 06 Oct 2017, 11:01
How about 1 shl 32-1?
Post 06 Oct 2017, 11:01
View user's profile Send private message Visit poster's website Reply with quote
Furs



Joined: 04 Mar 2016
Posts: 2493
Furs 06 Oct 2017, 11:04
Well I was talking about notation for hex numbers (and this was just one example), otherwise of course there's an infinite ways you can write it as (with a lot of redundancy), even decimal. But anyway I meant 0x is superior to h notation Razz (because C/C++ also use it and they are the best HLL languages Cool)

I'd use "1 shl 32-1" if it made sense, depending on context (for example if it was related to a mask of bits, or bitfield)
Post 06 Oct 2017, 11:04
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20306
Location: In your JS exploiting you and your system
revolution 06 Oct 2017, 11:15
Or perhaps 1 shl (1 shl 5) - 1. That way we can change it to a 64 bit mask by only changing the 5 to a 6. Razz
Post 06 Oct 2017, 11:15
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8351
Location: Kraków, Poland
Tomasz Grysztar 06 Oct 2017, 11:34
Furs wrote:
Just use 0xFFFFFFFF, problem solved. Superior notation anyway.
I think the superiority of either is contextual and subjective. To me "int 21h" always looked way better than "int 0x21".

A note on a margin: this is just a curiosity, but early versions of fasm were so strongly case-sensitive that all hexadecimal digits had to be upper case. But thanks to that these early releases allowed hexadecimal numbers to start with a letter - for example "Ah" was a valid hexadecimal number, distinguished only by the case from the x86 register "ah".
Post 06 Oct 2017, 11:34
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8351
Location: Kraków, Poland
Tomasz Grysztar 06 Oct 2017, 11:53
Furs wrote:
(because C/C++ also use it and they are the best HLL languages Cool)
This is obviously Wink another statement that is going to be considered very subjective on the board that has many followers of the Niklaus Wirth ideas (myself included) and you would not have to look long for a case of someone having a critical opinion on the superiority of C/C++. I think of much of my work as dedicated to providing some kind of counterbalance to the language designs that went "mainstream", even thought that may be a lost battle and the future generations may grow up thinking that some of the choices that became the most popular could not have been any other way, while in fact many of them were a product of forgotten limitations or coincidences, years later considered "obviously a good choice" mainly because of the habitualization. I think this may even be similar to how the music preferences form.
Post 06 Oct 2017, 11:53
View user's profile Send private message Visit poster's website Reply with quote
Furs



Joined: 04 Mar 2016
Posts: 2493
Furs 06 Oct 2017, 13:42
Tomasz Grysztar wrote:
Furs wrote:
(because C/C++ also use it and they are the best HLL languages Cool)
This is obviously Wink another statement that is going to be considered very subjective on the board that has many followers of the Niklaus Wirth ideas (myself included) and you would not have to look long for a case of someone having a critical opinion on the superiority of C/C++. I think of much of my work as dedicated to providing some kind of counterbalance to the language designs that went "mainstream", even thought that may be a lost battle and the future generations may grow up thinking that some of the choices that became the most popular could not have been any other way, while in fact many of them were a product of forgotten limitations or coincidences, years later considered "obviously a good choice" mainly because of the habitualization. I think this may even be similar to how the music preferences form.
Well of course it's subjective but... it just makes more sense. Not to mention it avoids the issue presented here with prefixing with a 0 as well. We read left to right, so even though numbers should technically be read right to left, we still parse text from the left. When we then see a number (digit) or 0x, we know it's a hex number or whatnot. Suffixes are just worse, objectively. Then we can scan it from right to left as hex number instead.

C/C++ also have great syntax (even though a lot of people bash it, they just don't understand what true programming is about). Examples:

  • Curly braces for delimiting blocks: compact and very readable/clear. Plus, you can place them how you want; short blocks on one line if that makes surrounding code "cleaner" and less dense. Contrast this with "begin" and "end" (especially the "begin" is retarded). I think people forget programming is about being compact while still keeping readability, not about writing an essay. This is an area I dislike C++ since much of the standard library is verbose compared to C. In this case, C is a beauty.

  • Assignment via a logical and compact symbol = not any stupidity like <- or := or other nonsense. I'm just sick and annoyed at mathematicians and others who "get confused" about the = symbol and want bullshit like <- or whatever for assignment. Seriously, it literally infests so-called "pseudo-code" with their garbage.

    Math has horrible syntax. That's a fact. It's my number one reason I hate it, even though I like its underlying logic. Mathematicians who get confused about programs should stick to their idiotic math notation and leave the computer world to people who realize how beautiful assignment via = is.

    Let's not start about their stupid use of greek letters/alphabet or whatever other nonsense as if to be as obscure as possible to others so they can feel good about their "skills". The list goes on: "if and only if" (because just "if" is not enough of course, and no I don't care about absolute english meaning, it's a damn notation), or using "let" all over the place to be as verbose as possible. Can't just talk casually, nah.

    The only ones more annoying when talking or describing something than mathematicians are lawyers and their legalese, I don't think I need to explain why.


Compare:
Code:
a = 5; b = 6;    
with "pseudo-code" bullshit like:
Code:
let a be 5; let b be 6;    
Which one is more compact and readable? Former by far. If it's not, you should revisit the way you mentally read source code. Less novels, more programming reading IMO. Verbosity is not good Wink (speaking in general here ofc)

Another thing about C/C++ is the fact that they allow you to be "raw" with your stuff. It's not required, but they allow you to. "Safe arrays" being a builtin language construct (instead of library feature) is just dumb, if it concerns a runtime cost. This is why D is a horrible language, even though it's similar to C++.

Languages that get compiled to machine code should be as optimized as possible. No infesting the runtime with crap. Minimally invasive machine code. Otherwise, managed or scripting languages should be used. Compiling to machine code should be a serious thing not a casual crap and ending up with super bloated executables. For casuals scripting languages fit the bill just fine.

Yeah, C++ is bloated, but if you compare any program compiled in C (less C++) versus any of the other popular HLLs, you always see C much smaller and more efficient. That's because the other languages should not be compiled to machine code. That's what makes them horrible. Infest the machine code with crap like "safe arrays" and redundant checks during runtime is appalling. At least managed code has this built-in, so it's more tolerated.


Then again, a lot of people also bash x86 (and bashed it for a long time) clinging to stupid RISC designs, fortunately x86 won the popularity contest or we'd be stuck with those idiocies like MIPS (ARM is more tolerable at least). Doesn't change the fact x86 is the best (to me). x86 isn't perfect though, it has a lot of redundancy. But RISC has much more redundancy, in the name of "order".

A lot of people like RISC because it's more "ordered" and "simple" as in almost all operations are similar in structure, but that is exactly why it's NOT good and I despise it. This leads to redundancy in the name of keeping things simple. The best, objectively, is that which has zero redundancy.

I know that you, for example, said you liked the sal opcode because it kept a nice symmetry. I completely disagree with this idea. sal is perfect example of redundancy that should not exist and I hate it. That's why I despise RISC and don't care how "clean" people say it is. Everything redundant should be special purposed, that would be an ideal CPU without the human mind infesting it. (e.g. xor reg, reg may be the only way to clear something to zero, sub reg, reg should be something special and such)
Post 06 Oct 2017, 13:42
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20306
Location: In your JS exploiting you and your system
revolution 06 Oct 2017, 14:22
Hehe, a number formatting question turns into a CISC vs RISC discussion only on board.flatassembler.net.

I don't like to think of things like this as better or worse, but rather just different, and for different purposes, different needs, different prices, different power usages, different memory sizes, different ...

Fortunately popularity does not equate to better. The former is quantifiable, the latter is subjective.
Post 06 Oct 2017, 14:22
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8351
Location: Kraków, Poland
Tomasz Grysztar 06 Oct 2017, 15:01
revolution wrote:
I don't like to think of things like this as better or worse, but rather just different, and for different purposes, different needs, different prices, different power usages, different memory sizes, different ...

Fortunately popularity does not equate to better. The former is quantifiable, the latter is subjective.
My points exactly. Smile
Post 06 Oct 2017, 15:01
View user's profile Send private message Visit poster's website Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20306
Location: In your JS exploiting you and your system
revolution 06 Oct 2017, 19:52
Tomasz Grysztar wrote:
A note on a margin: this is just a curiosity, but early versions of fasm were so strongly case-sensitive that all hexadecimal digits had to be upper case. But thanks to that these early releases allowed hexadecimal numbers to start with a letter - for example "Ah" was a valid hexadecimal number, distinguished only by the case from the x86 register "ah".
I'm actually glad I never saw those versions. I might never have come back to see a later version. I would have been scarred for life. Wink
Post 06 Oct 2017, 19:52
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8351
Location: Kraków, Poland
Tomasz Grysztar 06 Oct 2017, 20:00
revolution wrote:
I'm actually glad I never saw those versions. I might never have come back to see a later version. I would have been scarred for life. Wink
I'm glad I have realized my mistake soon enough. Wink
Post 06 Oct 2017, 20:00
View user's profile Send private message Visit poster's website Reply with quote
Furs



Joined: 04 Mar 2016
Posts: 2493
Furs 07 Oct 2017, 11:33
Well, I never said that they're good because they are popular. Heck, I hate Java or Python and they're both "popular" (especially Python, the syntax is just horrendous and forced indentation is ugh...). I only stated that it's good C/C++ became popular (in my opinion of course) since they have good syntax (to me, not as a literature author Razz).

I don't think C is perfect though. Function pointer syntax is a bit... ehm hard to grasp for newbies. It does make sense when you learn how it parses though. Wouldn't say I'm a fan of that.

Also, Lisp is a nice concept but again, the syntax is horrendous. It's great that it is compact and is less ugly than some Perl's "compact syntax", but the parentheses just throw me off. They just look so intimidating.
Post 07 Oct 2017, 11:33
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8351
Location: Kraków, Poland
Tomasz Grysztar 07 Oct 2017, 13:09
Furs wrote:
Also, Lisp is a nice concept but again, the syntax is horrendous. It's great that it is compact and is less ugly than some Perl's "compact syntax", but the parentheses just throw me off. They just look so intimidating.
On this point we agree. I too perceive LISP as a really nice idea packed into a horrible syntax. It tempts to write something complex and interesting in it, but then in it ends up visually on par with esoteric languages.
Post 07 Oct 2017, 13:09
View user's profile Send private message Visit poster's website Reply with quote
neville



Joined: 13 Jul 2008
Posts: 507
Location: New Zealand
neville 08 Oct 2017, 04:11
I want to revisit the '0x' notation convention used by C/C++ etc which I absolutely despise because I feel strongly that it is totally illogical and therefore completely without merit.

For a start it obviously requires ALL hex numbers to start with a '0' whether they need to or not. That's inefficient and just plain DUMB!!

Secondly it uses 'x' for hex. That's about as logical as using 'y' for assembly or 'r' for assembler... h is for hex, just as d is for decimal etc.

Thirdly, it precedes the hex number with its stupid notation which probably prevents the 2-char sequence '0x' ever being used as a string elsewhere, at least not without some useless warning message from the compiler...

So its clearly time for a far superior HLL, maybe called C++++, in which hex numbers are ONLY identified by a trailing 'h' and must be preceded by a '0' ONLY if they start with an 'alpha' digit Very Happy Wink

_________________
FAMOS - the first memory operating system
Post 08 Oct 2017, 04:11
View user's profile Send private message Visit poster's website Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20306
Location: In your JS exploiting you and your system
revolution 08 Oct 2017, 06:39
Code:
0hffffffff
0xffffffff
0ffffffffh
$ffffffff
hex(ffffffff)
ffffffff_hex    
Maybe we should have a poll to determine the most liked and then refuse to implement it unless C also uses it.
Post 08 Oct 2017, 06:39
View user's profile Send private message Visit poster's website Reply with quote
Furs



Joined: 04 Mar 2016
Posts: 2493
Furs 08 Oct 2017, 10:58
neville wrote:
For a start it obviously requires ALL hex numbers to start with a '0' whether they need to or not. That's inefficient and just plain DUMB!!
Inefficient? It makes it clear the number is probably not decimal (in fact it's pretty common that starting with a 0 means "octal number" in some cases and not just C) so your brain can process such number faster. Suffixes for bases are beyond dumb. Even binary numbers should be done like "0b10100100" rather than b suffix. Suffixes signify units or formats not base.

neville wrote:
Secondly it uses 'x' for hex. That's about as logical as using 'y' for assembly or 'r' for assembler... h is for hex, just as d is for decimal etc.
d for decimal is also dumb, who uses that? Talk about redundancy and inefficiency. x is for hex since it's base sixteen. h suffix sounds like "half" as in half-precision floating point number. Rolling Eyes

Code:
1234UL    ; unsigned long integer, base 10
0x1234UL  ; unsigned long integer, base 16
1.0f      ; single-precision floating point constant    
No ambiguity, perfectly logical. Look at this bullshit of your suggestion:
Code:
1234hUL   ; WTF is this hUL unit/format?!?    


neville wrote:
Thirdly, it precedes the hex number with its stupid notation which probably prevents the 2-char sequence '0x' ever being used as a string elsewhere, at least not without some useless warning message from the compiler...
"String" beginning with a digit is not valid token anyway, so what's your point?

Consistency must not be your forte.
Post 08 Oct 2017, 10:58
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  
Goto page 1, 2  Next

< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.