Microcontroller programming: Find the maximum number and store it in the BIG unit

Publisher:blq0681Latest update time:2018-05-11 Source: eefocus Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

Microcontroller programming: Find the maximum number and store it in the BIG unit.
Assume that the internal RAM stores a group of unsigned numbers starting from the LIST unit, with the number of data being 30. Program to find the maximum number and store it in the BIG unit.
;----------------------------------------------------------------
Best answer:

The procedure is as follows:

    MOV BIG, #0
    MOV R0, #LIST
    MOV R2, #30
CHA:
    MOV A, @R0
    CJNE A, BIG, QQQ
QQQ:
    JC WWW
    MOV BIG, A
WWW:
    INC R0
    DJNZ R2, CHA
    SJMP $
END

;End 
;--------------------------------------------------------------------------------
=================================================================
Another question:

Microcontroller programming question is urgent!!! Experts please come in, I will give you points!!! 
Reward points: 20 | Solved time: 2010-4-11 21:41 |

1. Program the high 4 bits in the external data memory 2100H unit to be "1", and the rest of the bits to be "0"
2. Program the 0th and 7th bits in the internal data memory 40H unit to be "1", and the rest of the bits to be inverted.
Add comments, thank you
;----------------------------------------------------------------

Best answer:

1. Program the high 4 bits in the external data memory 2100H unit to "1" and the rest to "0"

MOV DPTR, #2100H ; set address
MOV A, #11110000B ; prepare digital
MOVX @DPTR, A ; send to external data memory 2100H unit

2. Program the 0th and 7th bits of the internal data memory 40H unit to "1" and invert the remaining bits.

MOV A, 40H
ORL A, #10000001B ; or, that is, adding according to the "bit"
XRL A, #01111110B ; using 1 XOR, equivalent to taking the inverse
MOV 40H, A

;----------------------------------------------------------------
Postscript:
The logic operation instructions of the 51 single-chip microcomputer can be directly performed on the RAM address on the chip.
Using this method, only two instructions are needed:

ORL 40H, #10000001B; or, that is, adding according to the "bit"
XRL 40H, #01111110B; using 1 XOR, which is equivalent to AND negation

. This method is too simple!
However, if it is for homework, I am afraid it will not work, because teachers all hope to solve it with stupid methods.


Reference address:Microcontroller programming: Find the maximum number and store it in the BIG unit

Previous article:Design a pulse generator with adjustable pulse width and duty cycle of 50% and 25%
Next article:MCU Programming: Find the average value of 8 unsigned numbers

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号