public void JE(String label) { Debug("MOV"); if (!assemblyBuilder.inFunction) { throw ParseError("JE Instruction must be in a func"); } OperandToken condOperand1 = tokenizer.NextOperand(); Debug("COND1 : {0}", condOperand1); OperandToken condOperand2 = tokenizer.NextOperand(); Debug("COND2 : {0}", condOperand2); OperandToken jumpOperand = tokenizer.NextOperand(); Debug("JMP : {0}", jumpOperand); MemoryOp condOp1 = condOperand1.GetMemoryOp(assemblyBuilder.currentFunction); Op condOp2 = condOperand2.GetOp(assemblyBuilder.currentFunction); Op jumpOp = jumpOperand.GetJumpOp(assemblyBuilder.currentFunction); assemblyBuilder.currentFunction.AddInstruction(new InstructionMemoryOpAndOpAndOp(label, Instructions.Move, condOp1, condOp2, jumpOp)); }
/* * public void dotMain(String label) * { * Debug(".main"); * * if (!assembly.inFunction) throw ParseError(".main command must be in a func"); * if (label != null) throw ParseError(".main can't be labeled"); * * assembly.CurrentFunctionIsMain(); * parseState = ParseState.Frame; * } * * public void dotException(String label) * { * Debug(".exception"); * * if (!assembly.inFunction) throw ParseError(".exception command must be in a func"); * if(parseState != ParseState.StartOfFrame) throw ParseError(".exception must be at the start of a FRAME"); * * assembly.currentFunction.IncludeException(); * parseState = ParseState.Frame; * } * public void dotStack(String label) * { * Debug(".stack"); * UInt64 num = tokenizer.GetUnsignedNumber(); * * if (!assembly.inFunction) throw ParseError(".stack command must be in a func"); * * if (label == null) * { * assembly.currentFunction.FrameAllocateVariable(num); * } * else * { * assembly.currentFunction.AddFrameOffsetLabel(label, num); * } * parseState = ParseState.Frame; * } * public void dotReturn(String label) * { * Debug(".return"); * if (label != null) throw ParseError("A return statement can't have a Label?"); * * UInt64 size = tokenizer.GetUnsignedNumber(); * * if (!assembly.inFunction) throw ParseError(".return command must be in a func"); * assembly.currentFunction.SetReturnPointerSettings(false, (UInt32)size); * } * public void dotReturnTable(String label) * { * Debug(".returntable"); * if (label != null) throw ParseError("A return statement can't have a Label?"); * * UInt64 size = tokenizer.GetUnsignedNumber(); * * if (!assembly.inFunction) throw ParseError(".return-table command must be in a func"); * assembly.currentFunction.SetReturnPointerSettings(true, (UInt32)size); * } * * public void func(String label) * { * Debug("func"); * if (label != null) throw ParseError("A func command can't have a label"); * * assembly.NewFunction(); * * * parseState = ParseState.StartOfFrame; * } */ public void MOV(String label) { Debug("MOV"); if (!assemblyBuilder.inFunction) { throw ParseError("MOV Instruction must be in a func"); } OperandToken dstOperand = tokenizer.NextOperand(); Debug("DST : {0}", dstOperand); OperandToken srcOperand = tokenizer.NextOperand(); Debug("SRC : {0}", srcOperand); MemoryOp dstOp = dstOperand.GetMemoryOp(assemblyBuilder.currentFunction); Op srcOp = srcOperand.GetOp(assemblyBuilder.currentFunction); assemblyBuilder.currentFunction.AddInstruction(new InstructionMemoryOpAndOp(label, Instructions.Move, dstOp, srcOp)); }