私の割り当てでは、数値の配列をとり、それをARMアセンブリに入れて2の補数を実行して、それを表示のためにもう一度出力します。私は仕事のほとんどを行うことができましたが、出力は正しく動作していないと私に伝えます。ARMのプログラミングでは、入力配列をクリアするために配列とmallocを出力しますか?
Cコード:
#include <stdio.h>
int * comp(int a[], int size) ;
void main(int argc, char * argv[])
{
int array[] = { 1, -1, 252, -252, 0, 3015 } ;
int size = sizeof(array)/sizeof(int) ;
int * result ;
int i ;
result = comp(array, size) ;
printf("Original Complement\n") ;
for(i = 0 ; i < size ; i++)
printf("%d %d\n", array[i], *(result+i)) ;
}
ARMアセンブリ:
AREA |comp$code|, CODE, READONLY ; tell the assembler stuff
IMPORT malloc ; import malloc to be used
EXPORT comp ; tell the assembler to show this label to the linker
comp ; the label defining the entry point
stmfd sp!, {v1-v6, lr} ; standard entry
str v1, [a1] ; copy a1 over to v1
str v2, [a2] ; copy a1 over to v1
bl malloc ; clears pointer for new array
loop
ldr a4,[v1],#4 ; start going through loop starting at top or array
mvn a4, a4 ; ones complement
add a4,a4,#1 ; make it 2's complement
str a4,[a1], #4 ; move back into the array
subs v2, v2, #1 ; set a flag for the end of the loop
bne loop ; start again for the next value in the array
ldmfd sp!, {v1-v6, pc} ; puts all registers back into the caller
END
出力:
はOriginal Complement
0 -442500552
-1 -442500552
252 0
-252 0
0 0
3015 0
は、誰も私がなぜその私に与えて、このようなめちゃくちゃ出力
を把握することができます
あなたが選択した変更を行う出力の違いはありませんでしたが、あなたの応答に感謝します。 – NaGeLxZ