Re: What causes this infinite loop?
- From: Frank Kotler <spamtrap@xxxxxxxxxx>
- Date: Wed, 09 Aug 2006 15:05:31 -0400
Jerry Coffin wrote:
In article <NIOdneYyOeh3OUTZnZ2dnUVZ_tKdnZ2d@xxxxxxxxxxx>, spamtrap@xxxxxxxxxx says...
[ ... ]
With most assemblers, "It's not just a good idea, it's the law!" Usually, an "identifier" must not start with a decimal digit, a number must start with a decimal digit. If the "hex number" starts with a decimal digit, you don't have to add a zero. There isn't much point to "mov ah, 09h" :)
I'm not at all sure that's true of most assemblers at all. Most of the assemblers I've used on non-Intel platforms have used what I'd consider more sensible rules. There's virtually nothing sensible about using a suffix to signal a number's base -- a prefix makes far more sense. It makes the code easier to read and the assembler easier to write.
Okay, I'm not familiar with that many assemblers - especially non-x86. I go back far enough that "x" used to mean "times" - multiplication - and whenever I see "zero times ???" my brain goes "BZZZZT", so I really don't like the "0x" notation. I'm gradually getting used to it, but it's taking a long time! :)
In a typical case, a hexadecimal number is signalled by a '$' as a prefix:
lda #14 ; loads accumulator with 14 decimal
lda #$14 ; loads accumulator with 14 hexadecimal
Simple, straightforward, and no confusion. Oh, in case you wondered, those same assemblers typically signal an immediate value with '#':
lda #14 ; the value 14
lda 14 ; the value from address 14
lda (14) ; the value pointed to by address 14
; some use '[14]' or '*14' instead.
Since assemblers for Intel platforms generally don't require anything to signal an immediate value,
..... but many do...
there's nearly constant confusion in this area. Specifically, there are three distinct cases, but they provide only two notations to differentiate between them.
Some assemblers (e.g. NASM) have consistent rules, but from the number of times questions about this arise here, it's pretty clear that most people don't quite understand them. Even when you do understand them, it's annoying to use (IMO, obviously).
Not so obvious to me... Seems quite unintuitive to require some "marker" to indicate an immediate. The "[mem]" notation visually suggests "contents" to me. What could be simpler? Obviously, preferences differ - different assemblers don't do it differently by accident!
Best,
Frank
.
- References:
- What causes this infinite loop?
- From: Sam
- Re: What causes this infinite loop?
- From: Jerry Coffin
- What causes this infinite loop?
- Prev by Date: Re: What language are assemblers written in?
- Next by Date: Re: What language are assemblers written in?
- Previous by thread: Re: What causes this infinite loop?
- Next by thread: [Q] How to know which CPU issues PCI config cycle in SMM ?
- Index(es):
Relevant Pages
|