Cannot parse line with .SELECT with dialect asMSX
Fubukimaru opened this issue · 26 comments
Hello!
I'm getting the following error:
Cannot parse line CODE.ASM#39: .SELECT 1 AT 06000h left over tokens: [AT, 06000h]
Could it be that it's clashing with another SELECT
definition?
https://github.com/Fubukimaru/asMSX/blob/master/doc/asmsx.md#25-directives
Oh! that's my bad, I now realize that I missed many asMSX directives! At least, I am seeing ".SELECT", ".SUBPAGE", ".CALLBIOS" amd ".CALLDOS"! Let's keep this issue open, and I'll add support for these as soon as possible! I have been taking a break from working on MDL, but I think it might be time to get back to working on it :)
If you need any help, ping me :).
And sorry for opening so many issues :P
sure! and don't worry about all the issues, it's great to have activity in the project haha :)
Hi Fubukimaru, quick question, I was looking at .SELECT, and is the code that will be generated the one in the "select_page_direct" and "select_page_register" functions here https://github.com/Fubukimaru/asMSX/blob/master/src/dura.y?
Just making sure I get it right before implementing, hehe :)
Hey!
Yes, those functions are called from this part of the code:
| PSEUDO_SELECT value PSEUDO_AT value
{
if (conditional[conditional_level])
{
if (rom_type != MEGAROM)
error_message(40, fname_src, lines);
select_page_direct($2, $4);
}
}
| PSEUDO_SELECT REGISTER PSEUDO_AT value
{
if (conditional[conditional_level])
{
if (rom_type != MEGAROM)
error_message(40, fname_src, lines);
select_page_register($2, $4);
}
}
So:
PSEUDO_SELECT value PSEUDO_AT value
-> .SELECT value AT value
This ends up as:
select_page_direct(value, value)
And this:
PSEUDO_SELECT REGISTER PSEUDO_AT value
-> .SELECT register AT value
Ends up as:
select_page_register(register, value)
If you need more info ping me :)
ok! I think I have it! But just to confirm, just before I make another release. This example code:
; Test case:
.megarom konami
.start loop
loop:
jr loop
.select 1 at 06000h
ld a,3
.select a at 07000h
ld b,5
.select b at 08000h
Would translate to this in standard Z80 notation, right?:
org #4000
db "AB", loop % 256, loop / 256, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
loop:
jr loop
push af
ld a, 1
ld (#6000), a
pop af
ld a, 3
ld (#7000), a
ld b, 5
push af
ld a, b
ld (#8000), a
pop af
If the previous is correct, then my last commit solves the issue with ".select", and I'll make a quick release that includes the fix! :p
I had to use http://map.grauw.nl/resources/z80instr.php to check the opcodes, but yes!
Looks good. Thanks Santi!
Apologies for the delay! I just made a new release with the .SELECT support in asMSX included. If you get a chance to try it and it still does not work as expected, by all means, let me know (and reopen the ticket, but I'll close it for now :)
Release here: https://github.com/santiontanon/mdlz80optimizer/releases/tag/alphav1.2
Great! I'll test it :).
Thanks for the work!
I'm getting the following:
|| Picked up _JAVA_OPTIONS: -Djava.util.prefs.userRoot=/home/fubu/.config/java
|| ERROR: Problem parsing file STAN_MG.ASM: java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
|| ERROR: java.util.ArrayList.rangeCheck(ArrayList.java:659)
|| ERROR: java.util.ArrayList.get(ArrayList.java:435)
|| ERROR: parser.dialects.ASMSXDialect.parseLine(ASMSXDialect.java:397)
|| ERROR: parser.LineParser.parseInternal(LineParser.java:249)
|| ERROR: parser.LineParser.parse(LineParser.java:183)
|| ERROR: parser.LineParser.parse(LineParser.java:173)
|| ERROR: parser.CodeBaseParser.parseSourceFileInternal(CodeBaseParser.java:208)
|| ERROR: parser.CodeBaseParser.parseSourceFile(CodeBaseParser.java:102)
|| ERROR: parser.CodeBaseParser.parseMainSourceFile(CodeBaseParser.java:39)
|| ERROR: cl.Main.main(Main.java:38)
In other file I'm getting the following:
|| Picked up _JAVA_OPTIONS: -Djava.util.prefs.userRoot=/home/fubu/.config/java
|| ERROR: No op spec matches with operator in line SRC/ROOMRUT.GEN#25: ld (ROOMEXITS),A
Is there something I can help with?
Wow, thanks for testing it so fast! :)
Ah, the first one is a bug, my bad! haha Just fixed it, and reuploaded the new version on the same link as above!
But in the second case, the error is correct, right? I just tried that line in asMSX, and it does not compile, the indirection should use square brackets, like "ld [ROOMEXITS],A". The line does parse fine in MDL with any other dialect, but if you select asMSX that line will not parse. Does it parse in the latest version of asMSX? (maybe I have an older version)
About the second error: We also cover ZILOG standard syntax (https://github.com/Fubukimaru/asMSX/blob/master/doc/asmsx.md, 2.5 Directives).
There is a flag to swap the [] to (). This has been present for a long time but probably most of users use it without .ZILOG directive (or -z flag). We're making an effort now on supporting legacy behaviour and more standard (book-like) behaviours. Is it possible to cover both?
Thanks!
Oh! I see!!! of course! Will add support right away. I will add something equivalent to the "-z" flag, and also support the ".ZILOG" directive, to be as close to asMSX as possible.
Alright! updated the release again! :)
now, when you select the "dialect", you can use "asmsx", or "asmsx-zilog", which should simulate the "-z" argument in asMSX (if I got it right, haha). The ".ZILOG" directive is also supported now.
Hello Santi!
Thanks for your work :).
That should be it. I will test it this afternoon if I'm able to :)
On the other hand, I assume that this is already covered but just in case: All the directives are recognized with and without the dot, e.g. ZILOG and .ZILOG.
Great! And yes! I have not tested this much, but in principle all directives are supported with and without the dot :)
I have detected an issue with the SELECT
directive:
This is not correctly parsed in MDL:
SELECT a AT A000h
However this gets correctly parsed:
.select a at A000h
We get Missing token 'at'
. Interestingly SELECT a at A000h
also works. Looks like at
needs to be in lowercase, is it possible?
On the other hand on other directive we get this:
Cannot parse line CODE.ASM#347: SUBPAGE 1 at 06000h left over tokens: [1, at, 06000h]
By the way: I have tested Zilog and using asmsx-zilog. Works like a charm :)
Thanks!
Ops, you are completely right, there was an "equals" instead of a "equalsIgnoreCase" in that path of the code... Fixed that! :)
Will add the "subpage" directive later today and make an update on the release. Will ping here when done. Thanks a lot for testing, this is awesome btw! :D
You and your software are awesome ;). I'm just messing with it.
haha, thanks :)
Ok, I added initial support for ".subpage/subpage" and updated the release. I haven't tested it as much as I'd like, but I hope it works as expected haha :)
For some reason I'm getting an error 2:
[fubu@Yae CODE2020_macro]$ java -jar ~/bin/mdl.jar -dialect asmsx-zilog -po CODE.ASM
Picked up _JAVA_OPTIONS: -Djava.util.prefs.userRoot=/home/fubu/.config/java
[fubu@Yae CODE2020_macro]$ echo $?
2
Any clue on how to test this to give you more info?
Hmm, interesting. An exit value of "2" means there was an error in parsing the .asm file. But I'm surprised no other error was shown before failing! There must be a path in the code where it fails silently. Would you mind sharing that CODE.ASM file privately (I'll not redistribute), so, I can test? :)
I was able to reduce the code to the minimum expression:
MEGAROM KonamiSCC
select 1 at 06000h
xor a
When you have the MEGAROM
directive it looks like select
makes it crash.
Thanks! And indeed there was a bug! mdl translates directives like "select ..." to assembler instructions, but I was translating them to instructions with square brackets for indirections. When the "zilog" mode was activated, some of those instructions became illegal. I just had to make sure to generate indirections with "[" or "(" when generating code internally depending on whether the zilog mode is on or off :)
Release updated! Thanks a lot again! :D
Looks like it's working correctly, thanks!