Closed iddq closed 4 years ago
I do not know, but I did try with org $1000 and it assembled. Perhaps some issue with "zero page" - does the HD6303 even have such a thing?
forwarding references doesn't work if the label's address is lower than 0x100
forwarding references doesn't work if the label's address is lower than 0x100
... for HD6303. I tested 6502 and it works fine.
The error is in the 'jsr' instruction. Replace it with a 'jmp' and it assembles OK.
I suspect this may be an issue/confusion related to the multiple forms of the HD6303 JSR instruction...
In particular, there is a one-byte form and a two-byte form. With the destination address being one-byte (high byte is zero) then that may lead to confusion in the assembly?
With that in mind, I tried the following, which assembles...
processor hd6303
org $0
jsr.w test
test
bra test
giving the following list file...
------- FILE ./test.asm LEVEL 1 PASS 2
1 0003 processor hd6303
2 0005 ????
3 0000 org $0
4 0000
5 0000
6 0000 bd 00 03 jsr.w test
7 0003 test
8 0003 20 fe bra test
This looks correct to me. So, my suggestion - when in the first page of memory, you must manually force the two-byte instruction with a suffix of '.w' on jsr instructions.
To sum this one up in a nutshell: JSR instruction has three forms. One is specific to the first page of memory. In the case of a JSR with a forward reference to a label in the first page, the assembler is confused between the two options - short-form and long-form. If the 'jsr' follows the label, the assembler will correctly put the single byte jsr form. If the jsr precedes the label, the assembler errors-out because of a label size mismatch. In particular, where it is expecting an 8-bit label it sees a 16-bit label. The proposed 'solution' gets around the label mismatch error by forcing the long-form instruction to be used in the case where we require a JSR before a label which is in the first page. If a single-byte JSR is required in this situation, instead use a macro to manually insert the opcode and address.
This is only the top of the iceberg. DASM has general problems when addresses change.
E.g. I tried to create a conditional branching macro. So depending on the target address, the code would either be e.g.:
bne label
or
beq skip$
jmp label
skip$
But DASM doesn't like that, probably because the code length varies between passes and this affects all following labels. I am not sure if this can be fixed easily.
Thomas, can you provide a small test case for your conditional branch failure?
There you go: test.zip
For test 5, it seems that in the first passes, the code is compiled using varying parts of the macro. The target address changes, but that's fine. But in pass 3 DASM detects that it has to use JMP, which causes the target address to change again. And that is not liked by DASM.
Use -v4 to see the address of ForwardErr:
Thanks. I'll see if anything can be done.
The original test case appear to work in the current master. It looks like the "allow labels to shift between multiple passes" update fixed the issue.
Can you please help me why is it wrong?