相关疑难解决方法(0)

asm in C"'mov'的内存引用太多了"

我看过关于同样错误的帖子,但我仍然得到错误:

 too many memory references for `mov'
 junk `hCPUIDmov buffer' after expression
Run Code Online (Sandbox Code Playgroud)

...这是代码(mingw compiler/C :: B):


    #include iostream

    using namespace std;

    union aregister
    {
        int theint;
        unsigned bits[32];
    };

    union tonibbles
    {
        int integer;
        short parts[2];
    };

    void GetSerial()
    {
        int part1,part2,part3;
        aregister issupported;
        int buffer;

        __asm(
            "mov %eax, 01h"
            "CPUID"
            "mov buffer, edx"
        );//do the cpuid, move the edx (feature set register) to "buffer"


        issupported.theint = buffer;
        if(issupported.bits[18])//it is supported
        {
            __asm(
                "mov part1, eax"
                "mov %eax, 03h"
                "CPUID" …
Run Code Online (Sandbox Code Playgroud)

c assembly

8
推荐指数
2
解决办法
3万
查看次数

在 .intel_syntax GNU C 内联汇编中引用内存操作数

使用内联汇编编译和链接源文件时,我发现链接错误。

以下是测试文件:

via:$ cat test.cxx
extern int libtest();
int main(int argc, char* argv[])
{
    return libtest();
}

$ cat lib.cxx
#include <stdint.h>
int libtest()
{
    uint32_t rnds_00_15;    
    __asm__ __volatile__
    (
        ".intel_syntax noprefix         ;\n\t"
        "mov DWORD PTR [rnds_00_15], 1  ;\n\t"
        "cmp DWORD PTR [rnds_00_15], 1  ;\n\t"
        "je  done                       ;\n\t"
        "done:                          ;\n\t"
        ".att_syntax noprefix           ;\n\t"
        :
        : [rnds_00_15] "m" (rnds_00_15)
        : "memory", "cc"
    );

    return 0;
}
Run Code Online (Sandbox Code Playgroud)

编译和链接程序会导致:

via:$ g++ -fPIC test.cxx lib.cxx -c
via:$ g++ -fPIC lib.o test.o -o test.exe
lib.o: …
Run Code Online (Sandbox Code Playgroud)

c++ gcc linker-errors inline-assembly intel-syntax

3
推荐指数
1
解决办法
1209
查看次数

x86-64 操作数的汇编顺序

x86-64汇编中操作数的顺序是什么?:指令目标,源或:指令源,目标

我有三本书和两种不同的方法!

assembly x86-64 att intel-syntax

3
推荐指数
1
解决办法
1207
查看次数

如何从内联asm访问C结构/变量?

请考虑以下代码:

    int bn_div(bn_t *bn1, bn_t *bn2, bn_t *bnr)
  {
    uint32 q, m;        /* Division Result */
    uint32 i;           /* Loop Counter */
    uint32 j;           /* Loop Counter */

    /* Check Input */
    if (bn1 == NULL) return(EFAULT);
    if (bn1->dat == NULL) return(EFAULT);
    if (bn2 == NULL) return(EFAULT);
    if (bn2->dat == NULL) return(EFAULT);
    if (bnr == NULL) return(EFAULT);
    if (bnr->dat == NULL) return(EFAULT);


    #if defined(__i386__) || defined(__amd64__)
    __asm__ (".intel_syntax noprefix");
    __asm__ ("pushl %eax");
    __asm__ ("pushl %edx");
    __asm__ ("pushf");
    __asm__ ("movl %eax, …
Run Code Online (Sandbox Code Playgroud)

c x86 freebsd clang inline-assembly

2
推荐指数
1
解决办法
1813
查看次数

标签 统计

assembly ×2

c ×2

inline-assembly ×2

intel-syntax ×2

att ×1

c++ ×1

clang ×1

freebsd ×1

gcc ×1

linker-errors ×1

x86 ×1

x86-64 ×1