Programming using assembly language, With M-IDE 51 Software

in #blog6 years ago

PROGRAMMING BASICS WITH SOFTWARE M-IDE 51

  1. Purpose

a. Praktikan can use M-IDE simulator as support in designing program.
b. Praktikan can use 8031/8051 microcontroller hardware resource for program simulation.

  1. Basic Theory
    Programming using assembly language (low level language) requires understanding of registers, including the name of each register of the controller chip used and the register structure itself. Physically, the workings of a microcontroller can be described as read instruction cycles stored in memory. The microcontroller determines the address of the program memory to be read, and performs the process of reading the data in memory.
    The read data is interpreted as an instruction. The address of the instruction is stored by the microcontroller in the register, known as the program counter. This instruction is for example an arithmetic program involving 2 registers. The tools in the assembly program are very minimal, unlike in the high level language programming language is ready for use. The author of the assembly program must determine everything, determine the location of the program it writes in program-memory, create constant data and constant tablel in the program-memory, create the working variables in the data-memory and so on.

The assembly-source program is a collection of command lines written with a simple text-editing program, such as an EDIT.COM program in DOS, or a NOTEPAD program in Windows or MIDE-51. The set of rows is typically stored into files with the name of the extension *. ASM and so on, depending on the Assembler program that will be used to process the assembly-source program.

AT89C51 Microcontroller is one type of high performance 8 bit CMOS microcontroller with low power dissipation, compatible with MCS-51 product. Then have a re-programming Flash Memory 4 Kbyte with 1000 times write / erase resistance.

Besides, there is Internal RAM with a capacity of 128 x 8 bits. And operating frequency up to 24 MHz. The microcontroller also has 32 1/0 ports that are divided into 4 ports with 8 lines 1/0, then there is also a serial port with full duplex serial control, two 16 bit timers / counters and an internal oscillator and timer circuit.

Each command-line is a complete command, meaning a command can not be split into more than one line. One command line can consist of 4 parts, the first part is recognized as a label or often also referred to as a symbol, the second part is identified as the operating code, the third part is

operand and last part is comment. Between these parts are separated by a space or tabulator.

a. Label

Labels are used to name a command-line, so it can be easy to debug it in program writing. Labels can name the corresponding row. The label section is often referred to as a symbol part, this happens if the label is not used to mark the part of the program, but used to mark the data section.

b. Section of the Operating Code

The operating code (operation code or often abbreviated as OpCode) is part of the command to be done. In this case known two kinds of operating code, the first is the code-operation to regulate the work of microprocessor / microcontroller. The second type is used to manage the work of the assembler program, often called the assembler directive. Code-operation is written in the form of mnemonic, ie form of abbreviations are relatively easy to remember, for example is MOV, ACALL, RET and so forth.
This code-operation is determined by the microprocessor / microcontroller manufacturer. The translation task is performed by a program called the Assembler Program. Outside the code-specified operation of the microprocessor / microcontroller manufacturer, there is also code-operation to manage the work of the assembler program, for example used to determine the location of the program in memory (ORG), used to form the variable (DS), forming tables and data constant (DB, DW) and so forth.

c. The operand part

The operand is a complement to the operating code section, but not all operating codes require an operand, so it can happen that a command line consists only of operation code without an operand. On the contrary there is also an operating code that needs more than one operand, in this case between the operand one with the other separated by a comma. The form operands vary widely, can be codes used to declare the register in the processor, can be memory-number ( memory address) expressed as a number or a label name, can be data ready for operation.

d. Comment section

The comment section is the program writer's notes, although this section is not absolutely necessary but it is very helpful documentation issue. Reading the comments on each command-line, it is easy to understand the intended purpose of the line, it is helpful to others who read the program. Separator comment section with previous section is a space or tabulator,

though the first letter of the comment is often a semicolon, a special separator for comment.
For the purposes of intense documentation, it is often a commentary line, in which case the first letter of the line is a semicolon. AT89S51 has a very complete set of instructions. MOV instructions for bytes are grouped according to addressing modes. The addressing mode describes how operands are operated. Here is an explanation of the various addressing modes. Common forms of assembly programs are as follows:

PROGRAMMING BASICS WITH SOFTWARE M-IDE 51 ()
The contents of memory is the hexadecimal number known by the microcontroller, which is a representation of the assembly language that has been created. Mnemonic or opcode is the code that will take action against the operand. Operand is data processed by opcode. An opcode may require 1, 2 or more operands, sometimes not necessarily operands. While comments can we provide by using a semicolon (;).

  1. List of Tools and Materials

a. 8051 Simulator (M-IDE 51)

b. PC / Laptop

  1. Safety

To carry out practicum Microprocessor and Embedded system is required steps for safety:
a. Before the practicum begins, each praktikan prepares the jobsheet.

b. Make sure the power cable connections on the computer are connected and no cables are open.
c. Make sure the computer connection with other equipment, such as keyboard and mouse are connected.

d. Turn on the computer, and wait until the operating system finish loading and can already be used.
e. Run only the M-IDE 51 program.

f. Type the program using the assembler editor on M-IDE.

g. Finish the practicum, turn off the computer and restore the keyboard and mouse in place.
h. Trim the chairs and other appliances, and clean the table from any paperwork.

  1. Work Steps

a. Open the software M-IDE 51, and will appear M-IDE 51 window as follows:
2.PNG

b. In this lab, the 8051 device will be used. To select a device, click on New, then choose Device> Select.
3.PNG

c. A Select Device window will appear, select 8051 and click Ok.
4.PNG
d. Then type the program as follows
5.PNG
e. After that, we can start trying to simulate the program as above. That is by choosing Build> Build and Sim or by pressing Shift + Ctrl + F9 on the keyboard, as shown below.
6.PNG
f. If there is no error, then Emulator window will appear as follows
7.PNG
8.PNG
g. Next, to execute the instructions from the code that has been typed one by one is by pressing the Step into next instruction (F11) below.
9.PNG
h. Then the existing instructions will run. That is LJMP, then mov R0, # 20 (assigns 20h to R0), then mov A, R0 (assigns R0 to A), then mov R1, # 20 (assigns 20h to R1), then ADD A , R1 (sums the value of R1 with A) and also mov R2, A (assigns A into R2).
10.PNG

  1. Addressing Data Table

By following the Work Step as mentioned. We can try by filling in another value. As with changing the values as in the following table below.
11.PNG

  1. Practical Questions

a. How to choose CPU that will be used.

b. Try to mention the sequence to be done to select the CPU registers A <PC <R0, R1, and R2.
c. What instruction is used to enter data directly into the register?
d. Why is the contents of register A and register R2 the same?

Answer:

a. To select a device, click on New, then choose Device> Select. Then select 8051 and click Ok.

b. In the UMPS program, to select CPU registers A, R0, R1, and R2 can be done with the following steps:

• Select Configure on the Menu

• Select CPU registers

• Next add the respective registers ACC, R0, R1, and R2 on the CPU register by pressing the ADD toolbar or click on the ADD.3 menu.

c. The instructions used are mov, # data
d. Since the contents of register A are moved to register R2 with mov r2, a.

  1. Analysis

From the above program, starting with the code of org 00h, which means at start from the starting point, then ljmp start, will do long jump to 16 bit after 00h. Then label start :. After that with the mov moves r0, # 20h, the 20h data is moved into r0 and r0 will be worth 20h. Then mov a, r0, that is to copy the value of r0 into A (accumulator) and will be the same value as r0 which is 20h. Then mov r1, # 20h same as r0, # 20h, then r1 will also be worth 20h. Then there is the instruction add a, r1. Which means summing the value on r1 to Accumulator.

  1. Conclusions

From the above practice, using M-IDE 51 makes it easy to learn assembly language to program the hardware. There are also various types of devices / devices available that can be used to program and simulate the desired microcontroller.

Coin Marketplace

STEEM 0.21
TRX 0.13
JST 0.030
BTC 67538.43
ETH 3518.61
USDT 1.00
SBD 2.81