wla-dx icon indicating copy to clipboard operation
wla-dx copied to clipboard

Possibility for a strict instruction mode?

Open jwrayth opened this issue 4 years ago • 6 comments

I'm targeting the 65816 and I have continually had issues were WLADX infers the wrong sizing for an instruction/operand. From reading past issues, I understand that this is a difficult problem to solve based on the current implementation between the assembler and the linker.

What I would like to suggest is; Would it be feasible to introduce a "strict sizing" mode that requires the programmer to always explicitly declare the size suffix for the instruction/operand and disable all inference? Personally, I would find this much more useful than trying to decorate my code with sizing hint directives.

I'm not sure where to start looking at a feature like this in the codebase, so I wanted to raise it as an issue first to get some expert opinion.

jwrayth avatar Jan 29 '21 08:01 jwrayth

The place to implement this feature might be in decode_*.c files, I think, as there source code is turned into WLA's internal symbols.

Enhancement idea: Currently decode_*.c files are difficult to edit, so perhaps encapsulating the code inside to a function would make life easier?

vhelin avatar Jan 29 '21 12:01 vhelin

Is there a proposed syntax/compiler flag for this feature?

jeffythedragonslayer avatar Feb 21 '23 18:02 jeffythedragonslayer

No, but if you implement this then you are free to choose the flag as long as it is of the same format as the other flags :)

vhelin avatar Feb 21 '23 19:02 vhelin

Ok. @jwrayth can we get an example code snippet of the kind of code you want to be able to write as well as the way WLA-DX forces you to do it right now?

jeffythedragonslayer avatar Feb 21 '23 19:02 jeffythedragonslayer

Sure thing! So in my 65816 project I'm not using directives like .16BIT to allow instructions to infer size, I'm using explicit operand sizing on my instructions.

For example, instead of

.16BIT
lda #$80

I would use

lda.w #$80

I was looking for a mode to disable any inferred sizing, and force the user to explicitly declare the size of the instruction/operand (when applicable). This is so that I can receive errors when the operand sizing has been omitted.

jwrayth avatar Feb 22 '23 08:02 jwrayth

Just a sidenote (mainly for @jeffythedragonslayer): Instead of giving

lda.w #$80

which is a bit nasty if you think it from the point of a MC68000 programmer, you can also give

lda #$80.w

vhelin avatar Feb 22 '23 10:02 vhelin