• Home
  • About
    • Seokmin.Lee photo

      Seokmin.Lee

      Hello, I am a master's student in the Department of Convergence Security (Samsung Advanced Security) at Korea University.After graduation, I am expected as a security developer or researcher member of Samsung SDS.

    • Learn More
    • LinkedIn
    • Github
  • Posts
    • All Tags

[assembly]inline assembly jump,loop

07 Mar 2021

  int i=0,  j=0;
         __asm__ __volatile__(
                  "movl $0, %0  \n\t"
                  "movl $0, %1  \n\t"
           ".Lp1 : "
                   "cmpl $9, %0 \n\t"
                   "jge .End \n\t"
                   "incl %0 \n\t"
        ".Lp2 : "
                   "cmpl $9, %1  \n\t"
                   "jl .Lp4 \n\t"
                   "movl $0,  %1 \n\t"
                   "jmp .Lp1 \n\t"
        ".Lp3 : "
                   "movl  %1, 4(%%esp) \n\t"
                   "movl  %0, (%%esp) \n\t"
                   "call  print \n\t"
                   "movl 4(%%esp), %1 \n\t"
                   "movl (%%esp), %0 \n\t"
                   "jmp .Lp2   \n\t"
        ".Lp4 : "
                   "incl %1   \n\t"
                   "jmp .Lp3 \n\t"
        ".End : "
                   "movl $0,  %0 \n\t"    //
                   :
                   :"r" (i), "r" (j)
          );

reference: http://home.konkuk.ac.kr/~cris/xe/?mid=sp_board&document_srl=3203



assemblycomputer-architecture Share Tweet +1