<p>There cannot be stricto sensu an equivalent of <code>asm</code>, because it is essentially for <em>compiled</em> languages (and <code>asm</code> is possible in C because C compilers emit assembler code!).</p>

<p>I have published in my <a href="https://arxiv.org/pdf/1109.0779.pdf" rel="nofollow noreferrer">DSL2011</a> paper a description of 
<em>MELT - a Translated Domain Specific Language Embedded in the GCC Compiler</em></p>

<p>I describ in that paper several traits which helps in generating C code from MELT (which is a Lisp-like language translated to C or C++).</p>

<p>But interpreted languages with a bytecode interpreter (e.g. Lua, Guile, Nim, Ocaml) provide hooks to add new primitives into that bytecode interpreter. Usually, the bytecode operation would be something like <em>invoke primitive#N with arguments arg1 arg2 arg3</em>.</p>

<p>You could implement your language (some DSL) as a translator to C. This is <a href="https://softwareengineering.stackexchange.com/a/257873/40065">usual practice</a>, and quite fun to do. You then code some "naive" compiler from your language to C. You could consider instead using some JIT-compiling library like <a href="https://gcc.gnu.org/onlinedocs/jit/" rel="nofollow noreferrer">libgccjit</a> or <a href="http://llvm.org/" rel="nofollow noreferrer">LLVM</a> or libjit or lightning or <a href="https://github.com/asmjit/asmjit" rel="nofollow noreferrer">asmjit</a>.</p>

<p>And some languages are <a href="https://github.com/asmjit/asmjit" rel="nofollow noreferrer">homoiconic</a>, they are then exposing somehow their bytecode or some good enough IR. Learn <a href="https://en.wikipedia.org/wiki/Lisp_(programming_language)" rel="nofollow noreferrer">Lisp</a> (at least read <a href="https://mitpress.mit.edu/sites/default/files/sicp/index.html" rel="nofollow noreferrer">SICP</a>) then read <a href="https://en.wikipedia.org/wiki/Lisp_in_Small_Pieces" rel="nofollow noreferrer"><em>Lisp In Small Pieces</em></a></p>

<p>Be aware of <a href="https://en.wikipedia.org/wiki/Greenspun%27s_tenth_rule" rel="nofollow noreferrer"><em>Greenspun's tenth rule</em></a>. Look into <a href="https://archive.fosdem.org/2018/schedule/event/alternative_histories/" rel="nofollow noreferrer"><em>The circuit less traveled</em></a> talk by Liam Proven at FOSDEM 2018.</p>
Is there any interpreted language exposing its bytecode (or any IR)
<p>I'm curious to know if any language exists that gives the programmer the possibility to 'emit' bytecode in the middle of the source code. To be more clear, is there any interpreted language that has a facility similar to the <code>asm</code> keyword for c/c++ ?  </p>