Functions with more than one entry
Pages: 1 2
Steve Drain (222) 1620 posts |
True, but it is trivial to do that if you want to: DIM P% 19 [OPT 2 ._ADDRESS LDR r0,[r9],#8;lval of address% LDR r1,[r9],#8;lval of string$ LDR r1,[r1];address of string$ STR r1,[r0];address => address% MOV pc,lr ] string$="Hello world!"+CHR$13 CALL_ADDRESS,string$,address% PRINT $address% Use |
Rick Murray (539) 13840 posts |
Oh, I noticed that (which is why it’s all zero, I tried different values) but since I was using StrongHelp and only doing it for the sake of doing it, I couldn’t be bothered to dig up the PRM to see if it agreed with SH (and thus not with reality). At any rate, it certainly seems like Territory has impressed me with even more brokenness. ;) |
Rick Murray (539) 13840 posts |
Uh… Yeah… It does a quick bit of shifting to nuke the upper sixteen bits of R3, which is weird given that only bits 0-2 are defined as doing anything. Then, get this, we OR in the two flags. Yup, TheF…? Edit: Reported |
Steve Drain (222) 1620 posts |
Thanks for that, Rick, it saves me the bother. ;-) |
Sprow (202) 1158 posts |
Take a moment to read the whole function before jumping to conclusions, as collation is a multi-pass affair. Scroll down as far down as line 378, for example, where the user’s flags are restored. |
Steve Drain (222) 1620 posts |
E pur si muove I still cannot get Collate to work as I know I have before, just with a simple SYS call. Perhaps it is me. ;-] |
Rick Murray (539) 13840 posts |
Okay. I won’t pretend to understand exactly what is going on inside. Instead, I’ll look at it from the outside. Here’s a modified version of the above program (fixed the name buffer N% being about forty bytes too small ;) ).
What we’re doing is running through the entire process four times, building the data tables with identical data to start with, and rebuilding the assembler code to pass flags (0, 1, 2, and finally 3). This corresponds to obey case/obey accents, ignore case/obey accents, obey case/ignore accents, and finally ignore both case and accents. And here is the result. *_names2 After territory-collate sorting with flags = 0 0000987C : Angela 000097EC : april 0000982C : Ásfríðr 0000984C : aubrey 0000980C : Æronwen 0000985C : clemence 0000983C : Clíodhna 0000986C : Clotilde 000097FC : Emily 0000981C : Jessica After territory-collate sorting with flags = 1 0000987C : Angela 000097EC : april 0000982C : Ásfríðr 0000984C : aubrey 0000980C : Æronwen 0000985C : clemence 0000983C : Clíodhna 0000986C : Clotilde 000097FC : Emily 0000981C : Jessica After territory-collate sorting with flags = 2 0000987C : Angela 000097EC : april 0000982C : Ásfríðr 0000984C : aubrey 0000980C : Æronwen 0000985C : clemence 0000983C : Clíodhna 0000986C : Clotilde 000097FC : Emily 0000981C : Jessica After territory-collate sorting with flags = 3 0000987C : Angela 000097EC : april 0000982C : Ásfríðr 0000984C : aubrey 0000980C : Æronwen 0000985C : clemence 0000983C : Clíodhna 0000986C : Clotilde 000097FC : Emily 0000981C : Jessica * I built a version with OPT 3 to verify that it was passing different flags to Territory_Collate. It was. So why is the result identical for each possible flags option? Surely whether, or not, you’re paying attention to case and/or accents would cause the order to change when some names begin with a lower case letter, and one begins with an ‘Á’ (plus the ‘Æ’ too)? |
André Timmermans (100) 655 posts |
I am surprised that it works with territory number 0, UK is 1 and the other countries have a higher number. |
Rick Murray (539) 13840 posts |
|
André Timmermans (100) 655 posts |
Ah, I missed the MVN, I am too used to ObjAsm automatically transforming MOV of negatives into MVN instructions. |
Martin Avison (27) 1494 posts |
I have updated the bug report with some details of further confusion if flag bit 2 is used, which according to the StrongHelp manual is ‘interpret cardinals (5.22+)’, which should result in File9 < File10. |
Rick Murray (539) 13840 posts |
Thanks. As I was just looking at names, I didn’t do anything with bit 2. But… What? That looks both backwards and the cutoff (0-2 and 3-7) doesn’t make sense. Edit: only had a cursory look at the code (on break at work), but nothing looks like it is particularly wrong…other than being a big pile of assembler. ;) |
Fred Graute (114) 645 posts |
The code compares the strings ignoring case and accents. If this produces a match then, and only then, are the flags taken into consideration. So comparing Comparing It seems this SWI behaves differently from what many, including me, had inferred from its description. |
Martin Avison (27) 1494 posts |
I have just used a small program to test just Territory_Collate, and it seems to me that the case flag and cardinal flags are working ok. The accent flag is working, but I have no idea which should be high! So I am now confused, and wondering what sequence the UK territory accented characters are really in – and are they treated as accented characters? My test program is:
|
Rick Murray (539) 13840 posts |
Sorry for the terseness. I had written a longer reply, but managed to stiff the machine. So, take two…
Doesn’t seem to be the case. I replaced Emily with april (lower case), and it sorted the names in the order Angela, April, april for flag settings 0-3. Given that april was before April in the input data, one might have expected to see it sorted first if the case was not being considered.
Certainly. We’ve had to make logical assumptions given that the description is too damn short to be useful. Things like “if we are NOT ignoring case, then case will be considered”. Plus, as far as I can tell, the actual behaviour is non-obvious. Furthermore, it’s a great shame that there is no “Western European” option to the Collate SWI, because the Betamax/German-S-thing will only be counted as an S in German. Brits get the fl and fi ligatures counted as ‘fl’ and ‘fi’. It doesn’t seem to recognise æ as ‘ae’ (but might in French?). This design flaw means it’s pretty much not possible to correctly sort a list of names where some are local and some are foreign. As my example shows, it’ll get it mostly correct, but not completely. As to hanging the machine… I made a whoopsie. Name #0 was “april” and name #9 was also “april” (I meant to make it capitalised and forgot). I’m not sure which SWI objected, but no error was raised. The machine just stiffed. Yay! |
Grahame Parish (436) 481 posts |
What does it do if there are two entries which are identical? Shuffle them both around forever? |
Martin Avison (27) 1494 posts |
I also made a whoopsie … It seems that flag bit 2 (interpret cardinals) works as intended. I have corrected my bug comment.
Some sort techniques preserve the order of equal keys, but the majority do not, and it is random which ends up first. I cannot remember offhand what HeapSort does. It is random with my ArmSort, which uses flash and shell sort algorithms. |
Rick Murray (539) 13840 posts |
Might be a bug in my code, but it hung (in an unrecoverable way as it will have been stuck somewhere in the OS)… so, yeah, probably beating itself across the head trying to work out which should come first. ;-) |
Martin Avison (27) 1494 posts |
I supect that line is a bug. As written flags% will be taken as a register number to load into r3, when I think it should be a literal Not sure if that could cause a loop, however! |
Rick Murray (539) 13840 posts |
That’s a good point. I’ll fiddle with that next time I’m at the computer and see if egg suddenly splatters over my face. :-) PS: Lesson number one billion, four hundred thousand and thirty eight for why one shouldn’t use assembler in the 21st century… |
Fred Graute (114) 645 posts |
Apply the fix Martin suggested, and make sure april comes before April, and you will see a difference in the output depending on case-sensitivity. The code I tested with was quite similar to Martin’s:
|
Pages: 1 2