Advertisement
Guest User

Untitled

a guest
Dec 21st, 2014
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.56 KB | None | 0 0
  1. .386
  2. .MODEL FLAT
  3. ExitProcess PROTO NEAR32 stdcall,dwExitCode:DWORD
  4. Include io.h
  5. cr equ 0DH
  6. Lf equ 0AH
  7.  
  8. .STACK 4096
  9. .DATA
  10.  
  11. number dword ?
  12.  
  13. string byte 40 dup(?)
  14. rejected byte ", Rejected",cr,0
  15. positiveNumber byte ", Positive",cr,0
  16. negativeNumber byte ", Negative",cr,0
  17. numberOfPos byte "Positive Numbers: ",0
  18. numberOfNeg byte "Negative Numbers: ",0
  19. runningSum byte "Running Sum of Positive numbers: ",0
  20.  
  21. newline byte cr,Lf,0
  22.  
  23. numaschar byte 11 dup(?),0
  24. numPosaschar byte 11 dup(?),0
  25. numNegaschar byte 11 dup(?),0
  26. sumasChar byte 11 dup(?),0
  27.  
  28.  
  29. .code
  30.  
  31. _start:
  32. sub ebx,ebx ; numberOfPos = 0
  33. sub ecx,ecx ; numberOfNeg = 0
  34. sub edx,edx ; runningSum = 0
  35.  
  36.  
  37. forever:
  38. input string, 40
  39. atod string
  40. cmp eax,0
  41. je finish
  42.  
  43. cmp eax,10
  44. jg invalid
  45.  
  46. cmp eax,-10
  47. jl invalid
  48.  
  49. cmp eax,0
  50. jg positive
  51. jl negative
  52.  
  53. jmp jumpToMainLoop
  54.  
  55. positive:
  56. inc ebx
  57. add edx,eax
  58. dtoa numaschar,eax
  59. output numaschar
  60. output positiveNumber
  61. output newline
  62.  
  63. negative:
  64. add ecx,1
  65. dtoa numaschar,eax
  66. output numaschar
  67. output negativeNumber
  68. output newline
  69.  
  70. invalid:
  71. dtoa numaschar,eax
  72. output numaschar
  73. output rejected
  74. output newline
  75.  
  76.  
  77. finish:
  78. dtoa numPosaschar, ebx
  79. dtoa numNegaschar, ecx
  80. dtoa sumasChar, edx
  81.  
  82. output numberOfPos
  83. output numPosaschar
  84. output newline
  85. output numberOfNeg
  86. output numNegaschar
  87. output newline
  88. output runningSum
  89. output sumasChar
  90. output newline
  91.  
  92.  
  93. INVOKE ExitProcess, 0
  94. PUBLIC _start
  95. END
  96.  
  97. jumpToMainLoop:
  98. jmp forever
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement