0% found this document useful (0 votes)
1K views

Experiment 1 Familiarization With The Edsim51 Simulator and The 8051 Instruction Set

The document describes an experiment using the EdSim51 simulator to familiarize students with its operation and the 8051 instruction set. It discusses loading and running programs using the simulator's IDE and observing the effect on registers and peripherals. Students are guided through examples of basic data transfer and arithmetic instructions, exploring the instruction set, and observing flag settings in the PSW register.

Uploaded by

DefinitelyNotCy
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
1K views

Experiment 1 Familiarization With The Edsim51 Simulator and The 8051 Instruction Set

The document describes an experiment using the EdSim51 simulator to familiarize students with its operation and the 8051 instruction set. It discusses loading and running programs using the simulator's IDE and observing the effect on registers and peripherals. Students are guided through examples of basic data transfer and arithmetic instructions, exploring the instruction set, and observing flag settings in the PSW register.

Uploaded by

DefinitelyNotCy
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

EXPERIMENT 1

FAMILIARIZATION WITH THE EdSim51 SIMULATOR AND THE 8051


INSTRUCTION SET

Learning Objectives:
1. Demonstrate how the EdSim51 simulator works.
2. Apply the basic operating commands of the EdSim51 simulator.
3. Understand/use the instruction set of 8051.
4. Demonstrate how the 8051 Microcontroller works with different I/O interfaces.

DISCUSSION

The EdSim51 simulator allows the students to write assembly language programs using the
8051instruction set. The simulator also allows debugging of codes, going through each line of
code, and observing the effect of each line to the internal memory and the external peripheral.

Different virtual I/O peripherals were interfaced with the simulator. At the bottom panel of
Figure 1, virtual peripherals that are interfaced with the 8051 Microcontroller are demonstrated.
Some of these virtual peripherals are LEDs, switches, seven-segment displays (SSD), a DOT
matrix, a keypad, a DC motor, among others.
IDE

LEDs

SWITCHES

FIGURE 1
DC MOTOR
LCD
SEVEN-SEGMENT DISPLAY

The top left box is the microcontroller panel which gives the student access to all of the
8051's registers, data memory and code memory. The upper middle part is the integrated
development environment (IDE) or the assembly code panel where the user either loads an
https://www.edsim51.com/index.html

assembly program or writes the code directly. The top right box displays the list of the 32
port pins, the current value of the port pin, and what each is connected to.

FIGURE 2

Figure 2 demonstrates the microcontroller panel. Boxes in white can be edited directly,
while boxes in grey, cannot. The content of the Data Memory can be altered manually by
entering the address at the blue box (below the Modify RAM), and the corresponding value
at the white box (right side of the blue box). By default, Data Memory is displayed. To
switch to Code Memory, click the button named Data Memory. Only the first 127 bytes of
code memory are displayed. To view beyond the 127 byte, use the blue box to enter the
th

starting address. Changing the starting address to be displayed in the code memory will
affect the machine code and the assembly program.

Registers are used to store information temporarily. The accumulator Acc is used for
arithmetic and logic operations. The register B is used as an extra hand for Acc, especially
during multiplication and division. Registers R0 to R7 are the general-purpose registers.
These general-purpose registers cannot be used as a destination in any arithmetic operation.
Data pointer register (DPTR) is a 16-bit register and is divided into two. The DPL is the

https://www.edsim51.com/index.html

low byte, while DPH is the higher byte of the DPTR. The Instruction Pointer (IP) and the
Program Counter (PC) are both 16-bit registers. These two are both responsible for
pointing to an address of the next instruction to be fetched and executed.

FIGURE 3

Figure 3 shows the mnemonic form of each instruction and their corresponding addresses.
The machine code equivalent (operation code-op code) of each mnemonic form is stored
in the code memory. The operand, which are normally in hexadecimal form, are stored in
the data memory.

https://www.edsim51.com/index.html

The 8051 instruction set is grouped into four: Data Transfer (MOV, PUSH, POP),
Arithmetic Operations (ADD, SUB, INC, DEC, MUL, DIV), Logical Operations (ANL,
ORL, XRL, CLR), and Program Branching (LCALL, RET, LJMP, JNZ, JZ, NOP). Always
remember that the value in the data movement instruction should be within 0 to 0FFH or 0
to 255 in decimal.

