386 MODEL FLAT STDCALL EXTERN GetStdHandle NEAR EXTERN WriteConsoleA 2

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
.386
.MODEL FLAT, STDCALL
EXTERN GetStdHandle@4:NEAR
EXTERN WriteConsoleA@20:NEAR
EXTERN CharToOemA@8:NEAR
EXTERN ReadConsoleA@20:NEAR
EXTERN ExitProcess@4:NEAR
EXTERN lstrlenA@4:NEAR
EXTERN Sleep@4:NEAR
;Сегмент данных
.DATA
HOut DD 0
HIn DD 0
W DB "Введите строку: ",0
W2 DB "Результат: ",0
String DB 400 DUP(?)
Char DB " ";32
Lenght DD ?
Temp DD ?
;Сегмент кода
.CODE
MAIN PROC
PUSH OFFSET W
PUSH OFFSET W
CALL CharToOemA@8
PUSH OFFSET W2
PUSH OFFSET W2
CALL CharToOemA@8
PUSH -10
CALL GetStdHandle@4
MOV HIn, EAX
PUSH -11
CALL GetStdHandle@4
MOV HOut, EAX
PUSH OFFSET W
CALL lstrlenA@4
; Вывести приглашение к вводу
PUSH 0
PUSH OFFSET Temp
PUSH EAX
PUSH OFFSET W
PUSH HOut
CALL WriteConsoleA@20
; Произвести ввод
PUSH 0
PUSH OFFSET Lenght
PUSH 400
PUSH OFFSET String
PUSH HIn
CALL ReadConsoleA@20
; Вызов процедуры удаления повтора символа в строке
PUSH DWORD PTR Char
PUSH Lenght
PUSH OFFSET String
CALL Del
POP Lenght
;--------- вывод результата ---------
PUSH OFFSET W2
CALL lstrlenA@4
; Вывести приглашение к вводу
PUSH 0
PUSH OFFSET Temp
PUSH EAX
PUSH OFFSET W2
PUSH HOut
CALL WriteConsoleA@20
PUSH 0
PUSH OFFSET Temp
PUSH Lenght
PUSH OFFSET String
PUSH HOut
CALL WriteConsoleA@20
MainExit:
PUSH 0
PUSH 5000
CALL Sleep@4
CALL ExitProcess@4
MAIN ENDP
Del PROC
cld
MOV EBP, ESP
MOV EDI,[EBP+4]
MOV ECX,[EBP+8]
MOV EAX,[EBP+12]
MOV EBX,ECX
delloop:
REPNE SCASB
MOV ESI,EDI
CMP ECX,0
JE endloop
DEC EDI
DEC EBX
PUSH ECX
PUSH EDI
REP MOVSB
POP EDI
POP ECX
JMP delloop
endloop:
MOV [EBP+12],EBX
RET 8
Del ENDP
read_of_con proc
read_of_con ENDP
END MAIN