Advertisement
Guest User

Untitled

a guest
Dec 23rd, 2011
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.98 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,dwLength: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
  55. ret
  56.  
  57. stringLengthProc ENDP
  58.  
  59. ;************************************************
  60.  
  61. SwapIt PROC PROTO :DWORD,:DWORD
  62.  
  63. push ecx
  64. push edx
  65. offset inName,eax
  66. mov ecx,dwLength
  67. mov edx,lpString
  68. dec ecx
  69. add ecx,edx
  70. jmp short SwpIt1
  71.  
  72. SwpIt0: mov al,[edx]
  73. mov ah,[ecx]
  74. mov [ecx],al
  75. mov [edx],ah
  76. dec ecx
  77. inc edx
  78.  
  79. SwpIt1: cmp ecx,edx
  80. ja SwpIt0
  81. pop edx
  82. pop ecx
  83. ret
  84.  
  85. SwapIt ENDP
  86.  
  87. ;************************************************
  88.  
  89. main PROC
  90.  
  91. call getNameProc
  92. INVOKE stringLengthProc,offset inName
  93. ; INVOKE SwapIt,offset inName,eax
  94. mov edx,offset inName
  95. call WriteString
  96. call Crlf
  97. exit
  98.  
  99. main ENDP
  100.  
  101. ;################################################
  102.  
  103. END main
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement