Advertisement
DMG

strip()

DMG
Nov 16th, 2014
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # Program za stripovanje stringa
  2. # dmarjanovic
  3.  
  4. .section .data
  5.     str_1: .ascii "    dragutin marjanovic      \0"
  6.  
  7. .section .text
  8. .globl main
  9.  
  10. main:
  11.     movl $0, %esi
  12.  
  13. for_length:
  14.     cmpb $0, str_1(,%esi,1)
  15.     je continue
  16.    
  17.     incl %esi
  18.     jmp for_length
  19.    
  20. continue:
  21.     decl %esi
  22.    
  23.     right_strip:
  24.         cmpb $32, str_1(,%esi,1)
  25.         jne next_continue
  26.        
  27.         movb $0, str_1(,%esi,1)
  28.         decl %esi
  29.         jmp right_strip
  30.        
  31.     next_continue:
  32.         movl $0, %ebp
  33.         movl $0, %esi
  34.         for_space:
  35.             cmpb $32, str_1(,%esi,1)
  36.             jne left_strip
  37.            
  38.             incl %esi
  39.             jmp for_space
  40.            
  41.     left_strip:
  42.         cmpb $0, str_1(,%esi,1)
  43.         je end
  44.        
  45.         movb str_1(,%esi,1), %cl
  46.         movb %cl, str_1(,%ebp,1)
  47.        
  48.         incl %esi
  49.         incl %ebp
  50.         jmp left_strip
  51.    
  52. end:
  53.     movl $0, str_1(,%ebp,1)
  54.  
  55.     movl $1, %eax
  56.     int $0x80
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement