fork download
  1. section .data
  2. minha_string db 'ABZZZZZZZZPWDDEEFGHX', 0 ; String com terminador 0
  3. achou_msg db 'Achou o PWD!', 0xA
  4. achou_len equ $ - achou_msg
  5.  
  6. section .text
  7. global _start
  8.  
  9. _start:
  10. mov esi, minha_string ; ESI aponta para o início da string
  11.  
  12. procurar:
  13. mov al, [esi] ; pega o byte apontado por ESI e coloca em AL
  14. inc esi
  15. cmp al, 0 ; Chegou ao final da string? (terminador 0)
  16. je nao_achou
  17. cmp al, 'P' ; Comparar caractere atual com 'X'
  18. je achoup
  19. jmp procurar ; Continua procurando
  20.  
  21. achoup:
  22. mov al, [esi] ; pega o byte apontado por ESI e coloca em AL
  23. inc esi
  24. cmp al, 0 ; Chegou ao final da string? (terminador 0)
  25. je nao_achou
  26. cmp al, 'W' ; Comparar caractere atual com 'X'
  27. je achouw
  28. jmp procurar ; Continua procurando
  29.  
  30. achouw:
  31. mov al, [esi] ; pega o byte apontado por ESI e coloca em AL
  32. inc esi
  33. cmp al, 0 ; Chegou ao final da string? (terminador 0)
  34. je nao_achou
  35. cmp al, 'D' ; Comparar caractere atual com 'X'
  36. je achou
  37. jmp procurar ; Continua procurando
  38.  
  39. achou:
  40. ; escreve mensagem "Achou o X!"
  41. mov eax, 4 ; syscall write
  42. mov ebx, 1 ; STDOUT
  43. mov ecx, achou_msg
  44. mov edx, achou_len
  45. int 0x80
  46. jmp sair
  47.  
  48. nao_achou:
  49. ; se não quiser fazer nada, apenas sair
  50. jmp sair
  51.  
  52. sair:
  53. mov eax, 1 ; syscall exit
  54. xor ebx, ebx
  55. int 0x80
Success #stdin #stdout 0s 5320KB
stdin
Standard input is empty
stdout
Achou o PWD!