Code Memory Read-Only Data Moves

Code Memory Read-Only Data Moves

Data moves between RAM locations and 8051 registers are made by using MOV and MOVX opcodes. The data is usually of a temporary or "scratch pad" nature and disap­pears when the system is powered down.

There are times when access to a preprogrammed mass of data is needed, such as when using tables of predefined bytes. This data must be permanent to be of repeated use and is stored in the program ROM using assembler directives that store programmed data anywhere in ROM that the programmer wishes.

Access to this data is made possible by using indirect addressing and the A register in conjunction with either the PC or the DPTR, as shown in Figure 3.2. In both cases, the number in register A is added to the pointing register to form the address in ROM where the desired data is to be found. The data is then fetched from the ROM address so formed and placed in the A register. The original data in A is lost, and the addressed data takes its place.

As shown in the following table, the letter C is added to the MOV mnemonic to high­light the use of the opcodes for moving data from the source address in the Code ROM to the A register in the 8051:

Mnemonic

Operation

MOVC A,@A+DPTR

Copy the code byte, found at the ROM address formed by adding A and the DPTR, to A

MOVC A,@A+PC

Copy the code byte, found at the ROM address formed by adding A and the PC, to A

Note that the DPTR and the PC are not changed; the A register contains the ROM byte found at the address formed.

The following table shows examples of code ROM moves using register and indirect addressing modes:

Mnemonic

Operation

MOV DPTR,#1234h

Copy the immediate number 1234h to the DPTR

MOV A,#56h

Copy the immediate number 56h to A

MOVC A,@A+DPTR

Copy the contents of address ͞1͞͞2͞8͞͞A͞h͞ to A

MOVC A,@A+PC

Copies the contents of address 4059h to A if the PC contained 4000h and A contained 58h when the opcode is executed.

CAUTION

The PC is incremented by one (to point to the next instruction) before it is added to A to form the final address of the code byte.

All data is moved from the code memory to the A register.

MOVC is normally used with internal or external ROM and can address 4K of internal or 64K bytes of external code.

Leave a comment

Your email address will not be published. Required fields are marked *