Fifth test: The addition, subtraction, multiplication, division method of the single-chip microcomputer-51 Test Course of the single-chip microcomputer Assembly Language

Source: Internet
Author: User

I can see this question. A lot of people may need to hit the stone brother's board. What is the value of 7 + 5? How do you teach this? But in single-chip microcomputer, numbers are used

Binary representation: This is just a bit of a logging/

Even though we have not learned a command for teaching materials. However, I mean to do a few experiments first to increase your interest in single chip microcomputer.

There are too many specific commands, but it's okay. Generally, we only need to remember 10-20 commonly used commands.

OK. Start now.

We write the following two Commands

MoV P1, #23 h
End

This program we must understand, is the 23h hexadecimal number sent to P1 port (that is, P1.0--P1.7)

After Hex is compiled

Then insert the chip into the lab seat; you can see that the P1.0-1.7 status is;

P1.0 destroy

P1.1 destroy

P1.2 bright

P1.3 bright

P1.4 bright

P1.5 destroy

P1.6 bright

P1.7 bright

(Running photos of the Development Kit of relying on days)

 

Why?

Note: Because the eight lights at the P1 port are connected to positive 5 V at one end and port at one end, the port is 0 at a low level. Luminous tube bright. The height is not bright.

Sort from high to low (from 1.7 --- 1.0)

That is 00100011. The number is 23 h. What? You don't believe it?

Now, let's take a look! 00100011 binary is 100011. The preceding 0 is not counted according to the mathematical principle.

Open the computer program/attachment/calculator with me, and set the calculator as a scientific type. Then click binary and enter 100011

Then click hexadecimal to see that the number has changed to 23. This is the 23h we entered,

Exercise: 25 H + 36 h?

The procedure is as follows:

MoV r0, #25 h; send the number of 25 registers to R0 immediately

MoV A, #36 h; send 36 immediately to the accumulators

Add a, R0; Add the content of R0 and A, and the result is in

NOP; null operation

POV P1, A; send the value of the accumulators A to the P1 port.

End; End

Compile the program and then burn it into the film for running. The light status is displayed

P1.0 destroy

P1.1 destroy

P1.2 bright

P1.3 destroy

P1.4 destroy

P1.5 bright

P1.6 destroy

P1.7 bright

That is, the binary number is 01011011. Let's use the above calculator to see if the result is correct: Set the calculator to hexadecimal first, and enter

25 + 36 = 5E

Then click the binary result 1011110. The result is completely correct 〉

You can continue to exercise on your own.

Subtraction command subb

Multiplication command MUL

Division instruction Div

I believe that after studying this section, you will be very impressed with these commands. At the same time, we have

Profound Understanding.

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.