From a92630e5c7fa274ce96b38dd153bbcfdb16d04d7 Mon Sep 17 00:00:00 2001 From: chrisly42 Date: Fri, 8 Oct 2021 15:09:41 +0200 Subject: [PATCH] Added Address Register Indirect with Base Displacement addressing mode. --- .../plugins/m68k/parser/M68kParser.java | 267 ++++++++++++++++-- .../intellij/plugins/m68k/psi/M68kTypes.java | 6 + .../plugins/m68k/psi/M68kVisitor.java | 13 + .../intellij/plugins/m68k/asm/M68kIsa.kt | 2 + .../platon42/intellij/plugins/m68k/m68k.bnf | 41 ++- .../plugins/m68k/psi/M68kAddressModeUtil.kt | 23 +- ...M68kWithOptionalAddressRegisterIndirect.kt | 6 + .../m68k/psi/M68kWithOptionalIndexRegister.kt | 6 + .../m68k/parser/AddressingModesTest.kt | 40 +++ ..._indirect_with_index_base_displacement.txt | 34 +++ ..._index_base_displacement_without_index.txt | 24 ++ ..._indirect_with_index_base_displacement.txt | 35 +++ ...rect_with_index_base_displacement_only.txt | 22 ++ ...ndex_base_displacement_with_dreg_index.txt | 29 ++ ...h_index_base_displacement_without_areg.txt | 32 +++ ..._index_base_displacement_without_index.txt | 26 ++ ...rect_with_index_base_displacement_zero.txt | 17 ++ 17 files changed, 589 insertions(+), 34 deletions(-) create mode 100644 src/main/java/de/platon42/intellij/plugins/m68k/psi/M68kWithOptionalAddressRegisterIndirect.kt create mode 100644 src/main/java/de/platon42/intellij/plugins/m68k/psi/M68kWithOptionalIndexRegister.kt create mode 100644 src/test/resources/parser/addressingmodes/pc_indirect_with_index_base_displacement.txt create mode 100644 src/test/resources/parser/addressingmodes/pc_indirect_with_index_base_displacement_without_index.txt create mode 100644 src/test/resources/parser/addressingmodes/register_indirect_with_index_base_displacement.txt create mode 100644 src/test/resources/parser/addressingmodes/register_indirect_with_index_base_displacement_only.txt create mode 100644 src/test/resources/parser/addressingmodes/register_indirect_with_index_base_displacement_with_dreg_index.txt create mode 100644 src/test/resources/parser/addressingmodes/register_indirect_with_index_base_displacement_without_areg.txt create mode 100644 src/test/resources/parser/addressingmodes/register_indirect_with_index_base_displacement_without_index.txt create mode 100644 src/test/resources/parser/addressingmodes/register_indirect_with_index_base_displacement_zero.txt diff --git a/src/main/gen/de/platon42/intellij/plugins/m68k/parser/M68kParser.java b/src/main/gen/de/platon42/intellij/plugins/m68k/parser/M68kParser.java index 9f8a598..6f5b88a 100644 --- a/src/main/gen/de/platon42/intellij/plugins/m68k/parser/M68kParser.java +++ b/src/main/gen/de/platon42/intellij/plugins/m68k/parser/M68kParser.java @@ -40,10 +40,11 @@ public class M68kParser implements PsiParser, LightPsiParser { create_token_set_(ADDRESS_REGISTER, DATA_REGISTER, REGISTER, SPECIAL_REGISTER), create_token_set_(ABSOLUTE_ADDRESS_ADDRESSING_MODE, ADDRESSING_MODE, ADDRESS_REGISTER_DIRECT_ADDRESSING_MODE, ADDRESS_REGISTER_INDIRECT_ADDRESSING_MODE, ADDRESS_REGISTER_INDIRECT_POST_INC_ADDRESSING_MODE, ADDRESS_REGISTER_INDIRECT_PRE_DEC_ADDRESSING_MODE, ADDRESS_REGISTER_INDIRECT_WITH_DISPLACEMENT_NEW_ADDRESSING_MODE, ADDRESS_REGISTER_INDIRECT_WITH_DISPLACEMENT_OLD_ADDRESSING_MODE, - ADDRESS_REGISTER_INDIRECT_WITH_INDEX_NEW_ADDRESSING_MODE, ADDRESS_REGISTER_INDIRECT_WITH_INDEX_OLD_ADDRESSING_MODE, DATA_REGISTER_DIRECT_ADDRESSING_MODE, IMMEDIATE_DATA, - MEMORY_INDIRECT_ADDRESSING_MODE, MEMORY_INDIRECT_POST_INDEXED_ADDRESSING_MODE, MEMORY_INDIRECT_PRE_INDEXED_ADDRESSING_MODE, PROGRAM_COUNTER_INDIRECT_WITH_DISPLACEMENT_NEW_ADDRESSING_MODE, - PROGRAM_COUNTER_INDIRECT_WITH_DISPLACEMENT_OLD_ADDRESSING_MODE, PROGRAM_COUNTER_INDIRECT_WITH_INDEX_NEW_ADDRESSING_MODE, PROGRAM_COUNTER_INDIRECT_WITH_INDEX_OLD_ADDRESSING_MODE, PROGRAM_COUNTER_MEMORY_INDIRECT_ADDRESSING_MODE, - PROGRAM_COUNTER_MEMORY_INDIRECT_POST_INDEXED_ADDRESSING_MODE, PROGRAM_COUNTER_MEMORY_INDIRECT_PRE_INDEXED_ADDRESSING_MODE, REGISTER_LIST_ADDRESSING_MODE, SPECIAL_REGISTER_DIRECT_ADDRESSING_MODE), + ADDRESS_REGISTER_INDIRECT_WITH_INDEX_BASE_DISPLACEMENT_ADDRESSING_MODE, ADDRESS_REGISTER_INDIRECT_WITH_INDEX_NEW_ADDRESSING_MODE, ADDRESS_REGISTER_INDIRECT_WITH_INDEX_OLD_ADDRESSING_MODE, DATA_REGISTER_DIRECT_ADDRESSING_MODE, + IMMEDIATE_DATA, MEMORY_INDIRECT_ADDRESSING_MODE, MEMORY_INDIRECT_POST_INDEXED_ADDRESSING_MODE, MEMORY_INDIRECT_PRE_INDEXED_ADDRESSING_MODE, + PROGRAM_COUNTER_INDIRECT_WITH_DISPLACEMENT_NEW_ADDRESSING_MODE, PROGRAM_COUNTER_INDIRECT_WITH_DISPLACEMENT_OLD_ADDRESSING_MODE, PROGRAM_COUNTER_INDIRECT_WITH_INDEX_BASE_DISPLACEMENT_ADDRESSING_MODE, PROGRAM_COUNTER_INDIRECT_WITH_INDEX_NEW_ADDRESSING_MODE, + PROGRAM_COUNTER_INDIRECT_WITH_INDEX_OLD_ADDRESSING_MODE, PROGRAM_COUNTER_MEMORY_INDIRECT_ADDRESSING_MODE, PROGRAM_COUNTER_MEMORY_INDIRECT_POST_INDEXED_ADDRESSING_MODE, PROGRAM_COUNTER_MEMORY_INDIRECT_PRE_INDEXED_ADDRESSING_MODE, + REGISTER_LIST_ADDRESSING_MODE, SPECIAL_REGISTER_DIRECT_ADDRESSING_MODE), create_token_set_(BINARY_ADD_EXPR, BINARY_BITWISE_AND_EXPR, BINARY_BITWISE_OR_EXPR, BINARY_BITWISE_XOR_EXPR, BINARY_CMP_EQ_EXPR, BINARY_CMP_GE_EXPR, BINARY_CMP_GT_EXPR, BINARY_CMP_LE_EXPR, BINARY_CMP_LT_EXPR, BINARY_CMP_NE_EXPR, BINARY_DIV_EXPR, BINARY_LOGICAL_AND_EXPR, @@ -211,6 +212,37 @@ public class M68kParser implements PsiParser, LightPsiParser { return r; } + /* ********************************************************** */ + // ROUND_L (internalBaseDisplacementOption1|internalBaseDisplacementOption2|internalBaseDisplacementOption3)? ROUND_R + public static boolean AddressRegisterIndirectWithIndexBaseDisplacementAddressingMode(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "AddressRegisterIndirectWithIndexBaseDisplacementAddressingMode")) return false; + if (!nextTokenIsFast(b, ROUND_L)) return false; + boolean r; + Marker m = enter_section_(b, l, _NONE_, ADDRESS_REGISTER_INDIRECT_WITH_INDEX_BASE_DISPLACEMENT_ADDRESSING_MODE, ""); + r = consumeTokenFast(b, ROUND_L); + r = r && AddressRegisterIndirectWithIndexBaseDisplacementAddressingMode_1(b, l + 1); + r = r && consumeToken(b, ROUND_R); + exit_section_(b, l, m, r, false, null); + return r; + } + + // (internalBaseDisplacementOption1|internalBaseDisplacementOption2|internalBaseDisplacementOption3)? + private static boolean AddressRegisterIndirectWithIndexBaseDisplacementAddressingMode_1(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "AddressRegisterIndirectWithIndexBaseDisplacementAddressingMode_1")) return false; + AddressRegisterIndirectWithIndexBaseDisplacementAddressingMode_1_0(b, l + 1); + return true; + } + + // internalBaseDisplacementOption1|internalBaseDisplacementOption2|internalBaseDisplacementOption3 + private static boolean AddressRegisterIndirectWithIndexBaseDisplacementAddressingMode_1_0(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "AddressRegisterIndirectWithIndexBaseDisplacementAddressingMode_1_0")) return false; + boolean r; + r = internalBaseDisplacementOption1(b, l + 1); + if (!r) r = internalBaseDisplacementOption2(b, l + 1); + if (!r) r = internalBaseDisplacementOption3(b, l + 1); + return r; + } + /* ********************************************************** */ // ROUND_L (expr SEPARATOR)? AddressRegister SEPARATOR IndexRegister ROUND_R public static boolean AddressRegisterIndirectWithIndexNewAddressingMode(PsiBuilder b, int l) { @@ -289,18 +321,20 @@ public class M68kParser implements PsiParser, LightPsiParser { // | AddressRegisterIndirectAddressingMode // | AddressRegisterIndirectWithDisplacementNewAddressingMode // | ProgramCounterIndirectWithDisplacementNewAddressingMode - // | MemoryIndirectAddressingMode - // | ProgramCounterMemoryIndirectAddressingMode - // | MemoryIndirectPostIndexedAddressingMode - // | ProgramCounterMemoryIndirectPostIndexedAddressingMode - // | MemoryIndirectPreIndexedAddressingMode - // | ProgramCounterMemoryIndirectPreIndexedAddressingMode // | AddressRegisterIndirectWithIndexNewAddressingMode // | ProgramCounterIndirectWithIndexNewAddressingMode // | AddressRegisterIndirectWithDisplacementOldAddressingMode // | ProgramCounterIndirectWithDisplacementOldAddressingMode // | AddressRegisterIndirectWithIndexOldAddressingMode // | ProgramCounterIndirectWithIndexOldAddressingMode + // | AddressRegisterIndirectWithIndexBaseDisplacementAddressingMode + // | ProgramCounterIndirectWithIndexBaseDisplacementAddressingMode + // | MemoryIndirectAddressingMode + // | ProgramCounterMemoryIndirectAddressingMode + // | MemoryIndirectPostIndexedAddressingMode + // | ProgramCounterMemoryIndirectPostIndexedAddressingMode + // | MemoryIndirectPreIndexedAddressingMode + // | ProgramCounterMemoryIndirectPreIndexedAddressingMode // | SpecialRegisterDirectAddressingMode // | DataRegisterDirectAddressingMode // | AddressRegisterDirectAddressingMode @@ -316,18 +350,20 @@ public class M68kParser implements PsiParser, LightPsiParser { if (!r) r = AddressRegisterIndirectAddressingMode(b, l + 1); if (!r) r = AddressRegisterIndirectWithDisplacementNewAddressingMode(b, l + 1); if (!r) r = ProgramCounterIndirectWithDisplacementNewAddressingMode(b, l + 1); - if (!r) r = MemoryIndirectAddressingMode(b, l + 1); - if (!r) r = ProgramCounterMemoryIndirectAddressingMode(b, l + 1); - if (!r) r = MemoryIndirectPostIndexedAddressingMode(b, l + 1); - if (!r) r = ProgramCounterMemoryIndirectPostIndexedAddressingMode(b, l + 1); - if (!r) r = MemoryIndirectPreIndexedAddressingMode(b, l + 1); - if (!r) r = ProgramCounterMemoryIndirectPreIndexedAddressingMode(b, l + 1); if (!r) r = AddressRegisterIndirectWithIndexNewAddressingMode(b, l + 1); if (!r) r = ProgramCounterIndirectWithIndexNewAddressingMode(b, l + 1); if (!r) r = AddressRegisterIndirectWithDisplacementOldAddressingMode(b, l + 1); if (!r) r = ProgramCounterIndirectWithDisplacementOldAddressingMode(b, l + 1); if (!r) r = AddressRegisterIndirectWithIndexOldAddressingMode(b, l + 1); if (!r) r = ProgramCounterIndirectWithIndexOldAddressingMode(b, l + 1); + if (!r) r = AddressRegisterIndirectWithIndexBaseDisplacementAddressingMode(b, l + 1); + if (!r) r = ProgramCounterIndirectWithIndexBaseDisplacementAddressingMode(b, l + 1); + if (!r) r = MemoryIndirectAddressingMode(b, l + 1); + if (!r) r = ProgramCounterMemoryIndirectAddressingMode(b, l + 1); + if (!r) r = MemoryIndirectPostIndexedAddressingMode(b, l + 1); + if (!r) r = ProgramCounterMemoryIndirectPostIndexedAddressingMode(b, l + 1); + if (!r) r = MemoryIndirectPreIndexedAddressingMode(b, l + 1); + if (!r) r = ProgramCounterMemoryIndirectPreIndexedAddressingMode(b, l + 1); if (!r) r = SpecialRegisterDirectAddressingMode(b, l + 1); if (!r) r = DataRegisterDirectAddressingMode(b, l + 1); if (!r) r = AddressRegisterDirectAddressingMode(b, l + 1); @@ -1210,6 +1246,58 @@ public class M68kParser implements PsiParser, LightPsiParser { return r; } + /* ********************************************************** */ + // ROUND_L (BaseDisplacement SEPARATOR)? PC (SEPARATOR IndexRegister)? ROUND_R + public static boolean ProgramCounterIndirectWithIndexBaseDisplacementAddressingMode(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "ProgramCounterIndirectWithIndexBaseDisplacementAddressingMode")) return false; + if (!nextTokenIsFast(b, ROUND_L)) return false; + boolean r; + Marker m = enter_section_(b, l, _NONE_, PROGRAM_COUNTER_INDIRECT_WITH_INDEX_BASE_DISPLACEMENT_ADDRESSING_MODE, ""); + r = consumeTokenFast(b, ROUND_L); + r = r && ProgramCounterIndirectWithIndexBaseDisplacementAddressingMode_1(b, l + 1); + r = r && consumeToken(b, PC); + r = r && ProgramCounterIndirectWithIndexBaseDisplacementAddressingMode_3(b, l + 1); + r = r && consumeToken(b, ROUND_R); + exit_section_(b, l, m, r, false, null); + return r; + } + + // (BaseDisplacement SEPARATOR)? + private static boolean ProgramCounterIndirectWithIndexBaseDisplacementAddressingMode_1(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "ProgramCounterIndirectWithIndexBaseDisplacementAddressingMode_1")) return false; + ProgramCounterIndirectWithIndexBaseDisplacementAddressingMode_1_0(b, l + 1); + return true; + } + + // BaseDisplacement SEPARATOR + private static boolean ProgramCounterIndirectWithIndexBaseDisplacementAddressingMode_1_0(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "ProgramCounterIndirectWithIndexBaseDisplacementAddressingMode_1_0")) return false; + boolean r; + Marker m = enter_section_(b); + r = BaseDisplacement(b, l + 1); + r = r && consumeToken(b, SEPARATOR); + exit_section_(b, m, null, r); + return r; + } + + // (SEPARATOR IndexRegister)? + private static boolean ProgramCounterIndirectWithIndexBaseDisplacementAddressingMode_3(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "ProgramCounterIndirectWithIndexBaseDisplacementAddressingMode_3")) return false; + ProgramCounterIndirectWithIndexBaseDisplacementAddressingMode_3_0(b, l + 1); + return true; + } + + // SEPARATOR IndexRegister + private static boolean ProgramCounterIndirectWithIndexBaseDisplacementAddressingMode_3_0(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "ProgramCounterIndirectWithIndexBaseDisplacementAddressingMode_3_0")) return false; + boolean r; + Marker m = enter_section_(b); + r = consumeTokenFast(b, SEPARATOR); + r = r && IndexRegister(b, l + 1); + exit_section_(b, m, null, r); + return r; + } + /* ********************************************************** */ // ROUND_L (expr SEPARATOR)? PC SEPARATOR IndexRegister ROUND_R public static boolean ProgramCounterIndirectWithIndexNewAddressingMode(PsiBuilder b, int l) { @@ -1617,6 +1705,153 @@ public class M68kParser implements PsiParser, LightPsiParser { return r; } + /* ********************************************************** */ + // (BaseDisplacement SEPARATOR)? (AddressRegister SEPARATOR)? IndexRegister + static boolean internalBaseDisplacementOption1(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "internalBaseDisplacementOption1")) return false; + boolean r; + Marker m = enter_section_(b); + r = internalBaseDisplacementOption1_0(b, l + 1); + r = r && internalBaseDisplacementOption1_1(b, l + 1); + r = r && IndexRegister(b, l + 1); + exit_section_(b, m, null, r); + return r; + } + + // (BaseDisplacement SEPARATOR)? + private static boolean internalBaseDisplacementOption1_0(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "internalBaseDisplacementOption1_0")) return false; + internalBaseDisplacementOption1_0_0(b, l + 1); + return true; + } + + // BaseDisplacement SEPARATOR + private static boolean internalBaseDisplacementOption1_0_0(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "internalBaseDisplacementOption1_0_0")) return false; + boolean r; + Marker m = enter_section_(b); + r = BaseDisplacement(b, l + 1); + r = r && consumeToken(b, SEPARATOR); + exit_section_(b, m, null, r); + return r; + } + + // (AddressRegister SEPARATOR)? + private static boolean internalBaseDisplacementOption1_1(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "internalBaseDisplacementOption1_1")) return false; + internalBaseDisplacementOption1_1_0(b, l + 1); + return true; + } + + // AddressRegister SEPARATOR + private static boolean internalBaseDisplacementOption1_1_0(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "internalBaseDisplacementOption1_1_0")) return false; + boolean r; + Marker m = enter_section_(b); + r = AddressRegister(b, l + 1); + r = r && consumeToken(b, SEPARATOR); + exit_section_(b, m, null, r); + return r; + } + + /* ********************************************************** */ + // (BaseDisplacement SEPARATOR)? AddressRegister (SEPARATOR IndexRegister)? + static boolean internalBaseDisplacementOption2(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "internalBaseDisplacementOption2")) return false; + boolean r; + Marker m = enter_section_(b); + r = internalBaseDisplacementOption2_0(b, l + 1); + r = r && AddressRegister(b, l + 1); + r = r && internalBaseDisplacementOption2_2(b, l + 1); + exit_section_(b, m, null, r); + return r; + } + + // (BaseDisplacement SEPARATOR)? + private static boolean internalBaseDisplacementOption2_0(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "internalBaseDisplacementOption2_0")) return false; + internalBaseDisplacementOption2_0_0(b, l + 1); + return true; + } + + // BaseDisplacement SEPARATOR + private static boolean internalBaseDisplacementOption2_0_0(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "internalBaseDisplacementOption2_0_0")) return false; + boolean r; + Marker m = enter_section_(b); + r = BaseDisplacement(b, l + 1); + r = r && consumeToken(b, SEPARATOR); + exit_section_(b, m, null, r); + return r; + } + + // (SEPARATOR IndexRegister)? + private static boolean internalBaseDisplacementOption2_2(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "internalBaseDisplacementOption2_2")) return false; + internalBaseDisplacementOption2_2_0(b, l + 1); + return true; + } + + // SEPARATOR IndexRegister + private static boolean internalBaseDisplacementOption2_2_0(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "internalBaseDisplacementOption2_2_0")) return false; + boolean r; + Marker m = enter_section_(b); + r = consumeToken(b, SEPARATOR); + r = r && IndexRegister(b, l + 1); + exit_section_(b, m, null, r); + return r; + } + + /* ********************************************************** */ + // BaseDisplacement (SEPARATOR AddressRegister)? (SEPARATOR IndexRegister)? + static boolean internalBaseDisplacementOption3(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "internalBaseDisplacementOption3")) return false; + boolean r; + Marker m = enter_section_(b); + r = BaseDisplacement(b, l + 1); + r = r && internalBaseDisplacementOption3_1(b, l + 1); + r = r && internalBaseDisplacementOption3_2(b, l + 1); + exit_section_(b, m, null, r); + return r; + } + + // (SEPARATOR AddressRegister)? + private static boolean internalBaseDisplacementOption3_1(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "internalBaseDisplacementOption3_1")) return false; + internalBaseDisplacementOption3_1_0(b, l + 1); + return true; + } + + // SEPARATOR AddressRegister + private static boolean internalBaseDisplacementOption3_1_0(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "internalBaseDisplacementOption3_1_0")) return false; + boolean r; + Marker m = enter_section_(b); + r = consumeToken(b, SEPARATOR); + r = r && AddressRegister(b, l + 1); + exit_section_(b, m, null, r); + return r; + } + + // (SEPARATOR IndexRegister)? + private static boolean internalBaseDisplacementOption3_2(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "internalBaseDisplacementOption3_2")) return false; + internalBaseDisplacementOption3_2_0(b, l + 1); + return true; + } + + // SEPARATOR IndexRegister + private static boolean internalBaseDisplacementOption3_2_0(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "internalBaseDisplacementOption3_2_0")) return false; + boolean r; + Marker m = enter_section_(b); + r = consumeToken(b, SEPARATOR); + r = r && IndexRegister(b, l + 1); + exit_section_(b, m, null, r); + return r; + } + /* ********************************************************** */ // !<> (MacroDefinition | statement) (<>|EOL) static boolean line(PsiBuilder b, int l) { diff --git a/src/main/gen/de/platon42/intellij/plugins/m68k/psi/M68kTypes.java b/src/main/gen/de/platon42/intellij/plugins/m68k/psi/M68kTypes.java index 2b0758f..b7aa5f8 100644 --- a/src/main/gen/de/platon42/intellij/plugins/m68k/psi/M68kTypes.java +++ b/src/main/gen/de/platon42/intellij/plugins/m68k/psi/M68kTypes.java @@ -18,6 +18,7 @@ public interface M68kTypes { IElementType ADDRESS_REGISTER_INDIRECT_PRE_DEC_ADDRESSING_MODE = new M68kElementType("ADDRESS_REGISTER_INDIRECT_PRE_DEC_ADDRESSING_MODE"); IElementType ADDRESS_REGISTER_INDIRECT_WITH_DISPLACEMENT_NEW_ADDRESSING_MODE = new M68kElementType("ADDRESS_REGISTER_INDIRECT_WITH_DISPLACEMENT_NEW_ADDRESSING_MODE"); IElementType ADDRESS_REGISTER_INDIRECT_WITH_DISPLACEMENT_OLD_ADDRESSING_MODE = new M68kElementType("ADDRESS_REGISTER_INDIRECT_WITH_DISPLACEMENT_OLD_ADDRESSING_MODE"); + IElementType ADDRESS_REGISTER_INDIRECT_WITH_INDEX_BASE_DISPLACEMENT_ADDRESSING_MODE = new M68kElementType("ADDRESS_REGISTER_INDIRECT_WITH_INDEX_BASE_DISPLACEMENT_ADDRESSING_MODE"); IElementType ADDRESS_REGISTER_INDIRECT_WITH_INDEX_NEW_ADDRESSING_MODE = new M68kElementType("ADDRESS_REGISTER_INDIRECT_WITH_INDEX_NEW_ADDRESSING_MODE"); IElementType ADDRESS_REGISTER_INDIRECT_WITH_INDEX_OLD_ADDRESSING_MODE = new M68kElementType("ADDRESS_REGISTER_INDIRECT_WITH_INDEX_OLD_ADDRESSING_MODE"); IElementType ADDRESS_SIZE = new M68kElementType("ADDRESS_SIZE"); @@ -67,6 +68,7 @@ public interface M68kTypes { IElementType PREPROCESSOR_KEYWORD = new M68kElementType("PREPROCESSOR_KEYWORD"); IElementType PROGRAM_COUNTER_INDIRECT_WITH_DISPLACEMENT_NEW_ADDRESSING_MODE = new M68kElementType("PROGRAM_COUNTER_INDIRECT_WITH_DISPLACEMENT_NEW_ADDRESSING_MODE"); IElementType PROGRAM_COUNTER_INDIRECT_WITH_DISPLACEMENT_OLD_ADDRESSING_MODE = new M68kElementType("PROGRAM_COUNTER_INDIRECT_WITH_DISPLACEMENT_OLD_ADDRESSING_MODE"); + IElementType PROGRAM_COUNTER_INDIRECT_WITH_INDEX_BASE_DISPLACEMENT_ADDRESSING_MODE = new M68kElementType("PROGRAM_COUNTER_INDIRECT_WITH_INDEX_BASE_DISPLACEMENT_ADDRESSING_MODE"); IElementType PROGRAM_COUNTER_INDIRECT_WITH_INDEX_NEW_ADDRESSING_MODE = new M68kElementType("PROGRAM_COUNTER_INDIRECT_WITH_INDEX_NEW_ADDRESSING_MODE"); IElementType PROGRAM_COUNTER_INDIRECT_WITH_INDEX_OLD_ADDRESSING_MODE = new M68kElementType("PROGRAM_COUNTER_INDIRECT_WITH_INDEX_OLD_ADDRESSING_MODE"); IElementType PROGRAM_COUNTER_MEMORY_INDIRECT_ADDRESSING_MODE = new M68kElementType("PROGRAM_COUNTER_MEMORY_INDIRECT_ADDRESSING_MODE"); @@ -167,6 +169,8 @@ public interface M68kTypes { return new M68kAddressRegisterIndirectWithDisplacementNewAddressingModeImpl(node); } else if (type == ADDRESS_REGISTER_INDIRECT_WITH_DISPLACEMENT_OLD_ADDRESSING_MODE) { return new M68kAddressRegisterIndirectWithDisplacementOldAddressingModeImpl(node); + } else if (type == ADDRESS_REGISTER_INDIRECT_WITH_INDEX_BASE_DISPLACEMENT_ADDRESSING_MODE) { + return new M68kAddressRegisterIndirectWithIndexBaseDisplacementAddressingModeImpl(node); } else if (type == ADDRESS_REGISTER_INDIRECT_WITH_INDEX_NEW_ADDRESSING_MODE) { return new M68kAddressRegisterIndirectWithIndexNewAddressingModeImpl(node); } else if (type == ADDRESS_REGISTER_INDIRECT_WITH_INDEX_OLD_ADDRESSING_MODE) { @@ -263,6 +267,8 @@ public interface M68kTypes { return new M68kProgramCounterIndirectWithDisplacementNewAddressingModeImpl(node); } else if (type == PROGRAM_COUNTER_INDIRECT_WITH_DISPLACEMENT_OLD_ADDRESSING_MODE) { return new M68kProgramCounterIndirectWithDisplacementOldAddressingModeImpl(node); + } else if (type == PROGRAM_COUNTER_INDIRECT_WITH_INDEX_BASE_DISPLACEMENT_ADDRESSING_MODE) { + return new M68kProgramCounterIndirectWithIndexBaseDisplacementAddressingModeImpl(node); } else if (type == PROGRAM_COUNTER_INDIRECT_WITH_INDEX_NEW_ADDRESSING_MODE) { return new M68kProgramCounterIndirectWithIndexNewAddressingModeImpl(node); } else if (type == PROGRAM_COUNTER_INDIRECT_WITH_INDEX_OLD_ADDRESSING_MODE) { diff --git a/src/main/gen/de/platon42/intellij/plugins/m68k/psi/M68kVisitor.java b/src/main/gen/de/platon42/intellij/plugins/m68k/psi/M68kVisitor.java index bcadc3c..701ad43 100644 --- a/src/main/gen/de/platon42/intellij/plugins/m68k/psi/M68kVisitor.java +++ b/src/main/gen/de/platon42/intellij/plugins/m68k/psi/M68kVisitor.java @@ -45,6 +45,13 @@ public class M68kVisitor extends PsiElementVisitor { // visitWithDisplacement(o); } + public void visitAddressRegisterIndirectWithIndexBaseDisplacementAddressingMode(@NotNull M68kAddressRegisterIndirectWithIndexBaseDisplacementAddressingMode o) { + visitAddressingMode(o); + // visitWithOptionalAddressRegisterIndirect(o); + // visitWithBaseDisplacement(o); + // visitWithIndexRegister(o); + } + public void visitAddressRegisterIndirectWithIndexNewAddressingMode(@NotNull M68kAddressRegisterIndirectWithIndexNewAddressingMode o) { visitAddressingMode(o); // visitWithAddressRegisterIndirect(o); @@ -180,6 +187,12 @@ public class M68kVisitor extends PsiElementVisitor { // visitWithDisplacement(o); } + public void visitProgramCounterIndirectWithIndexBaseDisplacementAddressingMode(@NotNull M68kProgramCounterIndirectWithIndexBaseDisplacementAddressingMode o) { + visitAddressingMode(o); + // visitWithBaseDisplacement(o); + // visitWithIndexRegister(o); + } + public void visitProgramCounterIndirectWithIndexNewAddressingMode(@NotNull M68kProgramCounterIndirectWithIndexNewAddressingMode o) { visitAddressingMode(o); // visitWithDisplacement(o); diff --git a/src/main/java/de/platon42/intellij/plugins/m68k/asm/M68kIsa.kt b/src/main/java/de/platon42/intellij/plugins/m68k/asm/M68kIsa.kt index f3133b4..5f31939 100644 --- a/src/main/java/de/platon42/intellij/plugins/m68k/asm/M68kIsa.kt +++ b/src/main/java/de/platon42/intellij/plugins/m68k/asm/M68kIsa.kt @@ -44,8 +44,10 @@ enum class AddressMode(val description: String, val syntax: String) { PROGRAM_COUNTER_INDIRECT_WITH_DISPLACEMENT("program counter indirect with displacement", "(d16,PC)"), ADDRESS_REGISTER_INDIRECT_WITH_INDEX("address register indirect with index", "(d8,An,Xn)"), ADDRESS_REGISTER_INDIRECT_WITH_SCALED_INDEX("address register indirect with scaled index", "(d8,An,Xn*s)"), + ADDRESS_REGISTER_INDIRECT_WITH_BASE_DISPLACEMENT("address register indirect with index (base displacement)", "(bd,An,Xn*s)"), PROGRAM_COUNTER_INDIRECT_WITH_INDEX("program counter indirect with index", "(d8,PC,Xn)"), PROGRAM_COUNTER_INDIRECT_WITH_SCALED_INDEX("program counter indirect with scaled index", "(d8,PC,Xn*s)"), + PROGRAM_COUNTER_INDIRECT_WITH_BASE_DISPLACEMENT("program counter indirect with index (base displacement)", "(bd,PC,Xn*s)"), MEMORY_INDIRECT("memory indirect", "([bd,An],od)"), MEMORY_INDIRECT_POSTINDEXED("memory indirect postindexed", "([bd,An],Xn*s,od)"), MEMORY_INDIRECT_PREINDEXED("memory indirect preindexed", "([bd,An,Xn*s],od)"), diff --git a/src/main/java/de/platon42/intellij/plugins/m68k/m68k.bnf b/src/main/java/de/platon42/intellij/plugins/m68k/m68k.bnf index ed80540..dc5cd8a 100644 --- a/src/main/java/de/platon42/intellij/plugins/m68k/m68k.bnf +++ b/src/main/java/de/platon42/intellij/plugins/m68k/m68k.bnf @@ -263,18 +263,20 @@ AddressingMode ::= ImmediateData | AddressRegisterIndirectAddressingMode | AddressRegisterIndirectWithDisplacementNewAddressingMode | ProgramCounterIndirectWithDisplacementNewAddressingMode - | MemoryIndirectAddressingMode - | ProgramCounterMemoryIndirectAddressingMode - | MemoryIndirectPostIndexedAddressingMode - | ProgramCounterMemoryIndirectPostIndexedAddressingMode - | MemoryIndirectPreIndexedAddressingMode - | ProgramCounterMemoryIndirectPreIndexedAddressingMode | AddressRegisterIndirectWithIndexNewAddressingMode | ProgramCounterIndirectWithIndexNewAddressingMode | AddressRegisterIndirectWithDisplacementOldAddressingMode | ProgramCounterIndirectWithDisplacementOldAddressingMode | AddressRegisterIndirectWithIndexOldAddressingMode | ProgramCounterIndirectWithIndexOldAddressingMode + | AddressRegisterIndirectWithIndexBaseDisplacementAddressingMode + | ProgramCounterIndirectWithIndexBaseDisplacementAddressingMode + | MemoryIndirectAddressingMode + | ProgramCounterMemoryIndirectAddressingMode + | MemoryIndirectPostIndexedAddressingMode + | ProgramCounterMemoryIndirectPostIndexedAddressingMode + | MemoryIndirectPreIndexedAddressingMode + | ProgramCounterMemoryIndirectPreIndexedAddressingMode | SpecialRegisterDirectAddressingMode | DataRegisterDirectAddressingMode | AddressRegisterDirectAddressingMode @@ -334,6 +336,33 @@ AddressRegisterIndirectWithIndexNewAddressingMode ::= ROUND_L (expr SEPARATOR)? ] } +private internalBaseDisplacementOption1 ::= (BaseDisplacement SEPARATOR)? (AddressRegister SEPARATOR)? IndexRegister +private internalBaseDisplacementOption2 ::= (BaseDisplacement SEPARATOR)? AddressRegister (SEPARATOR IndexRegister)? +private internalBaseDisplacementOption3 ::= BaseDisplacement (SEPARATOR AddressRegister)? (SEPARATOR IndexRegister)? + +AddressRegisterIndirectWithIndexBaseDisplacementAddressingMode ::= ROUND_L (internalBaseDisplacementOption1|internalBaseDisplacementOption2|internalBaseDisplacementOption3)? ROUND_R +{ + implements = [ + "de.platon42.intellij.plugins.m68k.psi.M68kWithOptionalAddressRegisterIndirect" + "de.platon42.intellij.plugins.m68k.psi.M68kWithBaseDisplacement" + "de.platon42.intellij.plugins.m68k.psi.M68kWithOptionalIndexRegister" + ] + methods = [ + baseDisplacement = "BaseDisplacement" + ] +} + +ProgramCounterIndirectWithIndexBaseDisplacementAddressingMode ::= ROUND_L (BaseDisplacement SEPARATOR)? PC (SEPARATOR IndexRegister)? ROUND_R +{ + implements = [ + "de.platon42.intellij.plugins.m68k.psi.M68kWithBaseDisplacement" + "de.platon42.intellij.plugins.m68k.psi.M68kWithOptionalIndexRegister" + ] + methods = [ + baseDisplacement = "BaseDisplacement" + ] +} + MemoryIndirectAddressingMode ::= ROUND_L SQUARE_L (BaseDisplacement SEPARATOR)? AddressRegister SQUARE_R (SEPARATOR OuterDisplacement)? ROUND_R { implements = [ diff --git a/src/main/java/de/platon42/intellij/plugins/m68k/psi/M68kAddressModeUtil.kt b/src/main/java/de/platon42/intellij/plugins/m68k/psi/M68kAddressModeUtil.kt index d2f3d89..2fae054 100644 --- a/src/main/java/de/platon42/intellij/plugins/m68k/psi/M68kAddressModeUtil.kt +++ b/src/main/java/de/platon42/intellij/plugins/m68k/psi/M68kAddressModeUtil.kt @@ -14,10 +14,12 @@ object M68kAddressModeUtil { is M68kAddressRegisterIndirectWithDisplacementOldAddressingMode -> AddressMode.ADDRESS_REGISTER_INDIRECT_WITH_DISPLACEMENT is M68kAddressRegisterIndirectWithIndexNewAddressingMode -> if (hasScale(addressingMode)) AddressMode.ADDRESS_REGISTER_INDIRECT_WITH_SCALED_INDEX else AddressMode.ADDRESS_REGISTER_INDIRECT_WITH_INDEX is M68kAddressRegisterIndirectWithIndexOldAddressingMode -> if (hasScale(addressingMode)) AddressMode.ADDRESS_REGISTER_INDIRECT_WITH_SCALED_INDEX else AddressMode.ADDRESS_REGISTER_INDIRECT_WITH_INDEX + is M68kAddressRegisterIndirectWithIndexBaseDisplacementAddressingMode -> AddressMode.ADDRESS_REGISTER_INDIRECT_WITH_BASE_DISPLACEMENT is M68kProgramCounterIndirectWithDisplacementNewAddressingMode -> AddressMode.PROGRAM_COUNTER_INDIRECT_WITH_DISPLACEMENT is M68kProgramCounterIndirectWithDisplacementOldAddressingMode -> AddressMode.PROGRAM_COUNTER_INDIRECT_WITH_DISPLACEMENT is M68kProgramCounterIndirectWithIndexNewAddressingMode -> if (hasScale(addressingMode)) AddressMode.PROGRAM_COUNTER_INDIRECT_WITH_SCALED_INDEX else AddressMode.PROGRAM_COUNTER_INDIRECT_WITH_INDEX is M68kProgramCounterIndirectWithIndexOldAddressingMode -> if (hasScale(addressingMode)) AddressMode.PROGRAM_COUNTER_INDIRECT_WITH_SCALED_INDEX else AddressMode.PROGRAM_COUNTER_INDIRECT_WITH_INDEX + is M68kProgramCounterIndirectWithIndexBaseDisplacementAddressingMode -> AddressMode.PROGRAM_COUNTER_INDIRECT_WITH_BASE_DISPLACEMENT is M68kMemoryIndirectAddressingMode -> AddressMode.MEMORY_INDIRECT is M68kMemoryIndirectPreIndexedAddressingMode -> AddressMode.MEMORY_INDIRECT_PREINDEXED is M68kMemoryIndirectPostIndexedAddressingMode -> AddressMode.MEMORY_INDIRECT_POSTINDEXED @@ -54,21 +56,18 @@ object M68kAddressModeUtil { is M68kAddressRegisterIndirectPostIncAddressingMode -> listOf(Register.getRegFromName(addressingMode.addressRegister.text) to (RWM_READ_L or RWM_MODIFY_L)) is M68kAddressRegisterIndirectPreDecAddressingMode -> listOf(Register.getRegFromName(addressingMode.addressRegister.text) to (RWM_READ_L or RWM_MODIFY_L)) - is M68kWithAddressRegisterIndirect -> { - if (addressingMode is M68kWithIndexRegister) { - listOf( - Register.getRegFromName(addressingMode.addressRegister.text) to RWM_READ_L, - Register.getRegFromName(addressingMode.indexRegister.register.text) to if (addressingMode.indexRegister.isLongWidth) RWM_READ_L else RWM_READ_W - ) - } else { - listOf(Register.getRegFromName(addressingMode.addressRegister.text) to RWM_READ_L) - } - } - is M68kWithIndexRegister -> listOf(Register.getRegFromName(addressingMode.indexRegister.register.text) to if (addressingMode.indexRegister.isLongWidth) RWM_READ_L else RWM_READ_W) + is M68kWithAddressRegisterIndirect -> listOf(Register.getRegFromName(addressingMode.addressRegister.text) to RWM_READ_L) + is M68kWithOptionalAddressRegisterIndirect -> if (addressingMode.addressRegister != null) listOf(Register.getRegFromName(addressingMode.addressRegister!!.text) to RWM_READ_L) else emptyList() is M68kDataRegisterDirectAddressingMode -> listOf(Register.getRegFromName(addressingMode.dataRegister.text) to rwm) is M68kAddressRegisterDirectAddressingMode -> listOf(Register.getRegFromName(addressingMode.addressRegister.text) to rwm) is M68kRegisterListAddressingMode -> addressingMode.registers.map { it to rwm } else -> throw IllegalArgumentException("Unknown addressing mode $addressingMode") - } + }.plus( + when (addressingMode) { + is M68kWithIndexRegister -> listOf(Register.getRegFromName(addressingMode.indexRegister.register.text) to if (addressingMode.indexRegister.isLongWidth) RWM_READ_L else RWM_READ_W) + is M68kWithOptionalIndexRegister -> if (addressingMode.indexRegister != null) listOf(Register.getRegFromName(addressingMode.indexRegister!!.register.text) to if (addressingMode.indexRegister!!.isLongWidth) RWM_READ_L else RWM_READ_W) else emptyList() + else -> emptyList() + } + ) } } \ No newline at end of file diff --git a/src/main/java/de/platon42/intellij/plugins/m68k/psi/M68kWithOptionalAddressRegisterIndirect.kt b/src/main/java/de/platon42/intellij/plugins/m68k/psi/M68kWithOptionalAddressRegisterIndirect.kt new file mode 100644 index 0000000..1b54a9c --- /dev/null +++ b/src/main/java/de/platon42/intellij/plugins/m68k/psi/M68kWithOptionalAddressRegisterIndirect.kt @@ -0,0 +1,6 @@ +package de.platon42.intellij.plugins.m68k.psi + +interface M68kWithOptionalAddressRegisterIndirect : M68kAddressingMode { + + val addressRegister: M68kAddressRegister? +} \ No newline at end of file diff --git a/src/main/java/de/platon42/intellij/plugins/m68k/psi/M68kWithOptionalIndexRegister.kt b/src/main/java/de/platon42/intellij/plugins/m68k/psi/M68kWithOptionalIndexRegister.kt new file mode 100644 index 0000000..7311bf8 --- /dev/null +++ b/src/main/java/de/platon42/intellij/plugins/m68k/psi/M68kWithOptionalIndexRegister.kt @@ -0,0 +1,6 @@ +package de.platon42.intellij.plugins.m68k.psi + +interface M68kWithOptionalIndexRegister : M68kAddressingMode { + + val indexRegister: M68kIndexRegister? +} \ No newline at end of file diff --git a/src/test/java/de/platon42/intellij/plugins/m68k/parser/AddressingModesTest.kt b/src/test/java/de/platon42/intellij/plugins/m68k/parser/AddressingModesTest.kt index f1b9237..350cc69 100644 --- a/src/test/java/de/platon42/intellij/plugins/m68k/parser/AddressingModesTest.kt +++ b/src/test/java/de/platon42/intellij/plugins/m68k/parser/AddressingModesTest.kt @@ -212,6 +212,46 @@ internal class AddressingModesTest : AbstractParsingTest() { testGoodSyntax(testCase, " move.l ([pc,a0.l*4]),d0\n") } + @Test + internal fun register_indirect_with_index_base_displacement(@MyTestCase testCase: ParsingTestExtension.IParsingTestCase) { + testGoodSyntax(testCase, " move.l (100.w,a0,a0.l*4),d0\n") + } + + @Test + internal fun register_indirect_with_index_base_displacement_without_areg(@MyTestCase testCase: ParsingTestExtension.IParsingTestCase) { + testGoodSyntax(testCase, " move.l (100.w,a0.l*4),d0\n") + } + + @Test + internal fun register_indirect_with_index_base_displacement_without_index(@MyTestCase testCase: ParsingTestExtension.IParsingTestCase) { + testGoodSyntax(testCase, " move.l (100.l,a0),d0\n") + } + + @Test + internal fun register_indirect_with_index_base_displacement_with_dreg_index(@MyTestCase testCase: ParsingTestExtension.IParsingTestCase) { + testGoodSyntax(testCase, " move.l (d0),(d0.w*4)\n") + } + + @Test + internal fun register_indirect_with_index_base_displacement_only(@MyTestCase testCase: ParsingTestExtension.IParsingTestCase) { + testGoodSyntax(testCase, " move.l (100.l),d0\n") + } + + @Test + internal fun register_indirect_with_index_base_displacement_zero(@MyTestCase testCase: ParsingTestExtension.IParsingTestCase) { + testGoodSyntax(testCase, " move.l (),d0\n") + } + + @Test + internal fun pc_indirect_with_index_base_displacement(@MyTestCase testCase: ParsingTestExtension.IParsingTestCase) { + testGoodSyntax(testCase, " move.l (100.w,pc,a0.l*4),d0\n") + } + + @Test + internal fun pc_indirect_with_index_base_displacement_without_index(@MyTestCase testCase: ParsingTestExtension.IParsingTestCase) { + testGoodSyntax(testCase, " move.l (100.l,pc),d0\n") + } + @Test internal fun absolute_address(@MyTestCase testCase: ParsingTestExtension.IParsingTestCase) { testGoodSyntax(testCase, " move.l 4.w,a6\n") diff --git a/src/test/resources/parser/addressingmodes/pc_indirect_with_index_base_displacement.txt b/src/test/resources/parser/addressingmodes/pc_indirect_with_index_base_displacement.txt new file mode 100644 index 0000000..9b2995a --- /dev/null +++ b/src/test/resources/parser/addressingmodes/pc_indirect_with_index_base_displacement.txt @@ -0,0 +1,34 @@ +Assembly File: a.asm + PsiWhiteSpace(' ') + M68kStatementImpl(STATEMENT) + M68kAsmInstructionImpl(ASM_INSTRUCTION) + M68kAsmOpImpl(ASM_OP) + PsiElement(M68kTokenType.MNEMONIC)('move') + M68kOperandSizeImpl(OPERAND_SIZE) + PsiElement(M68kTokenType.OPSIZE_L)('.l') + PsiWhiteSpace(' ') + M68kProgramCounterIndirectWithIndexBaseDisplacementAddressingModeImpl(PROGRAM_COUNTER_INDIRECT_WITH_INDEX_BASE_DISPLACEMENT_ADDRESSING_MODE) + PsiElement(M68kTokenType.ROUND_L)('(') + M68kBaseDisplacementImpl(BASE_DISPLACEMENT) + M68kLiteralExprImpl(LITERAL_EXPR) + PsiElement(M68kTokenType.DECIMAL)('100') + M68kDataWidthImpl(DATA_WIDTH) + PsiElement(M68kTokenType.OPSIZE_W)('.w') + PsiElement(M68kTokenType.SEPARATOR)(',') + PsiElement(M68kTokenType.PC)('pc') + PsiElement(M68kTokenType.SEPARATOR)(',') + M68kIndexRegisterImpl(INDEX_REGISTER) + M68kAddressRegisterImpl(ADDRESS_REGISTER) + PsiElement(M68kTokenType.AREG)('a0') + M68kDataWidthImpl(DATA_WIDTH) + PsiElement(M68kTokenType.OPSIZE_L)('.l') + PsiElement(M68kTokenType.OP_AR_MUL)('*') + M68kIndexScaleImpl(INDEX_SCALE) + M68kLiteralExprImpl(LITERAL_EXPR) + PsiElement(M68kTokenType.DECIMAL)('4') + PsiElement(M68kTokenType.ROUND_R)(')') + PsiElement(M68kTokenType.SEPARATOR)(',') + M68kDataRegisterDirectAddressingModeImpl(DATA_REGISTER_DIRECT_ADDRESSING_MODE) + M68kDataRegisterImpl(DATA_REGISTER) + PsiElement(M68kTokenType.DREG)('d0') + PsiElement(M68kTokenType.EOL)('\n') \ No newline at end of file diff --git a/src/test/resources/parser/addressingmodes/pc_indirect_with_index_base_displacement_without_index.txt b/src/test/resources/parser/addressingmodes/pc_indirect_with_index_base_displacement_without_index.txt new file mode 100644 index 0000000..eed82e0 --- /dev/null +++ b/src/test/resources/parser/addressingmodes/pc_indirect_with_index_base_displacement_without_index.txt @@ -0,0 +1,24 @@ +Assembly File: a.asm + PsiWhiteSpace(' ') + M68kStatementImpl(STATEMENT) + M68kAsmInstructionImpl(ASM_INSTRUCTION) + M68kAsmOpImpl(ASM_OP) + PsiElement(M68kTokenType.MNEMONIC)('move') + M68kOperandSizeImpl(OPERAND_SIZE) + PsiElement(M68kTokenType.OPSIZE_L)('.l') + PsiWhiteSpace(' ') + M68kProgramCounterIndirectWithIndexBaseDisplacementAddressingModeImpl(PROGRAM_COUNTER_INDIRECT_WITH_INDEX_BASE_DISPLACEMENT_ADDRESSING_MODE) + PsiElement(M68kTokenType.ROUND_L)('(') + M68kBaseDisplacementImpl(BASE_DISPLACEMENT) + M68kLiteralExprImpl(LITERAL_EXPR) + PsiElement(M68kTokenType.DECIMAL)('100') + M68kDataWidthImpl(DATA_WIDTH) + PsiElement(M68kTokenType.OPSIZE_L)('.l') + PsiElement(M68kTokenType.SEPARATOR)(',') + PsiElement(M68kTokenType.PC)('pc') + PsiElement(M68kTokenType.ROUND_R)(')') + PsiElement(M68kTokenType.SEPARATOR)(',') + M68kDataRegisterDirectAddressingModeImpl(DATA_REGISTER_DIRECT_ADDRESSING_MODE) + M68kDataRegisterImpl(DATA_REGISTER) + PsiElement(M68kTokenType.DREG)('d0') + PsiElement(M68kTokenType.EOL)('\n') \ No newline at end of file diff --git a/src/test/resources/parser/addressingmodes/register_indirect_with_index_base_displacement.txt b/src/test/resources/parser/addressingmodes/register_indirect_with_index_base_displacement.txt new file mode 100644 index 0000000..858634f --- /dev/null +++ b/src/test/resources/parser/addressingmodes/register_indirect_with_index_base_displacement.txt @@ -0,0 +1,35 @@ +Assembly File: a.asm + PsiWhiteSpace(' ') + M68kStatementImpl(STATEMENT) + M68kAsmInstructionImpl(ASM_INSTRUCTION) + M68kAsmOpImpl(ASM_OP) + PsiElement(M68kTokenType.MNEMONIC)('move') + M68kOperandSizeImpl(OPERAND_SIZE) + PsiElement(M68kTokenType.OPSIZE_L)('.l') + PsiWhiteSpace(' ') + M68kAddressRegisterIndirectWithIndexBaseDisplacementAddressingModeImpl(ADDRESS_REGISTER_INDIRECT_WITH_INDEX_BASE_DISPLACEMENT_ADDRESSING_MODE) + PsiElement(M68kTokenType.ROUND_L)('(') + M68kBaseDisplacementImpl(BASE_DISPLACEMENT) + M68kLiteralExprImpl(LITERAL_EXPR) + PsiElement(M68kTokenType.DECIMAL)('100') + M68kDataWidthImpl(DATA_WIDTH) + PsiElement(M68kTokenType.OPSIZE_W)('.w') + PsiElement(M68kTokenType.SEPARATOR)(',') + M68kAddressRegisterImpl(ADDRESS_REGISTER) + PsiElement(M68kTokenType.AREG)('a0') + PsiElement(M68kTokenType.SEPARATOR)(',') + M68kIndexRegisterImpl(INDEX_REGISTER) + M68kAddressRegisterImpl(ADDRESS_REGISTER) + PsiElement(M68kTokenType.AREG)('a0') + M68kDataWidthImpl(DATA_WIDTH) + PsiElement(M68kTokenType.OPSIZE_L)('.l') + PsiElement(M68kTokenType.OP_AR_MUL)('*') + M68kIndexScaleImpl(INDEX_SCALE) + M68kLiteralExprImpl(LITERAL_EXPR) + PsiElement(M68kTokenType.DECIMAL)('4') + PsiElement(M68kTokenType.ROUND_R)(')') + PsiElement(M68kTokenType.SEPARATOR)(',') + M68kDataRegisterDirectAddressingModeImpl(DATA_REGISTER_DIRECT_ADDRESSING_MODE) + M68kDataRegisterImpl(DATA_REGISTER) + PsiElement(M68kTokenType.DREG)('d0') + PsiElement(M68kTokenType.EOL)('\n') \ No newline at end of file diff --git a/src/test/resources/parser/addressingmodes/register_indirect_with_index_base_displacement_only.txt b/src/test/resources/parser/addressingmodes/register_indirect_with_index_base_displacement_only.txt new file mode 100644 index 0000000..9d0e850 --- /dev/null +++ b/src/test/resources/parser/addressingmodes/register_indirect_with_index_base_displacement_only.txt @@ -0,0 +1,22 @@ +Assembly File: a.asm + PsiWhiteSpace(' ') + M68kStatementImpl(STATEMENT) + M68kAsmInstructionImpl(ASM_INSTRUCTION) + M68kAsmOpImpl(ASM_OP) + PsiElement(M68kTokenType.MNEMONIC)('move') + M68kOperandSizeImpl(OPERAND_SIZE) + PsiElement(M68kTokenType.OPSIZE_L)('.l') + PsiWhiteSpace(' ') + M68kAddressRegisterIndirectWithIndexBaseDisplacementAddressingModeImpl(ADDRESS_REGISTER_INDIRECT_WITH_INDEX_BASE_DISPLACEMENT_ADDRESSING_MODE) + PsiElement(M68kTokenType.ROUND_L)('(') + M68kBaseDisplacementImpl(BASE_DISPLACEMENT) + M68kLiteralExprImpl(LITERAL_EXPR) + PsiElement(M68kTokenType.DECIMAL)('100') + M68kDataWidthImpl(DATA_WIDTH) + PsiElement(M68kTokenType.OPSIZE_L)('.l') + PsiElement(M68kTokenType.ROUND_R)(')') + PsiElement(M68kTokenType.SEPARATOR)(',') + M68kDataRegisterDirectAddressingModeImpl(DATA_REGISTER_DIRECT_ADDRESSING_MODE) + M68kDataRegisterImpl(DATA_REGISTER) + PsiElement(M68kTokenType.DREG)('d0') + PsiElement(M68kTokenType.EOL)('\n') \ No newline at end of file diff --git a/src/test/resources/parser/addressingmodes/register_indirect_with_index_base_displacement_with_dreg_index.txt b/src/test/resources/parser/addressingmodes/register_indirect_with_index_base_displacement_with_dreg_index.txt new file mode 100644 index 0000000..91084a1 --- /dev/null +++ b/src/test/resources/parser/addressingmodes/register_indirect_with_index_base_displacement_with_dreg_index.txt @@ -0,0 +1,29 @@ +Assembly File: a.asm + PsiWhiteSpace(' ') + M68kStatementImpl(STATEMENT) + M68kAsmInstructionImpl(ASM_INSTRUCTION) + M68kAsmOpImpl(ASM_OP) + PsiElement(M68kTokenType.MNEMONIC)('move') + M68kOperandSizeImpl(OPERAND_SIZE) + PsiElement(M68kTokenType.OPSIZE_L)('.l') + PsiWhiteSpace(' ') + M68kAddressRegisterIndirectWithIndexBaseDisplacementAddressingModeImpl(ADDRESS_REGISTER_INDIRECT_WITH_INDEX_BASE_DISPLACEMENT_ADDRESSING_MODE) + PsiElement(M68kTokenType.ROUND_L)('(') + M68kIndexRegisterImpl(INDEX_REGISTER) + M68kDataRegisterImpl(DATA_REGISTER) + PsiElement(M68kTokenType.DREG)('d0') + PsiElement(M68kTokenType.ROUND_R)(')') + PsiElement(M68kTokenType.SEPARATOR)(',') + M68kAddressRegisterIndirectWithIndexBaseDisplacementAddressingModeImpl(ADDRESS_REGISTER_INDIRECT_WITH_INDEX_BASE_DISPLACEMENT_ADDRESSING_MODE) + PsiElement(M68kTokenType.ROUND_L)('(') + M68kIndexRegisterImpl(INDEX_REGISTER) + M68kDataRegisterImpl(DATA_REGISTER) + PsiElement(M68kTokenType.DREG)('d0') + M68kDataWidthImpl(DATA_WIDTH) + PsiElement(M68kTokenType.OPSIZE_W)('.w') + PsiElement(M68kTokenType.OP_AR_MUL)('*') + M68kIndexScaleImpl(INDEX_SCALE) + M68kLiteralExprImpl(LITERAL_EXPR) + PsiElement(M68kTokenType.DECIMAL)('4') + PsiElement(M68kTokenType.ROUND_R)(')') + PsiElement(M68kTokenType.EOL)('\n') \ No newline at end of file diff --git a/src/test/resources/parser/addressingmodes/register_indirect_with_index_base_displacement_without_areg.txt b/src/test/resources/parser/addressingmodes/register_indirect_with_index_base_displacement_without_areg.txt new file mode 100644 index 0000000..3b4bcbc --- /dev/null +++ b/src/test/resources/parser/addressingmodes/register_indirect_with_index_base_displacement_without_areg.txt @@ -0,0 +1,32 @@ +Assembly File: a.asm + PsiWhiteSpace(' ') + M68kStatementImpl(STATEMENT) + M68kAsmInstructionImpl(ASM_INSTRUCTION) + M68kAsmOpImpl(ASM_OP) + PsiElement(M68kTokenType.MNEMONIC)('move') + M68kOperandSizeImpl(OPERAND_SIZE) + PsiElement(M68kTokenType.OPSIZE_L)('.l') + PsiWhiteSpace(' ') + M68kAddressRegisterIndirectWithIndexBaseDisplacementAddressingModeImpl(ADDRESS_REGISTER_INDIRECT_WITH_INDEX_BASE_DISPLACEMENT_ADDRESSING_MODE) + PsiElement(M68kTokenType.ROUND_L)('(') + M68kBaseDisplacementImpl(BASE_DISPLACEMENT) + M68kLiteralExprImpl(LITERAL_EXPR) + PsiElement(M68kTokenType.DECIMAL)('100') + M68kDataWidthImpl(DATA_WIDTH) + PsiElement(M68kTokenType.OPSIZE_W)('.w') + PsiElement(M68kTokenType.SEPARATOR)(',') + M68kIndexRegisterImpl(INDEX_REGISTER) + M68kAddressRegisterImpl(ADDRESS_REGISTER) + PsiElement(M68kTokenType.AREG)('a0') + M68kDataWidthImpl(DATA_WIDTH) + PsiElement(M68kTokenType.OPSIZE_L)('.l') + PsiElement(M68kTokenType.OP_AR_MUL)('*') + M68kIndexScaleImpl(INDEX_SCALE) + M68kLiteralExprImpl(LITERAL_EXPR) + PsiElement(M68kTokenType.DECIMAL)('4') + PsiElement(M68kTokenType.ROUND_R)(')') + PsiElement(M68kTokenType.SEPARATOR)(',') + M68kDataRegisterDirectAddressingModeImpl(DATA_REGISTER_DIRECT_ADDRESSING_MODE) + M68kDataRegisterImpl(DATA_REGISTER) + PsiElement(M68kTokenType.DREG)('d0') + PsiElement(M68kTokenType.EOL)('\n') \ No newline at end of file diff --git a/src/test/resources/parser/addressingmodes/register_indirect_with_index_base_displacement_without_index.txt b/src/test/resources/parser/addressingmodes/register_indirect_with_index_base_displacement_without_index.txt new file mode 100644 index 0000000..2f6296a --- /dev/null +++ b/src/test/resources/parser/addressingmodes/register_indirect_with_index_base_displacement_without_index.txt @@ -0,0 +1,26 @@ +Assembly File: a.asm + PsiWhiteSpace(' ') + M68kStatementImpl(STATEMENT) + M68kAsmInstructionImpl(ASM_INSTRUCTION) + M68kAsmOpImpl(ASM_OP) + PsiElement(M68kTokenType.MNEMONIC)('move') + M68kOperandSizeImpl(OPERAND_SIZE) + PsiElement(M68kTokenType.OPSIZE_L)('.l') + PsiWhiteSpace(' ') + M68kAddressRegisterIndirectWithIndexBaseDisplacementAddressingModeImpl(ADDRESS_REGISTER_INDIRECT_WITH_INDEX_BASE_DISPLACEMENT_ADDRESSING_MODE) + PsiElement(M68kTokenType.ROUND_L)('(') + M68kBaseDisplacementImpl(BASE_DISPLACEMENT) + M68kLiteralExprImpl(LITERAL_EXPR) + PsiElement(M68kTokenType.DECIMAL)('100') + M68kDataWidthImpl(DATA_WIDTH) + PsiElement(M68kTokenType.OPSIZE_L)('.l') + PsiElement(M68kTokenType.SEPARATOR)(',') + M68kIndexRegisterImpl(INDEX_REGISTER) + M68kAddressRegisterImpl(ADDRESS_REGISTER) + PsiElement(M68kTokenType.AREG)('a0') + PsiElement(M68kTokenType.ROUND_R)(')') + PsiElement(M68kTokenType.SEPARATOR)(',') + M68kDataRegisterDirectAddressingModeImpl(DATA_REGISTER_DIRECT_ADDRESSING_MODE) + M68kDataRegisterImpl(DATA_REGISTER) + PsiElement(M68kTokenType.DREG)('d0') + PsiElement(M68kTokenType.EOL)('\n') \ No newline at end of file diff --git a/src/test/resources/parser/addressingmodes/register_indirect_with_index_base_displacement_zero.txt b/src/test/resources/parser/addressingmodes/register_indirect_with_index_base_displacement_zero.txt new file mode 100644 index 0000000..6826e3d --- /dev/null +++ b/src/test/resources/parser/addressingmodes/register_indirect_with_index_base_displacement_zero.txt @@ -0,0 +1,17 @@ +Assembly File: a.asm + PsiWhiteSpace(' ') + M68kStatementImpl(STATEMENT) + M68kAsmInstructionImpl(ASM_INSTRUCTION) + M68kAsmOpImpl(ASM_OP) + PsiElement(M68kTokenType.MNEMONIC)('move') + M68kOperandSizeImpl(OPERAND_SIZE) + PsiElement(M68kTokenType.OPSIZE_L)('.l') + PsiWhiteSpace(' ') + M68kAddressRegisterIndirectWithIndexBaseDisplacementAddressingModeImpl(ADDRESS_REGISTER_INDIRECT_WITH_INDEX_BASE_DISPLACEMENT_ADDRESSING_MODE) + PsiElement(M68kTokenType.ROUND_L)('(') + PsiElement(M68kTokenType.ROUND_R)(')') + PsiElement(M68kTokenType.SEPARATOR)(',') + M68kDataRegisterDirectAddressingModeImpl(DATA_REGISTER_DIRECT_ADDRESSING_MODE) + M68kDataRegisterImpl(DATA_REGISTER) + PsiElement(M68kTokenType.DREG)('d0') + PsiElement(M68kTokenType.EOL)('\n') \ No newline at end of file