fork download
  1. %macro print 2
  2. mov rax,1
  3. mov rdi,1
  4. mov rsi,%1
  5. mov rdx,%2
  6. syscall
  7. %endmacro
  8.  
  9. section .data
  10.  
  11. msg db "Counting +ve and -ve elements of an array.",10
  12. msglen equ $-msg
  13. msg1 db "Positive nos. are : "
  14. msglen1 equ $-msg1
  15. msg2 db "Negetive nos. are : "
  16. msglen2 equ $-msg2
  17.  
  18. array dd 12345678h,723490ffh,570036f8h,88006789h,8a9f3680h,0a0dab23h,3bcd0200h
  19. pcnt db 0
  20. ncnt db 0
  21.  
  22.  
  23. section .bss
  24.  
  25. dispbuff resb 2
  26.  
  27. section .txt
  28. global _start
  29. _start:
  30. print msg,msglen
  31.  
  32. mov rsi,array
  33. mov rcx,07
  34.  
  35. again:
  36. bt dword[rsi],31
  37. jnc pnxt
  38. inc byte[ncnt]
  39. jmp pskip
  40. pnxt: inc byte[pcnt]
  41. pskip: inc rsi
  42. inc rsi
  43. inc rsi
  44. inc rsi
  45. loop again
  46. print msg1,msglen1
  47. mov bl,[pcnt]
  48. call disp_result
  49.  
  50.  
  51. print msg2,msglen2
  52. mov bl,[ncnt]
  53. call disp_result
  54.  
  55.  
  56. mov rax,60
  57. mov rdi,0
  58. Syscall
  59.  
  60. disp_result:
  61. mov rdi,dispbuff
  62. mov rcx,02
  63. dispup1:
  64. rol bl,4
  65. mov dl,bl
  66. and dl,0fh
  67. add dl,30h
  68. cmp dl,39h
  69. jbe dispskip1
  70. add dl,07h
  71. dispskip1:
  72. mov [rdi],dl
  73. inc rdi
  74. loop dispup1
  75. print dispbuff,2
  76. ret
  77.  
Success #stdin #stdout 0.01s 5312KB
stdin
Standard input is empty
stdout
Counting +ve and -ve elements of an array.
Positive nos. are : 05Negetive nos. are :  02