Advertisement
Guest User

Untitled

a guest
Nov 20th, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.50 KB | None | 0 0
  1. bits 32 ; assembling for the 32 bits architecture
  2.  
  3. ; declare the EntryPoint (a label defining the very first instruction of the program)
  4. global start
  5.  
  6. ; declare external functions needed by our program
  7. extern exit,printf ; tell nasm that exit exists even if we won't be defining it
  8. import exit msvcrt.dll
  9. import printf msvcrt.dll ; exit is a function that ends the calling process. It is defined in msvcrt.dll
  10. ; msvcrt.dll contains exit, printf and all the other important C-runtime specific functions
  11.  
  12. ; our data is declared here (the variables needed by our program)
  13. segment data use32 class=data
  14. s dw 01h,0f303h,05h,07h ; ...
  15. l equ ($-s)/2
  16. d resb l
  17. format db '%d ',0
  18. ;s=01 00 , 03 f3, 05 00,07 00
  19. ; our code starts here
  20. segment code use32 class=code
  21. start:
  22. mov esi,1
  23. mov edi,0
  24. for_sir:
  25. cmp esi,l
  26. jae end_for
  27. mov al,[s+esi]
  28. cmp al,0
  29. jns pas_urmator
  30. mov [d+edi],al
  31. inc edi
  32. pas_urmator:
  33. add esi, 2
  34. jmp for_sir
  35. end_for:
  36. mov esi,0
  37. repeta:
  38. cmp esi,edi
  39. je final
  40. mov al,[d+esi]
  41. cbw
  42. cwde
  43. push eax
  44. push dword format
  45. call [printf]
  46. add esp, 4*2
  47. add esi,1
  48. jmp repeta
  49. final:
  50. push dword 0 ; push the parameter for exit onto the stack
  51. call [exit] ; call exit to terminate the program
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement