admin管理员组

文章数量:1302384

I am looking over a segment of code for starting a boot loader to load Linux.

static inline u16 ds(void)
{
    u16 seg;
    asm("movw %%ds,%0" : "=rm" (seg));
    return seg;
}

I believe that this is a way to write assembly inline into the c program. How does this translate to pure assembly? Is this formatting universal for x86/ARM architecture? Is this another abstraction of real assembly to an architecture independent expression?

From what I understand, this instruction moves the word in the regester zero (0) to some place.

Either 1. The ds register.

or 2. Into the address stored in the ds register.

Or does it do something else entirely? What is the meaning of two % before ds?

本文标签: linuxBoottime assembly code architecture specificStack Overflow