drcjt / CSharp-80

C# AOT compiler for Z80 based computers including the TRS-80 and ZX Spectrum
https://drcjt.github.io/CSharp-80/
GNU General Public License v3.0
51 stars 3 forks source link

Consider using MemoryOperand in Z80 Assembler #224

Open drcjt opened 1 year ago

drcjt commented 1 year ago

Currrently Z80 assembler is bit of a mish mash of methods and techniques for specifying operands.

If an operand is to refer to memory then could use a new class e.g. MemoryOperand as per how iced assembler does this. Will need something to indicate in the call that something is to be a memory operand e.g.

assembler.Ld(R16.HL, MemoryOperand(4020)); Would correspond to:

LD HL, (4020)

drcjt commented 1 year ago

Consider reviewing how ryujit represents instructions. See "Instruction Encoding" section in https://github.com/dotnet/runtime/blob/main/docs/design/coreclr/jit/ryujit-overview.md

drcjt commented 1 year ago

See #225 which now uses ideas from iced assembler to give a more natural representation for memory operations. So

assembler.Ld(R16.HL, MemoryOperand(4020));

Now becomes:

assembler.Ld(HL, __[4020]);

Note that can use HL for first parameter due to "using static" directive.