.globl _start _start: b reset ldr pc, _undefined_instruction ldr pc, _software_interrupt ldr pc, _prefetch_abort ldr pc, _data_abort ldr pc, _not_used ldr pc, _irq ldr pc, _fiq _TEXT_BASE: .word TEXT_BASE .globl _armboot_start _armboot_start: .word _start .globl _bss_start _bss_start: .word __bss_start .globl _bss_end _bss_end: .word _end adr r0, _start /* r0 <- current position o...
by luo_hao - 内核/嵌入技术 - 2006-07-27 22:17:18 阅读(1098) 回复(1)
有两个arm asm文件,属于gnu asm语法,后缀为.S .加入project以后,可能被认为是intel 汇编,编译出错。 我看编译Rules里的编译器为Nasm,是不是应该改这个地方呢?还是别的方法?
int checksum_v1(int *data) { char i; //2nd time, "int" replaces "char" int sum = 0; for(i = 0; i < 64; i++) sum += data; return sum; } 上面这段代码,用arm-linux-gcc -S checksum_v1.c 反汇编一次; 然后讲int 代替char,再反汇编一次,将所得的两个文件比较了一下 1st: str r3, [fp, #-20] .L2: ldr r3, [fp, #-20] cmp r3, #63 ble .L5 b .L3 .L5: ldr r3, [fp, #-20] mov r2, r3, asl #2 ldr r3, [f...
请问代码中内嵌的汇编是什么意思,那里有文档可以看。 static __inline__ int atomic_sub_and_test (int i, atomic_t * v) { unsigned char c; __asm__ __volatile__ ("lock ; subl %2,%0; sete %1":"=m" (v->counter), "=qm" (c):"ir" (i), "m" (v->counter):"memory"); return c; }
vc 中的汇编代码 int a = 1, b = 2, c = 3; __asm { push a; push b; push c; pop b; pop a; pop c; } 转换成gcc的asm代码,要如何写?谢谢 [ 本帖最后由 okyzx 于 2007-2-3 23:23 编辑 ]
一个困扰许久的问题... vc 环境调试时可以查看每条语句的汇编代码 例如: 5: printf("hello,world!\n"); 00401028 push offset string "hello,world!\n" (0042001c) 0040102D call printf (00401060) 00401032 add esp,4 6: 7: return 0; 00401035 xor eax,eax gcc 中使用哪个选项可以生成 每条语句的对应汇编代码 ? $ gcc -S hello.c -o hello.s 好像只能生成汇编文件...
Intel VC 可以编译成功 [code]void toggleLed(unsigned char ledMask) { #define P2LTCH 0xFF5E /* The address of the I/O register. */ asm { mov dx, P2LTCH /* Load the address of the register. */ in al, dx /* Read the contents of the register. */ mov ah, ledMask /* Move the ledMask into a register. */ xor al, ah ...
一段代码想用gcc改写 源代码是这样的(intel语法) mov token, eax 我改写成这样的 __asm__ __volatile__ ( "movl %%eax, $0" : "=m"(token) : ); 不知道为什么还是有错 请教各位大牛.
我用gcc调试这个程序的时候会出错 提示内嵌汇编的那一行说:test.c:7: error: expected ‘)’ before ‘:’ token 请问这是怎么回事? /**/ int main (int _argc,char* _argv[]) { int * _p = (int*)_argc; (*_p) = 9999; _asm_ ("":::"memory"); if (* _p==9999) return 5; return (* _p); }
#define set_domain(x) \ do { \ __asm__ __volatile__( \ "mcr p15, 0, %0, c3, c0 @ set domain" \ : : "r" (x)); \ @能猜出来这部分代码的功能,但是有什么资料可以查到这中写法的规则吗?谢谢 } while (0)
C代码:
//foo.c
void foo(int m, int n)
{
printf("m=%d, n=%d\n", m, n);
}
int main()
{
int b = 3;
foo(b+=3, ++b);
printf("b=%d\n", b);
return 0;
}
上面c代码对应的汇编代码:
arm-linux-objdump foo.o
temp.o: file format elf32-littlearm
Disassembly of section .text:
00000000