├── .gitignore
├── README.md
├── docs
├── asm.txt
├── configuration.txt
├── java_on_spec.png
└── jni.txt
├── examples
├── ZXSpectrumDemoLib
│ ├── pom.xml
│ └── src
│ │ └── main
│ │ ├── java
│ │ └── com
│ │ │ └── igormaznitsa
│ │ │ └── j2z80
│ │ │ └── bootstrap
│ │ │ └── java
│ │ │ ├── io
│ │ │ └── PrintStream.java
│ │ │ └── lang
│ │ │ └── System.java
│ │ └── resources
│ │ └── com
│ │ └── igormaznitsa
│ │ └── j2z80
│ │ └── bootstrap
│ │ └── java
│ │ └── io
│ │ └── PrintStream.a80
└── ZXSpectrumHelloWorld
│ ├── pom.xml
│ └── src
│ └── main
│ ├── java
│ └── com
│ │ └── igormaznitsa
│ │ └── test
│ │ └── helloworld
│ │ ├── ZXScreen.java
│ │ └── main.java
│ └── resources
│ └── com
│ └── igormaznitsa
│ └── test
│ └── helloworld
│ └── ZXScreen.a80
├── j2z80-api
├── pom.xml
└── src
│ ├── main
│ └── java
│ │ └── com
│ │ └── igormaznitsa
│ │ └── j2z80
│ │ ├── ClassContext.java
│ │ ├── MethodContext.java
│ │ ├── TranslatorContext.java
│ │ ├── TranslatorLogger.java
│ │ ├── api
│ │ └── additional
│ │ │ ├── AdditionPath.java
│ │ │ ├── J2ZAdditionalBlock.java
│ │ │ ├── NeedsATHROWManager.java
│ │ │ ├── NeedsBREAKPOINTManager.java
│ │ │ ├── NeedsCheckcastManager.java
│ │ │ ├── NeedsINTArithmeticManager.java
│ │ │ ├── NeedsINVOKEINTERFACEManager.java
│ │ │ ├── NeedsINVOKEVIRTUALManager.java
│ │ │ ├── NeedsInstanceofManager.java
│ │ │ └── NeedsMemoryManager.java
│ │ ├── bootstrap
│ │ ├── AbstractBootClass.java
│ │ ├── BootClassException.java
│ │ └── java
│ │ │ └── lang
│ │ │ └── Object.java
│ │ ├── ids
│ │ ├── ClassID.java
│ │ ├── ClassMethodInfo.java
│ │ └── MethodID.java
│ │ └── utils
│ │ ├── LabelAndFrameUtils.java
│ │ ├── MutableObjectContainer.java
│ │ └── Utils.java
│ └── test
│ └── java
│ └── com
│ └── igormaznitsa
│ └── j2z80
│ ├── ids
│ └── ClassMethodInfoTest.java
│ └── utils
│ └── UtilsTest.java
├── j2z80-plugin
├── nbactions.xml
├── pom.xml
└── src
│ ├── assembly
│ └── bundle.xml
│ ├── main
│ ├── java
│ │ └── com
│ │ │ └── igormaznitsa
│ │ │ ├── j2z80
│ │ │ ├── jvmprocessors
│ │ │ │ ├── AbstractFieldProcessor.java
│ │ │ │ ├── AbstractInvokeProcessor.java
│ │ │ │ ├── AbstractJvmCommandProcessor.java
│ │ │ │ ├── Processor_AALOAD.java
│ │ │ │ ├── Processor_AASTORE.java
│ │ │ │ ├── Processor_ACONST_NULL.java
│ │ │ │ ├── Processor_ALOAD.java
│ │ │ │ ├── Processor_ANEWARRAY.java
│ │ │ │ ├── Processor_ARETURN.java
│ │ │ │ ├── Processor_ARRAYLENGTH.java
│ │ │ │ ├── Processor_ASTORE.java
│ │ │ │ ├── Processor_ATHROW.java
│ │ │ │ ├── Processor_BALOAD.java
│ │ │ │ ├── Processor_BASTORE.java
│ │ │ │ ├── Processor_BIPUSH.java
│ │ │ │ ├── Processor_BREAKPOINT.java
│ │ │ │ ├── Processor_CALOAD.java
│ │ │ │ ├── Processor_CASTORE.java
│ │ │ │ ├── Processor_CHECKCAST.java
│ │ │ │ ├── Processor_DUP.java
│ │ │ │ ├── Processor_DUP2.java
│ │ │ │ ├── Processor_DUP2_X1.java
│ │ │ │ ├── Processor_DUP2_X2.java
│ │ │ │ ├── Processor_DUP_X1.java
│ │ │ │ ├── Processor_DUP_X2.java
│ │ │ │ ├── Processor_GETFIELD.java
│ │ │ │ ├── Processor_GETSTATIC.java
│ │ │ │ ├── Processor_GOTO.java
│ │ │ │ ├── Processor_GOTO_W.java
│ │ │ │ ├── Processor_I2B.java
│ │ │ │ ├── Processor_I2C.java
│ │ │ │ ├── Processor_I2S.java
│ │ │ │ ├── Processor_IADD.java
│ │ │ │ ├── Processor_IALOAD.java
│ │ │ │ ├── Processor_IAND.java
│ │ │ │ ├── Processor_IASTORE.java
│ │ │ │ ├── Processor_ICONST.java
│ │ │ │ ├── Processor_IDIV.java
│ │ │ │ ├── Processor_IFEQ.java
│ │ │ │ ├── Processor_IFGE.java
│ │ │ │ ├── Processor_IFGT.java
│ │ │ │ ├── Processor_IFLE.java
│ │ │ │ ├── Processor_IFLT.java
│ │ │ │ ├── Processor_IFNE.java
│ │ │ │ ├── Processor_IFNONNULL.java
│ │ │ │ ├── Processor_IFNULL.java
│ │ │ │ ├── Processor_IF_ACMPEQ.java
│ │ │ │ ├── Processor_IF_ACMPNE.java
│ │ │ │ ├── Processor_IF_ICMPEQ.java
│ │ │ │ ├── Processor_IF_ICMPGE.java
│ │ │ │ ├── Processor_IF_ICMPGT.java
│ │ │ │ ├── Processor_IF_ICMPLE.java
│ │ │ │ ├── Processor_IF_ICMPLT.java
│ │ │ │ ├── Processor_IF_ICMPNE.java
│ │ │ │ ├── Processor_IINC.java
│ │ │ │ ├── Processor_ILOAD.java
│ │ │ │ ├── Processor_IMUL.java
│ │ │ │ ├── Processor_INEG.java
│ │ │ │ ├── Processor_INSTANCEOF.java
│ │ │ │ ├── Processor_INVOKEINTERFACE.java
│ │ │ │ ├── Processor_INVOKESPECIAL.java
│ │ │ │ ├── Processor_INVOKESTATIC.java
│ │ │ │ ├── Processor_INVOKEVIRTUAL.java
│ │ │ │ ├── Processor_IOR.java
│ │ │ │ ├── Processor_IREM.java
│ │ │ │ ├── Processor_IRETURN.java
│ │ │ │ ├── Processor_ISHL.java
│ │ │ │ ├── Processor_ISHR.java
│ │ │ │ ├── Processor_ISTORE.java
│ │ │ │ ├── Processor_ISUB.java
│ │ │ │ ├── Processor_IUSHR.java
│ │ │ │ ├── Processor_IXOR.java
│ │ │ │ ├── Processor_JSR.java
│ │ │ │ ├── Processor_JSR_W.java
│ │ │ │ ├── Processor_LDC.java
│ │ │ │ ├── Processor_LDC_W.java
│ │ │ │ ├── Processor_LOOKUPSWITCH.java
│ │ │ │ ├── Processor_MONITORENTER.java
│ │ │ │ ├── Processor_MONITOREXIT.java
│ │ │ │ ├── Processor_MULTIANEWARRAY.java
│ │ │ │ ├── Processor_NEW.java
│ │ │ │ ├── Processor_NEWARRAY.java
│ │ │ │ ├── Processor_NOP.java
│ │ │ │ ├── Processor_POP.java
│ │ │ │ ├── Processor_POP2.java
│ │ │ │ ├── Processor_PUTFIELD.java
│ │ │ │ ├── Processor_PUTSTATIC.java
│ │ │ │ ├── Processor_RET.java
│ │ │ │ ├── Processor_RETURN.java
│ │ │ │ ├── Processor_SALOAD.java
│ │ │ │ ├── Processor_SASTORE.java
│ │ │ │ ├── Processor_SIPUSH.java
│ │ │ │ ├── Processor_SWAP.java
│ │ │ │ └── Processor_TABLESWITCH.java
│ │ │ └── translator
│ │ │ │ ├── ClassContextImpl.java
│ │ │ │ ├── DefaultTranslatorLogger.java
│ │ │ │ ├── InstanceofTable.java
│ │ │ │ ├── InvokeinterfaceTable.java
│ │ │ │ ├── InvokevirtualTable.java
│ │ │ │ ├── MainPrefixPostfixGenerator.java
│ │ │ │ ├── MethodContextImpl.java
│ │ │ │ ├── MethodTranslator.java
│ │ │ │ ├── NativeClassProcessor.java
│ │ │ │ ├── TranslatorImpl.java
│ │ │ │ ├── jar
│ │ │ │ ├── ClassValidator.java
│ │ │ │ ├── ZClassPath.java
│ │ │ │ └── ZParsedJar.java
│ │ │ │ ├── mojos
│ │ │ │ └── TranslatorMojo.java
│ │ │ │ ├── optimizator
│ │ │ │ ├── AsmOptimizer.java
│ │ │ │ ├── AsmOptimizerChain.java
│ │ │ │ ├── OptimizationChainFactory.java
│ │ │ │ ├── OptimizationLevel.java
│ │ │ │ └── base
│ │ │ │ │ ├── OptimizationConst.java
│ │ │ │ │ ├── OptimizationState.java
│ │ │ │ │ └── ReplacePatterns.java
│ │ │ │ └── utils
│ │ │ │ ├── AsmAssertions.java
│ │ │ │ ├── ClassUtils.java
│ │ │ │ └── MethodUtils.java
│ │ │ └── z80asm
│ │ │ ├── AsmTranslator.java
│ │ │ ├── EquDirectiveContainer.java
│ │ │ ├── LabelAddressContainer.java
│ │ │ ├── LocalLabelExpectant.java
│ │ │ ├── PositioningByteBuffer.java
│ │ │ ├── Z80Asm.java
│ │ │ ├── asmcommands
│ │ │ ├── AbstractAsmCommand.java
│ │ │ ├── AsmCommandADC.java
│ │ │ ├── AsmCommandADD.java
│ │ │ ├── AsmCommandAND.java
│ │ │ ├── AsmCommandASSERT.java
│ │ │ ├── AsmCommandBIT.java
│ │ │ ├── AsmCommandCALL.java
│ │ │ ├── AsmCommandCCF.java
│ │ │ ├── AsmCommandCLRLOC.java
│ │ │ ├── AsmCommandCP.java
│ │ │ ├── AsmCommandCPD.java
│ │ │ ├── AsmCommandCPDR.java
│ │ │ ├── AsmCommandCPI.java
│ │ │ ├── AsmCommandCPIR.java
│ │ │ ├── AsmCommandCPL.java
│ │ │ ├── AsmCommandDAA.java
│ │ │ ├── AsmCommandDEC.java
│ │ │ ├── AsmCommandDEFB.java
│ │ │ ├── AsmCommandDEFM.java
│ │ │ ├── AsmCommandDEFS.java
│ │ │ ├── AsmCommandDEFW.java
│ │ │ ├── AsmCommandDI.java
│ │ │ ├── AsmCommandDJNZ.java
│ │ │ ├── AsmCommandEI.java
│ │ │ ├── AsmCommandEND.java
│ │ │ ├── AsmCommandENT.java
│ │ │ ├── AsmCommandEQU.java
│ │ │ ├── AsmCommandEX.java
│ │ │ ├── AsmCommandEXX.java
│ │ │ ├── AsmCommandHALT.java
│ │ │ ├── AsmCommandIM.java
│ │ │ ├── AsmCommandIN.java
│ │ │ ├── AsmCommandINC.java
│ │ │ ├── AsmCommandIND.java
│ │ │ ├── AsmCommandINDR.java
│ │ │ ├── AsmCommandINI.java
│ │ │ ├── AsmCommandINIR.java
│ │ │ ├── AsmCommandJP.java
│ │ │ ├── AsmCommandJR.java
│ │ │ ├── AsmCommandLD.java
│ │ │ ├── AsmCommandLDD.java
│ │ │ ├── AsmCommandLDDR.java
│ │ │ ├── AsmCommandLDI.java
│ │ │ ├── AsmCommandLDIR.java
│ │ │ ├── AsmCommandNEG.java
│ │ │ ├── AsmCommandNOP.java
│ │ │ ├── AsmCommandOR.java
│ │ │ ├── AsmCommandORG.java
│ │ │ ├── AsmCommandOTDR.java
│ │ │ ├── AsmCommandOTIR.java
│ │ │ ├── AsmCommandOUT.java
│ │ │ ├── AsmCommandOUTD.java
│ │ │ ├── AsmCommandOUTI.java
│ │ │ ├── AsmCommandPOP.java
│ │ │ ├── AsmCommandPUSH.java
│ │ │ ├── AsmCommandRES.java
│ │ │ ├── AsmCommandRET.java
│ │ │ ├── AsmCommandRETI.java
│ │ │ ├── AsmCommandRETN.java
│ │ │ ├── AsmCommandRL.java
│ │ │ ├── AsmCommandRLA.java
│ │ │ ├── AsmCommandRLC.java
│ │ │ ├── AsmCommandRLCA.java
│ │ │ ├── AsmCommandRLD.java
│ │ │ ├── AsmCommandRR.java
│ │ │ ├── AsmCommandRRA.java
│ │ │ ├── AsmCommandRRC.java
│ │ │ ├── AsmCommandRRCA.java
│ │ │ ├── AsmCommandRRD.java
│ │ │ ├── AsmCommandRST.java
│ │ │ ├── AsmCommandSBC.java
│ │ │ ├── AsmCommandSCF.java
│ │ │ ├── AsmCommandSET.java
│ │ │ ├── AsmCommandSLA.java
│ │ │ ├── AsmCommandSRA.java
│ │ │ ├── AsmCommandSRL.java
│ │ │ ├── AsmCommandSUB.java
│ │ │ ├── AsmCommandXOR.java
│ │ │ └── ParsedAsmLine.java
│ │ │ ├── exceptions
│ │ │ └── AsmTranslationException.java
│ │ │ └── expression
│ │ │ └── LightExpression.java
│ └── resources
│ │ └── com
│ │ └── igormaznitsa
│ │ └── j2z80
│ │ ├── japi
│ │ └── java
│ │ │ └── io
│ │ │ └── java.io.PrintStream.a80
│ │ └── jvmprocessors
│ │ ├── AALOAD.a80
│ │ ├── AASTORE.a80
│ │ ├── ACONST_NULL.a80
│ │ ├── ALOAD.a80
│ │ ├── ANEWARRAY.a80
│ │ ├── ARETURN.a80
│ │ ├── ARRAYLENGTH.a80
│ │ ├── ASTORE.a80
│ │ ├── ATHROW.a80
│ │ ├── ATHROW_MANAGER.a80
│ │ ├── BALOAD.a80
│ │ ├── BASTORE.a80
│ │ ├── BIPUSH.a80
│ │ ├── BREAKPOINT.a80
│ │ ├── BREAKPOINT_MANAGER.a80
│ │ ├── CALOAD.a80
│ │ ├── CASTORE.a80
│ │ ├── CHECKCAST.a80
│ │ ├── CHECKCAST_MANAGER.a80
│ │ ├── DUP.a80
│ │ ├── DUP2.a80
│ │ ├── DUP2_X1.a80
│ │ ├── DUP2_X2.a80
│ │ ├── DUP_X1.a80
│ │ ├── DUP_X2.a80
│ │ ├── GETFIELD.a80
│ │ ├── GETSTATIC.a80
│ │ ├── GOTO.a80
│ │ ├── GOTO_W.a80
│ │ ├── I2B.a80
│ │ ├── I2C.a80
│ │ ├── I2S.a80
│ │ ├── IADD.a80
│ │ ├── IALOAD.a80
│ │ ├── IAND.a80
│ │ ├── IASTORE.a80
│ │ ├── ICONST.a80
│ │ ├── IDIV.a80
│ │ ├── IFEQ.a80
│ │ ├── IFGE.a80
│ │ ├── IFGT.a80
│ │ ├── IFLE.a80
│ │ ├── IFLT.a80
│ │ ├── IFNE.a80
│ │ ├── IFNONNULL.a80
│ │ ├── IFNULL.a80
│ │ ├── IF_ACMPEQ.a80
│ │ ├── IF_ACMPNE.a80
│ │ ├── IF_ICMPEQ.a80
│ │ ├── IF_ICMPGE.a80
│ │ ├── IF_ICMPGT.a80
│ │ ├── IF_ICMPLE.a80
│ │ ├── IF_ICMPLT.a80
│ │ ├── IF_ICMPNE.a80
│ │ ├── IINC.a80
│ │ ├── ILOAD.a80
│ │ ├── IMUL.a80
│ │ ├── INEG.a80
│ │ ├── INSTANCEOF.a80
│ │ ├── INSTANCEOF_MANAGER.a80
│ │ ├── INT_ARITHMETIC_MANAGER.a80
│ │ ├── INVOKEINTERFACE.a80
│ │ ├── INVOKEINTERFACE_MANAGER.a80
│ │ ├── INVOKESPECIAL.a80
│ │ ├── INVOKESTATIC.a80
│ │ ├── INVOKEVIRTUAL.a80
│ │ ├── INVOKEVIRTUAL_MANAGER.a80
│ │ ├── IOR.a80
│ │ ├── IREM.a80
│ │ ├── IRETURN.a80
│ │ ├── ISHL.a80
│ │ ├── ISHR.a80
│ │ ├── ISTORE.a80
│ │ ├── ISUB.a80
│ │ ├── IUSHR.a80
│ │ ├── IXOR.a80
│ │ ├── JSR.a80
│ │ ├── JSR_W.a80
│ │ ├── LDC.a80
│ │ ├── LDC_W.a80
│ │ ├── LOOKUPSWITCH.a80
│ │ ├── MEMORY_MANAGER.a80
│ │ ├── MONITORENTER.a80
│ │ ├── MONITOREXIT.a80
│ │ ├── MULTIANEWARRAY.a80
│ │ ├── NEW.a80
│ │ ├── NEWARRAY.a80
│ │ ├── NOP.a80
│ │ ├── POP.a80
│ │ ├── POP2.a80
│ │ ├── PUTFIELD.a80
│ │ ├── PUTSTATIC.a80
│ │ ├── RET.a80
│ │ ├── RETURN.a80
│ │ ├── SALOAD.a80
│ │ ├── SASTORE.a80
│ │ ├── SIPUSH.a80
│ │ ├── SWAP.a80
│ │ ├── TABLESWITCH.a80
│ │ └── processorlist.txt
│ └── test
│ ├── java
│ ├── com
│ │ └── igormaznitsa
│ │ │ ├── j2z80
│ │ │ ├── jvmprocessors
│ │ │ │ ├── AbstractIntMathManagerBasedTest.java
│ │ │ │ ├── AbstractInvokeTest.java
│ │ │ │ ├── AbstractJVMBranchTest.java
│ │ │ │ ├── AbstractJVMSelectTest.java
│ │ │ │ ├── AbstractJvmCommandProcessorTest.java
│ │ │ │ ├── AbstractTestBasedOnMemoryManager.java
│ │ │ │ ├── AdditionPathTest.java
│ │ │ │ ├── TestAALOAD.java
│ │ │ │ ├── TestAASTORE.java
│ │ │ │ ├── TestACONST_NULL.java
│ │ │ │ ├── TestALOAD.java
│ │ │ │ ├── TestANEWARRAY.java
│ │ │ │ ├── TestARETURN.java
│ │ │ │ ├── TestARRAYLENGTH.java
│ │ │ │ ├── TestASTORE.java
│ │ │ │ ├── TestATHROW.java
│ │ │ │ ├── TestBALOAD.java
│ │ │ │ ├── TestBASTORE.java
│ │ │ │ ├── TestBIPUSH.java
│ │ │ │ ├── TestBREAK.java
│ │ │ │ ├── TestBranches.java
│ │ │ │ ├── TestCALOAD.java
│ │ │ │ ├── TestCASTORE.java
│ │ │ │ ├── TestCHECKCAST.java
│ │ │ │ ├── TestDUP.java
│ │ │ │ ├── TestDUP2.java
│ │ │ │ ├── TestDUP2_X1.java
│ │ │ │ ├── TestDUP2_X2.java
│ │ │ │ ├── TestDUP_X1.java
│ │ │ │ ├── TestDUP_X2.java
│ │ │ │ ├── TestGETFIELD.java
│ │ │ │ ├── TestGETSTATIC.java
│ │ │ │ ├── TestI2B.java
│ │ │ │ ├── TestI2C.java
│ │ │ │ ├── TestI2S.java
│ │ │ │ ├── TestIADD.java
│ │ │ │ ├── TestIALOAD.java
│ │ │ │ ├── TestIAND.java
│ │ │ │ ├── TestIASTORE.java
│ │ │ │ ├── TestICONST.java
│ │ │ │ ├── TestIDIV.java
│ │ │ │ ├── TestIINC.java
│ │ │ │ ├── TestILOAD.java
│ │ │ │ ├── TestIMUL.java
│ │ │ │ ├── TestINEG.java
│ │ │ │ ├── TestINSTANCEOF.java
│ │ │ │ ├── TestINVOKEINTERFACE.java
│ │ │ │ ├── TestINVOKESPECIAL.java
│ │ │ │ ├── TestINVOKESTATIC.java
│ │ │ │ ├── TestINVOKEVIRTUAL.java
│ │ │ │ ├── TestIOR.java
│ │ │ │ ├── TestIREM.java
│ │ │ │ ├── TestIRETURN.java
│ │ │ │ ├── TestISHL.java
│ │ │ │ ├── TestISHR.java
│ │ │ │ ├── TestISTORE.java
│ │ │ │ ├── TestISUB.java
│ │ │ │ ├── TestIUSHR.java
│ │ │ │ ├── TestIXOR.java
│ │ │ │ ├── TestJSR.java
│ │ │ │ ├── TestJSR_W.java
│ │ │ │ ├── TestLDC.java
│ │ │ │ ├── TestLDC_W.java
│ │ │ │ ├── TestLOOKUPSWITCH.java
│ │ │ │ ├── TestMONITORENTER.java
│ │ │ │ ├── TestMONITOREXIT.java
│ │ │ │ ├── TestMULTIANEWARRAY.java
│ │ │ │ ├── TestNEW.java
│ │ │ │ ├── TestNEWARRAY.java
│ │ │ │ ├── TestNOP.java
│ │ │ │ ├── TestPOP.java
│ │ │ │ ├── TestPOP2.java
│ │ │ │ ├── TestPUTFIELD.java
│ │ │ │ ├── TestPUTSTATIC.java
│ │ │ │ ├── TestRET.java
│ │ │ │ ├── TestRETURN.java
│ │ │ │ ├── TestSALOAD.java
│ │ │ │ ├── TestSASTORE.java
│ │ │ │ ├── TestSIPUSH.java
│ │ │ │ ├── TestSWAP.java
│ │ │ │ └── TestTABLESWITCH.java
│ │ │ └── translator
│ │ │ │ ├── MethodTranslatorTest.java
│ │ │ │ ├── optimizator
│ │ │ │ └── base
│ │ │ │ │ └── ReplacePatternsTest.java
│ │ │ │ └── utils
│ │ │ │ └── ClassUtilsTest.java
│ │ │ └── z80asm
│ │ │ ├── PositioningByteBufferTest.java
│ │ │ ├── Z80AsmTest.java
│ │ │ ├── asmcommands
│ │ │ ├── AbstractAsmCommandTest.java
│ │ │ ├── AllOperationTest.java
│ │ │ ├── AsmCommandDEFBTest.java
│ │ │ ├── AsmCommandDEFSTest.java
│ │ │ ├── AsmCommandDEFWTest.java
│ │ │ ├── AsmCommandENTTest.java
│ │ │ ├── AsmCommandLineTest.java
│ │ │ ├── AsmCommandORGTest.java
│ │ │ ├── ParsedAsmLineTest.java
│ │ │ └── expression
│ │ │ │ └── LightExpressionTest.java
│ │ │ └── expression
│ │ │ └── LightExpressionTest.java
│ └── j80
│ │ └── cpu
│ │ ├── Z80.java
│ │ └── Z80debug.java
│ └── resources
│ └── com
│ └── igormaznitsa
│ └── z80asm
│ ├── asmcommands
│ └── all_commands.txt
│ ├── equ.asm
│ ├── hello_world.asm
│ ├── local.asm
│ ├── localatend.asm
│ ├── multilabeled.asm
│ └── only_label.asm
├── j2z80-tests
├── ext-jar
│ ├── pom.xml
│ └── src
│ │ └── main
│ │ ├── java
│ │ └── com
│ │ │ └── igormaznitsa
│ │ │ └── memory
│ │ │ └── MemoryAccessor.java
│ │ └── resources
│ │ └── com
│ │ └── igormaznitsa
│ │ ├── hello.txt
│ │ └── memory
│ │ └── MemoryAccessor.a80
├── main-jar
│ ├── pom.xml
│ └── src
│ │ ├── main
│ │ ├── java
│ │ │ └── com
│ │ │ │ └── igormaznitsa
│ │ │ │ ├── impl
│ │ │ │ ├── MemoryFiller.java
│ │ │ │ ├── MemoryFillerFactory.java
│ │ │ │ ├── MemoryFillerJava.java
│ │ │ │ └── MemoryFillerNative.java
│ │ │ │ ├── j2z80test
│ │ │ │ └── Main.java
│ │ │ │ └── templategen
│ │ │ │ ├── EvenPatternGenerator.java
│ │ │ │ └── OddPatternGenerator.java
│ │ └── resources
│ │ │ └── com
│ │ │ └── igormaznitsa
│ │ │ └── impl
│ │ │ └── MemoryFillerNative#fillArea.asm
│ │ └── test
│ │ └── java
│ │ ├── com
│ │ └── igormaznitsa
│ │ │ └── j2z80
│ │ │ └── test
│ │ │ └── AcceptanceITCase.java
│ │ └── j80
│ │ └── cpu
│ │ ├── Z80.java
│ │ └── Z80debug.java
└── pom.xml
├── nbactions.xml
├── pom.xml
└── texts
├── gpl-3.0.txt
└── readme.txt
/.gitignore:
--------------------------------------------------------------------------------
1 | target
2 | *.iml
3 | .idea
4 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | Description
2 | ============
3 | It is a maven plugin developed for academical purposes, the plugin allows to translate compiled JVM byte codes into Z80 instructions. It works as a pattern compiler with minimal optimization. **Warning! It is not a JVM interpreter because it generates low-level native code for Z80. It doesn't contain any GC!**
4 |
5 | 
6 | ```Java
7 | package com.igormaznitsa.test.helloworld;
8 |
9 | import static com.igormaznitsa.test.helloworld.ZXScreen.*;
10 |
11 | public class main {
12 | public static final void mainz(){
13 | setTextColor(COLOR_RED, COLOR_WHITE);
14 | clearWholeScreen();
15 | System.out.println("Hello world!");
16 | setTextColor(COLOR_YELLOW, COLOR_BLUE);
17 | clearServiceScreen();
18 | System.err.println("Written in Java!!!");
19 | setBorderColor(COLOR_RED);
20 | }
21 | }
22 | ```
23 |
24 | As the input it uses JAR files It takes a JAR file and translate all found classes into solid Z80 binary block which can be started on real device or under emulator.
25 |
26 | It is not fully compatible with Java and has a lot of restrictions but it allows to use Java tool-chain and IDEs for Z80 developments.
27 |
28 | License
29 | ========
30 | The Sources published under [GNU GPL 3](http://www.gnu.org/copyleft/gpl.html)
31 |
32 | Donation
33 | =========
34 | If you like the software you can make some donation to the author
35 | [](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=AHWJHJFBAWGL2)
36 |
--------------------------------------------------------------------------------
/docs/asm.txt:
--------------------------------------------------------------------------------
1 | The Translator has a small embedded Z80 assembler which is used to translate generated assembler sources into binary representation. The assembler allows only (!) documented Z80 commands and also it has several special commands to manage the translating process and labels.
2 |
3 | Labels
4 | -------
5 | There are two kinds of labels:
6 | 1. Global labels. There can be only label with such name.
7 | 2. Local labels. Such kind of labels can be redefined. A Local label name starts with '@' symbol. To avoid duplication or wrong behaviour you can 'forget' all known local labes with the CLRLOC special command.
8 |
9 | Special commands
10 | ------------------
11 | ENT
- it defines the start point of the code
12 | ORG - it defines the current start address for translation
13 | DEFB ,.. - it allows to place byte values (1 cell per value) into memory cells
14 | DEFW ,.. - it allows to place word values (2 cells per value) into memory cells
15 | DEFM - save a string (8 bit per char) into memory cells
16 | DEFS - to make reservation of memory block with the length in bytes
17 | CLRLOC - the directive resets all met local labels
18 | : EQU - it allows to set some numeric value to a label
19 |
20 | Expressions as arguments
21 | --------------------------
22 | Only very lite expressions can be used in arguments, the assembler supports only two operators - "-" and "+" to be used n expressions. Also the '$' symbol can be used to get the current PC state. Very restricted but can be used strings, their chars will be combined into 4 byte word, for instance - " " -> 0x20202020, also strings support special chars [\t\r\n\b\"\'\\].
--------------------------------------------------------------------------------
/docs/java_on_spec.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/raydac/j2z80/3ce132df4f9249172d15a7de320f8fc4b13195d4/docs/java_on_spec.png
--------------------------------------------------------------------------------
/examples/ZXSpectrumDemoLib/src/main/resources/com/igormaznitsa/j2z80/bootstrap/java/io/PrintStream.a80:
--------------------------------------------------------------------------------
1 | JAVA.LANG.SYSTEN.PRINTLN:
2 | LD A,(IX-0)
3 | CALL 5633
4 | LD L,(IX-2)
5 | LD H,(IX-3)
6 | LD B,0
7 | LD C,(HL)
8 | INC HL
9 | LD E,L
10 | LD D,H
11 | CALL 8252
12 | RET
13 |
--------------------------------------------------------------------------------
/examples/ZXSpectrumHelloWorld/src/main/java/com/igormaznitsa/test/helloworld/ZXScreen.java:
--------------------------------------------------------------------------------
1 | package com.igormaznitsa.test.helloworld;
2 |
3 | public class ZXScreen {
4 | public static final int COLOR_BLACK = 0;
5 | public static final int COLOR_BLUE = 1;
6 | public static final int COLOR_RED = 2;
7 | public static final int COLOR_VIOLET = 3;
8 | public static final int COLOR_GREEN = 4;
9 | public static final int COLOR_LIGHTBLUE = 5;
10 | public static final int COLOR_YELLOW = 6;
11 | public static final int COLOR_WHITE = 7;
12 |
13 | public static native void setBorderColor(int color);
14 | public static native void setTextColor(int inkColor, int paperColor);
15 | public static native void clearWholeScreen();
16 | public static native void clearServiceScreen();
17 | }
18 |
--------------------------------------------------------------------------------
/examples/ZXSpectrumHelloWorld/src/main/java/com/igormaznitsa/test/helloworld/main.java:
--------------------------------------------------------------------------------
1 | package com.igormaznitsa.test.helloworld;
2 |
3 | import static com.igormaznitsa.test.helloworld.ZXScreen.*;
4 |
5 | public class main {
6 | public static final void mainz(){
7 | setTextColor(COLOR_RED, COLOR_WHITE);
8 | clearWholeScreen();
9 | System.out.println("Hello world!");
10 | setTextColor(COLOR_YELLOW, COLOR_BLUE);
11 | clearServiceScreen();
12 | System.err.println("Written in Java!!!");
13 | setBorderColor(COLOR_RED);
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/examples/ZXSpectrumHelloWorld/src/main/resources/com/igormaznitsa/test/helloworld/ZXScreen.a80:
--------------------------------------------------------------------------------
1 | BORDCR: EQU #5C48
2 | ATTR_P: EQU #5C8D
3 |
4 | com.igormaznitsa.test.helloworld.ZXScreen.setBorderColor#[I]V:
5 | LD A,(IX-0)
6 | AND 7
7 | OUT (#FE),A
8 | RET
9 |
10 | com.igormaznitsa.test.helloworld.ZXScreen.setTextColor#[II]V:
11 | LD B,(IX-0) ; ink color
12 | LD C,(IX-2) ; paper color
13 | LD A,C
14 | AND 7
15 | RLCA
16 | RLCA
17 | RLCA
18 | LD C,A
19 | LD A,B
20 | AND 7
21 | OR C
22 | LD (ATTR_P),A
23 | LD (BORDCR),A
24 | RET
25 |
26 | com.igormaznitsa.test.helloworld.ZXScreen.clearWholeScreen#[]V:
27 | CALL #0D6B
28 | RET
29 |
30 | com.igormaznitsa.test.helloworld.ZXScreen.clearServiceScreen#[]V:
31 | CALL #0D6E
32 | RET
--------------------------------------------------------------------------------
/j2z80-api/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 | com.igormaznitsa
7 | j2z80-pom
8 | 1.0.2-SNAPSHOT
9 |
10 |
11 | j2z80-api
12 | jar
13 |
14 |
15 |
16 | junit
17 | junit
18 |
19 |
20 | org.apache.bcel
21 | bcel
22 |
23 |
24 | org.mockito
25 | mockito-all
26 |
27 |
28 | org.springframework
29 | spring-core
30 | 5.1.6.RELEASE
31 |
32 |
33 | com.igormaznitsa
34 | meta-utils
35 | 1.1.3
36 |
37 |
38 |
39 |
--------------------------------------------------------------------------------
/j2z80-api/src/main/java/com/igormaznitsa/j2z80/TranslatorLogger.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 Igor Maznitsa.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.igormaznitsa.j2z80;
17 |
18 | /**
19 | * The interface describes a logger to be used inbound of the translator.
20 | *
21 | * @author Igor Maznutsa (igor.maznitsa@igormaznitsa.com)
22 | */
23 | public interface TranslatorLogger {
24 | /**
25 | * Print an information message
26 | *
27 | * @param str an information message, it can be null
28 | */
29 | void logInfo(String str);
30 |
31 | /**
32 | * Print a warning message
33 | *
34 | * @param str a warning message, it can be null
35 | */
36 | void logWarning(String str);
37 |
38 | /**
39 | * Print an error message
40 | *
41 | * @param str an error message, it can be null
42 | */
43 | void logError(String str);
44 | }
45 |
--------------------------------------------------------------------------------
/j2z80-api/src/main/java/com/igormaznitsa/j2z80/api/additional/AdditionPath.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 Igor Maznitsa.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.igormaznitsa.j2z80.api.additional;
17 |
18 | import java.lang.annotation.ElementType;
19 | import java.lang.annotation.Inherited;
20 | import java.lang.annotation.Retention;
21 | import java.lang.annotation.RetentionPolicy;
22 | import java.lang.annotation.Target;
23 |
24 | /**
25 | * The annotation describes the path to a native source file for the addition.
26 | *
27 | * @author Igor Maznitsa (igor.maznitsa@igormaznitsa.com)
28 | */
29 | @Target(value = {ElementType.TYPE})
30 | @Retention(RetentionPolicy.RUNTIME)
31 | @Inherited
32 | public @interface AdditionPath {
33 | String value();
34 | }
35 |
--------------------------------------------------------------------------------
/j2z80-api/src/main/java/com/igormaznitsa/j2z80/api/additional/J2ZAdditionalBlock.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 Igor Maznitsa.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.igormaznitsa.j2z80.api.additional;
17 |
18 | /**
19 | * The flag interface shows that the class declaring it is an addition for J2Z80 translator.
20 | *
21 | * @author Igor Maznitsa (igor.maznitsa@igormaznitsa.com)
22 | */
23 | public interface J2ZAdditionalBlock {
24 |
25 | }
26 |
--------------------------------------------------------------------------------
/j2z80-api/src/main/java/com/igormaznitsa/j2z80/api/additional/NeedsATHROWManager.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 Igor Maznitsa.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.igormaznitsa.j2z80.api.additional;
17 |
18 | /**
19 | * The addition shows that an implementing class needs to include the ATHROW manager.
20 | *
21 | * @author Igor Maznitsa (igor.maznitsa@igormaznitsa.com)
22 | */
23 | @AdditionPath("ATHROW_MANAGER.a80")
24 | public interface NeedsATHROWManager extends J2ZAdditionalBlock {
25 | /**
26 | * The label name of the memory cells (two cells) where the exception processing procedure address should be placed
27 | */
28 | public static final String ATHROW_PROCESSING_ADDRESS = "___ATHROW_PROCESSING_CODE_ADDRESS";
29 | }
30 |
--------------------------------------------------------------------------------
/j2z80-api/src/main/java/com/igormaznitsa/j2z80/api/additional/NeedsBREAKPOINTManager.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 Igor Maznitsa.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.igormaznitsa.j2z80.api.additional;
17 |
18 | /**
19 | * The addition shows that an implementing class needs to include the BREAKPOINT command
20 | * manager.
21 | *
22 | * @author Igor Maznitsa (igor.maznitsa@igormaznitsa.com)
23 | */
24 | @AdditionPath("BREAKPOINT_MANAGER.a80")
25 | public interface NeedsBREAKPOINTManager extends J2ZAdditionalBlock {
26 | /**
27 | * The label of the memory cells containing the current breakpoint processing subroutine address
28 | */
29 | public static final String BREAKPOINT_PROCESSING_SUB_ADDRESS = "___BREAKPOINT_PROCESSING_CODE_ADDRESS";
30 |
31 | /**
32 | * The label of the breakpoint processing subroutine stub (it does nothing)
33 | */
34 | public static final String BREAKPOINT_PROCESSING_STUB = "___BREAKPOINT_PROCESSING_STUB";
35 |
36 | /**
37 | * The label of the breakpoint processing manager subroutine
38 | */
39 | public static final String BREAKPOINT_PROCESSING_MANAGER = "___BREAKPOINT_PROCESSING_MANAGER";
40 | }
41 |
--------------------------------------------------------------------------------
/j2z80-api/src/main/java/com/igormaznitsa/j2z80/api/additional/NeedsCheckcastManager.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 Igor Maznitsa.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.igormaznitsa.j2z80.api.additional;
17 |
18 | /**
19 | * The addition shows that an implementing class needs to include the CHECKCAST
20 | * command manager.
21 | *
22 | * @author Igor Maznitsa (igor.maznitsa@igormaznitsa.com)
23 | */
24 | @AdditionPath("CHECKCAST_MANAGER.a80")
25 | public interface NeedsCheckcastManager extends J2ZAdditionalBlock {
26 | /**
27 | * The label of the subroutine processing checkcast commands
28 | */
29 | public static final String SUB_CHECKCAST = "___CHECKCAST";
30 | }
31 |
--------------------------------------------------------------------------------
/j2z80-api/src/main/java/com/igormaznitsa/j2z80/api/additional/NeedsINTArithmeticManager.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 Igor Maznitsa.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.igormaznitsa.j2z80.api.additional;
17 |
18 | /**
19 | * The addition shows that an implementing class needs to include the integer arithmetic manager.
20 | * The manager allows to emulate MUL, DIV and REM signed integer operations on Z80.
21 | *
22 | * @author Igor Maznitsa (igor.maznitsa@igormaznitsa.com)
23 | */
24 | @AdditionPath("INT_ARITHMETIC_MANAGER.a80")
25 | public interface NeedsINTArithmeticManager extends J2ZAdditionalBlock {
26 | /**
27 | * The label of the MUL emulating subroutine
28 | */
29 | public static final String SUB_INT_MUL = "___INT_MATH_MUL";
30 | /**
31 | * The label of the DIV emulating subroutine
32 | */
33 | public static final String SUB_INT_DIV = "___INT_MATH_DIV";
34 | /**
35 | * The label of the REM emulating subroutine
36 | */
37 | public static final String SUB_INT_REM = "___INT_MATH_REM";
38 | }
39 |
--------------------------------------------------------------------------------
/j2z80-api/src/main/java/com/igormaznitsa/j2z80/api/additional/NeedsINVOKEINTERFACEManager.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 Igor Maznitsa.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.igormaznitsa.j2z80.api.additional;
17 |
18 | /**
19 | * The addition shows that an implementing class needs to include the INVOKEINTERFACE
20 | * manager allows to invoke interface declared methods.
21 | *
22 | * @author Igor Maznitsa (igor.maznitsa@igormaznitsa.com)
23 | */
24 | @AdditionPath("INVOKEINTERFACE_MANAGER.a80")
25 | public interface NeedsINVOKEINTERFACEManager extends J2ZAdditionalBlock {
26 | /**
27 | * The label of the subroutine processing invoke interface calls.
28 | */
29 | public static final String SUB_INVOKE_INTERFACE = "___INVOKEINTERFACE";
30 | /**
31 | * The name of the macros which should be replaced by an the invoke address table label
32 | */
33 | public static final String MACROS_INVOKEINTERFACE_TABLE = "%invokeinterfacetable%";
34 | }
35 |
--------------------------------------------------------------------------------
/j2z80-api/src/main/java/com/igormaznitsa/j2z80/api/additional/NeedsINVOKEVIRTUALManager.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 Igor Maznitsa.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.igormaznitsa.j2z80.api.additional;
17 |
18 | /**
19 | * The addition shows that an implementing class needs to include the INVOKEVIRTUAL manager.
20 | * The manager allows to invoke virtual methods of classes.
21 | *
22 | * @author Igor Maznitsa (igor.maznitsa@igormaznitsa.com)
23 | */
24 | @AdditionPath("INVOKEVIRTUAL_MANAGER.a80")
25 | public interface NeedsINVOKEVIRTUALManager extends J2ZAdditionalBlock {
26 | /**
27 | * The macros name which should be replaced by either label or address of an invoke virtual table
28 | */
29 | public static final String MACROS_INVOKEVIRTUAL_TABLE = "%invokevirtualtable%";
30 | }
31 |
--------------------------------------------------------------------------------
/j2z80-api/src/main/java/com/igormaznitsa/j2z80/api/additional/NeedsInstanceofManager.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 Igor Maznitsa.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.igormaznitsa.j2z80.api.additional;
17 |
18 | /**
19 | * The addition shows that an implementing class needs to include the INSTANCEOF manager.
20 | *
21 | * @author Igor Maznitsa (igor.maznitsa@igormaznitsa.com)
22 | */
23 | @AdditionPath("INSTANCEOF_MANAGER.a80")
24 | public interface NeedsInstanceofManager extends J2ZAdditionalBlock {
25 | /**
26 | * The macros to be replaced by an instanceof table represented as String.
27 | */
28 | public static final String MACRO_INSTANCEOFTABLE = "%instanceoftable%";
29 | /**
30 | * The label of the memory address where the instanceof table will be placed
31 | */
32 | public static final String INSTANCEOF_TABLE_POINTER = "___INSTANCEOF_TABLE";
33 | /**
34 | * The label of the subroutine processing the instanceof logic
35 | */
36 | public static final String SUB_INSTANCEOF = "___INSTANCE_OF";
37 | }
38 |
--------------------------------------------------------------------------------
/j2z80-api/src/main/java/com/igormaznitsa/j2z80/utils/MutableObjectContainer.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 Igor Maznitsa.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.igormaznitsa.j2z80.utils;
17 |
18 | /**
19 | * A Special object-wrapper allows to change an object and emulate changing of method arguments inside th method
20 | *
21 | * @param the type of the carried object
22 | * @author Igor Maznitsa (igor.maznitsa@igormaznitsa.com)
23 | */
24 | public class MutableObjectContainer {
25 | private V value;
26 |
27 | public MutableObjectContainer() {
28 | this(null);
29 | }
30 |
31 | public MutableObjectContainer(final V value) {
32 | this.value = value;
33 | }
34 |
35 | public V get() {
36 | return this.value;
37 | }
38 |
39 | public void set(final V value) {
40 | this.value = value;
41 | }
42 |
43 | public boolean isNull() {
44 | return this.value == null;
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/j2z80-plugin/nbactions.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | CUSTOM-compile
5 | compile
6 |
7 | compiler:compile
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/j2z80-plugin/src/assembly/bundle.xml:
--------------------------------------------------------------------------------
1 |
4 | bundle
5 |
6 | false
7 | false
8 |
9 |
10 | jar
11 |
12 |
13 |
14 | ${project.build.directory}
15 | ${file.separator}
16 |
17 | *.jar.asc
18 | *.jar
19 | *.pom
20 | *.pom.asc
21 |
22 |
23 | original*.*
24 | *.zip
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/j2z80-plugin/src/main/java/com/igormaznitsa/j2z80/jvmprocessors/Processor_BALOAD.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 Igor Maznitsa.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.igormaznitsa.j2z80.jvmprocessors;
17 |
18 | import com.igormaznitsa.j2z80.translator.MethodTranslator;
19 | import org.apache.bcel.generic.BALOAD;
20 | import org.apache.bcel.generic.Instruction;
21 | import org.apache.bcel.generic.InstructionHandle;
22 |
23 | import java.io.IOException;
24 | import java.io.Writer;
25 |
26 | // class to process BALOAD with code 51
27 | public class Processor_BALOAD extends AbstractJvmCommandProcessor {
28 | private final String template;
29 |
30 | public Processor_BALOAD() {
31 | super();
32 | template = loadResourceFileAsString("BALOAD.a80");
33 | }
34 |
35 | @Override
36 | public String getName() {
37 | return "BALOAD";
38 | }
39 |
40 | @Override
41 | public void process(final MethodTranslator classProcessor, final Instruction instruction, final InstructionHandle handle, final Writer out) throws IOException {
42 | BALOAD nop = (BALOAD) instruction;
43 | out.write(template);
44 | out.write(NEXT_LINE);
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/j2z80-plugin/src/main/java/com/igormaznitsa/j2z80/jvmprocessors/Processor_DUP.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 Igor Maznitsa.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.igormaznitsa.j2z80.jvmprocessors;
17 |
18 | import com.igormaznitsa.j2z80.translator.MethodTranslator;
19 | import org.apache.bcel.generic.DUP;
20 | import org.apache.bcel.generic.Instruction;
21 | import org.apache.bcel.generic.InstructionHandle;
22 |
23 | import java.io.IOException;
24 | import java.io.Writer;
25 |
26 | // class to process DUP with code 089
27 | public class Processor_DUP extends AbstractJvmCommandProcessor {
28 | private final String template;
29 |
30 | public Processor_DUP() {
31 | super();
32 | template = loadResourceFileAsString("DUP.a80");
33 | }
34 |
35 | @Override
36 | public String getName() {
37 | return "DUP";
38 | }
39 |
40 | @Override
41 | public void process(final MethodTranslator methodTranslator, final Instruction instruction, final InstructionHandle handle, final Writer out) throws IOException {
42 | final DUP dup = (DUP) instruction;
43 | out.write(template);
44 | out.write(NEXT_LINE);
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/j2z80-plugin/src/main/java/com/igormaznitsa/j2z80/jvmprocessors/Processor_DUP2.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 Igor Maznitsa.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.igormaznitsa.j2z80.jvmprocessors;
17 |
18 | import com.igormaznitsa.j2z80.translator.MethodTranslator;
19 | import org.apache.bcel.generic.DUP2;
20 | import org.apache.bcel.generic.Instruction;
21 | import org.apache.bcel.generic.InstructionHandle;
22 |
23 | import java.io.IOException;
24 | import java.io.Writer;
25 |
26 | // class to process DUP2 with code 092
27 | public class Processor_DUP2 extends AbstractJvmCommandProcessor {
28 | private final String template;
29 |
30 | public Processor_DUP2() {
31 | super();
32 | template = loadResourceFileAsString("DUP2.a80");
33 | }
34 |
35 | @Override
36 | public String getName() {
37 | return "DUP2";
38 | }
39 |
40 | @Override
41 | public void process(final MethodTranslator methodTranslator, final Instruction instruction, final InstructionHandle handle, final Writer out) throws IOException {
42 | final DUP2 dup2 = (DUP2) instruction;
43 | out.write(template);
44 | out.write(NEXT_LINE);
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/j2z80-plugin/src/main/java/com/igormaznitsa/j2z80/jvmprocessors/Processor_I2B.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 Igor Maznitsa.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.igormaznitsa.j2z80.jvmprocessors;
17 |
18 | import com.igormaznitsa.j2z80.translator.MethodTranslator;
19 | import org.apache.bcel.generic.I2B;
20 | import org.apache.bcel.generic.Instruction;
21 | import org.apache.bcel.generic.InstructionHandle;
22 |
23 | import java.io.IOException;
24 | import java.io.Writer;
25 |
26 | // class to process I2B with code 145
27 | public class Processor_I2B extends AbstractJvmCommandProcessor {
28 | private final String template;
29 |
30 | public Processor_I2B() {
31 | super();
32 | template = loadResourceFileAsString("I2B.a80");
33 | }
34 |
35 | @Override
36 | public String getName() {
37 | return "I2B";
38 | }
39 |
40 | @Override
41 | public void process(final MethodTranslator methodTranslator, final Instruction instruction, final InstructionHandle handle, final Writer out) throws IOException {
42 | final I2B nop = (I2B) instruction;
43 | out.write(template);
44 | out.write(NEXT_LINE);
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/j2z80-plugin/src/main/java/com/igormaznitsa/j2z80/jvmprocessors/Processor_I2C.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 Igor Maznitsa.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.igormaznitsa.j2z80.jvmprocessors;
17 |
18 | import com.igormaznitsa.j2z80.translator.MethodTranslator;
19 | import org.apache.bcel.generic.I2C;
20 | import org.apache.bcel.generic.Instruction;
21 | import org.apache.bcel.generic.InstructionHandle;
22 |
23 | import java.io.IOException;
24 | import java.io.Writer;
25 |
26 | // class to process I2C with code 146
27 | public class Processor_I2C extends AbstractJvmCommandProcessor {
28 | private final String template;
29 |
30 | public Processor_I2C() {
31 | super();
32 | template = loadResourceFileAsString("I2C.a80");
33 | }
34 |
35 | @Override
36 | public String getName() {
37 | return "I2C";
38 | }
39 |
40 | @Override
41 | public void process(final MethodTranslator methodTranslator, final Instruction instruction, final InstructionHandle handle, final Writer out) throws IOException {
42 | final I2C i2c = (I2C) instruction;
43 | out.write(template);
44 | out.write(NEXT_LINE);
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/j2z80-plugin/src/main/java/com/igormaznitsa/j2z80/jvmprocessors/Processor_I2S.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 Igor Maznitsa.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.igormaznitsa.j2z80.jvmprocessors;
17 |
18 | import com.igormaznitsa.j2z80.translator.MethodTranslator;
19 | import org.apache.bcel.generic.I2S;
20 | import org.apache.bcel.generic.Instruction;
21 | import org.apache.bcel.generic.InstructionHandle;
22 |
23 | import java.io.IOException;
24 | import java.io.Writer;
25 |
26 | // class to process I2S with code 147
27 | public class Processor_I2S extends AbstractJvmCommandProcessor {
28 | private final String template;
29 |
30 | public Processor_I2S() {
31 | super();
32 | template = loadResourceFileAsString("I2S.a80");
33 | }
34 |
35 | @Override
36 | public String getName() {
37 | return "I2S";
38 | }
39 |
40 | @Override
41 | public void process(final MethodTranslator methodTranslator, final Instruction instruction, final InstructionHandle handle, final Writer out) throws IOException {
42 | final I2S i2s = (I2S) instruction;
43 | out.write(template);
44 | out.write(NEXT_LINE);
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/j2z80-plugin/src/main/java/com/igormaznitsa/j2z80/jvmprocessors/Processor_IADD.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 Igor Maznitsa.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.igormaznitsa.j2z80.jvmprocessors;
17 |
18 | import com.igormaznitsa.j2z80.translator.MethodTranslator;
19 | import org.apache.bcel.generic.IADD;
20 | import org.apache.bcel.generic.Instruction;
21 | import org.apache.bcel.generic.InstructionHandle;
22 |
23 | import java.io.IOException;
24 | import java.io.Writer;
25 |
26 | // class to process IADD with code 096
27 | public class Processor_IADD extends AbstractJvmCommandProcessor {
28 | private final String template;
29 |
30 | public Processor_IADD() {
31 | super();
32 | template = loadResourceFileAsString("IADD.a80");
33 | }
34 |
35 | @Override
36 | public String getName() {
37 | return "IADD";
38 | }
39 |
40 | @Override
41 | public void process(final MethodTranslator methodTranslator, final Instruction instruction, final InstructionHandle handle, final Writer out) throws IOException {
42 | final IADD iadd = (IADD) instruction;
43 | out.write(template);
44 | out.write(NEXT_LINE);
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/j2z80-plugin/src/main/java/com/igormaznitsa/j2z80/jvmprocessors/Processor_IAND.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 Igor Maznitsa.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.igormaznitsa.j2z80.jvmprocessors;
17 |
18 | import com.igormaznitsa.j2z80.translator.MethodTranslator;
19 | import org.apache.bcel.generic.IAND;
20 | import org.apache.bcel.generic.Instruction;
21 | import org.apache.bcel.generic.InstructionHandle;
22 |
23 | import java.io.IOException;
24 | import java.io.Writer;
25 |
26 | // class to process IAND with code 126
27 | public class Processor_IAND extends AbstractJvmCommandProcessor {
28 | private final String template;
29 |
30 | public Processor_IAND() {
31 | super();
32 | template = loadResourceFileAsString("IAND.a80");
33 | }
34 |
35 | @Override
36 | public String getName() {
37 | return "IAND";
38 | }
39 |
40 | @Override
41 | public void process(final MethodTranslator methodTranslator, final Instruction instruction, final InstructionHandle handle, final Writer out) throws IOException {
42 | final IAND iand = (IAND) instruction;
43 | out.write(template);
44 | out.write(NEXT_LINE);
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/j2z80-plugin/src/main/java/com/igormaznitsa/j2z80/jvmprocessors/Processor_INEG.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 Igor Maznitsa.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.igormaznitsa.j2z80.jvmprocessors;
17 |
18 | import com.igormaznitsa.j2z80.translator.MethodTranslator;
19 | import org.apache.bcel.generic.INEG;
20 | import org.apache.bcel.generic.Instruction;
21 | import org.apache.bcel.generic.InstructionHandle;
22 |
23 | import java.io.IOException;
24 | import java.io.Writer;
25 |
26 | // class to process INEG with code 116
27 | public class Processor_INEG extends AbstractJvmCommandProcessor {
28 | private final String template;
29 |
30 | public Processor_INEG() {
31 | super();
32 | template = loadResourceFileAsString("INEG.a80");
33 | }
34 |
35 | @Override
36 | public String getName() {
37 | return "INEG";
38 | }
39 |
40 | @Override
41 | public void process(final MethodTranslator methodTranslator, final Instruction instruction, final InstructionHandle handle, final Writer out) throws IOException {
42 | final INEG ineg = (INEG) instruction;
43 | out.write(template);
44 | out.write(NEXT_LINE);
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/j2z80-plugin/src/main/java/com/igormaznitsa/j2z80/jvmprocessors/Processor_IOR.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 Igor Maznitsa.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.igormaznitsa.j2z80.jvmprocessors;
17 |
18 | import com.igormaznitsa.j2z80.translator.MethodTranslator;
19 | import org.apache.bcel.generic.IOR;
20 | import org.apache.bcel.generic.Instruction;
21 | import org.apache.bcel.generic.InstructionHandle;
22 |
23 | import java.io.IOException;
24 | import java.io.Writer;
25 |
26 | // class to process IOR with code 128
27 | public class Processor_IOR extends AbstractJvmCommandProcessor {
28 | private final String template;
29 |
30 | public Processor_IOR() {
31 | super();
32 | template = loadResourceFileAsString("IOR.a80");
33 | }
34 |
35 | @Override
36 | public String getName() {
37 | return "IOR";
38 | }
39 |
40 | @Override
41 | public void process(final MethodTranslator methodTranslator, final Instruction instruction, final InstructionHandle handle, final Writer out) throws IOException {
42 | final IOR ior = (IOR) instruction;
43 | out.write(template);
44 | out.write(NEXT_LINE);
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/j2z80-plugin/src/main/java/com/igormaznitsa/j2z80/jvmprocessors/Processor_ISHL.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 Igor Maznitsa.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.igormaznitsa.j2z80.jvmprocessors;
17 |
18 | import com.igormaznitsa.j2z80.translator.MethodTranslator;
19 | import org.apache.bcel.generic.ISHL;
20 | import org.apache.bcel.generic.Instruction;
21 | import org.apache.bcel.generic.InstructionHandle;
22 |
23 | import java.io.IOException;
24 | import java.io.Writer;
25 |
26 | // class to process ISHL with code 120
27 | public class Processor_ISHL extends AbstractJvmCommandProcessor {
28 | private final String template;
29 |
30 | public Processor_ISHL() {
31 | super();
32 | template = loadResourceFileAsString("ISHL.a80");
33 | }
34 |
35 | @Override
36 | public String getName() {
37 | return "ISHL";
38 | }
39 |
40 | @Override
41 | public void process(final MethodTranslator methodTranslator, final Instruction instruction, final InstructionHandle handle, final Writer out) throws IOException {
42 | final ISHL ishl = (ISHL) instruction;
43 | out.write(template);
44 | out.write(NEXT_LINE);
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/j2z80-plugin/src/main/java/com/igormaznitsa/j2z80/jvmprocessors/Processor_ISHR.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 Igor Maznitsa.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.igormaznitsa.j2z80.jvmprocessors;
17 |
18 | import com.igormaznitsa.j2z80.translator.MethodTranslator;
19 | import org.apache.bcel.generic.ISHR;
20 | import org.apache.bcel.generic.Instruction;
21 | import org.apache.bcel.generic.InstructionHandle;
22 |
23 | import java.io.IOException;
24 | import java.io.Writer;
25 |
26 | // class to process ISHR with code 122
27 | public class Processor_ISHR extends AbstractJvmCommandProcessor {
28 | private final String template;
29 |
30 | public Processor_ISHR() {
31 | super();
32 | template = loadResourceFileAsString("ISHR.a80");
33 | }
34 |
35 | @Override
36 | public String getName() {
37 | return "ISHR";
38 | }
39 |
40 | @Override
41 | public void process(final MethodTranslator methodTranslator, final Instruction instruction, final InstructionHandle handle, final Writer out) throws IOException {
42 | final ISHR ishr = (ISHR) instruction;
43 | out.write(template);
44 | out.write(NEXT_LINE);
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/j2z80-plugin/src/main/java/com/igormaznitsa/j2z80/jvmprocessors/Processor_ISUB.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 Igor Maznitsa.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.igormaznitsa.j2z80.jvmprocessors;
17 |
18 | import com.igormaznitsa.j2z80.translator.MethodTranslator;
19 | import org.apache.bcel.generic.ISUB;
20 | import org.apache.bcel.generic.Instruction;
21 | import org.apache.bcel.generic.InstructionHandle;
22 |
23 | import java.io.IOException;
24 | import java.io.Writer;
25 |
26 | // class to process ISUB with code 100
27 | public class Processor_ISUB extends AbstractJvmCommandProcessor {
28 | private final String template;
29 |
30 | public Processor_ISUB() {
31 | super();
32 | template = loadResourceFileAsString("ISUB.a80");
33 | }
34 |
35 | @Override
36 | public String getName() {
37 | return "ISUB";
38 | }
39 |
40 | @Override
41 | public void process(final MethodTranslator methodTranslator, final Instruction instruction, final InstructionHandle handle, final Writer out) throws IOException {
42 | final ISUB isub = (ISUB) instruction;
43 | out.write(template);
44 | out.write(NEXT_LINE);
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/j2z80-plugin/src/main/java/com/igormaznitsa/j2z80/jvmprocessors/Processor_IXOR.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 Igor Maznitsa.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.igormaznitsa.j2z80.jvmprocessors;
17 |
18 | import com.igormaznitsa.j2z80.translator.MethodTranslator;
19 | import org.apache.bcel.generic.IXOR;
20 | import org.apache.bcel.generic.Instruction;
21 | import org.apache.bcel.generic.InstructionHandle;
22 |
23 | import java.io.IOException;
24 | import java.io.Writer;
25 |
26 | // class to process IXOR with code 130
27 | public class Processor_IXOR extends AbstractJvmCommandProcessor {
28 | private final String template;
29 |
30 | public Processor_IXOR() {
31 | super();
32 | template = loadResourceFileAsString("IXOR.a80");
33 | }
34 |
35 | @Override
36 | public String getName() {
37 | return "IXOR";
38 | }
39 |
40 | @Override
41 | public void process(final MethodTranslator methodTranslator, final Instruction instruction, final InstructionHandle handle, final Writer out) throws IOException {
42 | final IXOR ixor = (IXOR) instruction;
43 | out.write(template);
44 | out.write(NEXT_LINE);
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/j2z80-plugin/src/main/java/com/igormaznitsa/j2z80/jvmprocessors/Processor_NOP.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 Igor Maznitsa.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.igormaznitsa.j2z80.jvmprocessors;
17 |
18 | import com.igormaznitsa.j2z80.translator.MethodTranslator;
19 | import org.apache.bcel.generic.Instruction;
20 | import org.apache.bcel.generic.InstructionHandle;
21 | import org.apache.bcel.generic.NOP;
22 |
23 | import java.io.IOException;
24 | import java.io.Writer;
25 |
26 | // class to process NOP with code 00
27 | public class Processor_NOP extends AbstractJvmCommandProcessor {
28 | private final String template;
29 |
30 | public Processor_NOP() {
31 | super();
32 | template = loadResourceFileAsString("NOP.a80");
33 | }
34 |
35 | @Override
36 | public String getName() {
37 | return "NOP";
38 | }
39 |
40 | @Override
41 | public void process(final MethodTranslator methodTranslator, final Instruction instruction, final InstructionHandle handle, final Writer out) throws IOException {
42 | final NOP nop = (NOP) instruction;
43 | out.write(template);
44 | out.write(NEXT_LINE);
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/j2z80-plugin/src/main/java/com/igormaznitsa/j2z80/jvmprocessors/Processor_POP.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 Igor Maznitsa.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.igormaznitsa.j2z80.jvmprocessors;
17 |
18 | import com.igormaznitsa.j2z80.translator.MethodTranslator;
19 | import org.apache.bcel.generic.Instruction;
20 | import org.apache.bcel.generic.InstructionHandle;
21 | import org.apache.bcel.generic.POP;
22 |
23 | import java.io.IOException;
24 | import java.io.Writer;
25 |
26 | // class to process POP with code 87
27 | public class Processor_POP extends AbstractJvmCommandProcessor {
28 | private final String template;
29 |
30 | public Processor_POP() {
31 | super();
32 | template = loadResourceFileAsString("POP.a80");
33 | }
34 |
35 | @Override
36 | public String getName() {
37 | return "POP";
38 | }
39 |
40 | @Override
41 | public void process(final MethodTranslator methodTranslator, final Instruction instruction, final InstructionHandle handle, final Writer out) throws IOException {
42 | final POP pop = (POP) instruction;
43 | out.write(template);
44 | out.write(NEXT_LINE);
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/j2z80-plugin/src/main/java/com/igormaznitsa/j2z80/jvmprocessors/Processor_POP2.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 Igor Maznitsa.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.igormaznitsa.j2z80.jvmprocessors;
17 |
18 | import com.igormaznitsa.j2z80.translator.MethodTranslator;
19 | import org.apache.bcel.generic.Instruction;
20 | import org.apache.bcel.generic.InstructionHandle;
21 | import org.apache.bcel.generic.POP2;
22 |
23 | import java.io.IOException;
24 | import java.io.Writer;
25 |
26 | // class to process POP2 with code 88
27 | public class Processor_POP2 extends AbstractJvmCommandProcessor {
28 | private final String template;
29 |
30 | public Processor_POP2() {
31 | super();
32 | template = loadResourceFileAsString("POP2.a80");
33 | }
34 |
35 | @Override
36 | public String getName() {
37 | return "POP2";
38 | }
39 |
40 | @Override
41 | public void process(final MethodTranslator classProcessor, final Instruction instruction, final InstructionHandle handle, final Writer out) throws IOException {
42 | final POP2 pop2 = (POP2) instruction;
43 | out.write(template);
44 | out.write(NEXT_LINE);
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/j2z80-plugin/src/main/java/com/igormaznitsa/j2z80/jvmprocessors/Processor_SWAP.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 Igor Maznitsa.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.igormaznitsa.j2z80.jvmprocessors;
17 |
18 | import com.igormaznitsa.j2z80.translator.MethodTranslator;
19 | import org.apache.bcel.generic.Instruction;
20 | import org.apache.bcel.generic.InstructionHandle;
21 | import org.apache.bcel.generic.SWAP;
22 |
23 | import java.io.IOException;
24 | import java.io.Writer;
25 |
26 | // class to process SWAP with code 095
27 | public class Processor_SWAP extends AbstractJvmCommandProcessor {
28 | private final String template;
29 |
30 | public Processor_SWAP() {
31 | super();
32 | template = loadResourceFileAsString("SWAP.a80");
33 | }
34 |
35 | @Override
36 | public String getName() {
37 | return "SWAP";
38 | }
39 |
40 | @Override
41 | public void process(final MethodTranslator methodTranslator, final Instruction instruction, final InstructionHandle handle, final Writer out) throws IOException {
42 | final SWAP swap = (SWAP) instruction;
43 | out.write(template);
44 | out.write(NEXT_LINE);
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/j2z80-plugin/src/main/java/com/igormaznitsa/j2z80/translator/optimizator/AsmOptimizer.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 Igor Maznitsa.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.igormaznitsa.j2z80.translator.optimizator;
17 |
18 | import com.igormaznitsa.j2z80.TranslatorContext;
19 | import com.igormaznitsa.z80asm.asmcommands.ParsedAsmLine;
20 |
21 | import java.util.List;
22 |
23 | /**
24 | * The interface describes an optimizer working on the assembler level
25 | *
26 | * @author Igor Maznitsa (igor.maznitsa@igormaznitsa.com)
27 | */
28 | public interface AsmOptimizer {
29 | /**
30 | * Optimize assembler text.
31 | *
32 | * @param context a translator context, must not be null
33 | * @param asmParsedLines a list contains parsed assembler lines without spaces and nulls
34 | * @return a list contains optimized assembler lines
35 | */
36 | List optimizeAsmText(TranslatorContext context, List asmParsedLines);
37 | }
38 |
--------------------------------------------------------------------------------
/j2z80-plugin/src/main/java/com/igormaznitsa/j2z80/translator/optimizator/OptimizationChainFactory.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 Igor Maznitsa.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.igormaznitsa.j2z80.translator.optimizator;
17 |
18 | import com.igormaznitsa.j2z80.TranslatorContext;
19 | import com.igormaznitsa.j2z80.translator.optimizator.base.ReplacePatterns;
20 |
21 | public class OptimizationChainFactory {
22 |
23 | public static AsmOptimizerChain getOptimizators(final TranslatorContext context, final OptimizationLevel level) {
24 | if (level == null) {
25 | return new AsmOptimizerChain(context);
26 | }
27 | switch (level) {
28 | case NONE:
29 | return new AsmOptimizerChain(context);
30 | case BASE:
31 | return new AsmOptimizerChain(context, new ReplacePatterns());
32 | default:
33 | throw new IllegalArgumentException("Unsupported optimization level " + level);
34 | }
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/j2z80-plugin/src/main/java/com/igormaznitsa/j2z80/translator/optimizator/base/OptimizationConst.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 Igor Maznitsa.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.igormaznitsa.j2z80.translator.optimizator.base;
17 |
18 | import java.util.Collections;
19 | import java.util.List;
20 |
21 | interface OptimizationConst {
22 | String CLRLOC_STR = "CLRLOC";
23 | List NONE = Collections.emptyList();
24 | List CLRLOC = Collections.singletonList(CLRLOC_STR);
25 | }
26 |
--------------------------------------------------------------------------------
/j2z80-plugin/src/main/java/com/igormaznitsa/j2z80/translator/optimizator/base/ReplacePatterns.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 Igor Maznitsa.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.igormaznitsa.j2z80.translator.optimizator.base;
17 |
18 | import com.igormaznitsa.j2z80.TranslatorContext;
19 | import com.igormaznitsa.j2z80.translator.optimizator.AsmOptimizer;
20 | import com.igormaznitsa.z80asm.asmcommands.ParsedAsmLine;
21 |
22 | import java.util.LinkedList;
23 | import java.util.List;
24 |
25 | public class ReplacePatterns implements AsmOptimizer {
26 |
27 | @Override
28 | public List optimizeAsmText(final TranslatorContext context, final List lines) {
29 | final List result = new LinkedList<>(lines);
30 |
31 | boolean loop = true;
32 |
33 | while (loop && !Thread.currentThread().isInterrupted()) {
34 | loop = false;
35 | for (final OptimizationState optCase : OptimizationState.values()) {
36 | if (optCase.process(result)) {
37 | loop = true;
38 | break;
39 | }
40 | }
41 | }
42 |
43 | return result;
44 | }
45 |
46 | }
47 |
--------------------------------------------------------------------------------
/j2z80-plugin/src/main/java/com/igormaznitsa/j2z80/translator/utils/MethodUtils.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 Igor Maznitsa.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.igormaznitsa.j2z80.translator.utils;
17 |
18 | import org.apache.bcel.classfile.Method;
19 | import org.apache.bcel.generic.Type;
20 |
21 | public class MethodUtils {
22 | private MethodUtils() {
23 | }
24 |
25 | public static boolean isStaticInitializer(final Method method) {
26 | return method.isStatic() && method.getName().equals("")
27 | && method.getArgumentTypes().length == 0
28 | && method.getReturnType().getType() == Type.VOID.getType();
29 | }
30 |
31 |
32 | }
33 |
--------------------------------------------------------------------------------
/j2z80-plugin/src/main/java/com/igormaznitsa/z80asm/LocalLabelExpectant.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 Igor Maznitsa.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.igormaznitsa.z80asm;
17 |
18 | /**
19 | * The interface describes a local label expectant, it works like an observer but only one time.
20 | *
21 | * @author Imgor Maznitsa (igor.maznitsa@igormaznitsa.com)
22 | */
23 | public interface LocalLabelExpectant {
24 | /**
25 | * This method will be called when the needed label is registered.
26 | *
27 | * @param asmTranslator the assembler translator, must not be null
28 | * @param labelName the label name, must not be null
29 | * @param labelAddress the label address
30 | */
31 | void onLabelIsAccessible(AsmTranslator asmTranslator, String labelName, long labelAddress);
32 | }
33 |
--------------------------------------------------------------------------------
/j2z80-plugin/src/main/java/com/igormaznitsa/z80asm/asmcommands/AsmCommandCCF.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 Igor Maznitsa.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.igormaznitsa.z80asm.asmcommands;
17 |
18 | import com.igormaznitsa.z80asm.AsmTranslator;
19 |
20 | public class AsmCommandCCF extends AbstractAsmCommand {
21 |
22 | private static final byte[] MACHINE_CODE = new byte[] {0x3F};
23 |
24 | @Override
25 | public byte[] makeMachineCode(final AsmTranslator context, ParsedAsmLine asm) {
26 | return MACHINE_CODE;
27 | }
28 |
29 | @Override
30 | public String getName() {
31 | return "CCF";
32 | }
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/j2z80-plugin/src/main/java/com/igormaznitsa/z80asm/asmcommands/AsmCommandCLRLOC.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 Igor Maznitsa.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.igormaznitsa.z80asm.asmcommands;
17 |
18 | import com.igormaznitsa.z80asm.AsmTranslator;
19 |
20 | public class AsmCommandCLRLOC extends AbstractAsmCommand {
21 |
22 | public static final String NAME = "CLRLOC";
23 |
24 | @Override
25 | public byte[] makeMachineCode(final AsmTranslator context, final ParsedAsmLine asm) {
26 | context.clearLocalLabels();
27 | return EMPTY_ARRAY;
28 | }
29 |
30 | @Override
31 | public String getName() {
32 | return NAME;
33 | }
34 |
35 | @Override
36 | public Arguments getAllowedArgumentsNumber() {
37 | return Arguments.ANY;
38 | }
39 |
40 | @Override
41 | public boolean isSpecialDirective() {
42 | return true;
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/j2z80-plugin/src/main/java/com/igormaznitsa/z80asm/asmcommands/AsmCommandCPD.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 Igor Maznitsa.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.igormaznitsa.z80asm.asmcommands;
17 |
18 | import com.igormaznitsa.z80asm.AsmTranslator;
19 |
20 | public class AsmCommandCPD extends AbstractAsmCommand {
21 |
22 | private static final byte[] MACHINE_CODE = new byte[] {(byte) 0xED, (byte) 0xA9};
23 |
24 | @Override
25 | public byte[] makeMachineCode(final AsmTranslator context, ParsedAsmLine asm) {
26 | return MACHINE_CODE;
27 | }
28 |
29 | @Override
30 | public String getName() {
31 | return "CPD";
32 | }
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/j2z80-plugin/src/main/java/com/igormaznitsa/z80asm/asmcommands/AsmCommandCPDR.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 Igor Maznitsa.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.igormaznitsa.z80asm.asmcommands;
17 |
18 | import com.igormaznitsa.z80asm.AsmTranslator;
19 |
20 | public class AsmCommandCPDR extends AbstractAsmCommand {
21 |
22 | private static final byte[] MACHINE_CODE = new byte[] {(byte) 0xED, (byte) 0xB9};
23 |
24 | @Override
25 | public byte[] makeMachineCode(final AsmTranslator context, ParsedAsmLine asm) {
26 | return MACHINE_CODE;
27 | }
28 |
29 | @Override
30 | public String getName() {
31 | return "CPDR";
32 | }
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/j2z80-plugin/src/main/java/com/igormaznitsa/z80asm/asmcommands/AsmCommandCPI.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 Igor Maznitsa.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.igormaznitsa.z80asm.asmcommands;
17 |
18 | import com.igormaznitsa.z80asm.AsmTranslator;
19 |
20 | public class AsmCommandCPI extends AbstractAsmCommand {
21 |
22 | private static final byte[] MACHINE_CODE = new byte[] {(byte) 0xED, (byte) 0xA1};
23 |
24 | @Override
25 | public byte[] makeMachineCode(final AsmTranslator context, ParsedAsmLine asm) {
26 | return MACHINE_CODE;
27 | }
28 |
29 | @Override
30 | public String getName() {
31 | return "CPI";
32 | }
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/j2z80-plugin/src/main/java/com/igormaznitsa/z80asm/asmcommands/AsmCommandCPIR.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 Igor Maznitsa.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.igormaznitsa.z80asm.asmcommands;
17 |
18 | import com.igormaznitsa.z80asm.AsmTranslator;
19 |
20 | public class AsmCommandCPIR extends AbstractAsmCommand {
21 |
22 | private static final byte[] MACHINE_CODE = new byte[] {(byte) 0xED, (byte) 0xB1};
23 |
24 | @Override
25 | public byte[] makeMachineCode(final AsmTranslator context, ParsedAsmLine asm) {
26 | return MACHINE_CODE;
27 | }
28 |
29 | @Override
30 | public String getName() {
31 | return "CPIR";
32 | }
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/j2z80-plugin/src/main/java/com/igormaznitsa/z80asm/asmcommands/AsmCommandCPL.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 Igor Maznitsa.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.igormaznitsa.z80asm.asmcommands;
17 |
18 | import com.igormaznitsa.z80asm.AsmTranslator;
19 |
20 | public class AsmCommandCPL extends AbstractAsmCommand {
21 |
22 | private static final byte[] MACHINE_CODE = new byte[] {0x2F};
23 |
24 | @Override
25 | public byte[] makeMachineCode(final AsmTranslator context, ParsedAsmLine asm) {
26 | return MACHINE_CODE;
27 | }
28 |
29 | @Override
30 | public String getName() {
31 | return "CPL";
32 | }
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/j2z80-plugin/src/main/java/com/igormaznitsa/z80asm/asmcommands/AsmCommandDAA.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 Igor Maznitsa.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.igormaznitsa.z80asm.asmcommands;
17 |
18 | import com.igormaznitsa.z80asm.AsmTranslator;
19 |
20 | public class AsmCommandDAA extends AbstractAsmCommand {
21 |
22 | private static final byte[] MACHINE_CODE = new byte[] {0x27};
23 |
24 | @Override
25 | public byte[] makeMachineCode(final AsmTranslator context, ParsedAsmLine asm) {
26 | return MACHINE_CODE;
27 | }
28 |
29 | @Override
30 | public String getName() {
31 | return "DAA";
32 | }
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/j2z80-plugin/src/main/java/com/igormaznitsa/z80asm/asmcommands/AsmCommandDEFS.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 Igor Maznitsa.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.igormaznitsa.z80asm.asmcommands;
18 |
19 | import com.igormaznitsa.j2z80.translator.utils.AsmAssertions;
20 | import com.igormaznitsa.z80asm.AsmTranslator;
21 | import com.igormaznitsa.z80asm.expression.LightExpression;
22 |
23 | public class AsmCommandDEFS extends AbstractAsmCommand {
24 |
25 | @Override
26 | public byte[] makeMachineCode(final AsmTranslator context, final ParsedAsmLine asm) {
27 | final int value = new LightExpression(context, this, asm, asm.getArgs()[0]).calculate();
28 | AsmAssertions.assertUnsignedShort(value);
29 | return new byte[value];
30 | }
31 |
32 | @Override
33 | public String getName() {
34 | return "DEFS";
35 | }
36 |
37 | @Override
38 | public Arguments getAllowedArgumentsNumber() {
39 | return Arguments.ONE;
40 | }
41 |
42 | @Override
43 | public boolean isSpecialDirective() {
44 | return true;
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/j2z80-plugin/src/main/java/com/igormaznitsa/z80asm/asmcommands/AsmCommandDI.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 Igor Maznitsa.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.igormaznitsa.z80asm.asmcommands;
17 |
18 | import com.igormaznitsa.z80asm.AsmTranslator;
19 |
20 | public class AsmCommandDI extends AbstractAsmCommand {
21 |
22 | private static final byte[] MACHINE_CODE = new byte[] {(byte) 0xF3};
23 |
24 | @Override
25 | public byte[] makeMachineCode(final AsmTranslator context, ParsedAsmLine asm) {
26 | return MACHINE_CODE;
27 | }
28 |
29 | @Override
30 | public String getName() {
31 | return "DI";
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/j2z80-plugin/src/main/java/com/igormaznitsa/z80asm/asmcommands/AsmCommandDJNZ.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 Igor Maznitsa.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.igormaznitsa.z80asm.asmcommands;
17 |
18 | import com.igormaznitsa.z80asm.AsmTranslator;
19 | import com.igormaznitsa.z80asm.expression.LightExpression;
20 |
21 | public class AsmCommandDJNZ extends AbstractAsmCommand {
22 |
23 | @Override
24 | public byte[] makeMachineCode(final AsmTranslator context, final ParsedAsmLine asm) {
25 | final int address = new LightExpression(context, this, asm, asm.getArgs()[0]).calculate();
26 | final int offset = calculateAddressOffset(address, context.getPC());
27 | return new byte[] {0x10, (byte) offset};
28 | }
29 |
30 | @Override
31 | public String getName() {
32 | return "DJNZ";
33 | }
34 |
35 | @Override
36 | public Arguments getAllowedArgumentsNumber() {
37 | return Arguments.ONE;
38 | }
39 |
40 | }
41 |
--------------------------------------------------------------------------------
/j2z80-plugin/src/main/java/com/igormaznitsa/z80asm/asmcommands/AsmCommandEI.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 Igor Maznitsa.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.igormaznitsa.z80asm.asmcommands;
17 |
18 | import com.igormaznitsa.z80asm.AsmTranslator;
19 |
20 | public class AsmCommandEI extends AbstractAsmCommand {
21 |
22 | private static final byte[] MACHINE_CODE = new byte[] {(byte) 0xFB};
23 |
24 | @Override
25 | public byte[] makeMachineCode(final AsmTranslator context, ParsedAsmLine asm) {
26 | return MACHINE_CODE;
27 | }
28 |
29 | @Override
30 | public String getName() {
31 | return "EI";
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/j2z80-plugin/src/main/java/com/igormaznitsa/z80asm/asmcommands/AsmCommandENT.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 Igor Maznitsa.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.igormaznitsa.z80asm.asmcommands;
18 |
19 | import com.igormaznitsa.j2z80.translator.utils.AsmAssertions;
20 | import com.igormaznitsa.z80asm.AsmTranslator;
21 | import com.igormaznitsa.z80asm.expression.LightExpression;
22 |
23 | public class AsmCommandENT extends AbstractAsmCommand {
24 |
25 | @Override
26 | public byte[] makeMachineCode(final AsmTranslator context, final ParsedAsmLine asm) {
27 | final int address = new LightExpression(context, this, asm, asm.getArgs()[0]).calculate();
28 | AsmAssertions.assertAddress(address);
29 | context.setEntryPoint(address);
30 | return EMPTY_ARRAY;
31 | }
32 |
33 | @Override
34 | public String getName() {
35 | return "ENT";
36 | }
37 |
38 | @Override
39 | public Arguments getAllowedArgumentsNumber() {
40 | return Arguments.ONE;
41 | }
42 |
43 | @Override
44 | public boolean isSpecialDirective() {
45 | return true;
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/j2z80-plugin/src/main/java/com/igormaznitsa/z80asm/asmcommands/AsmCommandEX.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 Igor Maznitsa.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.igormaznitsa.z80asm.asmcommands;
17 |
18 | import com.igormaznitsa.z80asm.AsmTranslator;
19 |
20 | public class AsmCommandEX extends AbstractAsmCommand {
21 |
22 | public AsmCommandEX() {
23 | super();
24 | addCase("DE,HL", (byte) 0xEB);
25 | addCase("(SP),HL", (byte) 0xE3);
26 | addCase("(SP),IX", (byte) 0xDD, (byte) 0xE3);
27 | addCase("(SP),IY", (byte) 0xFD, (byte) 0xE3);
28 | addCase("AF,AF'", (byte) 0x08);
29 | }
30 |
31 | @Override
32 | public byte[] makeMachineCode(AsmTranslator context, final ParsedAsmLine asm) {
33 | return getPatternCase(asm.getSignature());
34 | }
35 |
36 | @Override
37 | public String getName() {
38 | return "EX";
39 | }
40 |
41 | @Override
42 | public Arguments getAllowedArgumentsNumber() {
43 | return Arguments.TWO;
44 | }
45 |
46 | }
47 |
--------------------------------------------------------------------------------
/j2z80-plugin/src/main/java/com/igormaznitsa/z80asm/asmcommands/AsmCommandEXX.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 Igor Maznitsa.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.igormaznitsa.z80asm.asmcommands;
17 |
18 | import com.igormaznitsa.z80asm.AsmTranslator;
19 |
20 | public class AsmCommandEXX extends AbstractAsmCommand {
21 |
22 | private static final byte[] MACHINE_CODE = new byte[] {(byte) 0xD9};
23 |
24 | @Override
25 | public byte[] makeMachineCode(final AsmTranslator context, ParsedAsmLine asm) {
26 | return MACHINE_CODE;
27 | }
28 |
29 | @Override
30 | public String getName() {
31 | return "EXX";
32 | }
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/j2z80-plugin/src/main/java/com/igormaznitsa/z80asm/asmcommands/AsmCommandHALT.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 Igor Maznitsa.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.igormaznitsa.z80asm.asmcommands;
17 |
18 | import com.igormaznitsa.z80asm.AsmTranslator;
19 |
20 | public class AsmCommandHALT extends AbstractAsmCommand {
21 |
22 | private static final byte[] MACHINE_CODE = new byte[] {0x76};
23 |
24 | @Override
25 | public byte[] makeMachineCode(final AsmTranslator context, ParsedAsmLine asm) {
26 | return MACHINE_CODE;
27 | }
28 |
29 | @Override
30 | public String getName() {
31 | return "HALT";
32 | }
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/j2z80-plugin/src/main/java/com/igormaznitsa/z80asm/asmcommands/AsmCommandIND.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 Igor Maznitsa.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.igormaznitsa.z80asm.asmcommands;
17 |
18 | import com.igormaznitsa.z80asm.AsmTranslator;
19 |
20 | public class AsmCommandIND extends AbstractAsmCommand {
21 |
22 | private static final byte[] MACHINE_CODE = new byte[] {(byte) 0xED, (byte) 0xAA};
23 |
24 | @Override
25 | public byte[] makeMachineCode(final AsmTranslator context, ParsedAsmLine asm) {
26 | return MACHINE_CODE;
27 | }
28 |
29 | @Override
30 | public String getName() {
31 | return "IND";
32 | }
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/j2z80-plugin/src/main/java/com/igormaznitsa/z80asm/asmcommands/AsmCommandINDR.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 Igor Maznitsa.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.igormaznitsa.z80asm.asmcommands;
17 |
18 | import com.igormaznitsa.z80asm.AsmTranslator;
19 |
20 | public class AsmCommandINDR extends AbstractAsmCommand {
21 |
22 | private static final byte[] MACHINE_CODE = new byte[] {(byte) 0xED, (byte) 0xBA};
23 |
24 | @Override
25 | public byte[] makeMachineCode(final AsmTranslator context, ParsedAsmLine asm) {
26 | return MACHINE_CODE;
27 | }
28 |
29 | @Override
30 | public String getName() {
31 | return "INDR";
32 | }
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/j2z80-plugin/src/main/java/com/igormaznitsa/z80asm/asmcommands/AsmCommandINI.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 Igor Maznitsa.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.igormaznitsa.z80asm.asmcommands;
17 |
18 | import com.igormaznitsa.z80asm.AsmTranslator;
19 |
20 | public class AsmCommandINI extends AbstractAsmCommand {
21 |
22 | private static final byte[] MACHINE_CODE = new byte[] {(byte) 0xED, (byte) 0xA2};
23 |
24 | @Override
25 | public byte[] makeMachineCode(final AsmTranslator context, ParsedAsmLine asm) {
26 | return MACHINE_CODE;
27 | }
28 |
29 | @Override
30 | public String getName() {
31 | return "INI";
32 | }
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/j2z80-plugin/src/main/java/com/igormaznitsa/z80asm/asmcommands/AsmCommandINIR.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 Igor Maznitsa.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.igormaznitsa.z80asm.asmcommands;
17 |
18 | import com.igormaznitsa.z80asm.AsmTranslator;
19 |
20 | public class AsmCommandINIR extends AbstractAsmCommand {
21 |
22 | private static final byte[] MACHINE_CODE = new byte[] {(byte) 0xED, (byte) 0xB2};
23 |
24 | @Override
25 | public byte[] makeMachineCode(final AsmTranslator context, ParsedAsmLine asm) {
26 | return MACHINE_CODE;
27 | }
28 |
29 | @Override
30 | public String getName() {
31 | return "INIR";
32 | }
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/j2z80-plugin/src/main/java/com/igormaznitsa/z80asm/asmcommands/AsmCommandLDD.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 Igor Maznitsa.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.igormaznitsa.z80asm.asmcommands;
17 |
18 | import com.igormaznitsa.z80asm.AsmTranslator;
19 |
20 | public class AsmCommandLDD extends AbstractAsmCommand {
21 |
22 | private static final byte[] MACHINE_CODE = new byte[] {(byte) 0xED, (byte) 0xA8};
23 |
24 | @Override
25 | public byte[] makeMachineCode(final AsmTranslator context, ParsedAsmLine asm) {
26 | return MACHINE_CODE;
27 | }
28 |
29 | @Override
30 | public String getName() {
31 | return "LDD";
32 | }
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/j2z80-plugin/src/main/java/com/igormaznitsa/z80asm/asmcommands/AsmCommandLDDR.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 Igor Maznitsa.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.igormaznitsa.z80asm.asmcommands;
17 |
18 | import com.igormaznitsa.z80asm.AsmTranslator;
19 |
20 | public class AsmCommandLDDR extends AbstractAsmCommand {
21 |
22 | private static final byte[] MACHINE_CODE = new byte[] {(byte) 0xED, (byte) 0xB8};
23 |
24 | @Override
25 | public byte[] makeMachineCode(final AsmTranslator context, ParsedAsmLine asm) {
26 | return MACHINE_CODE;
27 | }
28 |
29 | @Override
30 | public String getName() {
31 | return "LDDR";
32 | }
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/j2z80-plugin/src/main/java/com/igormaznitsa/z80asm/asmcommands/AsmCommandLDI.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 Igor Maznitsa.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.igormaznitsa.z80asm.asmcommands;
17 |
18 | import com.igormaznitsa.z80asm.AsmTranslator;
19 |
20 | public class AsmCommandLDI extends AbstractAsmCommand {
21 |
22 | private static final byte[] MACHINE_CODE = new byte[] {(byte) 0xED, (byte) 0xA0};
23 |
24 | @Override
25 | public byte[] makeMachineCode(final AsmTranslator context, ParsedAsmLine asm) {
26 | return MACHINE_CODE;
27 | }
28 |
29 | @Override
30 | public String getName() {
31 | return "LDI";
32 | }
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/j2z80-plugin/src/main/java/com/igormaznitsa/z80asm/asmcommands/AsmCommandLDIR.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 Igor Maznitsa.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.igormaznitsa.z80asm.asmcommands;
17 |
18 | import com.igormaznitsa.z80asm.AsmTranslator;
19 |
20 | public class AsmCommandLDIR extends AbstractAsmCommand {
21 |
22 | private static final byte[] MACHINE_CODE = new byte[] {(byte) 0xED, (byte) 0xB0};
23 |
24 | @Override
25 | public byte[] makeMachineCode(final AsmTranslator context, ParsedAsmLine asm) {
26 | return MACHINE_CODE;
27 | }
28 |
29 | @Override
30 | public String getName() {
31 | return "LDIR";
32 | }
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/j2z80-plugin/src/main/java/com/igormaznitsa/z80asm/asmcommands/AsmCommandNEG.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 Igor Maznitsa.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.igormaznitsa.z80asm.asmcommands;
17 |
18 | import com.igormaznitsa.z80asm.AsmTranslator;
19 |
20 | public class AsmCommandNEG extends AbstractAsmCommand {
21 |
22 | private static final byte[] MACHINE_CODE = new byte[] {(byte) 0xED, (byte) 0x44};
23 |
24 | @Override
25 | public byte[] makeMachineCode(final AsmTranslator context, ParsedAsmLine asm) {
26 | return MACHINE_CODE;
27 | }
28 |
29 | @Override
30 | public String getName() {
31 | return "NEG";
32 | }
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/j2z80-plugin/src/main/java/com/igormaznitsa/z80asm/asmcommands/AsmCommandNOP.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 Igor Maznitsa.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.igormaznitsa.z80asm.asmcommands;
17 |
18 | import com.igormaznitsa.z80asm.AsmTranslator;
19 |
20 | public class AsmCommandNOP extends AbstractAsmCommand {
21 |
22 | private static final byte[] MACHINE_CODE = new byte[1];
23 |
24 | @Override
25 | public byte[] makeMachineCode(final AsmTranslator context, ParsedAsmLine asm) {
26 | return MACHINE_CODE;
27 | }
28 |
29 | @Override
30 | public String getName() {
31 | return "NOP";
32 | }
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/j2z80-plugin/src/main/java/com/igormaznitsa/z80asm/asmcommands/AsmCommandORG.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 Igor Maznitsa.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.igormaznitsa.z80asm.asmcommands;
18 |
19 | import com.igormaznitsa.j2z80.translator.utils.AsmAssertions;
20 | import com.igormaznitsa.z80asm.AsmTranslator;
21 | import com.igormaznitsa.z80asm.expression.LightExpression;
22 |
23 | public class AsmCommandORG extends AbstractAsmCommand {
24 |
25 | @Override
26 | public byte[] makeMachineCode(final AsmTranslator context, final ParsedAsmLine asm) {
27 | final int address = new LightExpression(context, this, asm, asm.getArgs()[0]).calculate();
28 | AsmAssertions.assertAddress(address);
29 | context.setPC(address);
30 | return EMPTY_ARRAY;
31 | }
32 |
33 | @Override
34 | public String getName() {
35 | return "ORG";
36 | }
37 |
38 | @Override
39 | public Arguments getAllowedArgumentsNumber() {
40 | return Arguments.ONE;
41 | }
42 |
43 | @Override
44 | public boolean isSpecialDirective() {
45 | return true;
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/j2z80-plugin/src/main/java/com/igormaznitsa/z80asm/asmcommands/AsmCommandOTDR.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 Igor Maznitsa.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.igormaznitsa.z80asm.asmcommands;
17 |
18 | import com.igormaznitsa.z80asm.AsmTranslator;
19 |
20 | public class AsmCommandOTDR extends AbstractAsmCommand {
21 |
22 | private static final byte[] MACHINE_CODE = new byte[] {(byte) 0xED, (byte) 0xBB};
23 |
24 | @Override
25 | public byte[] makeMachineCode(final AsmTranslator context, ParsedAsmLine asm) {
26 | return MACHINE_CODE;
27 | }
28 |
29 | @Override
30 | public String getName() {
31 | return "OTDR";
32 | }
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/j2z80-plugin/src/main/java/com/igormaznitsa/z80asm/asmcommands/AsmCommandOTIR.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 Igor Maznitsa.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.igormaznitsa.z80asm.asmcommands;
17 |
18 | import com.igormaznitsa.z80asm.AsmTranslator;
19 |
20 | public class AsmCommandOTIR extends AbstractAsmCommand {
21 |
22 | private static final byte[] MACHINE_CODE = new byte[] {(byte) 0xED, (byte) 0xB3};
23 |
24 | @Override
25 | public byte[] makeMachineCode(final AsmTranslator context, ParsedAsmLine asm) {
26 | return MACHINE_CODE;
27 | }
28 |
29 | @Override
30 | public String getName() {
31 | return "OTIR";
32 | }
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/j2z80-plugin/src/main/java/com/igormaznitsa/z80asm/asmcommands/AsmCommandOUTD.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 Igor Maznitsa.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.igormaznitsa.z80asm.asmcommands;
17 |
18 | import com.igormaznitsa.z80asm.AsmTranslator;
19 |
20 | public class AsmCommandOUTD extends AbstractAsmCommand {
21 |
22 | private static final byte[] MACHINE_CODE = new byte[] {(byte) 0xED, (byte) 0xAB};
23 |
24 | @Override
25 | public byte[] makeMachineCode(final AsmTranslator context, ParsedAsmLine asm) {
26 | return MACHINE_CODE;
27 | }
28 |
29 | @Override
30 | public String getName() {
31 | return "OUTD";
32 | }
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/j2z80-plugin/src/main/java/com/igormaznitsa/z80asm/asmcommands/AsmCommandOUTI.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 Igor Maznitsa.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.igormaznitsa.z80asm.asmcommands;
17 |
18 | import com.igormaznitsa.z80asm.AsmTranslator;
19 |
20 | public class AsmCommandOUTI extends AbstractAsmCommand {
21 |
22 | private static final byte[] MACHINE_CODE = new byte[] {(byte) 0xED, (byte) 0xA3};
23 |
24 | @Override
25 | public byte[] makeMachineCode(final AsmTranslator context, ParsedAsmLine asm) {
26 | return MACHINE_CODE;
27 | }
28 |
29 | @Override
30 | public String getName() {
31 | return "OUTI";
32 | }
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/j2z80-plugin/src/main/java/com/igormaznitsa/z80asm/asmcommands/AsmCommandPOP.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 Igor Maznitsa.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.igormaznitsa.z80asm.asmcommands;
17 |
18 | import com.igormaznitsa.z80asm.AsmTranslator;
19 |
20 | public class AsmCommandPOP extends AbstractAsmCommand {
21 |
22 | public AsmCommandPOP() {
23 | super();
24 | addCase("BC", (byte) 0xC1);
25 | addCase("DE", (byte) 0xD1);
26 | addCase("HL", (byte) 0xE1);
27 | addCase("AF", (byte) 0xF1);
28 | addCase("IX", (byte) 0xDD, (byte) 0xE1);
29 | addCase("IY", (byte) 0xFD, (byte) 0xE1);
30 | }
31 |
32 | @Override
33 | public byte[] makeMachineCode(final AsmTranslator context, final ParsedAsmLine asm) {
34 | return getPatternCase(asm.getSignature());
35 | }
36 |
37 | @Override
38 | public String getName() {
39 | return "POP";
40 | }
41 |
42 | @Override
43 | public Arguments getAllowedArgumentsNumber() {
44 | return Arguments.ONE;
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/j2z80-plugin/src/main/java/com/igormaznitsa/z80asm/asmcommands/AsmCommandPUSH.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 Igor Maznitsa.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.igormaznitsa.z80asm.asmcommands;
17 |
18 | import com.igormaznitsa.z80asm.AsmTranslator;
19 |
20 | public class AsmCommandPUSH extends AbstractAsmCommand {
21 |
22 | public AsmCommandPUSH() {
23 | super();
24 | addCase("BC", (byte) 0xC5);
25 | addCase("DE", (byte) 0xD5);
26 | addCase("HL", (byte) 0xE5);
27 | addCase("AF", (byte) 0xF5);
28 | addCase("IX", (byte) 0xDD, (byte) 0xE5);
29 | addCase("IY", (byte) 0xFD, (byte) 0xE5);
30 | }
31 |
32 | @Override
33 | public byte[] makeMachineCode(final AsmTranslator context, final ParsedAsmLine asm) {
34 | return getPatternCase(asm.getSignature());
35 | }
36 |
37 | @Override
38 | public String getName() {
39 | return "PUSH";
40 | }
41 |
42 | @Override
43 | public Arguments getAllowedArgumentsNumber() {
44 | return Arguments.ONE;
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/j2z80-plugin/src/main/java/com/igormaznitsa/z80asm/asmcommands/AsmCommandRET.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 Igor Maznitsa.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.igormaznitsa.z80asm.asmcommands;
17 |
18 | import com.igormaznitsa.z80asm.AsmTranslator;
19 |
20 | public class AsmCommandRET extends AbstractAsmCommand {
21 |
22 | public AsmCommandRET() {
23 | super();
24 | addCase("", (byte) 0xC9);
25 | addCase("NZ", (byte) 0xC0);
26 | addCase("Z", (byte) 0xC8);
27 | addCase("NC", (byte) 0xD0);
28 | addCase("C", (byte) 0xD8);
29 | addCase("PO", (byte) 0xE0);
30 | addCase("PE", (byte) 0xE8);
31 | addCase("P", (byte) 0xF0);
32 | addCase("M", (byte) 0xF8);
33 | }
34 |
35 | @Override
36 | public byte[] makeMachineCode(final AsmTranslator context, final ParsedAsmLine asm) {
37 | return getPatternCase(asm.getSignature());
38 | }
39 |
40 | @Override
41 | public String getName() {
42 | return "RET";
43 | }
44 |
45 | @Override
46 | public Arguments getAllowedArgumentsNumber() {
47 | return Arguments.ZERO_ONE_OR_TWO;
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/j2z80-plugin/src/main/java/com/igormaznitsa/z80asm/asmcommands/AsmCommandRETI.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 Igor Maznitsa.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.igormaznitsa.z80asm.asmcommands;
17 |
18 | import com.igormaznitsa.z80asm.AsmTranslator;
19 |
20 | public class AsmCommandRETI extends AbstractAsmCommand {
21 |
22 | private static final byte[] MACHINE_CODE = new byte[] {(byte) 0xED, (byte) 0x4D};
23 |
24 | @Override
25 | public byte[] makeMachineCode(final AsmTranslator context, ParsedAsmLine asm) {
26 | return MACHINE_CODE;
27 | }
28 |
29 | @Override
30 | public String getName() {
31 | return "RETI";
32 | }
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/j2z80-plugin/src/main/java/com/igormaznitsa/z80asm/asmcommands/AsmCommandRETN.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 Igor Maznitsa.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.igormaznitsa.z80asm.asmcommands;
17 |
18 | import com.igormaznitsa.z80asm.AsmTranslator;
19 |
20 | public class AsmCommandRETN extends AbstractAsmCommand {
21 |
22 | private static final byte[] MACHINE_CODE = new byte[] {(byte) 0xED, (byte) 0x45};
23 |
24 | @Override
25 | public byte[] makeMachineCode(final AsmTranslator context, ParsedAsmLine asm) {
26 | return MACHINE_CODE;
27 | }
28 |
29 | @Override
30 | public String getName() {
31 | return "RETN";
32 | }
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/j2z80-plugin/src/main/java/com/igormaznitsa/z80asm/asmcommands/AsmCommandRLA.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 Igor Maznitsa.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.igormaznitsa.z80asm.asmcommands;
17 |
18 | import com.igormaznitsa.z80asm.AsmTranslator;
19 |
20 | public class AsmCommandRLA extends AbstractAsmCommand {
21 |
22 | private static final byte[] MACHINE_CODE = new byte[] {0x17};
23 |
24 | @Override
25 | public byte[] makeMachineCode(final AsmTranslator context, ParsedAsmLine asm) {
26 | return MACHINE_CODE;
27 | }
28 |
29 | @Override
30 | public String getName() {
31 | return "RLA";
32 | }
33 |
34 |
35 | }
36 |
--------------------------------------------------------------------------------
/j2z80-plugin/src/main/java/com/igormaznitsa/z80asm/asmcommands/AsmCommandRLCA.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 Igor Maznitsa.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.igormaznitsa.z80asm.asmcommands;
17 |
18 | import com.igormaznitsa.z80asm.AsmTranslator;
19 |
20 | public class AsmCommandRLCA extends AbstractAsmCommand {
21 |
22 | private static final byte[] MACHINE_CODE = new byte[] {0x07};
23 |
24 | @Override
25 | public byte[] makeMachineCode(final AsmTranslator context, ParsedAsmLine asm) {
26 | return MACHINE_CODE;
27 | }
28 |
29 | @Override
30 | public String getName() {
31 | return "RLCA";
32 | }
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/j2z80-plugin/src/main/java/com/igormaznitsa/z80asm/asmcommands/AsmCommandRLD.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 Igor Maznitsa.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.igormaznitsa.z80asm.asmcommands;
17 |
18 | import com.igormaznitsa.z80asm.AsmTranslator;
19 |
20 | public class AsmCommandRLD extends AbstractAsmCommand {
21 |
22 | private static final byte[] MACHINE_CODE = new byte[] {(byte) 0xED, (byte) 0x6F};
23 |
24 | @Override
25 | public byte[] makeMachineCode(final AsmTranslator context, ParsedAsmLine asm) {
26 | return MACHINE_CODE;
27 | }
28 |
29 | @Override
30 | public String getName() {
31 | return "RLD";
32 | }
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/j2z80-plugin/src/main/java/com/igormaznitsa/z80asm/asmcommands/AsmCommandRRA.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 Igor Maznitsa.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.igormaznitsa.z80asm.asmcommands;
17 |
18 | import com.igormaznitsa.z80asm.AsmTranslator;
19 |
20 | public class AsmCommandRRA extends AbstractAsmCommand {
21 |
22 | private static final byte[] MACHINE_CODE = new byte[] {0x1F};
23 |
24 | @Override
25 | public byte[] makeMachineCode(final AsmTranslator context, ParsedAsmLine asm) {
26 | return MACHINE_CODE;
27 | }
28 |
29 | @Override
30 | public String getName() {
31 | return "RRA";
32 | }
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/j2z80-plugin/src/main/java/com/igormaznitsa/z80asm/asmcommands/AsmCommandRRCA.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 Igor Maznitsa.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.igormaznitsa.z80asm.asmcommands;
17 |
18 | import com.igormaznitsa.z80asm.AsmTranslator;
19 |
20 | public class AsmCommandRRCA extends AbstractAsmCommand {
21 |
22 | private static final byte[] MACHINE_CODE = new byte[] {0x0F};
23 |
24 | @Override
25 | public byte[] makeMachineCode(final AsmTranslator context, ParsedAsmLine asm) {
26 | return MACHINE_CODE;
27 | }
28 |
29 | @Override
30 | public String getName() {
31 | return "RRCA";
32 | }
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/j2z80-plugin/src/main/java/com/igormaznitsa/z80asm/asmcommands/AsmCommandRRD.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 Igor Maznitsa.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.igormaznitsa.z80asm.asmcommands;
17 |
18 | import com.igormaznitsa.z80asm.AsmTranslator;
19 |
20 | public class AsmCommandRRD extends AbstractAsmCommand {
21 |
22 | private static final byte[] MACHINE_CODE = new byte[] {(byte) 0xED, (byte) 0x67};
23 |
24 | @Override
25 | public byte[] makeMachineCode(final AsmTranslator context, ParsedAsmLine asm) {
26 | return MACHINE_CODE;
27 | }
28 |
29 | @Override
30 | public String getName() {
31 | return "RRD";
32 | }
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/j2z80-plugin/src/main/java/com/igormaznitsa/z80asm/asmcommands/AsmCommandSCF.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 Igor Maznitsa.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.igormaznitsa.z80asm.asmcommands;
17 |
18 | import com.igormaznitsa.z80asm.AsmTranslator;
19 |
20 | public class AsmCommandSCF extends AbstractAsmCommand {
21 |
22 | private static final byte[] MACHINE_CODE = new byte[] {0x37};
23 |
24 | @Override
25 | public byte[] makeMachineCode(final AsmTranslator context, ParsedAsmLine asm) {
26 | return MACHINE_CODE;
27 | }
28 |
29 | @Override
30 | public String getName() {
31 | return "SCF";
32 | }
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/j2z80-plugin/src/main/java/com/igormaznitsa/z80asm/exceptions/AsmTranslationException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 Igor Maznitsa.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.igormaznitsa.z80asm.exceptions;
17 |
18 | /**
19 | * It is the special exception which will be thrown if there is some problems in code translation.
20 | *
21 | * @author Igor Maznitsa (igor.maznitsa@igormaznitsa.com)
22 | */
23 | @SuppressWarnings("serial")
24 | public class AsmTranslationException extends RuntimeException {
25 | private final String srcString;
26 | private final int lineNumber;
27 |
28 | public AsmTranslationException(final String message, final String srcString, final int lineNumber, final Throwable cause) {
29 | super(message, cause);
30 | this.srcString = srcString;
31 | this.lineNumber = lineNumber;
32 | }
33 |
34 | public String getSrcString() {
35 | return srcString;
36 | }
37 |
38 | public int getLineNumber() {
39 | return lineNumber;
40 | }
41 |
42 | @Override
43 | public String toString() {
44 | return getMessage() + "\'" + getSrcString() + "\' at " + getLineNumber() + " line";
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/j2z80-plugin/src/main/resources/com/igormaznitsa/j2z80/japi/java/io/java.io.PrintStream.a80:
--------------------------------------------------------------------------------
1 | JAVA.LANG.SYSTEN.PRINTLN:
2 | LD A,(IX-0)
3 | CALL 5633
4 | LD L,(IX-2)
5 | LD H,(IX-3)
6 | LD B,0
7 | LD C,(HL)
8 | INC HL
9 | LD E,L
10 | LD D,H
11 | CALL 8252
12 | RET
13 |
--------------------------------------------------------------------------------
/j2z80-plugin/src/main/resources/com/igormaznitsa/j2z80/jvmprocessors/AALOAD.a80:
--------------------------------------------------------------------------------
1 | ; 50 AALOAD (arrayref, index -> value)
2 | POP BC ; index
3 | POP HL ; array pointer
4 | SLA C ; BC<<1
5 | RL B
6 | ADD HL,BC ; make the cell address
7 | LD A,(HL); low byte
8 | LD C,A
9 | INC HL
10 | LD A,(HL); high byte
11 | LD B,A
12 | PUSH BC; place the cell data on stack
--------------------------------------------------------------------------------
/j2z80-plugin/src/main/resources/com/igormaznitsa/j2z80/jvmprocessors/AASTORE.a80:
--------------------------------------------------------------------------------
1 | ; 83 AASTORE arrayref, index, value ->
2 | POP DE ; value
3 | POP BC ; index
4 | POP HL ; array pointer
5 | SLA C ; BC<<1
6 | RL B
7 | ADD HL,BC ; make the cell address
8 | LD (HL),E; low byte
9 | INC HL
10 | LD (HL),D; high byte
--------------------------------------------------------------------------------
/j2z80-plugin/src/main/resources/com/igormaznitsa/j2z80/jvmprocessors/ACONST_NULL.a80:
--------------------------------------------------------------------------------
1 | ; 01 ACONST_NULL -> null
2 | LD BC,0
3 | PUSH BC
4 |
--------------------------------------------------------------------------------
/j2z80-plugin/src/main/resources/com/igormaznitsa/j2z80/jvmprocessors/ALOAD.a80:
--------------------------------------------------------------------------------
1 | ; 42,43,44,45 ALOAD -> ref
2 | LD C,(IX-%index%)
3 | LD B,(IX-%index%+1)
4 | PUSH BC
--------------------------------------------------------------------------------
/j2z80-plugin/src/main/resources/com/igormaznitsa/j2z80/jvmprocessors/ANEWARRAY.a80:
--------------------------------------------------------------------------------
1 | ; 189 ANEWARRAY count -> arrayref
2 | POP BC ; element number in BC pair
3 | CALL %address%
4 | PUSH BC ; place the reference to the first array element
5 |
6 |
7 |
--------------------------------------------------------------------------------
/j2z80-plugin/src/main/resources/com/igormaznitsa/j2z80/jvmprocessors/ARETURN.a80:
--------------------------------------------------------------------------------
1 | ; 176 ARETURN objref ->
2 | POP BC
3 | RET
--------------------------------------------------------------------------------
/j2z80-plugin/src/main/resources/com/igormaznitsa/j2z80/jvmprocessors/ARRAYLENGTH.a80:
--------------------------------------------------------------------------------
1 | ; 190 ARRAYLENGTH arrayref -> length
2 | POP BC
3 | CALL %address% ; get length of the array and place it in BC
4 | PUSH BC
5 |
6 |
--------------------------------------------------------------------------------
/j2z80-plugin/src/main/resources/com/igormaznitsa/j2z80/jvmprocessors/ASTORE.a80:
--------------------------------------------------------------------------------
1 | ; 75,76,77,78 ASTORE objref ->
2 | POP BC
3 | LD (IX-%index%),C
4 | LD (IX-%index%+1),B
5 |
6 |
--------------------------------------------------------------------------------
/j2z80-plugin/src/main/resources/com/igormaznitsa/j2z80/jvmprocessors/ATHROW.a80:
--------------------------------------------------------------------------------
1 | ; 191 ATHROW objref -> objref
2 | LD HL,$
3 | PUSH HL
4 | LD HL,(%address%)
5 | JP (HL)
6 |
--------------------------------------------------------------------------------
/j2z80-plugin/src/main/resources/com/igormaznitsa/j2z80/jvmprocessors/ATHROW_MANAGER.a80:
--------------------------------------------------------------------------------
1 | ; The stack must contains the address of the code which is throwing the exception
2 | ___ATHROW_PROCESSING_CODE_ADDRESS: DEFW #0000 ; address of processing code, in ZX-Spectrum it will work like RESET
--------------------------------------------------------------------------------
/j2z80-plugin/src/main/resources/com/igormaznitsa/j2z80/jvmprocessors/BALOAD.a80:
--------------------------------------------------------------------------------
1 | ; 51 BALOAD arrayref,index -> value
2 | POP BC ; index
3 | POP HL ; array pointer
4 | ADD HL,BC ; make the cell address
5 | LD A,(HL); data
6 | LD C,A
7 | LD B,0
8 | PUSH BC; place the data on stack
9 |
--------------------------------------------------------------------------------
/j2z80-plugin/src/main/resources/com/igormaznitsa/j2z80/jvmprocessors/BASTORE.a80:
--------------------------------------------------------------------------------
1 | ; 84 BASTORE arrayref, index, value ->
2 | POP DE ; value
3 | POP BC ; index
4 | POP HL ; array pointer
5 | ADD HL,BC ; make the cell address
6 | LD (HL),E; write data
7 |
--------------------------------------------------------------------------------
/j2z80-plugin/src/main/resources/com/igormaznitsa/j2z80/jvmprocessors/BIPUSH.a80:
--------------------------------------------------------------------------------
1 | ; 16 BIPUSH -> value
2 | LD BC,%value%
3 | PUSH BC
4 |
--------------------------------------------------------------------------------
/j2z80-plugin/src/main/resources/com/igormaznitsa/j2z80/jvmprocessors/BREAKPOINT.a80:
--------------------------------------------------------------------------------
1 | ; 202 BREAKPOINT
2 | LD HL,$ ; save the PC into HL
3 | JP %address%
--------------------------------------------------------------------------------
/j2z80-plugin/src/main/resources/com/igormaznitsa/j2z80/jvmprocessors/BREAKPOINT_MANAGER.a80:
--------------------------------------------------------------------------------
1 | CLRLOC
2 | ___BREAKPOINT_PROCESSING_CODE_ADDRESS: DEFW ___BREAKPOINT_PROCESSING_STUB ; address of breakpoint processing code
3 | ___BREAKPOINT_PROCESSING_STUB : RET
4 | ___BREAKPOINT_PROCESSING_MANAGER :
5 | PUSH BC
6 | PUSH HL
7 | LD BC,(___BREAKPOINT_PROCESSING_CODE_ADDRESS)
8 | LD (@CALL_BREAK_PROCESSOR+1),BC
9 | @CALL_BREAK_PROCESSOR:
10 | CALL 0 ; dynamic modifying call address
11 | POP HL
12 | POP BC
13 | INC HL
14 | INC HL
15 | INC HL
16 | INC HL
17 | INC HL
18 | INC HL
19 | JP (HL) ; jump to the next command after the break block
--------------------------------------------------------------------------------
/j2z80-plugin/src/main/resources/com/igormaznitsa/j2z80/jvmprocessors/CALOAD.a80:
--------------------------------------------------------------------------------
1 | ; 52 CALOAD arrayref, index -> value
2 | POP BC ; index
3 | POP HL ; array pointer
4 | ADD HL,BC ; make the cell address
5 | LD A,(HL); data
6 | LD C,A
7 | LD B,0
8 | PUSH BC; place the data on stack
9 |
--------------------------------------------------------------------------------
/j2z80-plugin/src/main/resources/com/igormaznitsa/j2z80/jvmprocessors/CASTORE.a80:
--------------------------------------------------------------------------------
1 | ; 85 CASTORE arrayref, index, value ->
2 | POP DE ; value
3 | POP BC ; index
4 | POP HL ; array pointer
5 | ADD HL,BC ; make the cell address
6 | LD (HL),E; write data
7 |
8 |
--------------------------------------------------------------------------------
/j2z80-plugin/src/main/resources/com/igormaznitsa/j2z80/jvmprocessors/CHECKCAST.a80:
--------------------------------------------------------------------------------
1 | ; 192 CHECKCAST objref -> objref
2 | POP BC
3 | LD DE,%id%
4 | CALL %address%
5 | PUSH BC
6 |
--------------------------------------------------------------------------------
/j2z80-plugin/src/main/resources/com/igormaznitsa/j2z80/jvmprocessors/CHECKCAST_MANAGER.a80:
--------------------------------------------------------------------------------
1 | CLRLOC
2 | ___CHECKCAST: ; check that object in BC can be cast to the class whose id in DE, if it is impossible then an exception will be thrown
3 | CLRLOC
4 | PUSH BC
5 | CALL ___INSTANCE_OF
6 | LD A,C
7 | OR A
8 | JP Z,@CHECKCAST_THROWEXCEPTION
9 | POP BC
10 | RET
11 |
12 | @CHECKCAST_THROWEXCEPTION:
13 | POP BC ; remove BC from stack, the return address has been left on the stack
14 | POP HL
15 | PUSH BC
16 | PUSH HL
17 | LD HL,(___ATHROW_PROCESSING_CODE_ADDRESS)
18 | JP (HL)
19 |
20 |
--------------------------------------------------------------------------------
/j2z80-plugin/src/main/resources/com/igormaznitsa/j2z80/jvmprocessors/DUP.a80:
--------------------------------------------------------------------------------
1 | ; 089 DUP value -> value,value
2 | POP BC
3 | PUSH BC
4 | PUSH BC
5 |
--------------------------------------------------------------------------------
/j2z80-plugin/src/main/resources/com/igormaznitsa/j2z80/jvmprocessors/DUP2.a80:
--------------------------------------------------------------------------------
1 | ; 092 DUP2 value1,value2 -> value1, value2, value1, value2
2 | POP BC
3 | POP HL
4 | PUSH HL
5 | PUSH BC
6 | PUSH HL
7 | PUSH BC
8 |
--------------------------------------------------------------------------------
/j2z80-plugin/src/main/resources/com/igormaznitsa/j2z80/jvmprocessors/DUP2_X1.a80:
--------------------------------------------------------------------------------
1 | ; 093 DUP2_X1 value3, value2, value1 -> value2, value1, value3, value2, value1
2 | POP BC
3 | POP HL
4 | POP DE
5 | PUSH HL
6 | PUSH BC
7 | PUSH DE
8 | PUSH HL
9 | PUSH BC
--------------------------------------------------------------------------------
/j2z80-plugin/src/main/resources/com/igormaznitsa/j2z80/jvmprocessors/DUP2_X2.a80:
--------------------------------------------------------------------------------
1 | ; 094 DUP2_X2 value4, value3, value2, value1 -> value2, value1, value4, value3, value2, value1
2 | POP BC
3 | POP HL
4 | POP DE
5 | POP AF
6 | PUSH HL
7 | PUSH BC
8 | PUSH AF
9 | PUSH DE
10 | PUSH HL
11 | PUSH BC
--------------------------------------------------------------------------------
/j2z80-plugin/src/main/resources/com/igormaznitsa/j2z80/jvmprocessors/DUP_X1.a80:
--------------------------------------------------------------------------------
1 | ; 090 DUP_X1 value2, value1 -> value1, value2, value1
2 | POP BC
3 | POP HL
4 | PUSH BC
5 | PUSH HL
6 | PUSH BC
--------------------------------------------------------------------------------
/j2z80-plugin/src/main/resources/com/igormaznitsa/j2z80/jvmprocessors/DUP_X2.a80:
--------------------------------------------------------------------------------
1 | ; 091 DUP_X2 value3, value2, value1 -> value1, value3, value2, value1
2 | POP BC
3 | POP HL
4 | POP DE
5 | PUSH BC
6 | PUSH DE
7 | PUSH HL
8 | PUSH BC
--------------------------------------------------------------------------------
/j2z80-plugin/src/main/resources/com/igormaznitsa/j2z80/jvmprocessors/GETFIELD.a80:
--------------------------------------------------------------------------------
1 | ; 180 GETFIELD objref -> value
2 | POP HL ; objref into HL
3 | LD DE,%address% ; offset into DE
4 | ADD HL,DE
5 | LD C,(HL)
6 | INC HL
7 | LD B,(HL)
8 | PUSH BC
9 |
10 |
--------------------------------------------------------------------------------
/j2z80-plugin/src/main/resources/com/igormaznitsa/j2z80/jvmprocessors/GETSTATIC.a80:
--------------------------------------------------------------------------------
1 | ; 178 GETSTATIC
2 | LD BC,(%address%)
3 | PUSH BC
4 |
--------------------------------------------------------------------------------
/j2z80-plugin/src/main/resources/com/igormaznitsa/j2z80/jvmprocessors/GOTO.a80:
--------------------------------------------------------------------------------
1 | ; 167 GOTO
2 | JP %address%
--------------------------------------------------------------------------------
/j2z80-plugin/src/main/resources/com/igormaznitsa/j2z80/jvmprocessors/GOTO_W.a80:
--------------------------------------------------------------------------------
1 | ; 200 GOTO_W
2 | JP %address%
--------------------------------------------------------------------------------
/j2z80-plugin/src/main/resources/com/igormaznitsa/j2z80/jvmprocessors/I2B.a80:
--------------------------------------------------------------------------------
1 | ; 145 I2B int -> byte
2 | CLRLOC
3 | POP HL
4 | XOR A
5 | LD H,A
6 | BIT 7,L
7 | JR Z,@BACK
8 | LD H,#FF
9 | @BACK: PUSH HL
10 |
--------------------------------------------------------------------------------
/j2z80-plugin/src/main/resources/com/igormaznitsa/j2z80/jvmprocessors/I2C.a80:
--------------------------------------------------------------------------------
1 | ; 146 I2C int -> char (int is 16 bit, char is 8 bit)
2 | POP HL
3 | XOR A
4 | LD H,A
5 | PUSH HL
6 |
7 |
--------------------------------------------------------------------------------
/j2z80-plugin/src/main/resources/com/igormaznitsa/j2z80/jvmprocessors/I2S.a80:
--------------------------------------------------------------------------------
1 | ; 147 I2S for j2z80 do nothing because we have the same format data
2 |
--------------------------------------------------------------------------------
/j2z80-plugin/src/main/resources/com/igormaznitsa/j2z80/jvmprocessors/IADD.a80:
--------------------------------------------------------------------------------
1 | ; 096 IADD val1 val2 -> result
2 | POP BC
3 | POP HL
4 | ADD HL,BC
5 | PUSH HL
6 |
7 |
--------------------------------------------------------------------------------
/j2z80-plugin/src/main/resources/com/igormaznitsa/j2z80/jvmprocessors/IALOAD.a80:
--------------------------------------------------------------------------------
1 | ; 46 IALOAD arrayref index -> int
2 | POP BC ; index
3 | POP HL ; array pointer
4 | SLA C ; BC<<1
5 | RL B
6 | ADD HL,BC ; make the cell address
7 | LD A,(HL); low byte
8 | LD C,A
9 | INC HL
10 | LD A,(HL); high byte
11 | LD B,A
12 | PUSH BC; place the cell data on stack
--------------------------------------------------------------------------------
/j2z80-plugin/src/main/resources/com/igormaznitsa/j2z80/jvmprocessors/IAND.a80:
--------------------------------------------------------------------------------
1 | ; 126 IAND val1 val2 -> result
2 | POP BC
3 | POP HL
4 | LD A,B
5 | AND H
6 | LD B,A
7 | LD A,C
8 | AND L
9 | LD C,A
10 | PUSH BC
11 |
12 |
--------------------------------------------------------------------------------
/j2z80-plugin/src/main/resources/com/igormaznitsa/j2z80/jvmprocessors/IASTORE.a80:
--------------------------------------------------------------------------------
1 | ; 79 IASTORE arrayref index value ->
2 | POP DE ; value
3 | POP BC ; index
4 | POP HL ; array pointer
5 | SLA C ; BC<<1
6 | RL B
7 | ADD HL,BC ; make the cell address
8 | LD (HL),E; low byte
9 | INC HL
10 | LD (HL),D; high byte
--------------------------------------------------------------------------------
/j2z80-plugin/src/main/resources/com/igormaznitsa/j2z80/jvmprocessors/ICONST.a80:
--------------------------------------------------------------------------------
1 | ; 02,03,04,05,06,07,08 ICONST
2 | LD BC,%value%
3 | PUSH BC
--------------------------------------------------------------------------------
/j2z80-plugin/src/main/resources/com/igormaznitsa/j2z80/jvmprocessors/IDIV.a80:
--------------------------------------------------------------------------------
1 | ; 108 IDIV val1, val2 -> result
2 | POP DE
3 | POP BC
4 | CALL %address%
5 | PUSH BC
6 |
--------------------------------------------------------------------------------
/j2z80-plugin/src/main/resources/com/igormaznitsa/j2z80/jvmprocessors/IFEQ.a80:
--------------------------------------------------------------------------------
1 | ; 153 IFEQ value ->
2 | POP BC
3 | LD A,B
4 | OR C
5 | JP Z,%address%
6 |
--------------------------------------------------------------------------------
/j2z80-plugin/src/main/resources/com/igormaznitsa/j2z80/jvmprocessors/IFGE.a80:
--------------------------------------------------------------------------------
1 | ; 156 IFGE value ->
2 | POP BC
3 | BIT 7,B
4 | JP Z,%address%
5 |
--------------------------------------------------------------------------------
/j2z80-plugin/src/main/resources/com/igormaznitsa/j2z80/jvmprocessors/IFGT.a80:
--------------------------------------------------------------------------------
1 | ; 157 IFGT value ->
2 | CLRLOC
3 | POP BC
4 | BIT 7,B
5 | JP NZ,@IFGTNOT
6 | LD A,B
7 | OR C
8 | JP NZ,%address%
9 | @IFGTNOT:
10 |
11 |
--------------------------------------------------------------------------------
/j2z80-plugin/src/main/resources/com/igormaznitsa/j2z80/jvmprocessors/IFLE.a80:
--------------------------------------------------------------------------------
1 | ; 158 IFLE value ->
2 | POP BC
3 | BIT 7,B
4 | JP NZ,%address%
5 | LD A,B
6 | OR C
7 | JP Z,%address%
8 |
9 |
--------------------------------------------------------------------------------
/j2z80-plugin/src/main/resources/com/igormaznitsa/j2z80/jvmprocessors/IFLT.a80:
--------------------------------------------------------------------------------
1 | ; 155 IFLT value ->
2 | POP BC
3 | BIT 7,B
4 | JP NZ,%address%
5 |
6 |
--------------------------------------------------------------------------------
/j2z80-plugin/src/main/resources/com/igormaznitsa/j2z80/jvmprocessors/IFNE.a80:
--------------------------------------------------------------------------------
1 | ; 154 IFNE value ->
2 | POP BC
3 | LD A,B
4 | OR C
5 | JP NZ,%address%
--------------------------------------------------------------------------------
/j2z80-plugin/src/main/resources/com/igormaznitsa/j2z80/jvmprocessors/IFNONNULL.a80:
--------------------------------------------------------------------------------
1 | ; 199 IFNONNULL
2 | POP BC
3 | LD A,C
4 | OR B
5 | JP NZ,%address%
--------------------------------------------------------------------------------
/j2z80-plugin/src/main/resources/com/igormaznitsa/j2z80/jvmprocessors/IFNULL.a80:
--------------------------------------------------------------------------------
1 | ; 198 IFNULL
2 | POP BC
3 | LD A,C
4 | OR B
5 | JP Z,%address%
6 |
--------------------------------------------------------------------------------
/j2z80-plugin/src/main/resources/com/igormaznitsa/j2z80/jvmprocessors/IF_ACMPEQ.a80:
--------------------------------------------------------------------------------
1 | ; 165 IF_ACMPEQ ref1 ref2 -> (ref1 == ref2)
2 | POP BC
3 | POP HL
4 | OR A
5 | SBC HL,BC
6 | JP Z,%address%
7 |
--------------------------------------------------------------------------------
/j2z80-plugin/src/main/resources/com/igormaznitsa/j2z80/jvmprocessors/IF_ACMPNE.a80:
--------------------------------------------------------------------------------
1 | ; 166 IF_ACMPNE ref1 ref2 -> (ref1 != ref2)
2 | POP BC
3 | POP HL
4 | OR A
5 | SBC HL,BC
6 | JP NZ,%address%
7 |
--------------------------------------------------------------------------------
/j2z80-plugin/src/main/resources/com/igormaznitsa/j2z80/jvmprocessors/IF_ICMPEQ.a80:
--------------------------------------------------------------------------------
1 | ; 159 IF_ICMPEQ value1, value2 -> (value1 == value2)
2 | POP BC
3 | POP HL
4 | OR A
5 | SBC HL,BC
6 | JP Z,%address%
7 |
--------------------------------------------------------------------------------
/j2z80-plugin/src/main/resources/com/igormaznitsa/j2z80/jvmprocessors/IF_ICMPGE.a80:
--------------------------------------------------------------------------------
1 | ; 162 IF_ICMPGE value1, value2 -> (value1>=value2)
2 | CLRLOC
3 | POP BC
4 | POP HL
5 | AND A
6 | SBC HL,BC
7 | JP M,@IF_ICMPGE_S
8 | JP PO,%address%
9 | JR @IF_ICMPGE_END
10 | @IF_ICMPGE_S:
11 | JP PE,%address%
12 | @IF_ICMPGE_END:
13 |
--------------------------------------------------------------------------------
/j2z80-plugin/src/main/resources/com/igormaznitsa/j2z80/jvmprocessors/IF_ICMPGT.a80:
--------------------------------------------------------------------------------
1 | ; 163 IF_ICMPGT value1, value2 -> (value1>value2)
2 | CLRLOC
3 | POP BC
4 | POP HL
5 | OR A
6 | SBC HL,BC
7 | JP M,@IF_ICMPGT_S
8 | JP PO,%address%
9 | JR @IF_ICMPGT_END
10 | @IF_ICMPGT_S:
11 | JP PE,%address%
12 | @IF_ICMPGT_END:
13 |
--------------------------------------------------------------------------------
/j2z80-plugin/src/main/resources/com/igormaznitsa/j2z80/jvmprocessors/IF_ICMPLE.a80:
--------------------------------------------------------------------------------
1 | ; 164 IF_ICMPLE value1, value2 -> (value1= (value1 < value2) (s!=p/v)
2 | CLRLOC
3 | POP BC
4 | POP HL
5 | AND A
6 | SBC HL,BC
7 | JP P,@IF_ICMPLT_NOS
8 | JP PO,%address%
9 | JR @IF_ICMPLT_END
10 | @IF_ICMPLT_NOS:
11 | JP PE,%address%
12 | @IF_ICMPLT_END:
--------------------------------------------------------------------------------
/j2z80-plugin/src/main/resources/com/igormaznitsa/j2z80/jvmprocessors/IF_ICMPNE.a80:
--------------------------------------------------------------------------------
1 | ; 160 IF_ICMPNE val1 val2 -> (val1 != val2)
2 | POP BC
3 | POP HL
4 | OR A
5 | SBC HL,BC
6 | JR NZ,%address%
7 |
--------------------------------------------------------------------------------
/j2z80-plugin/src/main/resources/com/igormaznitsa/j2z80/jvmprocessors/IINC.a80:
--------------------------------------------------------------------------------
1 | ; 132 IINC
2 | LD L,(IX-%index%)
3 | LD H,(IX-%index%+1)
4 | LD BC,%value%
5 | ADD HL,BC
6 | LD (IX-%index%),L
7 | LD (IX-%index%+1),H
--------------------------------------------------------------------------------
/j2z80-plugin/src/main/resources/com/igormaznitsa/j2z80/jvmprocessors/ILOAD.a80:
--------------------------------------------------------------------------------
1 | ; 26,27,28,29 ILOAD
2 | LD C,(IX-%index%)
3 | LD B,(IX-%index%+1)
4 | PUSH BC
--------------------------------------------------------------------------------
/j2z80-plugin/src/main/resources/com/igormaznitsa/j2z80/jvmprocessors/IMUL.a80:
--------------------------------------------------------------------------------
1 | ; 104 IMUL val1, val2 -> result
2 | POP BC
3 | POP DE
4 | CALL %address%
5 | PUSH BC
6 |
7 |
--------------------------------------------------------------------------------
/j2z80-plugin/src/main/resources/com/igormaznitsa/j2z80/jvmprocessors/INEG.a80:
--------------------------------------------------------------------------------
1 | ; 116 INEG x -> y (y = ~x+1)
2 | POP BC
3 | LD A,B
4 | CPL
5 | LD B,A
6 | LD A,C
7 | CPL
8 | LD C,A
9 | INC BC
10 | PUSH BC
11 |
12 |
--------------------------------------------------------------------------------
/j2z80-plugin/src/main/resources/com/igormaznitsa/j2z80/jvmprocessors/INSTANCEOF.a80:
--------------------------------------------------------------------------------
1 | ; 193 INSTANCEOF objref -> result [0|1]
2 | POP BC
3 | LD DE,%id%
4 | CALL ___INSTANCE_OF
5 | PUSH BC
6 |
7 |
--------------------------------------------------------------------------------
/j2z80-plugin/src/main/resources/com/igormaznitsa/j2z80/jvmprocessors/INVOKEINTERFACE.a80:
--------------------------------------------------------------------------------
1 | ; 185 INVOKEINTERFACE
2 | CLRLOC
3 |
4 | ; get class id for the objectref
5 | LD HL,%objrefoffset%
6 | ADD HL,SP ; the objref address in HL
7 |
8 | LD C,(HL) ; load the objref into BC
9 | INC HL
10 | LD B,(HL)
11 |
12 | CALL ___GET_OBJECT_CLASS_ID ; get the class id into BC
13 |
14 | LD H,B
15 | LD L,C
16 | LD DE,%id%
17 | CALL __PREPAREINVOKEINTERFACE ; HL contains class id, DE contains interface method id
18 |
19 | ; HL contains address and DE contains the full frame size in bytes
20 | LD (@INVOKE_JMP+1),HL
21 | LD C,E
22 | LD B,D
23 | LD A,%value%
24 |
25 | CALL ___BEFORE_INVOKE ; prepare the frame
26 |
27 | @INVOKE_JMP:
28 | CALL 0
29 | CALL ___AFTER_INVOKE ; restore the previous frame
30 | %postfix%
31 |
--------------------------------------------------------------------------------
/j2z80-plugin/src/main/resources/com/igormaznitsa/j2z80/jvmprocessors/INVOKESPECIAL.a80:
--------------------------------------------------------------------------------
1 | ; 183 INVOKESPECIAL
2 | %prefix%
3 | CALL %address%
4 | %postfix%
5 |
--------------------------------------------------------------------------------
/j2z80-plugin/src/main/resources/com/igormaznitsa/j2z80/jvmprocessors/INVOKESTATIC.a80:
--------------------------------------------------------------------------------
1 | ; 184 INVOKESTATIC
2 | %prefix%
3 | CALL %address%
4 | %postfix%
--------------------------------------------------------------------------------
/j2z80-plugin/src/main/resources/com/igormaznitsa/j2z80/jvmprocessors/INVOKEVIRTUAL.a80:
--------------------------------------------------------------------------------
1 | ; 182 INVOKEVIRTUAL
2 | CLRLOC
3 |
4 | ; get class id for the objectref
5 | LD HL,%objrefoffset%
6 | ADD HL,SP ; the objref address in HL
7 |
8 | LD C,(HL) ; load the objref into BC
9 | INC HL
10 | LD B,(HL)
11 |
12 | CALL ___GET_OBJECT_CLASS_ID ; get the class id into BC
13 |
14 | LD HL,%recordaddress%
15 | CALL __PREPAREINVOKEVIRTUAL ; HL contains record address start, BC contains object class id
16 |
17 | ; HL contains address and BC contains the full frame size in bytes
18 | LD (@INVOKE_JMP+1),HL
19 | LD A,%argumentarealen% ; load argument area length in bytes
20 |
21 | CALL ___BEFORE_INVOKE ; prepare the frame
22 |
23 | @INVOKE_JMP:
24 | CALL 0
25 | CALL ___AFTER_INVOKE ; restore the previous frame
26 | %postfix%
27 |
--------------------------------------------------------------------------------
/j2z80-plugin/src/main/resources/com/igormaznitsa/j2z80/jvmprocessors/INVOKEVIRTUAL_MANAGER.a80:
--------------------------------------------------------------------------------
1 | CLRLOC
2 |
3 | __PREPAREINVOKEVIRTUAL: ; (in) HL has the record start address, BC has the object class id -> (out) HL - method address, BC - frame size in bytes, exception will be thrown if not found
4 | PUSH DE
5 | PUSH BC ; put the object class id onto the stack
6 | POP DE ; now DE contains the object class id
7 |
8 | LD B,(HL)
9 | INC HL
10 |
11 | @FIND_LOOP:
12 | LD A,(HL)
13 | INC HL
14 | CP E
15 | JP Z,@CHECKPART2
16 | INC HL ; skip the rest
17 | JP @ENDCHECK
18 |
19 | @CHECKPART2:
20 | LD A,(HL)
21 | INC HL
22 | CP D
23 | JP Z,@FOUND
24 |
25 | @ENDCHECK:
26 | INC HL ; skip the record rest
27 | INC HL
28 | INC HL
29 | INC HL
30 | DJNZ @FIND_LOOP
31 |
32 | @FOREWER_LOOP_IF_NOT_FOUND: JR @FOREWER_LOOP_IF_NOT_FOUND ; it's an error situation shows that the compiler works by a wrong way
33 |
34 | @FOUND:
35 | LD E,(HL) ; load the method address into DE
36 | INC HL
37 | LD D,(HL)
38 | INC HL
39 | LD C,(HL) ; load frame size into BC
40 | INC HL
41 | LD B,(HL)
42 | EX DE,HL ; HL contains the method address
43 |
44 | POP DE ; restore DE from the stack
45 |
46 | RET
47 |
48 | ; The table contains all addresses for each interface implementing method
49 | ; of each class which can be called through INVOKEVIRTUAL
50 | ; (byte) number_of_records for the method
51 | ; triplet [number_of_records]
52 | ; triplet { (word) class_id (word) method_address (word) max_locals_for_method }
53 |
54 | %invokevirtualtable%
--------------------------------------------------------------------------------
/j2z80-plugin/src/main/resources/com/igormaznitsa/j2z80/jvmprocessors/IOR.a80:
--------------------------------------------------------------------------------
1 | ; 128 IOR a1 a2 -> result
2 | POP BC
3 | POP HL
4 | LD A,B
5 | OR H
6 | LD B,A
7 | LD A,C
8 | OR L
9 | LD C,A
10 | PUSH BC
--------------------------------------------------------------------------------
/j2z80-plugin/src/main/resources/com/igormaznitsa/j2z80/jvmprocessors/IREM.a80:
--------------------------------------------------------------------------------
1 | ; 112 IREM val1, val2 -> result
2 | POP DE
3 | POP BC
4 | CALL %address%
5 | PUSH BC
6 |
7 |
--------------------------------------------------------------------------------
/j2z80-plugin/src/main/resources/com/igormaznitsa/j2z80/jvmprocessors/IRETURN.a80:
--------------------------------------------------------------------------------
1 | ; 172 IRETURN
2 | POP BC
3 | RET
--------------------------------------------------------------------------------
/j2z80-plugin/src/main/resources/com/igormaznitsa/j2z80/jvmprocessors/ISHL.a80:
--------------------------------------------------------------------------------
1 | ; 120 ISHL val1 val2 -> result (result = val1 << val2)
2 | CLRLOC
3 | POP BC
4 | POP HL
5 | LD A,C
6 | OR A
7 | JR Z,@ISHLOOPEND
8 | LD B,A
9 | @ISHLLOOP:
10 | SLA L
11 | RL H
12 | DJNZ @ISHLLOOP
13 | @ISHLOOPEND:
14 | PUSH HL
15 |
--------------------------------------------------------------------------------
/j2z80-plugin/src/main/resources/com/igormaznitsa/j2z80/jvmprocessors/ISHR.a80:
--------------------------------------------------------------------------------
1 | ; 122 ISHR
2 | CLRLOC
3 | POP BC
4 | POP HL
5 | LD A,C
6 | OR A
7 | JR Z,@ISHRLOOPEND
8 | LD B,A
9 | @ISHRLOOP:
10 | SRA H
11 | RR L
12 | DJNZ @ISHRLOOP
13 | @ISHRLOOPEND:
14 | PUSH HL
15 |
--------------------------------------------------------------------------------
/j2z80-plugin/src/main/resources/com/igormaznitsa/j2z80/jvmprocessors/ISTORE.a80:
--------------------------------------------------------------------------------
1 | ; 59,60,61,62 ISTORE int ->
2 | POP BC
3 | LD (IX-%index%),C
4 | LD (IX-%index%+1),B
5 |
6 |
--------------------------------------------------------------------------------
/j2z80-plugin/src/main/resources/com/igormaznitsa/j2z80/jvmprocessors/ISUB.a80:
--------------------------------------------------------------------------------
1 | ; 100 ISUB val1 val2 -> result
2 | POP BC
3 | POP HL
4 | XOR A
5 | SBC HL,BC
6 | PUSH HL
7 |
--------------------------------------------------------------------------------
/j2z80-plugin/src/main/resources/com/igormaznitsa/j2z80/jvmprocessors/IUSHR.a80:
--------------------------------------------------------------------------------
1 | ; 124 IUSHR
2 | CLRLOC
3 | POP BC
4 | POP HL
5 | LD A,C
6 | OR A
7 | JR Z,@ISHRLOOPEND
8 | LD B,A
9 | @ISHRLOOP:
10 | SRL H
11 | RR L
12 | DJNZ @ISHRLOOP
13 | @ISHRLOOPEND:
14 | PUSH HL
15 |
--------------------------------------------------------------------------------
/j2z80-plugin/src/main/resources/com/igormaznitsa/j2z80/jvmprocessors/IXOR.a80:
--------------------------------------------------------------------------------
1 | ; 130 IXOR a1 a2 -> res
2 | POP BC
3 | POP HL
4 | LD A,B
5 | XOR H
6 | LD B,A
7 | LD A,C
8 | XOR L
9 | LD C,A
10 | PUSH BC
--------------------------------------------------------------------------------
/j2z80-plugin/src/main/resources/com/igormaznitsa/j2z80/jvmprocessors/JSR.a80:
--------------------------------------------------------------------------------
1 | ; 168 JSR --> address
2 | LD BC,$+3
3 | PUSH BC
4 | JP %address%
5 |
6 |
--------------------------------------------------------------------------------
/j2z80-plugin/src/main/resources/com/igormaznitsa/j2z80/jvmprocessors/JSR_W.a80:
--------------------------------------------------------------------------------
1 | ; 201 JSR_W
2 | LD BC,$+3
3 | PUSH BC
4 | JP %address%
5 |
--------------------------------------------------------------------------------
/j2z80-plugin/src/main/resources/com/igormaznitsa/j2z80/jvmprocessors/LDC.a80:
--------------------------------------------------------------------------------
1 | ; 18 LDC
2 | LD BC,%address%
3 | PUSH BC
--------------------------------------------------------------------------------
/j2z80-plugin/src/main/resources/com/igormaznitsa/j2z80/jvmprocessors/LDC_W.a80:
--------------------------------------------------------------------------------
1 | ; 19 LDC_W
2 | LD BC,%address%
3 | PUSH BC
--------------------------------------------------------------------------------
/j2z80-plugin/src/main/resources/com/igormaznitsa/j2z80/jvmprocessors/LOOKUPSWITCH.a80:
--------------------------------------------------------------------------------
1 | ; 171 LOOKUPSWITCH index -->
2 | CLRLOC
3 | POP BC
4 | LD HL,@___LOOKUPSWITCHTABLE
5 | LD A,%value%
6 | @___LOOKUPSWITCHLOOP:
7 |
8 | LD E,(HL)
9 | INC HL
10 | LD D,(HL)
11 | INC HL
12 |
13 | EX DE,HL
14 | OR A
15 | SBC HL,BC
16 | JR NZ,@___LOOKUPSWITCHNOEQU
17 |
18 | EX DE,HL
19 | LD E,(HL)
20 | INC HL
21 | LD D,(HL)
22 | EX DE,HL
23 |
24 | JP (HL)
25 | @___LOOKUPSWITCHNOEQU:
26 | EX DE,HL
27 | INC HL
28 | INC HL
29 |
30 | DEC A
31 | JP NZ,@___LOOKUPSWITCHLOOP
32 | JP %address%
33 |
34 | @___LOOKUPSWITCHTABLE:
35 |
36 |
--------------------------------------------------------------------------------
/j2z80-plugin/src/main/resources/com/igormaznitsa/j2z80/jvmprocessors/MONITORENTER.a80:
--------------------------------------------------------------------------------
1 | ; 194 MONITORENTER objref ->
2 | POP BC ; just drop the ref from the stack because single thread model
3 |
--------------------------------------------------------------------------------
/j2z80-plugin/src/main/resources/com/igormaznitsa/j2z80/jvmprocessors/MONITOREXIT.a80:
--------------------------------------------------------------------------------
1 | ; 195 MONITOREXIT objref ->
2 | POP BC ; just drop the ref from the stack because single thread model
--------------------------------------------------------------------------------
/j2z80-plugin/src/main/resources/com/igormaznitsa/j2z80/jvmprocessors/MULTIANEWARRAY.a80:
--------------------------------------------------------------------------------
1 | ; 197 MULTIANEWARRAY dim1, dim2, dim3 .. dimN -> address
2 | LD BC, %value%
3 | CALL %address%
4 | PUSH BC
5 |
6 |
--------------------------------------------------------------------------------
/j2z80-plugin/src/main/resources/com/igormaznitsa/j2z80/jvmprocessors/NEW.a80:
--------------------------------------------------------------------------------
1 | ; 187 NEW -> objref
2 | LD BC,%value% ; place the object cell number into BC
3 | LD DE,%id% ; place the object class id into DE
4 | CALL %address% ; create byte array with the size
5 | PUSH BC ; place the array reference on the stack
6 |
7 |
--------------------------------------------------------------------------------
/j2z80-plugin/src/main/resources/com/igormaznitsa/j2z80/jvmprocessors/NEWARRAY.a80:
--------------------------------------------------------------------------------
1 | ; 188 NEWARRAY elements -> address
2 | POP BC
3 | CALL %address%
4 | PUSH BC
5 |
6 |
--------------------------------------------------------------------------------
/j2z80-plugin/src/main/resources/com/igormaznitsa/j2z80/jvmprocessors/NOP.a80:
--------------------------------------------------------------------------------
1 | ; 00 NOP
2 | NOP
3 |
--------------------------------------------------------------------------------
/j2z80-plugin/src/main/resources/com/igormaznitsa/j2z80/jvmprocessors/POP.a80:
--------------------------------------------------------------------------------
1 | ; 87 POP value->
2 | POP HL
3 |
--------------------------------------------------------------------------------
/j2z80-plugin/src/main/resources/com/igormaznitsa/j2z80/jvmprocessors/POP2.a80:
--------------------------------------------------------------------------------
1 | ; 88 POP2
2 | POP HL
3 | POP HL
4 |
--------------------------------------------------------------------------------
/j2z80-plugin/src/main/resources/com/igormaznitsa/j2z80/jvmprocessors/PUTFIELD.a80:
--------------------------------------------------------------------------------
1 | ; 181 PUTFIELD objref, value ->
2 | POP BC ; value into BC
3 | POP HL ; objref into HL
4 | LD DE,%address% ; offset into DE
5 | ADD HL,DE
6 | LD (HL),C
7 | INC HL
8 | LD (HL),B
9 |
--------------------------------------------------------------------------------
/j2z80-plugin/src/main/resources/com/igormaznitsa/j2z80/jvmprocessors/PUTSTATIC.a80:
--------------------------------------------------------------------------------
1 | ; 179 PUTSTATIC value ->
2 | POP BC
3 | LD (%address%),BC
4 |
5 |
--------------------------------------------------------------------------------
/j2z80-plugin/src/main/resources/com/igormaznitsa/j2z80/jvmprocessors/RET.a80:
--------------------------------------------------------------------------------
1 | ; 169 RET
2 | LD L,(IX-%index%)
3 | LD H,(IX-%index%+1)
4 | JP (HL)
5 |
--------------------------------------------------------------------------------
/j2z80-plugin/src/main/resources/com/igormaznitsa/j2z80/jvmprocessors/RETURN.a80:
--------------------------------------------------------------------------------
1 | ; 177 RETURN
2 | RET
--------------------------------------------------------------------------------
/j2z80-plugin/src/main/resources/com/igormaznitsa/j2z80/jvmprocessors/SALOAD.a80:
--------------------------------------------------------------------------------
1 | ; 53 SALOAD arrayref index -> value
2 | POP BC ; index
3 | POP HL ; array pointer
4 | SLA C ; BC<<1
5 | RL B
6 | ADD HL,BC ; make the cell address
7 | LD A,(HL); low byte
8 | LD C,A
9 | INC HL
10 | LD A,(HL); high byte
11 | LD B,A
12 | PUSH BC; place the cell data on stack
--------------------------------------------------------------------------------
/j2z80-plugin/src/main/resources/com/igormaznitsa/j2z80/jvmprocessors/SASTORE.a80:
--------------------------------------------------------------------------------
1 | ; 86 SASTORE arrayref index value ->
2 | POP DE ; value
3 | POP BC ; index
4 | POP HL ; array pointer
5 | SLA C ; BC<<1
6 | RL B
7 | ADD HL,BC ; make the cell address
8 | LD (HL),E; low byte
9 | INC HL
10 | LD (HL),D; high byte
11 |
--------------------------------------------------------------------------------
/j2z80-plugin/src/main/resources/com/igormaznitsa/j2z80/jvmprocessors/SIPUSH.a80:
--------------------------------------------------------------------------------
1 | ; 17 SIPUSH -> short
2 | LD BC,%value%
3 | PUSH BC
4 |
5 |
--------------------------------------------------------------------------------
/j2z80-plugin/src/main/resources/com/igormaznitsa/j2z80/jvmprocessors/SWAP.a80:
--------------------------------------------------------------------------------
1 | ; 095 SWAP
2 | POP HL
3 | POP BC
4 | PUSH HL
5 | PUSH BC
--------------------------------------------------------------------------------
/j2z80-plugin/src/main/resources/com/igormaznitsa/j2z80/jvmprocessors/TABLESWITCH.a80:
--------------------------------------------------------------------------------
1 | ; 170 TABLESWITCH index ->
2 | CLRLOC
3 | POP BC
4 | ; check low index
5 | LD HL,%lowindex%
6 | LD E,C
7 | LD D,B
8 | EX DE,HL
9 | AND A
10 | SBC HL,DE
11 | JP P,@___TABLESWITCH_SSET0
12 | JP PO,%default%
13 | JR @___TABLESWITCH_CHECKHIGH
14 | @___TABLESWITCH_SSET0:
15 | JP PE,%default%
16 |
17 | ; check high index
18 | @___TABLESWITCH_CHECKHIGH:
19 | LD HL,%highindex%
20 | AND A
21 | SBC HL,BC
22 | JP P,@___TABLESWITCH_SSET1
23 | JP PO,%default%
24 | JR @___TABLESWITCH_PROCESS
25 | @___TABLESWITCH_SSET1:
26 | JP PE,%default%
27 |
28 | @___TABLESWITCH_PROCESS:
29 | ; calculate address cell
30 | LD DE,%lowindex%
31 | LD H,B
32 | LD L,C
33 | AND A
34 | SBC HL,DE
35 | EX DE,HL
36 | LD HL,@___TABLESWITCH_ADDRTABLE
37 | SLA E
38 | RL D
39 | ADD HL,DE
40 | LD E,(HL)
41 | INC HL
42 | LD D,(HL)
43 | EX DE,HL
44 | JP (HL)
45 |
46 | @___TABLESWITCH_ADDRTABLE:
47 |
48 |
--------------------------------------------------------------------------------
/j2z80-plugin/src/test/java/com/igormaznitsa/j2z80/jvmprocessors/AdditionPathTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 Igor Maznitsa.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.igormaznitsa.j2z80.jvmprocessors;
17 |
18 | import com.igormaznitsa.j2z80.api.additional.AdditionPath;
19 | import com.igormaznitsa.j2z80.api.additional.NeedsMemoryManager;
20 | import org.junit.Test;
21 |
22 | import static org.junit.Assert.assertNotNull;
23 |
24 | public class AdditionPathTest {
25 |
26 | @Test
27 | public void testAccessible() {
28 | assertNotNull("Must not be null", NeedsMemoryManager.class.getAnnotation(AdditionPath.class));
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/j2z80-plugin/src/test/java/com/igormaznitsa/j2z80/jvmprocessors/TestACONST_NULL.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 Igor Maznitsa.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.igormaznitsa.j2z80.jvmprocessors;
17 |
18 | import org.apache.bcel.generic.ACONST_NULL;
19 | import org.apache.bcel.generic.InstructionHandle;
20 | import org.junit.Test;
21 |
22 | import java.io.IOException;
23 | import java.io.StringWriter;
24 |
25 | import static org.junit.Assert.assertEquals;
26 | import static org.mockito.Mockito.mock;
27 |
28 | public class TestACONST_NULL extends AbstractJvmCommandProcessorTest {
29 |
30 | @Test
31 | public void testExecution() throws IOException {
32 | final AbstractJvmCommandProcessor processor = AbstractJvmCommandProcessor.findProcessor(ACONST_NULL.class);
33 | final StringWriter writer = new StringWriter();
34 |
35 | processor.process(CLASS_PROCESSOR_MOCK, new ACONST_NULL(), mock(InstructionHandle.class), writer);
36 | assertLinearExecutionToEnd(writer.toString());
37 | assertEquals(0, pop());
38 | assertEquals(INIT_SP, SP);
39 | }
40 |
41 | }
42 |
--------------------------------------------------------------------------------
/j2z80-plugin/src/test/java/com/igormaznitsa/j2z80/jvmprocessors/TestANEWARRAY.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 Igor Maznitsa.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.igormaznitsa.j2z80.jvmprocessors;
17 |
18 | import org.apache.bcel.generic.ANEWARRAY;
19 | import org.apache.bcel.generic.ARRAYLENGTH;
20 | import org.apache.bcel.generic.Instruction;
21 | import org.apache.bcel.generic.POP;
22 | import org.apache.bcel.generic.SIPUSH;
23 | import org.junit.Test;
24 |
25 | import static org.junit.Assert.assertEquals;
26 |
27 | public class TestANEWARRAY extends AbstractTestBasedOnMemoryManager {
28 |
29 | @Test(timeout = 3000L)
30 | public void testArrayCreation() throws Exception {
31 | push(1000);
32 | assertAllocateCommand(new Instruction[] {new ANEWARRAY(0), new ARRAYLENGTH()}, 2003);
33 | assertEquals(1000, pop());
34 | assertStackEmpty();
35 | }
36 |
37 | @Test(timeout = 3000L)
38 | public void testTwoArrayCreation() throws Exception {
39 | push(1000);
40 | assertAllocateCommand(new Instruction[] {new ANEWARRAY(0), new POP(), new SIPUSH((short) 1000), new ANEWARRAY(0)}, 4006);
41 | pop();
42 | assertStackEmpty();
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/j2z80-plugin/src/test/java/com/igormaznitsa/j2z80/jvmprocessors/TestARETURN.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 Igor Maznitsa.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.igormaznitsa.j2z80.jvmprocessors;
17 |
18 | import org.apache.bcel.generic.ARETURN;
19 | import org.apache.bcel.generic.InstructionHandle;
20 | import org.junit.Test;
21 |
22 | import java.io.IOException;
23 | import java.io.StringWriter;
24 |
25 | import static org.junit.Assert.assertEquals;
26 | import static org.mockito.Mockito.mock;
27 |
28 | public class TestARETURN extends AbstractJvmCommandProcessorTest {
29 |
30 | @Test(timeout = 3000L)
31 | public void testExecution() throws IOException {
32 | final AbstractJvmCommandProcessor processor = AbstractJvmCommandProcessor.findProcessor(ARETURN.class);
33 | final StringWriter writer = new StringWriter();
34 | processor.process(CLASS_PROCESSOR_MOCK, new ARETURN(), mock(InstructionHandle.class), writer);
35 |
36 | assertLinearExecutionToEnd("ld hl," + END_LABEL + "\n push hl\n ld hl,#1234\n push hl\n" + writer.toString());
37 |
38 | assertEquals(0x1234, BC());
39 | assertStackEmpty();
40 | }
41 |
42 | }
43 |
--------------------------------------------------------------------------------
/j2z80-plugin/src/test/java/com/igormaznitsa/j2z80/jvmprocessors/TestARRAYLENGTH.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 Igor Maznitsa.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.igormaznitsa.j2z80.jvmprocessors;
17 |
18 | import org.apache.bcel.generic.ANEWARRAY;
19 | import org.apache.bcel.generic.ARRAYLENGTH;
20 | import org.apache.bcel.generic.Instruction;
21 | import org.junit.Test;
22 |
23 | import static org.junit.Assert.assertEquals;
24 |
25 | public class TestARRAYLENGTH extends AbstractTestBasedOnMemoryManager {
26 |
27 | @Test(timeout = 3000L)
28 | public void testArrayLength() throws Exception {
29 | final int ARRAY_SIZE = 1234;
30 | push(ARRAY_SIZE);
31 | assertAllocateCommand(new Instruction[] {new ANEWARRAY(0), new ARRAYLENGTH()}, ARRAY_SIZE * 2 + 3);
32 | assertEquals(ARRAY_SIZE, pop());
33 | assertStackEmpty();
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/j2z80-plugin/src/test/java/com/igormaznitsa/j2z80/jvmprocessors/TestDUP.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 Igor Maznitsa.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.igormaznitsa.j2z80.jvmprocessors;
17 |
18 | import org.apache.bcel.generic.DUP;
19 | import org.apache.bcel.generic.InstructionHandle;
20 | import org.junit.Test;
21 |
22 | import java.io.IOException;
23 | import java.io.StringWriter;
24 |
25 | import static org.junit.Assert.assertEquals;
26 | import static org.mockito.Mockito.mock;
27 |
28 | public class TestDUP extends AbstractJvmCommandProcessorTest {
29 |
30 | @Test
31 | public void testExecution() throws IOException {
32 | final AbstractJvmCommandProcessor processor = AbstractJvmCommandProcessor.findProcessor(DUP.class);
33 | final StringWriter writer = new StringWriter();
34 | final int VALUE = 0xCAFE;
35 |
36 | push(VALUE);
37 |
38 | processor.process(CLASS_PROCESSOR_MOCK, new DUP(), mock(InstructionHandle.class), writer);
39 | assertLinearExecutionToEnd(writer.toString());
40 |
41 | assertEquals(VALUE, pop());
42 | assertEquals(VALUE, pop());
43 | assertStackEmpty();
44 | }
45 |
46 | }
47 |
--------------------------------------------------------------------------------
/j2z80-plugin/src/test/java/com/igormaznitsa/j2z80/jvmprocessors/TestIADD.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 Igor Maznitsa.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.igormaznitsa.j2z80.jvmprocessors;
17 |
18 | import org.apache.bcel.generic.IADD;
19 | import org.apache.bcel.generic.InstructionHandle;
20 | import org.junit.Test;
21 |
22 | import java.io.IOException;
23 | import java.io.StringWriter;
24 |
25 | import static org.junit.Assert.assertEquals;
26 | import static org.mockito.Mockito.mock;
27 |
28 | public class TestIADD extends AbstractJvmCommandProcessorTest {
29 |
30 | @Test
31 | public void testExecution() throws IOException {
32 | final AbstractJvmCommandProcessor processor = AbstractJvmCommandProcessor.findProcessor(IADD.class);
33 | final StringWriter writer = new StringWriter();
34 |
35 | final int VAL1 = 1345;
36 | final int VAL2 = -45;
37 |
38 | push(VAL1);
39 | push(VAL2);
40 |
41 | processor.process(CLASS_PROCESSOR_MOCK, new IADD(), mock(InstructionHandle.class), writer);
42 | assertLinearExecutionToEnd(writer.toString());
43 |
44 | assertEquals(VAL1 + VAL2, (short) pop());
45 | assertEquals(INIT_SP, SP);
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/j2z80-plugin/src/test/java/com/igormaznitsa/j2z80/jvmprocessors/TestIAND.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 Igor Maznitsa.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.igormaznitsa.j2z80.jvmprocessors;
17 |
18 | import org.apache.bcel.generic.IAND;
19 | import org.apache.bcel.generic.InstructionHandle;
20 | import org.junit.Test;
21 |
22 | import java.io.IOException;
23 | import java.io.StringWriter;
24 |
25 | import static org.junit.Assert.assertEquals;
26 | import static org.mockito.Mockito.mock;
27 |
28 | public class TestIAND extends AbstractJvmCommandProcessorTest {
29 |
30 | @Test
31 | public void testExecution() throws IOException {
32 | final AbstractJvmCommandProcessor processor = AbstractJvmCommandProcessor.findProcessor(IAND.class);
33 | final StringWriter writer = new StringWriter();
34 |
35 | final int VAL1 = 0xCAFE;
36 | final int VAL2 = 0xBABE;
37 |
38 | push(VAL1);
39 | push(VAL2);
40 |
41 | processor.process(CLASS_PROCESSOR_MOCK, new IAND(), mock(InstructionHandle.class), writer);
42 | assertLinearExecutionToEnd(writer.toString());
43 |
44 | assertEquals(VAL1 & VAL2, pop());
45 | assertEquals(INIT_SP, SP);
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/j2z80-plugin/src/test/java/com/igormaznitsa/j2z80/jvmprocessors/TestIOR.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 Igor Maznitsa.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.igormaznitsa.j2z80.jvmprocessors;
17 |
18 | import org.apache.bcel.generic.IOR;
19 | import org.apache.bcel.generic.InstructionHandle;
20 | import org.junit.Test;
21 |
22 | import java.io.IOException;
23 | import java.io.StringWriter;
24 |
25 | import static org.junit.Assert.assertEquals;
26 | import static org.mockito.Mockito.mock;
27 |
28 | public class TestIOR extends AbstractJvmCommandProcessorTest {
29 |
30 | @Test
31 | public void testExecution() throws IOException {
32 | final AbstractJvmCommandProcessor processor = AbstractJvmCommandProcessor.findProcessor(IOR.class);
33 | final StringWriter writer = new StringWriter();
34 |
35 | final int VAL1 = 0xCAFE;
36 | final int VAL2 = 0xBABE;
37 |
38 | push(VAL1);
39 | push(VAL2);
40 |
41 | processor.process(CLASS_PROCESSOR_MOCK, new IOR(), mock(InstructionHandle.class), writer);
42 | assertLinearExecutionToEnd(writer.toString());
43 |
44 | assertEquals(VAL1 | VAL2, pop());
45 | assertEquals(INIT_SP, SP);
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/j2z80-plugin/src/test/java/com/igormaznitsa/j2z80/jvmprocessors/TestIRETURN.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 Igor Maznitsa.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.igormaznitsa.j2z80.jvmprocessors;
17 |
18 | import org.apache.bcel.generic.IRETURN;
19 | import org.apache.bcel.generic.InstructionHandle;
20 | import org.junit.Test;
21 |
22 | import java.io.IOException;
23 | import java.io.StringWriter;
24 |
25 | import static org.junit.Assert.assertEquals;
26 | import static org.mockito.Mockito.mock;
27 |
28 | public class TestIRETURN extends AbstractJvmCommandProcessorTest {
29 |
30 | @Test(timeout = 3000L)
31 | public void testExecution() throws IOException {
32 | final AbstractJvmCommandProcessor processor = AbstractJvmCommandProcessor.findProcessor(IRETURN.class);
33 | final StringWriter writer = new StringWriter();
34 | processor.process(CLASS_PROCESSOR_MOCK, new IRETURN(), mock(InstructionHandle.class), writer);
35 |
36 | assertLinearExecutionToEnd("ld hl," + END_LABEL + "\n push hl\n ld hl,#1234\n push hl\n" + writer.toString());
37 |
38 | assertEquals(0x1234, BC());
39 | assertStackEmpty();
40 | }
41 |
42 | }
43 |
--------------------------------------------------------------------------------
/j2z80-plugin/src/test/java/com/igormaznitsa/j2z80/jvmprocessors/TestISUB.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 Igor Maznitsa.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.igormaznitsa.j2z80.jvmprocessors;
17 |
18 | import org.apache.bcel.generic.ISUB;
19 | import org.apache.bcel.generic.InstructionHandle;
20 | import org.junit.Test;
21 |
22 | import java.io.IOException;
23 | import java.io.StringWriter;
24 |
25 | import static org.junit.Assert.assertEquals;
26 | import static org.mockito.Mockito.mock;
27 |
28 | public class TestISUB extends AbstractJvmCommandProcessorTest {
29 |
30 | @Test
31 | public void testExecution() throws IOException {
32 | final AbstractJvmCommandProcessor processor = AbstractJvmCommandProcessor.findProcessor(ISUB.class);
33 | final StringWriter writer = new StringWriter();
34 |
35 | final int VAL1 = 1345;
36 | final int VAL2 = -45;
37 |
38 | push(VAL1);
39 | push(VAL2);
40 |
41 | processor.process(CLASS_PROCESSOR_MOCK, new ISUB(), mock(InstructionHandle.class), writer);
42 | assertLinearExecutionToEnd(writer.toString());
43 |
44 | assertEquals(VAL1 - VAL2, (short) pop());
45 | assertEquals(INIT_SP, SP);
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/j2z80-plugin/src/test/java/com/igormaznitsa/j2z80/jvmprocessors/TestIXOR.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 Igor Maznitsa.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.igormaznitsa.j2z80.jvmprocessors;
17 |
18 | import org.apache.bcel.generic.IXOR;
19 | import org.apache.bcel.generic.InstructionHandle;
20 | import org.junit.Test;
21 |
22 | import java.io.IOException;
23 | import java.io.StringWriter;
24 |
25 | import static org.junit.Assert.assertEquals;
26 | import static org.mockito.Mockito.mock;
27 |
28 | public class TestIXOR extends AbstractJvmCommandProcessorTest {
29 |
30 | @Test
31 | public void testExecution() throws IOException {
32 | final AbstractJvmCommandProcessor processor = AbstractJvmCommandProcessor.findProcessor(IXOR.class);
33 | final StringWriter writer = new StringWriter();
34 |
35 | final int VAL1 = 0xCAFE;
36 | final int VAL2 = 0xBABE;
37 |
38 | push(VAL1);
39 | push(VAL2);
40 |
41 | processor.process(CLASS_PROCESSOR_MOCK, new IXOR(), mock(InstructionHandle.class), writer);
42 | assertLinearExecutionToEnd(writer.toString());
43 |
44 | assertEquals(VAL1 ^ VAL2, pop());
45 | assertEquals(INIT_SP, SP);
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/j2z80-plugin/src/test/java/com/igormaznitsa/j2z80/jvmprocessors/TestMONITORENTER.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 Igor Maznitsa.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.igormaznitsa.j2z80.jvmprocessors;
17 |
18 | import org.apache.bcel.generic.InstructionHandle;
19 | import org.apache.bcel.generic.MONITORENTER;
20 | import org.junit.Test;
21 |
22 | import java.io.IOException;
23 | import java.io.StringWriter;
24 |
25 | import static org.mockito.Mockito.mock;
26 |
27 | public class TestMONITORENTER extends AbstractJvmCommandProcessorTest {
28 |
29 | @Test
30 | public void testExecution() throws IOException {
31 | final AbstractJvmCommandProcessor processor = AbstractJvmCommandProcessor.findProcessor(MONITORENTER.class);
32 | final StringWriter writer = new StringWriter();
33 | final int VALUE = 0xCAFE;
34 |
35 | push(VALUE);
36 |
37 | processor.process(CLASS_PROCESSOR_MOCK, new MONITORENTER(), mock(InstructionHandle.class), writer);
38 | assertLinearExecutionToEnd(writer.toString());
39 | assertStackEmpty();
40 | }
41 |
42 | }
43 |
--------------------------------------------------------------------------------
/j2z80-plugin/src/test/java/com/igormaznitsa/j2z80/jvmprocessors/TestMONITOREXIT.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 Igor Maznitsa.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.igormaznitsa.j2z80.jvmprocessors;
17 |
18 | import org.apache.bcel.generic.InstructionHandle;
19 | import org.apache.bcel.generic.MONITOREXIT;
20 | import org.junit.Test;
21 |
22 | import java.io.IOException;
23 | import java.io.StringWriter;
24 |
25 | import static org.mockito.Mockito.mock;
26 |
27 | public class TestMONITOREXIT extends AbstractJvmCommandProcessorTest {
28 |
29 | @Test
30 | public void testExecution() throws IOException {
31 | final AbstractJvmCommandProcessor processor = AbstractJvmCommandProcessor.findProcessor(MONITOREXIT.class);
32 | final StringWriter writer = new StringWriter();
33 | final int VALUE = 0xCAFE;
34 |
35 | push(VALUE);
36 |
37 | processor.process(CLASS_PROCESSOR_MOCK, new MONITOREXIT(), mock(InstructionHandle.class), writer);
38 | assertLinearExecutionToEnd(writer.toString());
39 | assertStackEmpty();
40 | }
41 |
42 | }
43 |
--------------------------------------------------------------------------------
/j2z80-plugin/src/test/java/com/igormaznitsa/j2z80/jvmprocessors/TestNOP.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 Igor Maznitsa.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.igormaznitsa.j2z80.jvmprocessors;
17 |
18 | import org.apache.bcel.generic.InstructionHandle;
19 | import org.apache.bcel.generic.NOP;
20 | import org.junit.Test;
21 |
22 | import java.io.IOException;
23 | import java.io.StringWriter;
24 |
25 | import static org.junit.Assert.assertEquals;
26 | import static org.mockito.Mockito.mock;
27 |
28 | public class TestNOP extends AbstractJvmCommandProcessorTest {
29 |
30 | @Test
31 | public void testExecution() throws IOException {
32 | final AbstractJvmCommandProcessor processor = AbstractJvmCommandProcessor.findProcessor(NOP.class);
33 | final StringWriter writer = new StringWriter();
34 | processor.process(CLASS_PROCESSOR_MOCK, new NOP(), mock(InstructionHandle.class), writer);
35 | assertLinearExecutionToEnd(writer.toString());
36 | assertEquals("One command", 1, PC - START_ADDRESS);
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/j2z80-plugin/src/test/java/com/igormaznitsa/j2z80/jvmprocessors/TestPOP.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 Igor Maznitsa.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.igormaznitsa.j2z80.jvmprocessors;
17 |
18 | import org.apache.bcel.generic.InstructionHandle;
19 | import org.apache.bcel.generic.POP;
20 | import org.junit.Test;
21 |
22 | import java.io.IOException;
23 | import java.io.StringWriter;
24 |
25 | import static org.junit.Assert.assertEquals;
26 | import static org.mockito.Mockito.mock;
27 |
28 | public class TestPOP extends AbstractJvmCommandProcessorTest {
29 |
30 | @Test
31 | public void testExecution() throws IOException {
32 | final AbstractJvmCommandProcessor processor = AbstractJvmCommandProcessor.findProcessor(POP.class);
33 | final StringWriter writer = new StringWriter();
34 |
35 | push(0);
36 |
37 | processor.process(CLASS_PROCESSOR_MOCK, new POP(), mock(InstructionHandle.class), writer);
38 | assertLinearExecutionToEnd(writer.toString());
39 |
40 | assertEquals(INIT_SP, SP);
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/j2z80-plugin/src/test/java/com/igormaznitsa/j2z80/jvmprocessors/TestPOP2.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 Igor Maznitsa.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.igormaznitsa.j2z80.jvmprocessors;
17 |
18 | import org.apache.bcel.generic.InstructionHandle;
19 | import org.apache.bcel.generic.POP2;
20 | import org.junit.Test;
21 |
22 | import java.io.IOException;
23 | import java.io.StringWriter;
24 |
25 | import static org.junit.Assert.assertEquals;
26 | import static org.mockito.Mockito.mock;
27 |
28 | public class TestPOP2 extends AbstractJvmCommandProcessorTest {
29 |
30 | @Test
31 | public void testExecution() throws IOException {
32 | final AbstractJvmCommandProcessor processor = AbstractJvmCommandProcessor.findProcessor(POP2.class);
33 | final StringWriter writer = new StringWriter();
34 |
35 | push(0);
36 | push(0);
37 |
38 | processor.process(CLASS_PROCESSOR_MOCK, new POP2(), mock(InstructionHandle.class), writer);
39 | assertLinearExecutionToEnd(writer.toString());
40 |
41 | assertEquals(INIT_SP, SP);
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/j2z80-plugin/src/test/java/com/igormaznitsa/j2z80/jvmprocessors/TestRET.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 Igor Maznitsa.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.igormaznitsa.j2z80.jvmprocessors;
17 |
18 | import org.apache.bcel.generic.InstructionHandle;
19 | import org.apache.bcel.generic.RET;
20 | import org.junit.Test;
21 |
22 | import java.io.IOException;
23 | import java.io.StringWriter;
24 |
25 | import static org.mockito.Mockito.mock;
26 |
27 | public class TestRET extends AbstractJvmCommandProcessorTest {
28 |
29 | @Test//(timeout=3000L)
30 | public void testExecution() throws IOException {
31 | final AbstractJvmCommandProcessor processor = AbstractJvmCommandProcessor.findProcessor(RET.class);
32 | final StringWriter writer = new StringWriter();
33 |
34 | final int IX_ADDRESS = 0x8000;
35 | final int INDEX = 23;
36 |
37 | processor.process(CLASS_PROCESSOR_MOCK, new RET(INDEX), mock(InstructionHandle.class), writer);
38 |
39 | IX = IX_ADDRESS;
40 |
41 | assertLinearExecutionToEnd("ld hl," + END_LABEL + "\n ld (" + (IX_ADDRESS - (INDEX << 1)) + "),hl \n " + writer.toString() + "\n LOOP: JR LOOP\n");
42 | assertStackEmpty();
43 | }
44 |
45 | }
46 |
--------------------------------------------------------------------------------
/j2z80-plugin/src/test/java/com/igormaznitsa/j2z80/jvmprocessors/TestRETURN.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 Igor Maznitsa.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.igormaznitsa.j2z80.jvmprocessors;
17 |
18 | import org.apache.bcel.generic.InstructionHandle;
19 | import org.apache.bcel.generic.RETURN;
20 | import org.junit.Test;
21 |
22 | import java.io.IOException;
23 | import java.io.StringWriter;
24 |
25 | import static org.junit.Assert.assertEquals;
26 | import static org.mockito.Mockito.mock;
27 |
28 | public class TestRETURN extends AbstractJvmCommandProcessorTest {
29 |
30 | @Test(timeout = 3000L)
31 | public void testExecution() throws IOException {
32 | final AbstractJvmCommandProcessor processor = AbstractJvmCommandProcessor.findProcessor(RETURN.class);
33 | final StringWriter writer = new StringWriter();
34 | processor.process(CLASS_PROCESSOR_MOCK, new RETURN(), mock(InstructionHandle.class), writer);
35 |
36 | assertLinearExecutionToEnd("ld hl," + END_LABEL + "\n push hl\n" + writer.toString());
37 |
38 | assertEquals(0x0, BC());
39 | assertStackEmpty();
40 | }
41 |
42 | }
43 |
--------------------------------------------------------------------------------
/j2z80-plugin/src/test/java/com/igormaznitsa/j2z80/translator/MethodTranslatorTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 Igor Maznitsa.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.igormaznitsa.j2z80.translator;
17 |
18 | public class MethodTranslatorTest {
19 |
20 | }
21 |
--------------------------------------------------------------------------------
/j2z80-plugin/src/test/java/com/igormaznitsa/z80asm/asmcommands/AbstractAsmCommandTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 Igor Maznitsa.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.igormaznitsa.z80asm.asmcommands;
17 |
18 | import org.junit.Test;
19 |
20 | import static org.junit.Assert.assertEquals;
21 |
22 | public class AbstractAsmCommandTest {
23 |
24 | @Test
25 | public void testExtractCalculatedPart() {
26 | assertEquals("java.lang.System.out#Ljava/io/PrintStream;", AbstractAsmCommand.extractCalculatedPart("(java.lang.System.out#Ljava/io/PrintStream;)"));
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/j2z80-plugin/src/test/java/com/igormaznitsa/z80asm/asmcommands/AsmCommandDEFBTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 Igor Maznitsa.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.igormaznitsa.z80asm.asmcommands;
17 |
18 | import com.igormaznitsa.z80asm.AsmTranslator;
19 | import org.junit.Test;
20 |
21 | import java.util.Arrays;
22 |
23 | import static org.junit.Assert.assertTrue;
24 | import static org.mockito.Mockito.mock;
25 | import static org.mockito.Mockito.when;
26 |
27 | public class AsmCommandDEFBTest {
28 |
29 | final AbstractAsmCommand defbCommand = AbstractAsmCommand.findCommandForName("DEFB");
30 |
31 | @Test
32 | public void testMachineCodeGeneration() {
33 | final AsmTranslator mockContext = mock(AsmTranslator.class);
34 | when(mockContext.getPC()).thenReturn(Integer.valueOf(1100));
35 | final ParsedAsmLine parsedLine = new ParsedAsmLine("defb 1,2,3,4,5,6,7,8,9,10,11,12");
36 | final byte[] generated = defbCommand.makeMachineCode(mockContext, parsedLine);
37 | assertTrue(Arrays.equals(new byte[] {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12}, generated));
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/j2z80-plugin/src/test/java/com/igormaznitsa/z80asm/asmcommands/AsmCommandDEFSTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 Igor Maznitsa.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.igormaznitsa.z80asm.asmcommands;
17 |
18 | import com.igormaznitsa.z80asm.AsmTranslator;
19 | import org.junit.Test;
20 |
21 | import static org.junit.Assert.assertEquals;
22 | import static org.mockito.Mockito.mock;
23 | import static org.mockito.Mockito.when;
24 |
25 | public class AsmCommandDEFSTest {
26 | final AbstractAsmCommand defsCommand = AbstractAsmCommand.findCommandForName("DEFS");
27 |
28 | @Test
29 | public void testMachineCodeGeneration() {
30 | final AsmTranslator mockContext = mock(AsmTranslator.class);
31 | when(mockContext.getPC()).thenReturn(Integer.valueOf(1100));
32 | final ParsedAsmLine parsedLine = new ParsedAsmLine("defs 2000+8000");
33 | final byte[] generated = defsCommand.makeMachineCode(mockContext, parsedLine);
34 | assertEquals(10000, generated.length);
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/j2z80-plugin/src/test/java/com/igormaznitsa/z80asm/asmcommands/AsmCommandORGTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 Igor Maznitsa.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.igormaznitsa.z80asm.asmcommands;
17 |
18 | import com.igormaznitsa.z80asm.AsmTranslator;
19 | import org.junit.Test;
20 |
21 | import static org.junit.Assert.assertEquals;
22 | import static org.mockito.Mockito.mock;
23 | import static org.mockito.Mockito.verify;
24 |
25 | public class AsmCommandORGTest {
26 |
27 | final AbstractAsmCommand orgCommand = AbstractAsmCommand.findCommandForName("ORG");
28 |
29 | @Test
30 | public void testSomeMethod() {
31 | final AsmTranslator mockContext = mock(AsmTranslator.class);
32 | final ParsedAsmLine parsedLine = new ParsedAsmLine("org #FF00");
33 | final byte[] generated = orgCommand.makeMachineCode(mockContext, parsedLine);
34 | assertEquals(0, generated.length);
35 | verify(mockContext).setPC(0xFF00);
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/j2z80-plugin/src/test/resources/com/igormaznitsa/z80asm/equ.asm:
--------------------------------------------------------------------------------
1 | org #0
2 | label1:
3 |
4 | equ #1000
5 | label2:
6 | equ #2000
7 |
8 |
9 | label2#: equ labela
10 |
11 |
12 | label3: equ #3000
13 | label4:
14 |
15 |
16 | label4#: equ #4000
17 |
18 | org #1234
19 | labela: DEFB 0
20 | end
21 |
--------------------------------------------------------------------------------
/j2z80-plugin/src/test/resources/com/igormaznitsa/z80asm/hello_world.asm:
--------------------------------------------------------------------------------
1 | ORG #1000 ; Start address of the routine
2 | START: LD A,2 ; set the output channel
3 | CALL #1601 ; to channel 2 (main part of TV display)
4 | LD HL,MSG ; Set HL register pair to address of the message
5 | LOOP: LD A,(HL) ; De-reference HL and store in A
6 | CP 0 ; Null terminator?
7 | RET Z ; If so, return
8 | RST #10 ; Print the character in A
9 | INC HL ; HL points at the next char to be printed
10 | JR LOOP
11 | MSG: DEFM "Hello, world!"
12 | DEFB 13 ; carriage return
13 | DEFB 0 ; null terminator
14 | END
--------------------------------------------------------------------------------
/j2z80-plugin/src/test/resources/com/igormaznitsa/z80asm/local.asm:
--------------------------------------------------------------------------------
1 | org #1000
2 | djnz @loop
3 | DEFM "test"
4 | @loop: NOP
5 | @loop: NOP
6 | DEFM "test"
7 | djnz @loop
8 | end
9 |
--------------------------------------------------------------------------------
/j2z80-plugin/src/test/resources/com/igormaznitsa/z80asm/localatend.asm:
--------------------------------------------------------------------------------
1 | ORG #1000
2 | CLRLOC
3 | POP HL
4 | LD (@RETADDR),HL
5 | POP HL
6 | LD (@TMPTXT),HL
7 | POP HL
8 | LD (@TMPCH),HL
9 | LD A,(@TMPCH)
10 | CALL 5633
11 | LD DE,(@TMPTXT)
12 | LD BC,10
13 | CALL 8252
14 | LD HL,(@RETADDR)
15 | PUSH HL
16 | RET
17 | @RETADDR: DEFW 0
18 | @TMPCH: DEFW 0
19 | @TMPTXT: DEFW 0
--------------------------------------------------------------------------------
/j2z80-plugin/src/test/resources/com/igormaznitsa/z80asm/multilabeled.asm:
--------------------------------------------------------------------------------
1 | org #2000
2 | label1:
3 | label2:
4 | label3: nop
5 | end
6 |
--------------------------------------------------------------------------------
/j2z80-plugin/src/test/resources/com/igormaznitsa/z80asm/only_label.asm:
--------------------------------------------------------------------------------
1 | ORG 6000
2 | SOME_LABEL:
--------------------------------------------------------------------------------
/j2z80-tests/ext-jar/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 | com.igormaznitsa
7 | j2z80-tests
8 | 0-SNAPSHOT
9 |
10 |
11 |
12 | UTF-8
13 | ${project.build.directory}/source.a80
14 | apache20
15 |
16 |
17 | ext-jar
18 | jar
19 |
20 |
21 |
22 |
23 | maven-jar-plugin
24 | 2.4
25 |
26 |
27 | package
28 |
29 | jar
30 |
31 |
32 | z80
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
--------------------------------------------------------------------------------
/j2z80-tests/ext-jar/src/main/java/com/igormaznitsa/memory/MemoryAccessor.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 Igor Maznitsa.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.igormaznitsa.memory;
17 |
18 | public class MemoryAccessor {
19 | public native static void writeWordToMemory(int address, int value);
20 | public native static int readWordFromMemory(int address);
21 | }
22 |
--------------------------------------------------------------------------------
/j2z80-tests/ext-jar/src/main/resources/com/igormaznitsa/hello.txt:
--------------------------------------------------------------------------------
1 | hello from resource
--------------------------------------------------------------------------------
/j2z80-tests/ext-jar/src/main/resources/com/igormaznitsa/memory/MemoryAccessor.a80:
--------------------------------------------------------------------------------
1 | com.igormaznitsa.memory.MemoryAccessor.writeWordToMemory#[II]V:
2 | LD H,(IX-0+1) ; address into HL
3 | LD L,(IX-0)
4 | LD B,(IX-2+1) ; value into BC
5 | LD C,(IX-2)
6 |
7 | LD (HL),C ; write value into the cells
8 | INC HL
9 | LD (HL),B
10 | RET
11 |
12 | com.igormaznitsa.memory.MemoryAccessor.readWordFromMemory#[I]I:
13 | LD H,(IX-0+1)
14 | LD L,(IX-0)
15 | LD C,(HL)
16 | INC HL
17 | LD B,(HL)
18 | RET
--------------------------------------------------------------------------------
/j2z80-tests/main-jar/src/main/java/com/igormaznitsa/impl/MemoryFiller.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 Igor Maznitsa.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.igormaznitsa.impl;
17 |
18 | import com.igormaznitsa.j2z80test.Main.AbstractTemplateGen;
19 |
20 | public interface MemoryFiller {
21 | public void fillArea(AbstractTemplateGen generator, int startAddress, int length);
22 | }
23 |
--------------------------------------------------------------------------------
/j2z80-tests/main-jar/src/main/java/com/igormaznitsa/impl/MemoryFillerFactory.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 Igor Maznitsa.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.igormaznitsa.impl;
17 |
18 | public class MemoryFillerFactory {
19 | public static final int FILLER_JAVA = 12364;
20 | public static final int FILLER_NATIVE = 2212;
21 |
22 | private static final Object [] fillers = new Object[]{(Object)new MemoryFillerJava(), (Object)new MemoryFillerNative()};
23 |
24 | static {
25 | for(int i=0;i 0) {
38 | MemoryAccessor.writeWordToMemory(address, generator.getValueForAddress(address));
39 | address += 2;
40 | len -= 2;
41 | }
42 | }
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/j2z80-tests/main-jar/src/main/java/com/igormaznitsa/impl/MemoryFillerNative.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 Igor Maznitsa.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.igormaznitsa.impl;
17 |
18 | import com.igormaznitsa.j2z80test.Main.AbstractTemplateGen;
19 |
20 | public class MemoryFillerNative extends MemoryFillerJava {
21 |
22 | @Override
23 | public native void fillArea(final AbstractTemplateGen generator, final int startAddress, final int endAddress);
24 |
25 | }
26 |
--------------------------------------------------------------------------------
/j2z80-tests/main-jar/src/main/java/com/igormaznitsa/templategen/EvenPatternGenerator.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 Igor Maznitsa.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.igormaznitsa.templategen;
17 |
18 | import com.igormaznitsa.j2z80test.Main;
19 |
20 | public class EvenPatternGenerator extends Main.AbstractTemplateGen {
21 |
22 | @Override
23 | public int getValueForAddress(final int address) {
24 | return address ^ 0x5555;
25 | }
26 |
27 | }
28 |
--------------------------------------------------------------------------------
/j2z80-tests/main-jar/src/main/java/com/igormaznitsa/templategen/OddPatternGenerator.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 Igor Maznitsa.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.igormaznitsa.templategen;
17 |
18 | import com.igormaznitsa.j2z80test.Main;
19 |
20 | public class OddPatternGenerator extends Main.AbstractTemplateGen {
21 |
22 | @Override
23 | public int getValueForAddress(final int address) {
24 | return address ^ (short)0xAAAA;
25 | }
26 |
27 | }
28 |
--------------------------------------------------------------------------------
/j2z80-tests/main-jar/src/main/resources/com/igormaznitsa/impl/MemoryFillerNative#fillArea.asm:
--------------------------------------------------------------------------------
1 | CLRLOC
2 |
3 | LD D,(IX-2+1) ; address of the AbstractTemplateGenerator object
4 | LD E,(IX-2)
5 |
6 | LD H,(IX-4+1) ; the start address into HL
7 | LD L,(IX-4)
8 |
9 | LD B,(IX-6+1) ; the length into BC
10 | LD C,(IX-6)
11 |
12 | ; just fill
13 | @FILLLOOP:
14 | LD A,B
15 | OR C
16 | JP Z,@END
17 |
18 | PUSH DE
19 | PUSH BC
20 | PUSH HL
21 |
22 | PUSH DE ; place objref
23 | PUSH HL ; place address
24 | ;---------------------------------
25 | ; get class id for the objectref
26 | LD HL,#2
27 | ADD HL,SP ; the objref address in HL
28 | LD C,(HL) ; load the objref into BC
29 | INC HL
30 | LD B,(HL)
31 | CALL ___GET_OBJECT_CLASS_ID ; get the class id into BC
32 | LD HL,com.igormaznitsa.j2z80test.MainSAbstractTemplateGen.getValueForAddress#[I]I_VT_REC
33 | CALL __PREPAREINVOKEVIRTUAL ; HL contains record address start, BC contains object class id
34 | ; HL contains address and BC contains the full frame size in bytes
35 | LD (@INVOKE_JMP+1),HL
36 | LD A,4 ; load argument area length in bytes
37 | CALL ___BEFORE_INVOKE ; prepare the frame
38 | @INVOKE_JMP:
39 | CALL 0
40 | CALL ___AFTER_INVOKE ; restore the previous frame
41 | ;-----------------------------------
42 | POP HL
43 |
44 | LD (HL),C
45 | INC HL
46 | LD (HL),B
47 | INC HL
48 |
49 | POP BC
50 |
51 | DEC BC
52 | DEC BC
53 |
54 | POP DE
55 |
56 | JP @FILLLOOP
57 | @END:
58 | RET
59 |
--------------------------------------------------------------------------------
/j2z80-tests/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 | com.igormaznitsa
7 | j2z80-pom
8 | 1.0.2-SNAPSHOT
9 |
10 |
11 | j2z80-tests
12 | pom
13 | 0-SNAPSHOT
14 |
15 |
16 | 1.0.2-SNAPSHOT
17 |
18 |
19 |
20 | ext-jar
21 | main-jar
22 |
23 |
24 |
--------------------------------------------------------------------------------
/nbactions.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | CUSTOM-Version set
5 | Version set
6 |
7 | versions:set
8 |
9 |
10 | 1.0.2-SNAPSHOT
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------