“ARM inline Assembler”的版本间的差异
来自个人维基
free6d1823(讨论 | 贡献) |
free6d1823(讨论 | 贡献) |
||
第13行: | 第13行: | ||
register result (r2) = y | register result (r2) = y | ||
result = (value >> 1) | result = (value >> 1) | ||
+ | |||
+ | example: sets the current program status register of the ARM CPU. | ||
+ | <source lang="c"> | ||
+ | asm("msr cpsr,%[ps]" : : [ps]"r"(status)); | ||
+ | </source> | ||
+ | int status; | ||
+ | ps (r2) = status | ||
+ | cpsr = ps | ||
Referernce: http://www.ethernut.de/en/documents/arm-inline-asm.html | Referernce: http://www.ethernut.de/en/documents/arm-inline-asm.html |
2019年11月8日 (五) 11:46的版本
asm(code : output operand list : input operand list : clobber list);
example: Rotating bits example
int x;
int y;
y= (x>>1);
asm("mov %[result], %[value], ror #1" : [result] "=r" (y) : [value] "r" (x));
register value (r1) = x
register result (r2) = y
result = (value >> 1)
example: sets the current program status register of the ARM CPU.
asm("msr cpsr,%[ps]" : : [ps]"r"(status));
int status;
ps (r2) = status
cpsr = ps
Referernce: http://www.ethernut.de/en/documents/arm-inline-asm.html