标签: ia16-gcc

扩展内联汇编中的约束“Rah”和“Ral”是什么意思?

这个问题的灵感来自另一个论坛上某人提出的问题。在以下代码中,扩展内联程序集约束RahRal含义是什么。我以前没见过这些:

#include<stdint.h>

void tty_write_char(uint8_t inchar, uint8_t page_num, uint8_t fg_color)
{
    asm (
        "int $0x10"
        :
        : "b" ((uint16_t)page_num<<8 | fg_color),
          "Rah"((uint8_t)0x0e), "Ral"(inchar));
}

void tty_write_string(const char *string, uint8_t page_num, uint8_t fg_color)
{
    while (*string)
        tty_write_char(*string++, page_num, fg_color);
}

/* Use the BIOS to print the first command line argument to the console */
int main(int argc, char *argv[])
{
    if (argc > 1)
        tty_write_string(argv[1], 0, 0);

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

特别是在这段代码中使用RahRal作为约束:

asm ( …
Run Code Online (Sandbox Code Playgroud)

x86 gcc inline-assembly x86-16 ia16-gcc

5
推荐指数
1
解决办法
148
查看次数

标签 统计

gcc ×1

ia16-gcc ×1

inline-assembly ×1

x86 ×1

x86-16 ×1