Advertisement
Guest User

Untitled

a guest
Dec 23rd, 2011
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.96 KB | None | 0 0
  1. Title flipTest
  2. INCLUDE Irvine32.inc
  3.  
  4. ;################################################
  5.  
  6. SwapIt PROTO :DWORD,:DWORD
  7. stringLengthProc PROTO :DWORD
  8.  
  9. ;################################################
  10.  
  11. .data
  12.  
  13. mes1 BYTE "Enter a 5 digit string: ",0
  14. inName DWORD 3 dup(0)
  15. math1 BYTE 2
  16. lpString:DWORD
  17. dwLength:DWORD
  18.  
  19. ;################################################
  20.  
  21. .code
  22.  
  23. ;************************************************
  24.  
  25. getNameProc PROC
  26.  
  27. push edx
  28. mov edx,offset mes1
  29. call WriteString
  30. mov edx,offset inName
  31. mov ecx, sizeof inName
  32. call ReadString
  33. pop edx
  34. ret
  35.  
  36. getNameProc ENDP
  37.  
  38. ;************************************************
  39.  
  40. ;stringLengthProc PROC lpString:DWORD
  41.  
  42. ;returns the string length in EAX
  43.  
  44. push ecx
  45. push edi
  46. mov al,0
  47. mov ecx,-1
  48. mov edi,lpString
  49. repnz scasb
  50. mov eax,-2
  51. sub eax,ecx
  52. pop edi
  53. pop ecx
  54. call SwapIt offset inName,eax
  55. ret
  56.  
  57. stringLengthProc ENDP
  58.  
  59. ;************************************************
  60.  
  61. SwapIt PROC
  62.  
  63. push ecx
  64. push edx
  65. mov ecx,dwLength
  66. mov edx,lpString
  67. dec ecx
  68. add ecx,edx
  69. jmp short SwpIt1
  70.  
  71. SwpIt0: mov al,[edx]
  72. mov ah,[ecx]
  73. mov [ecx],al
  74. mov [edx],ah
  75. dec ecx
  76. inc edx
  77.  
  78. SwpIt1: cmp ecx,edx
  79. ja SwpIt0
  80. pop edx
  81. pop ecx
  82. ret
  83.  
  84. SwapIt ENDP
  85.  
  86. ;************************************************
  87.  
  88. main PROC
  89.  
  90. call getNameProc
  91. INVOKE stringLengthProc,offset inName
  92. ; INVOKE SwapIt,offset inName,eax
  93. mov edx,offset inName
  94. call WriteString
  95. call Crlf
  96. exit
  97.  
  98. main ENDP
  99.  
  100. ;################################################
  101.  
  102. END main
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement