8051 assembly command Record.

Source: Internet
Author: User

There was a difference in the early 15, and now I'm back in the garden ... The work is busy on the one hand, another really long time did not engage these things.

Originally wanted to make a time-sharing operating system on the 8051 microcontroller, so read the next 8051 assembly under the Code, the summary record is as follows:

LJMP c:0149//long jump to 0x0149 address start execution command, this command is located at the 0x0000 address, is the first command.
MOV R0, #0x7F//Assign the immediate number to the R0 register
CLR A//current look is empty register A
MOV @R0, A//R0 as an address, assigning a value of 0 to its contents.
DJNZ r0,c:014c//If the R0 minus 1 is not 0, jump to the address of 014C to execute the command, now look at this command with the match on a command can easily complete the initialization of the specified memory segment, by Byte. However, the 0 address is not initialized at this time.
MOV SP, #0x17//sp is the stack pointer register, pointing to the top of the stack. Assigning the value of the 0x17 to the SP
LJMP c:0190//Jump to 0x0190 address to execute the command.
MOV DPTR, #0x028E//dptr is a 16-bit register that holds the address of the off-chip RAM.
CLR A//current look is empty register A
MOV R6, #0x01//Assign the immediate number to the R6 register
MOVC a,@a+dptr//MOVC is used to fetch data from ROM, a+dptr value as an address, and then assigns the stored value of this address to A
JZ c:0155//According to register (accumulator result, that is, a) flag bit determines jump result, for 0 jump, not 0 not jump.
INC DPTR//is the value of the DPTR register +1
MOV R7,a//assigns the value of a to R7
ANL A, #0x3F//and operation of the value and immediate number in register a, the result is saved in a
JNB 0xe0.5,01a9//e0 is the address of the ACC register, if the 5th bit of ACC is 0, jump 01a9 execution, otherwise the order is executed.
XCH A,R7//Swap values in a and R7
ANL A, #0xC0//and operation of the value and immediate number in register a, the result is saved in a
Add A,acc//a self-add operation
JZ c:0158//When a register is =0, jump to 0158 address to execute the command.
JC C:016A//Carry bit is 1 jump, otherwise do not jump
CLR A
MOVC a,@a+dptr//MOVC is used to fetch data from ROM, a+dptr value as an address, and then assigns the stored value of this address to A
INC DPTR//dptr+1
MOV R2,a//assigns a value to the R2 register
CLR A
MOVC a,@a+dptr
INC DPTR
MOV R0,a
CLR A
MOVC a,@a+dptr
INC DPTR
XCH a,r0
XCH A,DPL
XCH a,r0
XCH A,R2
XCH A,DPH
XCH R2
MOVX @DPTR, A

Feel the whole still did not understand this piece of code specifically to do. The above to understand a piece of code is the memory initialization, the following code to complete what function is really a little to understand.

But there was a good understanding of the assembly order, and no vain.

8051 assembly command Record.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.