Advertisement
Guest User

Untitled

a guest
Apr 22nd, 2019
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.82 KB | None | 0 0
  1.  
  2. %include "asm_io.inc"
  3. segment .data
  4. msg db " : ", 0
  5.  
  6. segment .bss
  7. input1 resd 1
  8. decomposto resd 10
  9. current resd 1
  10. castECX resd 1
  11. equal resb 0
  12.  
  13.  
  14.  
  15. segment .text
  16. global asm_main
  17.  
  18.  
  19. asm_main:
  20. ;call read_int ; read integer
  21. mov eax, 2010
  22. mov [input1], eax ; store into input1
  23.  
  24. nextNumber:
  25. mov eax, [input1]
  26. add eax, 1
  27. call print_int
  28. call print_nl
  29. mov [input1], eax ; store into input1
  30.  
  31. mov edi, decomposto
  32. cld
  33.  
  34.  
  35. mov ecx, 0
  36. multipleDivisionsBy10:
  37.  
  38. cdq
  39. mov ebx, 10
  40. div ebx
  41.  
  42. mov [current], eax
  43. mov eax, edx
  44. call print_int
  45. call print_nl
  46. add ecx, 1
  47. stosd
  48.  
  49. mov eax, [current]
  50. cmp eax, 0
  51. jg multipleDivisionsBy10
  52.  
  53. call print_nl
  54. mov eax, ecx
  55. call print_int
  56. call print_nl
  57.  
  58.  
  59.  
  60. ; [decomposto] from 0 to ecx-1 is the word
  61.  
  62. cld ; ZF ->
  63. mov eax, 1
  64. mov [equal], eax
  65.  
  66. letsCheckForEquality:
  67. mov ebx, [decomposto+ecx]
  68.  
  69. mov esi, decomposto
  70. mov [castECX], ecx
  71.  
  72. loopInsideLoop:
  73. lodsd
  74. cmp eax, ebx
  75.  
  76. call print_int
  77. mov eax, msg
  78. call print_string
  79. mov eax, ebx
  80. call print_int
  81. call print_nl
  82. ;je nextNumber
  83. loop loopInsideLoop
  84.  
  85. mov ecx, [castECX]
  86. loop letsCheckForEquality ; loops ecx times
  87.  
  88.  
  89. mov eax, [input1]
  90. call print_int
  91. call print_nl
  92. leave
  93. ret
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement