Realizing Bit Logic Operations Using Single Chip Microcomputer

Publisher:psi33Latest update time:2018-05-09 Source: eefocusKeywords:MCU Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

Write a program to complete the following logical functions:


Q = XYZ\F + XY\ZF + X\YZF + XYZF (\Y means Y is not, \Z means Z is not, etc.)


This logical expression can be simplified to: Q = XYZ + XYF + XZF


Assume that the pins corresponding to each variable are as follows:


X: P1.0

Y: P1.1

Z: P1.2

F: P1.3

Q: P1.7



The procedure is as follows:


MOV C, P1.0

ANL C, P1.1

ANL C, P1.2

MOV F0, C

MOV C, P1.0

ANL C, P1.1

ANL C, P1.3

ORL C, F0

MOV F0, C

MOV C, P1.0

ANL C, P1.2

ANL C, P1.3

ORL C, F0

MOV P1.7, C


END



=============================


MCU: Please write a program to implement the XOR operation of bit X and bit Y.


2010-10-12 22:03 The Invincible Chinese | Category: Other Programming Languages ​​| Views: 1546


Assume X and Y are stored at 00H and 01H respectively, and the result is that Z is stored at 02H.

(Note: 00H, 01H, 02H are bit addresses, belonging to D0, D1, D2 of internal RAM20H)


    CLR 02H

    MOV C, 00H

    ANL C, 01H

    JC _END_

    MOV C, 00H

    ORL C, 01H

    JNC _END_

    SETB 02H


_END_:


;over


END


=============================


Microcontroller: Please write a program to implement the XOR operation of bit X and bit Y.


Assume X and Y are stored in 00H and 01H respectively, and the result is that Z is stored in 02H.


Note: 00H, 01H, 02H are bit addresses, belonging to D0, D1, D2 of internal RAM20H


method 1:

;

    MOV C, 00H

    ANL C, /01H

    MOV F0, C

    MOV C, 01H

    ANL C, /00H

    ORL A, F0

    MOV 02H, C


END


;-----------------------


Method 2:

;

    CLR 02H

    JNB 00H, ZZZ

    JNB 01H, EXIT

    SJMP EXIT

ZZZ:

    JB 01H, EXIT

    SETB 02H

EXIT:


END


;-----------------------


Method 3:

;

    MOV A, 20H

    R R

    XRL A, 20H

    RL A

    RL A

    ANL A, #00000100B

    JZZZ

    ORL 20H, A

    SJMP EXIT

ZZZ:

    CPL A

    ANL 20H, A

EXIT:


END


;-----------------------


Keywords:MCU Reference address:Realizing Bit Logic Operations Using Single Chip Microcomputer

Previous article:Very amazing microcontroller program
Next article:Microcontroller assembly language programming: square root of the content in A

Recommended ReadingLatest update time:2024-11-16 03:48

Solution to power supply problem of MCU based on SE8510
1. Design of flyback isolated power supply based on SE8510 Figure 1 is the schematic diagram of the SE8510 flyback isolated power supply system. The SE8510 is an offline isolated primary-side controlled flyback LED driver control IC. The SE8510 uses a rugged high-voltage isolation process that can withstand an input v
[Power Management]
Solution to power supply problem of MCU based on SE8510
Design of human-computer interaction system with C8051F020 microcontroller as the control core
In the development of various modern instruments, human-computer interaction functions are playing an irreplaceable role. Instruments with friendly human-computer interaction interface will be easier to operate and use, thereby improving work efficiency. Liquid crystal displays (LCDs) have the characteristics of low p
[Microcontroller]
Design of human-computer interaction system with C8051F020 microcontroller as the control core
How is ADC done within an MCU?
What are the advantages of STM32? Apart from the publicity, a careful analysis shows that the STM32 clock is not fast, 72MHZ, and it cannot expand large-capacity RAM FLASH, nor does it have a powerful instruction set like DSP. What are its advantages? ---It’s about quickly collecting data and quickly processing it.
[Microcontroller]
How is ADC done within an MCU?
Simple calculator based on 51 single chip microcomputer proteus simulation digital tube display
hardware design Simulation diagram: Digital tube display, supports integer addition, subtraction, multiplication and division, but does not support decimals, negative numbers and continuous operations; (Result of 20x3 and 20÷3) programming //***********************************************************************
[Microcontroller]
Simple calculator based on 51 single chip microcomputer proteus simulation digital tube display
AT89S52 MCU simulates I2C bus protocol to read and write AT24C04
      The I2C bus is a 2-wire bus. The data line is SDA and the clock line is SCL. The structure is simple.        AT24C04 is an EEPROM with an I2C bus interface. The size is 512*8 bits. The MCU AT89S52 itself does not have an I2C bus interface, so a program can be written to use the parallel port to simulate the I2C
[Microcontroller]
How to transplant UCOSII to 51 microcontroller
1. Preparation work 1. Development environment: Keil C integrated development environment 2. Source code: The source code of UCOSII can be downloaded online. 3. Document analysis: 1) Processor-independent files in UCOSII files: OS_CORE.C OS_FLAG.C OS_MBOX.C OS_MEM.C OS_MUTEX.C OS_Q.C OS_SEM.C OS_TASK.C OS_TIME.C UCOS_
[Microcontroller]
How to transplant UCOSII to 51 microcontroller
51 single chip microcomputer controls the dynamic display program of digital tube
Description: Drive the four-digit digital tube to dynamically display numbers, which can be easily transplanted to other programs. For example: 1. To change the hardware to a three-digit or two-digit digital tube, just modify the COM number of the Display_Scan() function. 2. In this example, a common cathode digital
[Microcontroller]
Design of monitoring system for series lithium-ion battery pack based on single chip microcomputer
This paper introduces a monitoring system for series lithium-ion battery packs with a 51 series single-chip microcomputer as the main control unit. Differential amplifiers and analog switches are used to detect the voltage of single cells in turn, and the IO interface of the single-chip microcomputer and DS18B20 are u
[Power Management]
Design of monitoring system for series lithium-ion battery pack based on single chip microcomputer
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号