encyclopegia.org

Inline assembler

In computer programming, an inline assembler is a feature of some compilers that allows low-level code written in assembly language to be embedded within a program, among code that otherwise has been compiled from a higher-level language such as C or Ada.

In computer programming, an inline assembler is a feature of some compilers that allows low-level code written in assembly language to be embedded within a program, among code that otherwise has been compiled from a higher-level language such as C or Ada. include int syscall3(int num, int arg1, int arg2, int arg3) { int res = 0; asm ( "int $0x80" // make the request to the OS : "=a" (res), // return result in eax ("a") "+b" (arg1), // pass arg1 in ebx ("b") [as a "+" output because the syscall may change it] "+c" (arg2), // pass arg2 in ecx ("c") [ditto] "+d" (arg3) // pass arg3 in edx ("d") [ditto] : "a" (num) // pass system call number in eax ("a") : "memory", "cc", // announce to the compiler that the memory and condition codes have been modified "esi", "edi", "ebp" // these registers are clobbered [changed by the syscall] too ); // The operating system will return a negative value on error; // wrappers return -1 on error and set the errno global variable if (-125 // Compute the tangent of x real tan(real x) { asm { fld x[EBP] ; // load x fxam ; // test for oddball values fstsw AX ; sahf ; jc trigerr ; // C0 = 1: x is NAN, infinity, or empty // 387's can handle denormals SC18: fptan ; fstp ST(0) ; // dump X, which is always 1 fstsw AX ; sahf ; // if (!(fp_status & 0x20)) goto Lret jnp Lret ; // C2 = 1: x is out of range, do argument reduction fldpi ; // load pi fxch ; SC17: fprem1 ; // reminder (partial) fstsw AX ; sahf ; jp SC17 ; // C2 = 1: partial reminder, need to loop fstp ST(1) ; // remove pi from stack jmp SC18 ; } trigerr: return real.nan; Lret: // No need to manually return anything as the value is already on FP stack ; } The followed by conditional jump idiom is used to access the x87 FPU status word bits C0 and C2. stores the status in a general-purpose register; sahf sets the FLAGS register to the higher 8 bits of the register; and the jump is used to judge on whatever flag bit that happens to correspond to the FPU status bit.

References

No reference rows published for this article.

Cite this article

MLA

"Inline assembler." encyclopegia.org, 2026, https://encyclopegia.org/wiki/inline-assembler. Accessed 24 November 2026.

Chicago

"Inline assembler." encyclopegia.org. Accessed November 24, 2026. https://encyclopegia.org/wiki/inline-assembler.

APA

encyclopegia.org. (2026). Inline assembler. Retrieved November 24, 2026, from https://encyclopegia.org/wiki/inline-assembler

Accessed November 24, 2026 · CC BY-SA 4.0 · citation page · JSON

Related articles

Landskrona

enwiki · references available

Coachford

enwiki · references available

Comanche Moon

enwiki · references available

Courtmacsherry

enwiki · references available

Gothenburg Municipality

enwiki · references available

Dromod

enwiki · references available
CC BY-SA 4.0 · share-alike · https://en.wikipedia.org/w/index.php?oldid=1356350399 · 0.5 · snapshot enwiki-001356350399

Cite · JSON · Search

Related services and records

Services

  • Estate — measured countries, lanes and facts
  • Intel — live corroborated events
  • Legal — statutes, cases and citations
  • Encyclopedia — articles with inline sources
  • Space — launches, satellites and orbits
  • Search — federated search and reports
  • Pass — passport account and SSO
  • Corpora — read-only corpus origins
  • e01 — self-hosted corpora and tools

Text and metadata only; each target carries its own sources. Missing data is published as no-data, never estimated.