Comparison of 51 MCU C and assembly instructions

Publisher:koimqerolulkLatest update time:2016-09-22 Source: eefocus Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
1. Single instruction comparison:

Byte Operations

 

Addition instruction

Subtraction Instructions

Multiplication Instructions

Division Instructions

Modulo instruction

Bit Test Instructions

_testbit_ (bit);

Left shift instruction

Variable = Variable << 1;

Right shift instruction

Variable = Variable >> 1;

Bit Invert Instruction

AND instruction

OR instruction

XOR instruction

Subroutine call

RESULT=BYTESUB(ARG1, ARG2);

CALL BYTESUB

Judgment Instructions

CJNE R1,#0F0H,LABEL1

DJNZ R1,LABEL1

Table Lookup Instructions

RESULT = NUM[index];

MOVC A,@A+DPTR

Pointer operation instructions

POINT = & NUM;

RESULT = *POINT

 

2. Pseudo-instructions

Start Instructions

 

Interrupt entry vector

void timer0(void)interrupt 1 using 1

Variable definitions

Register Definition

unsigned char code tab[]={0x01,0x02,0x03,0x04};

 

3. Differences in program calls

Unsigned char BYTESUB(ARG1,ARG2)   //input ARG1,ARG2;output the result

{

}

……

RESULT=BYTESUB(ARG1,ARG2);

……

CALL BYTESUB

……

;INPUT: A,B

;OUTPUT: A

4. Differences in interrupt handling:

void timer0(void)interrupt 1 using 1 // Enable TC0 interrupt, interrupt number 1, use register group 1.

{

}

                     ORG 0BH

                     LJMP TC0ISR

TC0ISR:

Reference address:Comparison of 51 MCU C and assembly instructions

Previous article:Calling the 4*4 matrix keyboard module program
Next article:Research on 51 MCU Soft Mode PWM Error Rate

Recommended ReadingLatest update time:2024-11-16 13:40

“TMS320xF24xx to C2000™ Piccolo™ TMS320F280xx
Introduction The Texas Instruments (TI) TMS320xF24xx family of DSPs was introduced in 1997 as the first devices in the C2000™ product family. They are widely regarded as the first DSPs with on-chip flash and integrated CAN controllers. Features of the TMS320xF24xx include 16 PWM outputs for multi-axis motor c
[sensor]
“TMS320xF24xx to C2000™ Piccolo™ TMS320F280xx
51 MCU serial communication program, support custom protocol
The microcontroller source program is as follows: #include"reg52.h" /*51 serial port communication by boiling ice/no struggle, no life*/ typedef unsigned int u16; typedef unsigned char u8; #define Data_SIZE 7 //Data length stored in RevBuf array == uart_Data_SIZE-2 #define uart_Data_SIZE 5 //Actual length of the prot
[Microcontroller]
S3C2410 clock part summary
The clock part is relatively easy. Now let's sort it out according to the ideas in the datasheet. 1. Basic understanding of clock    The seventh part is "clock & power management", which is summarized as follows: 1 The clock & power management module of s3c2410 consists of three parts: clock control, usb control, and
[Microcontroller]
PIC18 serial bootloader in C language and PC serial communication program with bootloader in C# language
  New PIC18 Bootloader   PhsBoot_v3.0 is my latest PIC bootloader implemented in C language, using serial communication, suitable for PIC18, and I wrote a PC communication program PhsLoader_v3.0 for it in C#. PhsLoader_v3.0 sends data to PhsBoot_v3.0 through the serial port according to the custom communication prot
[Microcontroller]
Memory type and S3C2440 startup address
Preface This article records the S3C2440 startup address and various memory types 1. Memory type The mind map is as shown in the figure: 2. Explore the S3C2440 startup address 1. Why is the nand startup address 4096? Instruction: ldr sp, = 4096 Because the nand controller of S3C2440 will automatically move the f
[Microcontroller]
Memory type and S3C2440 startup address
Basic use of s3c2440 serial port
How to write UART program? 1. Serial port initialization Step 1: Set the pin ① Set the pins for the serial port. GPH2, 3 for TX0, RX0 Clear the bit, then set ② Set TX0 and RX0 internal pull-up, that is, configure the GPHUP register step2: Set baud rate (UBRDIV0) — 115200 == PCLK = 50MHz = UBRDIV0 = 26 ① Set UCON0 - Se
[Microcontroller]
51 MCU - External Interrupt 0 (INT0)
What is the register for? How to configure it? What is the purpose of configuring the register?  The register is a component of the central processing unit. It is a high-speed storage component with limited storage capacity. They can be used to temporarily store instructions, data and addresses. Registers can be used
[Microcontroller]
51 MCU Tutorial from Scratch—— 29 MCU Music Programming
Design of music program using single chip microcomputer Using a single-chip microcomputer (or single-board computer) to play music is probably one of the issues that radio enthusiasts are interested in. This article starts with the basic experiment of single-chip microcomputers, discusses the design pri
[Microcontroller]
51 MCU Tutorial from Scratch—— 29 MCU Music Programming
Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号