Advertisement
kerelius

lab7task1

Feb 27th, 2019
748
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. .686
  2. .model flat, c
  3.  
  4. includelib libcmt.lib
  5. includelib libvcruntime.lib
  6. includelib libucrt.lib
  7. includelib legacy_stdio_definitions.lib  
  8.  
  9. extern printf_s: proc
  10.  
  11.  
  12. .DATA
  13. inputFormatString byte "%d", 0
  14. newLine byte " ", 13, 10, 0
  15. TEN dword 10
  16.  
  17. .CODE
  18. main proc
  19.     push    4321
  20.     call    reverse
  21.     add     esp, 4
  22.  
  23.     push    offset newLine
  24.     call    printf_s
  25.     add     esp, 4
  26.    
  27.     xor     eax, eax
  28.     ret      
  29. main endp
  30.  
  31. reverse PROC
  32.    
  33.     push  ebp  
  34.     mov ebp,  esp  
  35.     sub   esp,  32     
  36.    
  37.     mov     eax, dword ptr [ebp + 8]
  38.     mov     ecx, 10
  39.     xor     edx, edx
  40.     div     ecx
  41.     mov     ebx, eax
  42.     push    edx
  43.     push    offset inputFormatString
  44.     call    printf_s
  45.     mov     eax, ebx
  46.     add     esp, 8
  47.     cmp     eax, 0
  48.     je      endReverse
  49.     push    eax
  50.     call    reverse
  51.     add     esp, 4
  52.    
  53. endReverse:
  54.     mov   esp, ebp  
  55.     pop   ebp  
  56.     ret                                 ; return to the main process
  57. reverse ENDP
  58. END
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement