Advertisement
Nofew

Thing with a bug!

Dec 1st, 2015
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. BITS 32
  2.  
  3. section .data
  4. Spaces: db 32,32,32,32
  5. section .bss
  6.  
  7. fahr: resd 1
  8. cels: resd 1
  9. current: resd 1
  10. upper: resd 1
  11. step: resd 1
  12. print: resd 1
  13. ncels: resd 1
  14. nfahr: resd 1
  15. section .text
  16. global _start
  17. _start:
  18. Initalize:
  19. mov eax,-100
  20. mov [fahr],eax
  21. mov [current],eax
  22. mov eax,20
  23. mov [step],eax
  24. mov eax,200
  25. mov [upper],eax
  26. PrimaryLoop:
  27. mov eax,0
  28. mov [ncels],eax
  29. mov [nfahr],eax
  30. mov eax,[current]
  31. mov [fahr],eax
  32. mov eax,[fahr]
  33. mov ebx,[upper]
  34. cmp eax,ebx
  35. jg Terminate
  36. DoMath:
  37. mov eax,[fahr]
  38. mov ebx,32
  39. sub eax,ebx
  40. mov ebx,5
  41. imul eax,ebx
  42. mov ecx,9
  43. mov edx,0
  44. cdq
  45. idiv ecx
  46. mov [cels],eax
  47. InsertStackMarker:
  48. mov eax,10000
  49. push eax
  50. CheckIfCelsIsNegative:
  51. mov eax,[cels]
  52. mov ebx,0
  53. cmp eax,ebx
  54. jl CelsIsNegative
  55. jmp PushCelsDigitsToStack
  56. CelsIsNegative:
  57. mov eax,1
  58. mov [ncels],eax
  59. mov eax,[cels]
  60. mov ebx,-1
  61. imul eax,ebx
  62. mov [cels],eax
  63. PushCelsDigitsToStack:
  64. mov eax,[cels]
  65. mov ebx,0
  66. cmp eax,ebx
  67. je GotAZero
  68. mov ecx,10
  69. mov edx,0
  70. cdq
  71. idiv ecx
  72. push edx
  73. mov [cels],eax
  74. jmp PushCelsDigitsToStack
  75. GotAZero:
  76. pop ebx
  77. cmp eax,ebx
  78. je JustAZero
  79. push ebx
  80. mov eax,10000
  81. cmp eax,ebx
  82. je ActualZero
  83. jmp DecideSign
  84. ActualZero:
  85. mov eax,0
  86. push eax
  87. jmp PushCelsDigitsToStack
  88. JustAZero:
  89. mov eax,0
  90. push eax
  91. DecideSign:
  92. mov eax,[ncels]
  93. mov ebx,1
  94. cmp eax,ebx
  95. je InsertSign
  96. jmp InsertAnotherStackMarker
  97. InsertSign:
  98. mov eax,45
  99. mov ebx,30h
  100. sub eax,ebx
  101. push eax
  102. InsertAnotherStackMarker:
  103. mov eax,10000
  104. push eax
  105. CheckIfFahrIsNegative:
  106. mov eax,[fahr]
  107. mov ebx,0
  108. cmp eax,ebx
  109. jl FahrIsNegative
  110. jmp PushFahrDigitsToStack
  111. FahrIsNegative:
  112. mov eax,1
  113. mov [nfahr],eax
  114. mov eax,[fahr]
  115. mov ebx,-1
  116. imul eax,ebx
  117. mov [cels],eax
  118. PushFahrDigitsToStack:
  119. mov eax,[fahr]
  120. mov ebx,0
  121. cmp eax,ebx
  122. je GotADifferentZero
  123. mov ecx,10
  124. mov edx,0
  125. cdq
  126. idiv ecx
  127. push edx
  128. mov [fahr],eax
  129. jmp PushFahrDigitsToStack
  130. ;;;;Something feels really wrong about GotADifferentZero...
  131. GotADifferentZero:
  132. pop ebx
  133. cmp eax,ebx
  134. je JustADifferentZero
  135. push ebx
  136. mov eax,10000
  137. cmp eax,ebx
  138. je AnotherActualZero
  139. jmp DecideAnotherSign
  140. AnotherActualZero:
  141. mov eax,0
  142. push eax
  143. jmp PushFahrDigitsToStack
  144. JustADifferentZero:
  145. mov eax,0
  146. push eax
  147. DecideAnotherSign:
  148. mov eax,[nfahr]
  149. mov ebx,1
  150. cmp eax,ebx
  151. je InsertAnotherSign
  152. jmp PrintFahrFromStack
  153. InsertAnotherSign:
  154. mov eax,45
  155. mov ebx,30h
  156. sub eax,ebx
  157. push eax
  158. PrintFahrFromStack:
  159. mov eax,10000
  160. pop ebx
  161. cmp eax,ebx
  162. je PrintWhitespace
  163. mov eax,30h
  164. add eax,ebx
  165. mov [print],eax
  166. mov eax,4
  167. mov ebx,1
  168. mov ecx,print
  169. mov edx,1
  170. int 80h
  171. jmp PrintFahrFromStack
  172. PrintWhitespace:
  173. mov eax,4
  174. mov ebx,1
  175. mov ecx,Spaces
  176. mov edx,4
  177. int 80h
  178. PrintCelsFromStack:
  179. mov eax,10000
  180. pop ebx
  181. cmp eax,ebx
  182. je IncrementFahr
  183. mov eax,30h
  184. add eax,ebx
  185. mov [print],eax
  186. mov eax,4
  187. mov ebx,1
  188. mov ecx,print
  189. mov edx,1
  190. int 80h
  191. jmp PrintCelsFromStack
  192. IncrementFahr:
  193. mov eax,[current]
  194. mov ebx,[step]
  195. add eax,ebx
  196. mov [fahr],eax
  197. mov [current],eax
  198. mov eax,10
  199. mov [print],eax
  200. mov eax,4
  201. mov ebx,1
  202. mov ecx,print
  203. mov edx,1
  204. int 80h
  205. jmp PrimaryLoop
  206. Terminate:
  207. mov eax,1
  208. mov ebx,0
  209. int 80h
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement