Exemple #1
0
        private bool AssignAddresses(AssemblyCode code, Section startupSection, List <AssembleError> errorList, out uint ramBottomWordAddress)
        {
            ramBottomWordAddress = 0;

            //Assign address of instructions
            {
                if (startupSection != null)
                { //From section marked as startup
                    AssignAddressForSectionInstruction(startupSection, ref ramBottomWordAddress);
                }
                for (int sectIdx = 0; sectIdx < code.Sections.Count; sectIdx++)
                {
                    Section sect = code.Sections[sectIdx];

                    if (sect == startupSection)
                    {
                        continue;
                    }

                    AssignAddressForSectionInstruction(sect, ref ramBottomWordAddress);
                }
            }

            //Assign address of variables
            {
                //Read-only variables
                foreach (var e in code.VariableAnalyzeResult.Readonlys)
                {
                    AddressSymbolInfo placeInfo = new Interface.Assemble.AddressSymbolInfo()
                    {
                        MemoryNumber = 0,
                        Address      = new Misc.AddressRange()
                        {
                            From = ramBottomWordAddress,
                            To   = ramBottomWordAddress
                        }
                    };
                    ramBottomWordAddress += 1;

                    e.PlacedInfo = placeInfo;
                }

                //Read-write variables
                foreach (var e in code.VariableAnalyzeResult.Readwrites)
                {
                    AddressSymbolInfo placeInfo = new Interface.Assemble.AddressSymbolInfo()
                    {
                        MemoryNumber = 0,
                        Address      = new Misc.AddressRange()
                        {
                            From = ramBottomWordAddress,
                            To   = ramBottomWordAddress
                        }
                    };
                    ramBottomWordAddress += 1;

                    e.PlacedInfo = placeInfo;
                }
            }

            return(true);
        }
        private bool AssignAddresses(AssemblyCode code, int startupSectionIndex, List <AssembleError> errorList, out uint ramBottomByteAddress, out uint instructionByteSize)
        {
            ramBottomByteAddress = 0;
            instructionByteSize  = 0;

            //Assign address of instructions
            {
                if (startupSectionIndex >= 0)
                { //From section marked as startup
                    AssignAddressForSectionInstruction(code, startupSectionIndex, ref ramBottomByteAddress);
                }
                for (int sectIdx = 0; sectIdx < code.Sections.Count; sectIdx++)
                {
                    if (sectIdx == startupSectionIndex)
                    {
                        continue;
                    }

                    Section sect = code.Sections[sectIdx];
                    AssignAddressForSectionInstruction(code, sectIdx, ref ramBottomByteAddress);
                }
            }
            instructionByteSize = ramBottomByteAddress;

            //Alignment
            if (ramBottomByteAddress % 4 != 0)
            {
                ramBottomByteAddress += 4 - (ramBottomByteAddress % 4);
            }

            //Assign address of variables
            {
                //Read-only variables
                foreach (var e in code.VariableAnalyzeResult.Readonlys)
                {
                    AddressSymbolInfo placeInfo = new Interface.Assemble.AddressSymbolInfo()
                    {
                        MemoryNumber = 0,
                        Address      = new Misc.AddressRange()
                        {
                            From = ramBottomByteAddress,
                            To   = ramBottomByteAddress
                        }
                    };
                    ramBottomByteAddress += 1 * 4;

                    e.PlacedInfo = placeInfo;
                }

                //Read-write variables
                foreach (var e in code.VariableAnalyzeResult.Readwrites)
                {
                    AddressSymbolInfo placeInfo = new Interface.Assemble.AddressSymbolInfo()
                    {
                        MemoryNumber = 0,
                        Address      = new Misc.AddressRange()
                        {
                            From = ramBottomByteAddress,
                            To   = ramBottomByteAddress
                        }
                    };
                    ramBottomByteAddress += 1 * 4;

                    e.PlacedInfo = placeInfo;
                }
            }

            return(true);
        }