DSEG segment array db 31 dup 0DBh mas1 db 31 dup 1h mas2 db 31 dup xx

  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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
DSEG segment
array db 31 dup (0DBh)
mas1 db 31 dup (1h)
mas2 db 31 dup (?)
xx db 2 dup (?) ; hranenie iksov
len dw 2 dup (?) ; hranenie kol-va elementov
mes db 'result ', 0dh, 0ah, '$'
bol db 0dh, 0ah, 'bolshe kol-va chetnix: $'
men db 0dh, 0ah, 'menshe kol-va nechetnih: $'
chet db 0dh, 0ah, 'kol-vo chetnix: $'
nech db 0dh, 0ah, 'kol-vo nechetnix: $'
DSEG ends
CSEG segment
assume CS:CSEG, DS:DSEG
start:
mov ax, dseg
mov ds, ax
mov dl, 1 ; i
mov cx, 30 ; do 31
evaluate:
mov al, dl
mov ah, 0
mov bl, 3
div bl ; Al = i/3
mov ah, 0
sub al, 7
MODUL: neg al
js MODUL
add al, dl
lea bx, array
mov dh, 0
add bx, dx
mov [bx], al
inc dl
loop evaluate
mov ah, 09h
lea dx, mes
int 21h
mov si, 1
mov cx, 30
vivod:
xor ax, ax
mov al, array[si]
call SHOW
inc si
loop vivod
mov si, 1
mov cx, 30
xor bx, bx
podschet:
test byte ptr array[si],1
jz cht ; perehod, esli ravno 0 (kol-vo chetnih)
inc bh
jmp exit
cht: inc bl
exit: inc si
loop podschet
mov xx[0], bl; kol-vo chet
mov xx[1], bh; kol-vo nechet
lea dx, chet
call OUT_STR
xor ax, ax
mov al, xx[0]
call SHOW
lea dx, nech
call OUT_STR
xor ax, ax
mov al, xx[1]
call SHOW
mov cx, 30
mov si, 1
xor di, di
sravnenie1:
mov ah, xx[0]
cmp ah, array[si]
jl m1
jmp exit1
m1: mov ah, array[si]
mov mas1[di], ah
inc di
jmp exit1
exit1: inc si
loop sravnenie1
mov len[0], di
mov cx, 30
mov si, 1
xor di, di
sravnenie2:
mov ah, xx[1]
cmp array[si], ah
jl m2
jmp exit2
m2: mov ah, array[si]
mov mas2[di], ah
inc di
jmp exit2
exit2: inc si
loop sravnenie2
mov len[2], di
lea dx, bol
call OUT_STR
mov cx, len[0]
mov si, 0
viv1:
xor ax, ax
mov al, mas1[si]
call SHOW
inc si
loop viv1
lea dx, men
call OUT_STR
mov cx, len[2]
mov si, 0
viv2:
xor ax, ax
mov al, mas2[si]
call SHOW
inc si
loop viv2
mov ax, 4c00h
int 21h
OUT_SIM proc
mov ah, 02h
add dl, 30h
int 21h
ret
OUT_SIM endp
OUT_STR proc
mov ah, 09h
int 21h
ret
OUT_STR endp
SHOW proc
mov bl, 10
div bl
push ax
mov dl, al
call OUT_SIM
pop ax
xchg ah, al
mov dl, al
call OUT_SIM
mov ah, 02h
mov dl, 20h
int 21h
ret
SHOW endp
CSEG ENDS
END start