|
发表于 2006-3-15 13:45:22
|
显示全部楼层
我取下来编译了:有两个错误:改为这样就好了:
- #define MEM_SIZE 15
- #define LOW_MEM 0x100000
- #define PAGING_MEM (MEM_SIZE*1024*1024)
- #define PAGING_PAGES (PAGING_MEM>>12)
- static unsigned char mem_map[PAGING_PAGES] = {0};
- unsigned long get_free_page()
- {
- register unsigned long __res asm("eax");
- __asm__ ("std; repne; scasb\n\t"
- "jne 1f\n\t"
- "movb $1, 1(%%edi)\n\t"
- "sall $12, %%ecx\n\t"
- "addl %2, %%ecx\n\t"
- "movl %%ecx, %%edx\n\t"
- "movl $1024, %%ecx\n\t"
- "leal 4092(%%edx), %%edi\n\t"
- "rep; stosl\n\t"
- "movl %%edx, %%eax\n"
- "1:"
- :"=a"(__res)
- :"0"(0), "i"(LOW_MEM), "c"(PAGING_PAGES),
- "D"(mem_map + PAGING_PAGES - 1)
- : "edx"
- );
- return __res;
- }
复制代码
1. 输入操作数为 0 不能空缺。
2. "edi", "ecx" 已经用在了 input output 部分不需要再列入 clobbered register 中。
clobbered register 主要是用在一段汇编代码会以隐含的方式改变某寄存器时,应列入其中。
From: info gcc :: C Extensions :: Extended Asm
- You may not write a clobber description in a way that overlaps with
- an input or output operand. For example, you may not have an operand
- describing a register class with one member if you mention that register
- in the clobber list. There is no way for you to specify that an input
- operand is modified without also specifying it as an output operand.
- Note that if all the output operands you specify are for this purpose
- (and hence unused), you will then also need to specify `volatile' for
- the `asm' construct, as described below, to prevent GCC from deleting
- the `asm' statement as unused.
复制代码 |
|