【问题标题】:operand type mismatch for `out', 'in''out'、'in' 的操作数类型不匹配
【发布时间】:2019-07-08 21:53:56
【问题描述】:

我有这个功能:

uint8_t getcmosflpd(void)
{
    uint8_t c;
    outb(0x70, 0x10);
    c = inb(0x70);
    return c;
}

当我编译它时,我得到这个错误:

/tmp/ccMmuD7U.s:28: Error: operand type mismatch for `out'
/tmp/ccMmuD7U.s:39: Error: operand type mismatch for `in'

这是我的 outb 和 inb 函数:

static inline void outb(uint16_t port, uint8_t val)
{
    asm volatile ("outb %0, %1" : : "a"(val), "Nd"(port));
}

static inline uint8_t inb(uint16_t port)
{
    uint8_t ret;
    asm volatile ("inb %1, %0"
                   : "=a"(ret)
                   : "Nd"(port));
    return ret;
}

怎么了?

【问题讨论】:

  • 编译器抱怨inout 但代码中提到过inboutb。你确定这些是编译器抱怨的行吗?
  • 谜团解开了,我正在用 -masm=intel 编译它... :facepalm:

标签: c osdev protected-mode


【解决方案1】:

我正在使用-masm=intel 进行编译。始终检查您的编译器标志!

【讨论】:

猜你喜欢
  • 2010-11-17
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2023-03-27
相关资源
最近更新 更多