CN101625643B - Address mapping method of 8051 single chip - Google Patents

Address mapping method of 8051 single chip Download PDF

Info

Publication number
CN101625643B
CN101625643B CN2009100592304A CN200910059230A CN101625643B CN 101625643 B CN101625643 B CN 101625643B CN 2009100592304 A CN2009100592304 A CN 2009100592304A CN 200910059230 A CN200910059230 A CN 200910059230A CN 101625643 B CN101625643 B CN 101625643B
Authority
CN
China
Prior art keywords
address
add
seglen
cmd
space
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Expired - Fee Related
Application number
CN2009100592304A
Other languages
Chinese (zh)
Other versions
CN101625643A (en
Inventor
孙银明
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
IPGoal Microelectronics Sichuan Co Ltd
Original Assignee
IPGoal Microelectronics Sichuan Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by IPGoal Microelectronics Sichuan Co Ltd filed Critical IPGoal Microelectronics Sichuan Co Ltd
Priority to CN2009100592304A priority Critical patent/CN101625643B/en
Publication of CN101625643A publication Critical patent/CN101625643A/en
Application granted granted Critical
Publication of CN101625643B publication Critical patent/CN101625643B/en
Expired - Fee Related legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Landscapes

  • Microcomputers (AREA)

Abstract

The invention discloses an address mapping method of 8051 single chip, wherein the method is characterized in that: LCALL and LJMP instructions are analyzed from absolute address 0000H to the final address in program code one by one and the absolute address CMD_ADD of LCALL and LJMP operations is obtained; and then whether the absolute address exceeds the address range of a first section SEGLEN is judged, when CMD_ADD is equal to or more than SEGLEN, the address exceeds the range, and when CMD_ADD is less than SEGLEN, the address does not exceed the range; and when CMD_ADD exceeds the range of SEGLEN, CMD_ADD is modified into a first SEGLEN address space in integral multiple of section address space SEGLEN. The invention requires no support of hardware to realize address mapping; section size can not be fixed but can be flexibly configured according to system requirement; the quantity of section can not be fixed but can be flexibly configured according to the system requirement.

Description

A kind of 8051 single-chip microcomputer address mapping methods
Technical field
The present invention relates to digital consumption electronic product system, particularly a kind of 8051 single-chip microcomputer address mapping methods.
Background technology
The space, program address of 8051 series monolithics is 64KB (words), and the data address space also is 64KB.The general system that adopts 8051 single-chip microcomputers, the program space all is to be divided into two parts, a part be read-only be that ROM (Read OnlyMemory) is fixing immutable, be used to store important system start-up code; Another part be read-write be PRAM (Program Random Access Memory), data-carrier store RAM (Random Access Memory) is placed on the space, program address, the purpose of this part code is for the expansion of program and upgrading.In the System on Chip/SoC the inside, because the cost of PRAM is high more a lot of than ROM, it is smaller that the PRAM address space all can design.
Actual program code can be bigger than PRAM, so program code need be loaded among the PRAM several times and moves.Real program code is because big more a lot of than PRAM; Generally be stored in outside the System on Chip/SoC; In system operation time, is loaded among the PRAM piecemeal according to the flow direction of instruction and carries out, and can practice thrift expansion and upgrading that system cost also can realize program code easily like this.
For example the size of PRAM is 4KB, and actual program code space requirement 40KB so just need be divided into 10 4KB with program code, according to the ruuning situation of program, is loaded among the PRAM piecemeal and moves.
As shown in Figure 1, the address space of PRAM be fix be 1000H to 1FFFH, size also is fixedly to be 4KB (explain with the 4KB size that here actual can be any size, first 4KB is exactly first section so).The scope in space, program address is that 1000H is the 40KB address space to AFFFH, is divided into 10 sections.When system moves, can be according to the trend of program, every section 4KB is loaded among the PRAM one by one with 10 sections, moves for system.Here just problem has been arranged, in 10 section programs, had only the 1st section the address of address and PRAM the same; Be that 1000H is to 1FFFH; And follow-up 9 sections address is all high than PRAM, and its program directly is loaded into can not be moved among the PRAM, need be with its map addresses to 1000H to 1FFFH.
The hardware mapping method specifies as follows:
8051 space, program address is 64KB; 16 address wire ADD [15:0] are promptly arranged; The address wire of PRAM 4KB space requirement is ADD [0:11]; As long as remaining address wire ADD [15:12] is fixed as 0001H, 2000H just can be mapped to 1000H to the 1FFFH space piecemeal to the address space of AFFFH, and other sector addresses that are about to except that the 1st section all are mapped to the 1st sector address space 1000H to 1FFFH.
Though do the mapping that can realize the address like this, the program code in each section is loaded into the PRAM space can correct execution, does not exceed problem and do not go out current address.But hardware address is mapped with following defective:
1, needs hardware that some address wire is fixed, increase hardware spending, also bring risk to system;
2, the section size fixedly brought of hardware address is also fixing, and the section of adjustment is big or small as required, uses dumb;
3, the fixed number of the section fixedly brought of hardware address is used underaction;
In the system that does not have the mapping of hardware address line, can't use this segmentation loading method.
In 8051 order set, relate to several instructions of specific address, as: LCALL (long call instruction); LJMP (long jump instruction) etc.; LJMP with wherein is an example, and order format is LJMP 1000H (example), and this instruction just might jump to the another one section from a section; Promptly, just do not needed map addresses as long as guarantee the not address of the section of exceeding of similar specific address.The specific address here is meant to be reference with address 0000H only, and address realm is whole 64KB space; Relative address then is to be reference with the present procedure instruction address, and address realm is 2KB.Specific address is not easy control, is easy to exceed the address of a section, and relative address is controlled easily, as long as specific address is done map addresses, has just realized the effect of program address mapping.
In the time of system start-up, the 1st section is loaded into the PRAM space, because the 1st section address with PRAM all is that 1000H is to 1FFFH, so system's operation is no problem; After being loaded into the 2nd section program code among the PRAM, address space is just inequality, and promptly program might exceed 1000H to the 1FFFH space in the address, causes catastrophic effect.Key is that the address is indifferent in the instruction of 8051 major part, promptly at 1000H to 1FFFH or 2000H to 2FFFH, operation can, the instruction relevant with the address also is divided into two types: specific address and relative address.The scope of specific address is whole 64KB, and the scope of relative address is 2KB, so the present invention will be modified to the PRAM address space and realize map addresses relating to the operated address of absolute address instruction in the program space.
Summary of the invention
The present invention provides a kind of 8051 single-chip microcomputer address mapping methods for solving the problems of the technologies described above, and is specially adapted to 8051 systems, the defective that can avoid the hardware address mapping to bring.
Technical scheme of the present invention is following:
A kind of 8051 single-chip microcomputer address mapping methods; It is characterized in that: program code is analyzed LCALL and LJMP instruction (because having only the specific address that might surpass first segment limit that is only of these two instruction manipulations) one by one from specific address 0000H to a last address; And obtain the specific address CMD_ADD of LCALL and LJMP operation, judge then whether this specific address surpasses first section address realm SEGLEN:
If CMD_ADD>=SEGLEN, the address exceeds so;
If CMD_ADD<SEGLEN thinks that then the address does not exceed;
When CMD_ADD exceeds the SEGLEN scope, CMD_ADD is modified to first section SEGLEN address space according to the integral multiple of sector address space S EGLEN, i.e. the address space at PRAM place.Every section program code moves needed specific address space and can not surpass first section PRAM address space like this, and the program of each section can be loaded into the PRAM space and normally moves so, reaches the purpose of map addresses.
The formula of address modification is:
NEW_ADD=CMD_ADD-(N-1)*SEGLEN
Wherein, the specific address of instruction manipulation in the CMD_ADD representation program code, NEW_ADD is amended address, and N is the segment number at program code place, and every section size is SEGLEN.
In program code, replace original C MD_ADD at last, just realized map addresses with NEW_ADD.
Beneficial effect of the present invention is following:
The present invention can not need the support of hardware, realizes map addresses; Canned paragraph is not big or small, according to system's needs flexible configuration; The quantity of canned paragraph not is according to system's needs flexible configuration.
Description of drawings
Fig. 1 is the address space synoptic diagram of PRAM
Embodiment
A kind of 8051 single-chip microcomputer address mapping methods; Program code is analyzed LCALL and LJMP instruction one by one from specific address 0000H to a last address; And obtain the specific address CMD_ADD of LCALL and LJMP operation, judge then whether this specific address surpasses first section address realm SEGLEN:
If CMD_ADD>=SEGLEN, the address exceeds so;
If CMD_ADD<SEGLEN thinks that then the address does not exceed;
When CMD_ADD exceeds the SEGLEN scope, CMD_ADD is modified to first section SEGLEN address space according to the integral multiple of sector address space S EGLEN, i.e. the address space at PRAM place.Every section program code moves needed specific address space and can not surpass first section PRAM address space like this, and the program of each section can be loaded into the PRAM space and normally moves so, reaches the purpose of map addresses.
The formula of address modification is:
NEW_ADD=CMD_ADD-(N-1)*SEGLEN
Wherein, the specific address of instruction manipulation in the CMD_ADD representation program code, NEW_ADD is amended address, and N is the segment number at program code place, and every section size is SEGLEN.
In program code, replace original C MD_ADD at last, just realized map addresses with NEW_ADD.
For example: certain instruction manipulation specific address CMD_ADD is 2500H in the program code; Amended address is NEW_ADD; The segment number N at the program code place of this operation is the 2nd section, and every section big or small SEGLEN is 1000H, and the address space of first section PRAM is that 1000H is to 1FFFH.Because CDM_ADD has surpassed the address space of PRAM, need shine upon NEW_ADD and replace CMD_ADD, according to formula:
NEW_ADD=CMD_ADD-(N-1)*SEGLEN
CMD_ADD=2500H
SEGLEN?=1000H
N =2
Calculate NEW_ADD=1500H.
NEW_ADD is in PRAM address 1000H within the 1FFFH scope, can be in PRAM control operation.According to this formula, with definitely all revising of all instruction manipulations in this section, program code just can normally be carried out in the PRAM space so, has realized the software address mapping.
This method does not need the support of hardware address mapping, and N (hop count amount) and SEGLEN (section size) in can the flexible configuration formula, can in the system that did not use the sector address mapping, use yet, and has successfully solved the defective that hardware address shines upon.
Said method is applicable to 8051 order set.
For example: in 8051 control system of a hardware address mapping, the gross space size of program code is 64KB, is divided into 8 sections, and every section size is 8KB.Address space from 0000H to 1FFFH is read-only code ROM, the address space of the 1st section PRAM be 2000H to 3FFFH, the program code in follow-up 6 sector address spaces need be loaded into the PRAM space piecemeal and carry out.
Hardware circuit is fixed as 001H with the ADD [15:13] among 16 address wire ADD [15:0], just can not surpass the address space of PRAM so from the address that 16 address wires are sent, and promptly follow-up 6 sections program code can be loaded into the operation of PRAM address space.Though realized map addresses like this, need hardware circuit fixed address line, the size of section is also immutable with the quantity of section.
Use the method for software address mapping following:
Always having 6 sector addresses needs mapping, and the scope of N is 1 to 6, the big or small SEGLEN=2000H of section, so according to formula:
NEW_ADD=CMD_ADD-(N-1)*2000H
With N from 1 to 6; From code, find whole specific address CMD_ADD; Calculate the NEW_ADD that is used for replacing respectively, through map addresses piecemeal, just can be all surpass the specific address in PRAM space in the program code; All be mapped to the PRAM address space, thereby guarantee that every section program code can normally carry out in the PARM space.
In 8051 systems that do not consider sectional address mapping, because function increases and revises, need extender code address space, utilize this segmentation mapping method, also can successfully realize, get a desired effect, for example:
In one 8051 system, read-only program ROM address space be 0000H to 7FFFH, promptly size is 32KB.But the space of loading section PRAM be 8000H to 9FFFH, promptly size is 8KB.Owing to need the expanding system function to increase code; Can only be able to loading department increase; The 8KB address space of PRAM can hold any more too much function code so, does not have map addresses on the hardware yet, does not promptly consider to load respectively use with a plurality of 8KB program segments.The mapping method that this paper proposed so just can solve this problem.
The size of PRAM is 8KB, and this part address space can be as the address space (reality as required can be littler than 8KB) of first section SEGLEN.
Suppose only to use back 4KB space among the PRAM as SEGLEN, so first section address space be 9000H to 9FFFH, i.e. SEGLEN=1000H
Suppose that the program size after the interpolation function is 19KB; Be far longer than the 8KB space of PRAM; What need increase so is that the hop count of unit is (19KB-8KB)/4KB round numbers N=3 with SEGLEN; Add among the PRAM first section N=4 so, promptly except that original PRAM 8KB, need to increase by the section of 3 4KB.
Can obtain from above
SEGLEN=1000H
N =4
With the program code of 19KB according to formula:
NEW_ADD=CMD_ADD-(N-1)*SEGLEN
N from 1 to 4; From code, find whole specific address CMD_ADD; Calculate the NEW_ADD that is used for replacing respectively; Just can all be mapped to the SEGLEN address space, thereby guarantee that every section program code can normally carry out in the SEGLEN space all surpass the specific address in SEGLEN space in the program code.System when operation is that carry out in the SEGLEN space with the back 4KB that each section is loaded into PRAM respectively as required, just can hold the code above 8KB, successful solution this system problem.

Claims (2)

1. single-chip microcomputer address mapping method; It is characterized in that: program code is analyzed LCALL and LJMP instruction one by one from specific address 0000H to a last address; And obtain the specific address CMD_ADD of LCALL and LJMP operation, judge then whether this specific address surpasses the first sector address space S EGLEN:
If CMD_ADD>=SEGLEN, the address exceeds so;
If CMD_ADD<SEGLEN, then the address does not exceed;
When CMD_ADD exceeds the SEGLEN scope, CMD_ADD is modified to the first sector address space S EGLEN according to the integral multiple of sector address space S EGLEN;
The formula of said address modification is:
NEW_ADD=CMD_ADD-(N-1)*SEGLEN
Wherein, the specific address of instruction LCALL and LJMP operation in the CMD_ADD representation program code, NEW_ADD is amended address, and N is the segment number at program code place, and promptly said integral multiple is meant N-1 doubly, and every section size is SEGLEN.
2. according to the said a kind of 8051 single-chip microcomputer address mapping methods of claim 1, it is characterized in that: after the address modification, in program code,, realize map addresses with NEW_ADD replacement original C MD_ADD.
CN2009100592304A 2009-05-08 2009-05-08 Address mapping method of 8051 single chip Expired - Fee Related CN101625643B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN2009100592304A CN101625643B (en) 2009-05-08 2009-05-08 Address mapping method of 8051 single chip

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN2009100592304A CN101625643B (en) 2009-05-08 2009-05-08 Address mapping method of 8051 single chip

Publications (2)

Publication Number Publication Date
CN101625643A CN101625643A (en) 2010-01-13
CN101625643B true CN101625643B (en) 2012-01-04

Family

ID=41521499

Family Applications (1)

Application Number Title Priority Date Filing Date
CN2009100592304A Expired - Fee Related CN101625643B (en) 2009-05-08 2009-05-08 Address mapping method of 8051 single chip

Country Status (1)

Country Link
CN (1) CN101625643B (en)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103678187B (en) * 2012-09-11 2016-08-03 北京兆易创新科技股份有限公司 A kind of micro-control unit and control method thereof
CN109324838B (en) * 2018-08-31 2022-05-10 深圳市元征科技股份有限公司 Execution method and execution device of single chip microcomputer program and terminal

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6516400B1 (en) * 1998-06-30 2003-02-04 Sony Corporation Data storage, data processing system and method
CN1584824A (en) * 2003-08-18 2005-02-23 上海海尔集成电路有限公司 Microprocessor frame based on CISC structure and instruction realizing style
CN1707223A (en) * 2004-06-12 2005-12-14 杨建华 Indoor moving robot positioning system and method based on bar code

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6516400B1 (en) * 1998-06-30 2003-02-04 Sony Corporation Data storage, data processing system and method
CN1584824A (en) * 2003-08-18 2005-02-23 上海海尔集成电路有限公司 Microprocessor frame based on CISC structure and instruction realizing style
CN1707223A (en) * 2004-06-12 2005-12-14 杨建华 Indoor moving robot positioning system and method based on bar code

Also Published As

Publication number Publication date
CN101625643A (en) 2010-01-13

Similar Documents

Publication Publication Date Title
KR102592376B1 (en) Apparatus and method for controlling command execution operation
CN105144100A (en) Programmable CPU register hardware context swap mechanism
EP0167572A1 (en) Data processing system including memory hierarchy.
CN105103144A (en) Apparatuses and methods for adaptive control of memory
CN102364430A (en) Microcontroller for supporting multi-programming on one time programmable memory and programming method
CN101763273B (en) Method for dynamically loading code into extended memory of embedded type system
CN101625643B (en) Address mapping method of 8051 single chip
CN101872306A (en) Embedded system for realizing software updating and software backup and implementation method thereof
JP4665760B2 (en) Electronic computer, semiconductor integrated circuit, control method, program generation method, and program
CN102681819A (en) Method and device for realizing flexible and low-cost instruct replacement
CN114047952B (en) Processor and method for single chip microcomputer, single chip microcomputer and storage medium
JP6143841B2 (en) Microcontroller with context switch
CN102270181B (en) Memory access method and device
US6886159B2 (en) Computer system, virtual machine, runtime representation of object, storage media and program transmission apparatus
US7216189B2 (en) Single BIOS technique for supporting processors with and without 64-bit extensions
EP3323039B1 (en) A method for enlarging data memory in an existing microprocessor architecture with limited memory addressing
TWI446259B (en) Integrated circuit for executing external codes and method thereof
AU632542B2 (en) Ring reduction logic mechanism
JPH09505428A (en) Microcontroller with page address mode
JP6739689B1 (en) Programmable controller
US20050099877A1 (en) Single operation per-bit memory access
CN107145333B (en) Data operation method and device, application, single chip microcomputer and embedded system
JP6691884B2 (en) Computer and application management method
US11720352B2 (en) Flexible command pointers to microcode operations
JP2003303132A (en) Semiconductor memory control device

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
C14 Grant of patent or utility model
GR01 Patent grant
CF01 Termination of patent right due to non-payment of annual fee
CF01 Termination of patent right due to non-payment of annual fee

Granted publication date: 20120104

Termination date: 20180508