HasanRasulov

trailingzeros.asm

Jan 24th, 2021 (edited)
487
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. %include 'functions.asm'
  2.  
  3. section .bss
  4. num resb LEN
  5. section .data
  6. section .text
  7. global _start      
  8.    
  9. _start:                
  10.      
  11.  
  12.     mov eax,SYS_READ
  13.     mov ebx,STDIN
  14.     mov ecx,num
  15.     mov edx,LEN
  16.     int 80h
  17.  
  18.     mov ebx,1    ;divident
  19.     mov ecx,0    ;number of zeros
  20.     mov edx,5    ;to multiply the divident
  21.     mov eax,0    ;quotient of divison
  22.  loop:
  23.     add ecx,eax  ;add the quotient of result
  24.     mov eax,ebx  ;move divident to eax
  25.     mov edx,5    ;move 5 to edx to multiply  
  26.     mul edx      ;multiply last divident with 5
  27.     mov ebx,eax  ;move divident to ebx
  28.  
  29.     mov eax,num  ;move number to eax to call atoi
  30.     call atoi    
  31.  
  32.     div ebx      ;divide number by current divident
  33.     cmp eax,1    ;if quotient is less than 1 finish
  34.     jge loop      
  35.    
  36.  
  37. out:
  38.     mov eax,ecx   ;move result to eax to print
  39.  
  40.     call iprintLF
  41.  
  42.     call quit
Add Comment
Please, Sign In to add comment