8051 asm program example




















Add a, r3 ; add reminder in new answer. Mov r0, a ; finally restore the content of r0. Statement 5: — transfer the block of data from 20h to 30h to external location h to h. Solution: — here we have to transfer 10 data bytes from internal to external RAM. So first, we need one counter. Then we need two pointers one for source second for destination. Mov r7, 0Ah ; initialize counter by 10d. Mov r0, 20h ; get initial source location. Mov dptr, h ; get initial destination location.

Nxt: Mov a, r0 ; get first content in acc. Movx dptr, a ; move it to external location. Inc r0 ; increment source location. Inc dptr ; increase destination location. Djnz r7, nxt ; decrease r7. Statement 6: — find out how many equal bytes between two memory blocks 10h to 20h and 20h to 30h. Solution: — here we shall compare each byte one by one from both blocks.

Increase the count every time when equal bytes are found. Mov r0, 10h ; get initial location of block1. Mov r1, 20h ; get initial location of block2. Mov r6, 00h ; equal byte counter. Starts from zero. Nxt: Mov a, r0 ; get content of block 1 in acc. Mov a, r1 ; get content of block 2 in acc. Cjne a, b, nomatch ; compare both if equal. Inc r6 ; increment the counter. Nomatch: inc r0 ; otherwise go for second number. Inc r1. Statement 7: — given block of h to h.

Find out how many bytes from this block are greater then the number in r2 and less then number in r3. Store the count in r4. Solution: — in this program, we shall take each byte one by one from given block. Now here two limits are given higher limit in r3 and lower limit in r2.

So we check first higher limit and then lower limit if the byte is in between these limits then count will be incremented. Mov dptr, h ; get initial location.

Op-codes in Assembly Language are called as Mnemonics. Op-codes are in binary format used in Machine Language while the Mnemonic which are equivalent to Op-codes are English like statements.

The second part of the instruction is called the Operand s and it represents the Data on which the operation is performed. The Source Operand is the Input of the operation and the Destination Operand is where the result is stored. The last part of the Structure of Assembly Language is the Comments. Comments are statements included by the developer for easier understanding of the code and is used for proper documentation of the Program.

The following statements will show a few possible ways of using Label, Instruction and Comments. Assembly Language Directives are not the instructions to the Microcontroller Assembler even though they are written in the Mnemonic field of the program. Assembly Language Directives are actually instructions to the Assembler and directs the Assembler Program what to do during the process of Assembling. We will now see about few of the important and frequently used Assembly Language Directives.

This is also the address from which the Microcontroller will start executing the code. Jump to MAIN. Keil provides following tools for development. C51 Optimizing C Cross Compiler,. A51 Macro Assembler,. Example generate a square wave of 10 Hz at pin P1. Example write a program to make 8 to 1 multiplexer with enable signal. Example take parallel input from port P1 convert it into serial and send it via P0. Example write a program to simultaneously transmit and receive data.

In this topic we learned how to interface LCD with microcontroller. LCD is used for displaying a different character, numbers or some message etc. There a 16 pins in LCD module. The LCD can be operating in 4bit or 8bit mode. First of all initialized the LCD. Data pins connected with port 2. In this tutorial we learned about how to interface the keypad using microcontroller. And also we learned about the programming part of the keypad.

In a keypad push button as a switches that arranged in row and columns. For best communicate and result displaying to connect the LCD with port 2 of microcontroller.

Keypad is connected to port 3 of microcontroller to scan the input. RS and Enable pin connect the port 1. In this topic we learned about the DC motor and how to interface with microcontroller. Directly connect the DC motor to microcontroller is not a good because the motor need more current else the microcontroller provide current. So to solve this problem we use a motor driver to interface with microcontroller. To solve the problem a motor driver IC is connected between DC motor and microcontroller.

In this topic we learned about the Stepper motor and how to interface with microcontroller. It has many applications in the field of robotics and mechatronics. The total rotation of the motor is divided into steps.

The angle of a single step is known as the stepper angle of the motor. This topic about the Servo motor, in this topic we learned how to interface and control servo motor using microcontroller. A servo motor is a mechanism that allows to control the angular position.



0コメント

  • 1000 / 1000