1

Is it possible to write a assembly and c code in possible? Lets say I want to copy a chunk of data from memory and before copying I want to disable all interrupts using assembly instruction. Another case may be that I want add subroutine written in assembly language.

Please let me know all the possible ways of doing this.

Vagish
  • 2,520
  • 19
  • 32
  • use `asm` block. http://msdn.microsoft.com/en-IN/library/45yd4tzz(v=vs.90).aspx http://asm.sourceforge.net/articles/rmiyagi-inline-asm.txt – Manoj Awasthi Aug 23 '13 at 05:27

2 Answers2

1

Yes you can, in C you can use the __asm__(...); code for in-lining assembly instructions directly into your compiled code.

An example: __asm__("movb %ch, (%ebx)");

Here's some documentation about it: http://www.codeproject.com/Articles/15971/Using-Inline-Assembly-in-C-C

Radnyx
  • 210
  • 2
  • 14
0

No, by the C standard you can't.

However there are compiler specific ways to do so. Check inline assembly for your compiler.

Or you can write the assembly you want to execute in separate .asm file as a function and then call it from C. However you will always have that call overhead.

On x64 there is no inline assembly. However there is one thing called intrinsics which allow you to do some things that C cannot.(They replace frequency used asm code)

You can read more about intrinsics here: http://msdn.microsoft.com/en-us/library/26td21ds.aspx

Nickie
  • 184
  • 2
  • 11