ARM assembly mean filter Experiment

Source: Internet
Author: User

The experiment requires that the maximum minimum value be removed after sorting, and then the remainder is averaged.

Sorting can be sorted with previous bubbles, and the key question is averaging. Because ARM does not have division, how should the average be asked?

The simplest way is to subtract, use dividend to subtract the number, see how many times it can be reduced.

However, to round up, because the registers are integers, the remainder is compared to half of the divisor, and if it is greater than one, the less or equal is ignored

So the dividend plus half of the divisor (rounded down) and then recycled minus the number on the line.

Area example,code,readonly ENTRY MOV r2,r0loop_1 CMP r1,r0 BGE loop_3 ADD r1,r1,#1SUB r2,r2,#1MOV r3,#0LDR R4,=0X40000000B loop_2 loop_2 CMP r3,r2 BGE loop_1 ADD r3,r3,#1Ldr R5,[R4] Ldr r6,[r4,#4] ADD r4,r4,#4CMP r5,r6 BLS loop_2 SUB r4,r4,#4STR r5,[r4,#4] STR R6,[R4] ADD r4,r4,#4B loop_2 loop_3 LDR SP,=0X40000000MOV r2,#0STR r2,[sp] MOV r3,#4MUL r3,r0,r3 SUB r3,r3,#4STR R2,[sp,r3] MOV r3,#0MOV r4,#0MOV r5,#0B loop_4 loop_4 CMP r2,r0 BGE loop_5 LDR R3,[SP,R4] Add r5,r5,r3 add r4,r4,#4ADD r2,r2,#1B loop_4 loop_5 SUB r2,r0,#2; ADD r5,r2,lsr#1; divisor of half MOV r1,#0B loop_6 loop_6 CMP r5,r2 BLO loop_end ADD r1,r1,#1, put the number of R1 SUB r5,r5,r2 B loop_6 loop_end NOP END

ARM assembly mean filter Experiment

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.