Can I write several Assembly instructions on one line?

Can I write several Assembly instructions on the same line as I can do with most high-level languages. Or does each assembler treat this function differently?

+4
source share
2 answers

Each assembler has its own syntax . Even Intel's syntax on x86 is actually not the same for different assemblers. Some examples

newline , , . GAS @ $ , , , . ;, , inc eax; int 3

('\n') "at" ('@'). [...] ('\n') ('!'). [...] ('\n'); ( H8/300) ('$'); ( Hitachi-SH H8/500) (';'). [...] ('\n') . ( ';', , . ", ".)

MASM , VARARG .

_ macro args:VARARG
   asm_txt TEXTEQU <>
   FORC char,<&args>
      IFDIF <&char>,<!\>
         STR asm_txt,<&char>
      ELSE
         asm_txt
         asm_txt TEXTEQU <>
      ENDIF
   ENDM
   asm_txt
endm

_ mov eax, -1 \ mov ebx, 2. : ?


, gcc, , , '\n'

asm("push rax\n\t" "mov rax, 0\n\t" "pop rax");

asm (: , )

asm("mov rbx, rax"); asm("xor rdx, rbx"); asm("mov rcx, 5");

, gas as ; , , gcc,

asm ...

AssemblerInstructions

, . , , . GCC , , .

asm, , . , , , ( \n\t). . , , .

https://gcc.gnu.org/onlinedocs/gcc-5.4.0/gcc/Basic-Asm.html


MSVC ; ,

__asm assembly-instruction [ ; ]
__asm { assembly-instruction-list } [ ; ]

__asm

__asm ​​ , :

__asm mov al, 2   __asm mov dx, 0xD007   __asm out dx, al

ARM RealView Assembler ; , :

++ ARM asm, ISO ++. , :

  • , :

    asm("instruction[;instruction]"); // Must be a single string asm{instruction[;instruction]}
    ...

  • , (;). , (").

+5

, . , . , , , .

-1

Source: https://habr.com/ru/post/1569271/


All Articles