PSW is 8-bit register that handles the flags and is located at address D0 (hover the mouse
pointer to the PSW to see RAM location of each register). The carry flag (CY), auxiliary
carry flag (AC), overflow flag (OV), parity flag (P) are the existing flags in the 8051
Microcontroller. Flags are affected after each execution of an arithmetic or logical
instruction. For example, Add and Subb instructions both affect the carry flag (CY),
overflow flag (OV), and auxiliary carry flag (AC). RS1 and RS0 in the PSW are used for
register bank selection. Tables 1 and 2 below show the corresponding register bank
selections. Changing the selection corresponds to RAM location changes. If the values of
RS0 and RS1 were not changed, by default they are at 00 setting.

TABLE 1

TABLE 2

PROCEDURE

PART I. – FAMILIARIZATION WITH THE SIMULATOR


1. Launch the EdSim51DI simulator.
2. Click new in the EdSim51DI IDE.
3. Click New and encode the following instructions at the IDE (integrated development
environment). The starting address 0000H.: Note: this is case sensitive.

ORG 0000H;initializing the starting address of the program
MAIN: ;start of the main program
CLR A ;clear the content of register Accumulator
MOV A, #19H ;loading the register Accumulator with 19H

https://www.edsim51.com/index.html

MOV R6, #09 ;loading the register B with decimal 09


MOV R0, A ;copy contents of A into register R0
END ;end of the program

ORG 0000H is used to initialize the starting address of the program. For normal operation, you
should start at address 0000H. MAIN is just a name or label given to the program. CLR A
makes sure that the register accumulator content is 00. MOV A, #19H loads the hexadecimal
value 19 to register accumulator. MOV R6, #09 loads the decimal value 09 to register R6.
MOV R0, A copies the contents of register A into register R0. END ends the whole program.
For additional information about the instruction set of 8051, refer to this link
http://www.keil.com/support/man/docs/is51/is51_opcodes.htm.

4. To speed up the output. Click Update Frequency (Update Freq.). For this program,
choose 1.
5. To save your program. Click Save. Use any filename in saving your program.
6. Assemble the program. Click Assm.
7. To observe the output. Click Run. Answer Q1.
8. To pause the execution. Click Pause.
9. To stop program execution. Click RST.
10. Click Assm.
11. To execute the program line per line. Click Step.
12. Observe the content of the registers at the left side of the simulator.
13. Click Pause.
14. To encode, edit, and debug the program. Click RST.
15. Add the instruction MOV R5, #256 after MOV R0, A.
16. Click Save.
17. Click Assm.
18. Click Run. Answer Q2.
19. Click RST. Add the following into the encoded program (after MOV R0, A)
a. Use register B to store 3CH.
b. Add the content of registers A and B.
c. Store the result (sum) in register A.
20. Click Save.
21. Click Assm.
22. Click Run. Answer Q3, Q4, and Q5.

PART II. – EXPLORING THE 8051 INSTRUCTION SET
1. Click new in the EdSim51DI IDE.
2. Encode the following at the starting address 0000H.
ORG 0000H ;initializing the starting address of the program
MAIN: ;start of the main program
CLR A ;clear the content of register Accumulator
MOV R5, #35H ;loading the register R5 with 35H
MOV R7, #45H;loading the register R7 with 45H
MOV A, #0 ;loading the register Accumulator with decimal 0
ADD A, R5 ;adding the contents of Accumulator and register R5. Destination is A.
ADD A, R7 adding the contents of Accumulator and register R7. Destination is A.
ADD A #27H adding the contents of Accumulator to value 27H. Destination is A.

https://www.edsim51.com/index.html

END ;end of the program

3. Click Save. Use a different filename.


4. Click Assm.
5. Click Run. Answer Q1-II.
6. Answer Q2-II and Q3-II.
7. Check the PSW value. Answer Q4-II.
8. Repeat steps #1 and #2 and encode the following instructions:
MOV R0, #50H ;loading the register R0 with 50H
MOV R1, #60H ;loading the register R1 with 60H
MOV R2, #70H ;loading the register R2 with 70H
MOV R7, #80H ;loading the register R7 with 80H
MOV R5, #90H ;loading the register R5 with 90H
9. Click Save. Use a different filename.
10. Change PSW to 18H.
11. Click Assm.
12. Click Run. Answer Q5-II (TABLE 4)
13. Click Pause.
14. Click RST.
15. Change PSW to 10H.
16. Click Save.
17. Click Assm.
18. Click Run. Answer Q5-II (TABLE 5)

https://www.edsim51.com/index.html

You might also like