In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-14 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly introduces the "ARM how to use assembly to judge the positive and negative numbers in the array" related knowledge, Xiaobian through the actual case to show you the process of operation, the method of operation is simple and fast, practical, hope that this "ARM how to use assembly to judge the positive and negative numbers in the array" article can help you solve the problem.
[ARM assembly] how to determine the positive and negative numbers in an array? Write at the front:
In many algorithms, if statements must be used to judge. We mentioned arrays earlier and practiced traversing arrays using the assembly loop framework, but when we use arrays, it is impossible to just iterate through arrays and find the sum of them. When we do some other operations on the array, we need to use the judgment statement, so what is the judgment statement in the assembly?
All judgment suffixes
In x86, we can only add a judge after the jump instruction `"B "`, while in ARM we can add a judgment flag after any instruction.
For all the judgment suffixes, I marked the commonly used ones in red:
Let's take a look at today's problem.
How to use assembly to judge the number of positive and negative numbers in an array?
In the assembly language, the basic framework of the program is unchanged, we have written the framework of loops before, here we can directly post the positive traversal program, and then we think about how to use the judgment suffix to separate the positive and negative numbers in the array, to judge the number and to sum separately.
1. Prepare 1.1 to be expressed in C pseudo code before compilation.
First, use C language to realize this function, so that it is easy to clarify the idea of realizing the function.
C language code:
# includeint main () {int ary [10] = {0recollection 1, 2, 2, 3, 4, 5, 6, 7, 8, 9}; int sum1=0,sum2=0, I; int zonal 0, 0; for (I = 0; I)
< 10; i++) { if(ary[i]>0) {zroomzroom1; sum1 = sum1 + ary [I];} else if (Ary1)
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.