private void AssignAddressForSectionInstruction(AssemblyCode code, int sectionIndex, ref uint ramBottomByteAddress)
        {
            var sect = code.Sections[sectionIndex];

            for (int instrIdx = 0; instrIdx < sect.AllInstructions.Length; instrIdx++)
            {
                Instruction            instr       = sect.AllInstructions[instrIdx];
                InstructionAnalyzeInfo analyzeInfo = InstructionAnalyzeInfos[sectionIndex][instrIdx];

                //Alignment (If needed)
                if (analyzeInfo.NeedToAlign && (ramBottomByteAddress % 4) != 0)
                {
                    ramBottomByteAddress += 4 - (ramBottomByteAddress % 4);
                }

                //Assign
                instr.PlacedInfo.MemoryNumber = 0;
                instr.PlacedInfo.Address      = new Misc.AddressRange()
                {
                    From = ramBottomByteAddress,
                    To   = ramBottomByteAddress + (uint)analyzeInfo.LengthInHalfWord * 2 - 1
                };

                //Update
                ramBottomByteAddress += (uint)analyzeInfo.LengthInHalfWord * 2;

                //This process is not necessary
                for (int oprIdx = 0; oprIdx < instr.Operands.Length; oprIdx++)
                {
                    instr.Operands[oprIdx].PlacedInfo.MemoryNumber = 0;
                    instr.Operands[oprIdx].PlacedInfo.Address      = instr.PlacedInfo.Address;
                }
            }
        }
        private bool AnalyzeInstructionType(AssemblyCode code, List <AssembleError> errorList)
        {
            InstructionAnalyzeInfos = new InstructionAnalyzeInfo[code.Sections.Count][];

            for (int sectIdx = 0; sectIdx < code.Sections.Count; sectIdx++)
            {
                var sect = code.Sections[sectIdx];
                InstructionAnalyzeInfos[sectIdx] = new InstructionAnalyzeInfo[sect.AllInstructions.Length];

                for (int instrIdx = 0; instrIdx < sect.AllInstructions.Length; instrIdx++)
                {
                    var instr = sect.AllInstructions[instrIdx];

                    int type;
                    if (!InstructionAssembler.SearchAssemblerType(instr, out type, errorList))
                    {
                        return(false);
                    }
                    InstructionAnalyzeInfos[sectIdx][instrIdx].Type = type;

                    int  length;
                    bool needToAlign;
                    if (!InstructionAssembler.EstimateInstructionLength(instr, type, out length, out needToAlign, errorList))
                    {
                        return(false);
                    }
                    InstructionAnalyzeInfos[sectIdx][instrIdx].LengthInHalfWord = length;
                    InstructionAnalyzeInfos[sectIdx][instrIdx].NeedToAlign      = needToAlign;
                }
            }

            return(true);
        }