Advertisement
heinrich23

funcptrtest.asm

Nov 15th, 2022
3,555
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.48 KB | None | 0 0
  1. .file "funcptrtest.c"
  2. .text
  3. .globl b
  4. .section .rodata
  5. .align 4
  6. .type b, @object
  7. .size b, 4
  8. b:
  9. .long 23
  10. .align 8
  11. .LC0:
  12. .string "Value of a (%d) is lesser then value of b (%d)\n"
  13. .align 8
  14. .LC1:
  15. .string "Value of a (%d) is equal value of b (%d)\n"
  16. .align 8
  17. .LC2:
  18. .string "Value of a (%d) is greater than value of b (%d)\n"
  19. .text
  20. .globl fun
  21. .type fun, @function
  22. fun:
  23. .LFB0:
  24. .cfi_startproc
  25. endbr64
  26. pushq %rbp
  27. .cfi_def_cfa_offset 16
  28. .cfi_offset 6, -16
  29. movq %rsp, %rbp
  30. .cfi_def_cfa_register 6
  31. subq $16, %rsp
  32. movl %edi, -4(%rbp)
  33. movl $23, %eax
  34. cmpl %eax, -4(%rbp)
  35. jge .L2.L2:
  36. movl $23, %eax
  37. cmpl %eax, -4(%rbp)
  38. jne .L4
  39. movl $23, %edx
  40. movl -4(%rbp), %eax
  41. movl %eax, %esi
  42. leaq .LC1(%rip), %rax
  43. movq %rax, %rdi
  44. movl $0, %eax
  45. call printf@PLT
  46. jmp .L5
  47. .L2:
  48. movl $23, %eax
  49. cmpl %eax, -4(%rbp)
  50. jne .L4
  51. movl $23, %edx
  52. movl -4(%rbp), %eax
  53. movl %eax, %esi
  54. leaq .LC1(%rip), %rax
  55. movq %rax, %rdi
  56. movl $0, %eax
  57. call printf@PLT
  58. .L2:
  59. movl $23, %eax
  60. cmpl %eax, -4(%rbp)
  61. jne .L4
  62. movl $23, %edx
  63. movl -4(%rbp), %eax
  64. movl %eax, %esi
  65. leaq .LC1(%rip), %rax
  66. movq %rax, %rdi
  67. movl $0, %eax
  68. call printf@PLT
  69. jmp .L5
  70. .L4:
  71. movl $23, %eax
  72. cmpl %eax, -4(%rbp)
  73. jle .L5
  74. movl $23, %edx
  75. movl -4(%rbp), %eax
  76. movl %eax, %esi
  77. leaq .LC2(%rip), %rax
  78. movq %rax, %rdi
  79. movl $0, %eax
  80. call printf@PLT
  81. .L5:
  82. nop
  83. leave
  84. .cfi_def_cfa 7, 8
  85. ret
  86. .cfi_endproc
  87. .LFE0:
  88. .size fun, .-fun
  89. .globl main
  90. .type main, @function
  91. main:
  92. .LFB1:
  93. .cfi_startproc
  94. endbr64
  95. pushq %rbp
  96. .cfi_def_cfa_offset 16
  97. .cfi_offset 6, -16
  98. movq %rsp, %rbp
  99. .cfi_def_cfa_register 6
  100. subq $32, %rsp
  101. movl %edi, -20(%rbp)
  102. movq %rsi, -32(%rbp)
  103. movl $0, -12(%rbp)
  104. leaq fun(%rip), %rax
  105. movq %rax, -8(%rbp)
  106. movl $23, %edx
  107. movq -8(%rbp), %rax
  108. movl %edx, %edi
  109. call *%rax
  110. movl $1, -12(%rbp)
  111. jmp .L7
  112. .L8:
  113. movl -12(%rbp), %eax
  114. movq -8(%rbp), %rdx
  115. movl %eax, %edi
  116. call *%rdx
  117. addl $11, -12(%rbp)
  118. .L7:
  119. cmpl $100, -12(%rbp)
  120. jle .L8
  121. movl $0, %eax
  122. leave
  123. .cfi_def_cfa 7, 8
  124. ret
  125. .cfi_endproc
  126. .LFE1:
  127. .size main, .-main
  128. .ident "GCC: (Ubuntu 11.3.0-1ubuntu1~22.04) 11.3.0"
  129. .section .note.GNU-stack,"",@progbits
  130. .section .note.gnu.property,"a"
  131. .align 8
  132. .long 1f - 0f
  133. .long 4f - 1f
  134. .long 5
  135. 0:
  136. .string "GNU"
  137. 1:
  138. .align 8
  139. .long 0xc0000002
  140. .long 3f - 2f
  141. 2:
  142. .long 0x3
  143. 3:
  144. .align 8
  145. 4:
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement