You are on page 1of 14

FACULTY OF ELECTRICAL ENGINEERING

UNIVERSITI TEKNOLOGI MARA

MICROPROCESSOR SYSTEM
(ECE 521)
LAB 1: Intel 8051 CPU PROGRAMMING
DATA TRANSFER INSTRUCTIONS

PREPARED BY
1. MUAZ BIN ROSLAN

2015100085

2. ZAID AKMAL BIN AHMAD AKIBI

2015183309

3. MUHAMMAD NABIL FADHULLAH BIN JAAFFAR

2015115251

4. SHAHMIR BIN SHAHIBULLAH

2015141181

PREPARED FOR
SIR MD MAHFUDZ MD ZAN

INTRODUCTION
The process of writing program for the microcontroller mainly consists of giving instructions
(commands) in the specific order in which they should be executed in order to carry out a
specific task. As electronics cannot understand what for example an instruction if the push
button is pressed- turn the light on means, then a certain number of simpler and precisely
defined orders that decoder can recognize must be used. All commands are known as
INSTRUCTION SET. All microcontrollers compatible with the 8051 have in total of 255
instructions, i.e. 255 different words available for program writing.
The 8051 architecture provides many functions (central processing unit (CPU), random access
memory (RAM), read-only memory (ROM), input/output (I/O), interrupt logic, timer, etc.) in one
package. 8-bit arithmetic logic unit (ALU) and accumulator, 8-bit registers (one 16-bit register
with special move instructions), 8-bit data bus and 216-bit address bus/program counter/data
pointer and related 8/11/16-bit operations; hence it is mainly an 8-bit microcontroller.It has also
Boolean processor with 17 instructions, 1-bit accumulator, 32 registers (4 bit-addressable 8-bit)
and up to 144 special 1 bit-addressable RAM variables (18 bit-addressable 8-bit).

Figure 1 8051 Programming model


The Intel 8051 CPU have Accumulator A and B, 8 data registers, R0 to R7, Program Status
Word (PSW), status register (SR), Program Counter and Data Pointer as shown in Figure 1.All
registers are 8 bit except for the Program Counter and Data Pointer are 16 bit in length. The
data registers
are used to store information (data) within the Intel8051 CPU itself. Accumulator A is used for all
Arithmetic and logic instructions.

PROCEDURE

1. 30H into Accumulator A, 48H into RO and D8H into Rl were programmed and stored.
Then, result and data were recorded.
2. 2004H in DPTR were programmed. Then, result and data were recorded.
3. Data 21H into external memory location 2050H were written and programmed. Then,
result and data were recorded.
4. R5 were sent to logic 11010011B and programmed. Then, result and data were
recorded.
5. Data between RO and ACC A were exchanged and programmed. Then, result and data
were recorded.

RESULT

QUESTION 1
Write a program that will store 30H into Accumulator A, 48H into R0 and D8H into R1. Execute
the program and explain the differences in the results.

Program Coding

Value of A, R0 and R1

QUESTION 2
Write a program that will store 2004H in DPTR. Execute the program and comment on the
results.

Program Coding

Result that stored in DPH and DPL

QUESTION 3
Write and execute a program that will store data 21H into external memory location 2050H.
Explain the results.

Program Coding

Result

QUESTION 4
Write a program that will send logic 11010011B to R5. Execute the program and comment
on the results.

Program Coding

Result

QUSTION 5
Write a program that will exchange data between R0 and ACC A. Execute the program and
comment on the results.

Program Coding

Result
Before exchange

After exchange

DISCUSSION
Question 1

The data 30H,48H and D8H is load into the accumulator of A,R0 and R1. Each data is started
by command #. The value of A but without the command # is send to 30H, R0 will be insert
into 48H and R1 will be insert into D8H. The last line of our command will be END, thus the
program is completed. Without the END the program cannot run.

Question 2

DPTR 0, DPTR 1 are made of two 8-bit registers of DPH and DPL in each segment. DPTR does
not have a single internal address but DPH and DPL are each assigned an address of their own.
The value of 2004H cannot be stored in on single address. So the value is divided into two-8 bit
register that is 20(DPH) and 04(DPL).

Question 3

Data pointer consist of 16-bits data and this data pointer is used to transfer internal memory
data into external memory location. It is only accessible via indirect addressing (MOV A,@Ri)
and effectively overlays the directly addressable area. After run, go to virtual MCU and XDATA
memory and the data 21H will store into external memory location 2050H

Question 4

The data in binary number is convert into a hex number and store it in accumulator A. The data
is read from a memory location and send to another memory location.The 11010011B is in
binary form. Then it is stored as Hexadecimal, 11010011B = D3H in R5.

Question 5
Before exchange

After exchange

In this exercise, the instruction command that is translate as XCH will exchange the data from
the source and destination. As seen from the picture above, the data of A(20) is exchange with
R0(30).

CONCLUSION

As conclusion at the end of the laboratory works, we are able to write assembly
language programs for the Intel 8051 CPU using data transfer instructions and execute
the programs on the Intel 8051 IDE. The instructions used in the MCU 8051 IDE
software that required in this laboratory work are the most basic one and very straight
forward. Thus this helps students to understand and knows how to use them before
going further into this microprocessor system. From this program, we also able to learn
on how to exchange the data from internal to external memory location. Besides that,
the experiment or lab we work in can teach how to identify the instruction for program
and data transfer. This program also help the user to interpret and identified the output
of the program, know where the wrong command being used and change them with the
right one, and lastly understand how the program is running.

You might also like