Vulpes

pdemo

Nov 1st, 2011
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. extern printf
  2.  
  3. segment .data
  4.         n_pt_s      db `asm: x%.8X `,10,0
  5.        
  6. segment .txt
  7.         global      display_number
  8.  
  9. display_number:         ;;
  10.         enter       0,0
  11.         mov     eax,        25  ;;random number
  12.         call        num_print
  13.         leave
  14.         ret
  15.  
  16.  
  17.  
  18.  
  19. num_print:  pusha               ;;pusha puts all values in my registers away so that I don't lose them
  20.  
  21.         push        eax     ;;now that value in eax, is  the second argument of my printf call
  22.         push        n_pt_s      ;;this string pointer (in the segment .data part) is the 1st argument of my printf call
  23.            
  24.         call        printf      ;;watch magic
  25.         add     esp,    8  ;;this is like poping twice from the 2 pushes I did earlier, only I don't write anything to the registers  ;remove 2 pushes on stack
  26.        
  27.         popa        ;; now I pop all values that were stored when I did the pusha
  28.         ret
Advertisement
Add Comment
Please, Sign In to add comment