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