Формирование массива из 10 двухбайтных чисел, найти номер максимального числа, страница 2

     mov qw2,di

     mov di,zx2

     xor si,si

     mov cx,2

M33:

                                   mov bv2,si

                                   mov bx,adr_y1

                                   mov ax,[bx+si]

                                   mov bx,adr_itog1

                                   add si,di

                                   mov [bx+si],ax

                                   mov si,bv2

                                   add si,2

                                   loop M33

               mov bx,adr_itog1

               mov al,[bx+2+di]

               mov bx,adr_itog2

               mov [bx+di],al

                         mov bx,adr_itog1

                         mov al,[bx+3+di]

                         mov bx,adr_itog2

                         mov [bx+1+di],al

               mov bx,adr_itog1

               mov al,[bx+di]

               mov bx,adr_itog2

               mov [bx+2+di],al

                         mov bx,adr_itog1

                         mov al,[bx+1+di]

                         mov bx,adr_itog2

                         mov [bx+3+di],al

     mov si,adr_itog2

     xor ax,ax

     add si,di

     mov dx,si

     mov ah,9

     int 21h

               add di,4

               mov zx2,di

     mov dx,rt2

     dec dx

     mov rt2,dx

     cmp dx,0

     je P_MTK0

               xor ax,ax

               mov dx,offset s1

               mov ah,9

               int 21h

     jmp P_NACH

P_MTK0:

.exit 0

end

Задание       (Вариант № 5) Сформировать массив из 10 двухбайтных чисел. Переписать во второй массив все отрицательные числа.

Блок-схема программы:

Программа

model small

.stack 100h

.data

mass_2 dw 0,0,0,0,0,0,0,0,0,0

s1 db "  $"

x1 db 0,0,0,0

y1 db 0,0,0,0

rt2 dw 0

qw2 dw 0

zx2 dw 0

bv2 dw 0

itog1 dw 0,0,0,0,0,0,0,0,0,0

itog2 dw '$',0,'$',0,'$',0,'$',0,'$',0,'$',0,'$',0,'$',0,'$',0,'$',0,'$'

adr_mass_2 dw 0

adr_x1 dw 0

adr_y1 dw 0

adr_itog1 dw 0

adr_itog2 dw 0

soob db "vvedite shesnadsaterichnoe chislo bolshimi bykvami  $"

a1 db 0,0,0,0

b1 db 0,0,0,0

c1 dw 0,0,0,0

summ dw 0,0,0,0,0,0,0,0,0,0

adr_a1 dw 0

adr_b1 dw 0

adr_c1 dw 0

adr_summ dw 0

qw dw 0

rt dw 0

.code

.startup

     mov dx,offset soob

     mov ah,9

     int 21h

               lea bx,a1                          // загрузка эффективного адреса a1  в регистр bx  

               mov adr_a1,bx

     lea bx,b1                                     // загрузка эффективного адреса b1   в регистр bx  

     mov adr_b1,bx

               lea bx,c1

               mov adr_c1,bx      

     lea bx,summ

     mov adr_summ,bx

               mov ax,10

               mov rt,ax

NACH:

     xor si,si       

     mov cx,4

M1:

     mov ah,1

     int 21h

     mov bx,adr_a1

     mov [bx+si],al

     inc si

     loop M1

               xor si,si

               mov cx,4

M2:

     mov bx,adr_a1

     mov dl,[bx+si]

     cmp dl,39h

     jbe MM1

     sub dl,7h

MM1:

     sub dl,30h

     mov bx,adr_b1

     mov [bx+si],dl

     inc si

               loop M2

     xor ax,ax

     mov bx,adr_b1

     mov al,[bx]

     shl ax,12

     mov bx,adr_c1

     mov [bx],ax

               xor ax,ax

               mov bx,adr_b1

               mov al,[bx+1]

               shl ax,8

               mov bx,adr_c1

               mov [bx+2],ax

     xor ax,ax

     mov bx,adr_b1

     mov al,[bx+2]

     shl ax,4

     mov bx,adr_c1

     mov [bx+4],ax

               xor ax,ax

               mov bx,adr_b1

               mov al,[bx+3]

               mov bx,adr_c1

               mov [bx+6],ax

     xor ax,ax

     mov cx,4

     xor si,si

M3:

     mov bx,adr_c1

     add ax,[bx+si]

     add si,2

     loop M3

               mov di,qw

               mov bx,adr_summ

               mov [bx+di],ax

               add di,2

               mov qw,di

     mov dx,rt

     dec dx

     mov rt,dx

     cmp dx,0

     je MTK0

               xor ax,ax

               mov dx,offset s1

               mov ah,9

               int 21h

     jmp NACH

MTK0:

               lea bx,summ

               lea di,mass_2

     mov cx,10

     xor si,si

     xor bp,bp

MK1:

     clc

     mov ax,[bx+si]

     shl ax,1                                                                                                        !

     jc MK2

     jmp MK3

MK2:

     mov dx,[bx+si]

     mov [di+bp],dx

     add bp,2

MK3:

     add si,2

     loop MK1

               lea bx,x1

               mov adr_x1,bx

     lea bx,y1

     mov adr_y1,bx

               lea bx,mass_2

               mov adr_mass_2,bx       

     xor ax,ax

     mov dx,offset s1

     mov ah,9

     int 21h

     int 21h

     int 21h

     int 21h

                                              mov ax,0

                                              mov qw2,ax

                                              mov zx2,ax

               mov ax,10

               mov rt2,ax

P_NACH:

                                   mov di,qw2

               xor ax,ax

               mov bx,adr_mass_2

               mov al,[bx+di]

               shr ax,4

               mov bx,adr_x1

               mov [bx],al

     xor ax,ax

     mov bx,adr_mass_2

     mov al,[bx+di]

     and al,00001111b

     mov bx,adr_x1

     mov [bx+1],al

               xor ax,ax

               mov bx,adr_mass_2

               mov al,[bx+1+di]

               shr ax,4

               mov bx,adr_x1

               mov [bx+2],al

     xor ax,ax

     mov bx,adr_mass_2

     mov al,[bx+1+di]

     and al,00001111b

     mov bx,adr_x1

     mov [bx+3],al

               mov cx,4

               xor si,si

M11:

     xor ax,ax

     mov bx,adr_x1

     mov al,[bx+si]

     cmp al,9

     jbe M22      

     add al,7h     

M22:

     add al,30h

     mov bx,adr_y1

     mov [bx+si],al

     inc si

     loop M11

                         lea bx,itog1

                         mov adr_itog1,bx

                         lea bx,itog2

                         mov adr_itog2,bx

     mov di,qw2

     add di,2

     mov qw2,di

     mov di,zx2

     xor si,si

     mov cx,2

M33:

                                   mov bv2,si

                                   mov bx,adr_y1

                                   mov ax,[bx+si]

                                   mov bx,adr_itog1

                                   add si,di

                                   mov [bx+si],ax

                                   mov si,bv2

                                   add si,2

                                   loop M33

               mov bx,adr_itog1

               mov al,[bx+2+di]

               mov bx,adr_itog2

               mov [bx+di],al

                         mov bx,adr_itog1

                         mov al,[bx+3+di]

                         mov bx,adr_itog2

                         mov [bx+1+di],al

               mov bx,adr_itog1

               mov al,[bx+di]

               mov bx,adr_itog2

               mov [bx+2+di],al

                         mov bx,adr_itog1

                         mov al,[bx+1+di]

                         mov bx,adr_itog2

                         mov [bx+3+di],al

     mov si,adr_itog2

     xor ax,ax

     add si,di

     mov dx,si

     mov ah,9

     int 21h

               add di,4

               mov zx2,di

     mov dx,rt2

     dec dx

     mov rt2,dx

     cmp dx,0

     je P_MTK0

               xor ax,ax

               mov dx,offset s1

               mov ah,9

               int 21h

     jmp P_NACH

P_MTK0:

.exit 0

end

Вывод: в ходе лабораторной работы были написаны программы на ассемблере, их проверка показала, что они работают правильно.