Advertisement
Guest User

Untitled

a guest
Dec 24th, 2011
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.11 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. ConsoleScreen CHAR_INFO 2000 DUP (<>) ; Declaring a structured variable, my default field, pg 335
  17.  
  18. ;.Data? ; Declare my unitialized Data (Irivine pg568)
  19.  
  20.  
  21. ;################################################
  22.  
  23. .code
  24.  
  25. ;************************************************
  26.  
  27. getNameProc PROC
  28.  
  29. push edx
  30. mov edx,offset mes1
  31. call WriteString
  32. mov edx,offset inName
  33. mov ecx, sizeof inName
  34. call ReadString
  35. pop edx
  36. ret
  37.  
  38. getNameProc ENDP
  39.  
  40. ;************************************************
  41.  
  42. stringLengthProc PROC lpString:DWORD
  43. ;returns the string length in EAX
  44.  
  45. push ecx
  46. push edi
  47. mov al,0
  48. mov ecx,-1
  49. mov edi,lpString
  50. repnz scasb
  51. mov eax,-2
  52. sub eax,ecx
  53. pop edi
  54. pop ecx
  55. ; call SwapIt
  56. ret
  57.  
  58. stringLengthProc ENDP
  59.  
  60. ;************************************************
  61.  
  62. SwapIt PROC lpString:DWORD,dwLength:DWORD
  63.  
  64. push ecx
  65. push edx
  66. ; mov offset inName,eax
  67. mov ecx,dwLength
  68. mov edx,lpString
  69. dec ecx
  70. add ecx,edx
  71. jmp short SwpIt1
  72.  
  73. SwpIt0: mov al,[edx]
  74. mov ah,[ecx]
  75. mov [ecx],al
  76. mov [edx],ah
  77. dec ecx
  78. inc edx
  79.  
  80. SwpIt1: cmp ecx,edx
  81. ja SwpIt0
  82. pop edx
  83. pop ecx
  84. ret
  85.  
  86. SwapIt ENDP
  87.  
  88. ;************************************************
  89.  
  90. main PROC
  91.  
  92. call getNameProc
  93. INVOKE stringLengthProc,offset inName
  94. ; INVOKE SwapIt,offset inName,eax
  95. mov edx,offset inName
  96. call WriteString
  97. call Crlf
  98. exit
  99.  
  100. main ENDP
  101.  
  102. ;################################################
  103.  
  104. END main
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement