2

我正在使用ARM/Cortex-A8 处理器平台。

我有一个简单的函数,我必须将两个指针传递给一个函数。这些指针稍后在只有我的内联汇编代码的那个函数中使用这个计划只是为了实现性能。

function(unsigned char *input, unsigned char *output)
{
     // What are the assembly instructions to use these two pointers here?
     // I will inline the assembly instructions here
}

main()
{
    unsigned char input[1000], output[1000];

    function(input, output);
}

谢谢

4

1 回答 1

4

假设您使用的是普通的 ARM ABI,这两个参数将传入R0R1。这是一个快速示例,展示了如何将字节从input缓冲区复制到output缓冲区(gcc 语法):

.text
.globl _function

_function:
   mov  r2, #0        // initialize loop counter
loop:
   ldrb r3, [r0, r2]  // load r3 with input[r2]
   strb r3, [r1, r2]  // store r3 to output[r2]
   add  r2, r2, #1    // increment loop counter
   cmp  r2, #1000     // test loop counter
   bne  loop
   mov  pc, lr
于 2010-09-09T16:21:46.753 回答