Resource centre for ZX Spectrum games
using Manic Miner and Jet Set Willy game engines
Archive of the
Manic Miner & Jet Set Willy Yahoo! Group
messages
|
|
||
|
|
Message: 5490
Author: andrewbroad
Date: 12/02/2006
Subject: Re: How best to represent hexadecimal? #
After sleeping on the problem and meditating further, I've decided
to use # as a prefix for hexadecimal literals.
If I see &86B0, $86B0 or #86B0, my brain is much quicker to tell me
that #86B0 contains 4 rather than 5 digits.
# is not the most common hex-prefix, but it's the one Geoff Eddy
uses in his disassemblies and on his website, and it's also used in
HTML as a prefix for hexadecimal colour-attributes.
I mentioned that some assemblers use $ to mean the current value of
the location-counter. Another (not Z80) assembler I've seen uses #
to denote an immediate operand - in denary - but I'll just have to
live with that.
I often use #n to mean "number n" (in denary), but I've never done
that in a MM/JSW context (I used this notation in my PhD thesis, and
I continue to do so when discussing tennis-rankings).
john_elliott_uk wrote:
>And in Windows XP's Command Prompt, it's used to separate multiple
>> (a) &DE. I like the idea of having a one-character non-
>> alphanumeric symbol as a prefix, as long as there's no ambiguity
>> with the use of & as the bitwise-AND operator. Unfortunately if
>> you type &DE on a command-line, it strips off the & unless you
>> type "&DE".
>
> Depends on the command line. In UNIX shells, it runs the task in
> the background.
commands on one command-line. I actually managed to start
RealSpectrum by using & in the vicinity of FILENAME.TAP!
# doesn't have such a drawback (at least not in Windows XP's Command
Prompt).
>> (e) DEh (as seen in assemblers, along with 222t for denary,I've revised SPECSAISIE Disassemble to use the # prefix for all
>> 11011110y for binary and 336o for octal). But this is long-
>> winded, and again could be misinterpreted as a variable-name
>> unless written as 0DEh - yuck!
>
> No Z80 assembler I've used allows hex numbers in this form to start
> with a letter, so if you want something that actually assembles
> you'd have to include the leading zero.
hexadecimal numbers > 9 when the command-line flag -h (output in
hexadecimal) is given.
I've written a new method ByteSupport.parseInt that acts as a
wrapper for Integer.parseInt, but recognises &, $, #, 0x and 0X as
hexadecimal prefixes, and h and H as hexadecimal suffixes. So far
only SPECSAISIE Disassemble calls this method, but soon SPECSAISIE
will use it for all numeric command-line arguments.
SPECSAISIE Assemble - when I write it - should recognise all these
hex-notations as input (but will no doubt require leading zeroes for
hex-literals starting with A-F when using the h suffix).
>> -----------------I guess I'll put # on the right-hand side then:
>> 128K memory-banks
>> -----------------
>>
>> My hex-notation will also have to interact with my bank-notation
>> (when I implement SPECSAISIE's model of 128K memory).
>>
>> e.g. John Elliott wrote "C300h in bank 3"
>>
>> 3:C300h
>> &3:C300 }
>> 3:&C300 } ditto re. $ and #
>> Ox3:C300
>> 3:0xC300
>
> Since the bank is always in the range 0-7 and therefore looks the
> same in denary, hex and octal, putting the indicator on the side
> with the bank number rather than the address might cause
> confusion.
3:#C300 (accepted as input and generated as output)
#3:C300 (rejected because C300 doesn't parse as an integer)
#3:#C300 (accepted as input, but the first # is unnecessary)
So SPECSAISIE will have a method parseAddress which will call
ByteSupport.parseInt for the substrings to the left and right of :
(and will also accept 48K memory-addresses, e.g. #C300 on its own).
> And if you used a convention that addresses formed b:xxxx wereBut that is inelegant and Spectrum-specific, and would break down if
> hexadecimal, and addresses formed b:nnnnn were hex, you wouldn't
> need any other indicator.
I ever did want to address ROM (addresses < 16384 = #4000) - to
access the standard font, for example, or to disassemble ROM.
> > Hex 5:86B0: C3 CA 87D'oh! :-o
> > (5: is unnecessary in this example
>
> and incorrect; 86B0h is in bank 2
--
Dr. Andrew Broad
http://geocities.com/andrewbroad/
http://geocities.com/andrewbroad/spectrum/
http://geocities.com/andrewbroad/spectrum/willy/
