Advertisement
Matetus

Reg 2

Dec 31st, 2018
483
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. .intel_syntax noprefix
  2.  
  3. .global main
  4. .text
  5.  
  6. main:
  7.     mov eax, [esp+8]     
  8.     mov eax, [eax+4]   
  9.    
  10.    
  11. p1:
  12.     mov ebx,eax
  13.     mov ecx,1
  14.     mov dh,byte ptr [eax]
  15.     cmp dh,'p'
  16.     je p2
  17.     cmp dh,'q'
  18.     je p2
  19.     cmp dh,'r'
  20.     je p2
  21.     inc eax
  22.     jmp p1
  23.  
  24. p2:
  25.     inc eax
  26.     inc ecx
  27.     mov dh,byte ptr [eax]
  28.     cmp dh,'q'
  29.     je p1
  30.     cmp dh,'r'
  31.     je p1
  32.  
  33. r:
  34.     inc eax
  35.     inc ecx
  36.     mov dh,byte ptr [eax]
  37.     cmp dh,'r'
  38.     je prin
  39.     cmp dh,'q'
  40.     je p1
  41.     jmp r
  42.    
  43.    
  44. prin:
  45.     mov eax,ebx
  46. printchar:
  47.     xor ebx,ebx
  48.     push ecx
  49.     mov bl,byte ptr [eax]
  50.     push eax
  51.     push ebx
  52.     mov ebx, offset messg
  53.     push ebx
  54.     call printf
  55.     add esp,8
  56.     pop eax
  57.     pop ecx
  58.     dec ecx
  59.     inc eax
  60.     cmp ecx,0
  61.     jne printchar
  62.    
  63.     #znak nowej lini dla wygladu
  64.     mov ebx, offset nl
  65.     push ebx
  66.     call printf
  67.     add esp,4
  68.     xor eax,eax
  69.     ret
  70.  
  71.  
  72. .data
  73.     nl: .asciz "\n"
  74.     messg: .asciz "%c"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement