Phil Pilgrim (PhiPi)
01-29-2008, 02:05 AM
Monday musings...
In a program's DAT section, if I enter
word long "abc", "def"
the assembler produces: "a", 0, 0, 0, "b", 0, "c", 0, "d", 0, "e", 0, "f", 0. I find it odd that the default alignment gets applied to each character rather than each group of characters, and odder still that the size modifier gets applied only to the first character of a group. It appears that the notational cohesion apparent in "abc" extends no further than the source code.
I wonder if this was intended, as it leads to a possible problem. Suppose I want a sequence of characters to begin in memory on a long boundary. I try this:
long byte "abcd"
The assembler flags the byte modifier with an error: "Size override must be larger." Hmm. Catch 22. I could certainly throw in a long 0 ahead of my string to align it, but that's awkward and wasteful. I could also make sure to declare my string after any other long declaration. But what if I had a whole bunch of strings whose first characters I want aligned on long boundaries? Must I then count the characters and pad them out by hand?
The solution, as I've discovered, is to place an empty long ahead of each string, thus:
long
byte "abc"
long
byte "efg"
A bit awkward, but it works. Nonetheless, wouldn't the following notation have been more concise (but for the first behavior noted above)?
long byte "abc", "efg"
Granted, treating strings cohesively would have required a way to include non-ASCII bytes within a group (which is what escape sequences are for). The string() notation might also have worked, but it generates an extra character and doesn't seem to be allowed in the DAT section anyway...
-Phil
In a program's DAT section, if I enter
word long "abc", "def"
the assembler produces: "a", 0, 0, 0, "b", 0, "c", 0, "d", 0, "e", 0, "f", 0. I find it odd that the default alignment gets applied to each character rather than each group of characters, and odder still that the size modifier gets applied only to the first character of a group. It appears that the notational cohesion apparent in "abc" extends no further than the source code.
I wonder if this was intended, as it leads to a possible problem. Suppose I want a sequence of characters to begin in memory on a long boundary. I try this:
long byte "abcd"
The assembler flags the byte modifier with an error: "Size override must be larger." Hmm. Catch 22. I could certainly throw in a long 0 ahead of my string to align it, but that's awkward and wasteful. I could also make sure to declare my string after any other long declaration. But what if I had a whole bunch of strings whose first characters I want aligned on long boundaries? Must I then count the characters and pad them out by hand?
The solution, as I've discovered, is to place an empty long ahead of each string, thus:
long
byte "abc"
long
byte "efg"
A bit awkward, but it works. Nonetheless, wouldn't the following notation have been more concise (but for the first behavior noted above)?
long byte "abc", "efg"
Granted, treating strings cohesively would have required a way to include non-ASCII bytes within a group (which is what escape sequences are for). The string() notation might also have worked, but it generates an extra character and doesn't seem to be allowed in the DAT section anyway...
-Phil