ARM汇编程序代码,用于在表中查找未配对的值

时间:2015-01-14 13:58:36

标签: assembly arm

我在ARM上的dcd表中有一组整数。它们都出现了偶数次,但是我试图获得仅出现一次的唯一数字。下面是我在ARM中的算法。



; I understand why it doesn't work obviously, but I just can't figure out better code

        AREA ExOdd1, CODE
		ENTRY
		
		LDR r1, =TABLE1
		MOV r2, #17
		MOV r6, r2
LOOP	LDR r3, [r1], #4 
		B LOOP2
		SUBS r2, r2, #1
		BNE LOOP

LOOP2	LDR r4, [r1], #4  
		CMP r4, r3
		BNE LOOP2
		EOREQ r5, r3, r4
		CMP [r1], #33
		BNE LOOP2

STOP	B STOP

TABLE1	DCD 10, 5, 10, 2, 5 ,95, 33, 95, 33, 10, 95, 33, 2, 10, 95, 2, 33

		END




1 个答案:

答案 0 :(得分:1)

        AREA ExOdd1, CODE
        ENTRY

        LDR r1, =TABLE1
        MOV r2, #17
LOOP    LDR r3, [r1], #4 
        EOR r4, r4, r3
        SUBS r2, r2, #1
        BNE LOOP

STOP    B STOP

TABLE1  DCD 10, 5, 10, 2, 5 ,95, 33, 95, 33, 10, 95, 33, 2, 10, 95, 2, 33
; the DCD directive just allocates all the
; needed memory locations for the values
; listed afterwards
; each value is stored in the next memory word.
        END