Talk:Inline Assembly/Examples: Difference between revisions

From OSDev.wiki
Latest comment: 13 years ago by Love4boobies
Jump to navigation Jump to search
Content added Content deleted
mNo edit summary
No edit summary
Line 19: Line 19:
}</pre>
}</pre>
--[[User:Quok|quok]] 19:17, 2 May 2009 (UTC)
--[[User:Quok|quok]] 19:17, 2 May 2009 (UTC)

I see some problems with this article:
:1. It only provides GCC inline assembly.
:2. It uses GCC-specific extensions although the "inline" keyword was introduced in C99.
:'''3. More importantly, everything here is more suited as a macro than inline assembly. It is important to understand that "inline" is just a compiler hint and may be ignored entirely as far as optimizations go (and probably will). The only thing one can be sure of is that a pointer to the function cannot be obtained.'''
:4. I/O support is directly supported in C (TR 1169).
It would be nice if someone explained why this article is neccessary.
--[[User:Love4boobies|Love4boobies]] 05:44, 10 March 2011 (UTC)

Revision as of 05:44, 10 March 2011

Rolled back edit by imate900 that added the following lgdt function, which is wrong for many reasons. I just did not have time to fix the example yet.

void *lgdt(void *gdt, int entries)
{
 struct { unsigned short *length, void *base } gdtr_t;
 gdtr_t *gdtr;
 gdtr.length = entries;
 gdtr.base = gdt;
 asm("lgdt (%0)": : "p" (&gdtr));
 asm("mov %ax, 0x10");
 asm("mov %ds, %ax");
 asm("mov %es, %ax");
 asm("mov %fs, %ax");
 asm("mov %gs, %ax");
 asm("mov %ss, %ax");
 goto fix_cs;
fix_cs:
 return;
}

--quok 19:17, 2 May 2009 (UTC)Reply[reply]

I see some problems with this article:

1. It only provides GCC inline assembly.
2. It uses GCC-specific extensions although the "inline" keyword was introduced in C99.
3. More importantly, everything here is more suited as a macro than inline assembly. It is important to understand that "inline" is just a compiler hint and may be ignored entirely as far as optimizations go (and probably will). The only thing one can be sure of is that a pointer to the function cannot be obtained.
4. I/O support is directly supported in C (TR 1169).

It would be nice if someone explained why this article is neccessary. --Love4boobies 05:44, 10 March 2011 (UTC)Reply[reply]