Advertisement
Guest User

Notes_Assemblyx64

a guest
Sep 23rd, 2017
837
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. .text
  2. # CONSTANTS
  3.  
  4. MYNAME:    .string    "Melvin\n"
  5. FORMATD:   .string    "%s" # %d: numbers | %s: for text
  6.  
  7. .global main
  8.  
  9. main:
  10.     enter $0,$0        #   Boilerplate: preserve caller bp and init callee bp
  11.    
  12.     movq  $FORMATD, %rdi # 1st argument: FORMAT DIGIT
  13.     movq  $MYNAME, %rsi  # 2st argument: Melvin
  14.     call  printf       # C printf(%rdi: %d, $MYNAME: "Melvin")
  15.  
  16.     xor   %rdi, %rdi   #   set the return code to magic num
  17.     leave              #   Boilerplate: set the bp back to what it was for our fellow caller, and reset our sp to the top of it's stackframe and this line is getting prettylong    
  18.    call  exit         # C exit(%rdi)
  19.  
  20. # movq $andy, %rip
  21.  
  22. ################MEMORY##################
  23. ### STACK
  24.  
  25. # The Lgenedary Caller
  26. # --- # 0xffffff72: 13    <--- %rbp
  27. #       0xffffff64: 24    
  28. # --- # 0xffffff56: 35
  29.  
  30. # We, the callee
  31. # --- # 0xffffff48: 0xffffff72     <--- %rsp
  32. #       0xffffff40: 0x69    
  33. # --- # 0xffffff32: 69          
  34.  
  35.  
  36. ####  HEAP
  37.  
  38. # 0x0fff4242:  ""
  39.  
  40. # 0x0fee3232:  0x42
  41.  
  42.  
  43.  
  44. ### CONST
  45.  
  46.  
  47. # 0x0f231848:  "M"  
  48. # 0x0f231850:   e    97
  49. # 0x0f231852:   l    ab
  50.  
  51.  
  52. #PROGRAM
  53. # 0x20 (main): F0 00 00
  54. # 0x21: 3f c3
  55. # 0x22:
  56. # 0x23:
  57.  
  58.  
  59. ################REGISTERS##################
  60.  
  61. # (destination index) rdi: 1st arg
  62. # (source index)      rsi: 2nd arg
  63. # (data)              rdx:
  64. # (counter)           rcx:
  65. # (temp8)             r8:
  66. # (temp9)             r9:
  67.  
  68. # (base)              rbx: 22
  69.  
  70. # (base pointer)      rbp: 0xffffff72
  71. # (stack pointer)     rsp: 0xffffff48
  72. # (instruction ptr)   rip:
  73.  
  74.  
  75. ###### SYMBOL TABLEEEE YEEEE BOIIIII
  76. # printf
  77. # scanf
  78. # exit
  79. # "c standard lib stuff"
  80. # " some other stuffffff"
  81. # main
  82. # bananderp
  83.  
  84.  
  85. ####### SHELSLLLLLL
  86. # ~$ ./programname -> call bananderp
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement