Сравнение массивов A и B. Элементы в результирующем массиве равны: 0 - при A[i]<>B[i], A[i] - при A[i]=B[i] - Assembler
Формулировка задачи:
Сравнение производить не по 2 цифры, а по одной!
sts SEGMENT PARA STACK 'Stack' DW 32 DUP (?) sts ENDS data SEGMENT mes1 db 'Enter',0Ah,0Dh,'$' mes2 db '1st',0Ah,0Dh,'$' mes3 db 10,13,'2nd',0Ah,0Dh,'$' mes4 db 10,13,'Rezult ',0Ah,0Dh,'$' famm db 21,? fam dw 10 dup (?) tabss db 21,? tabs dw 10 dup (?) dim dw 10 dup (?) data ends text SEGMENT assume CS:text, DS:data, SS:sts main proc far ;-----Block 1----------- push DS xor AX,AX push ax ;-----Block 2----------- mov ax,data mov DS,AX ;-----Block 3----------- lea DX,mes1 mov AH,09h int 21h ;-----Block 4----------- lea DX,mes2 mov AH,09h int 21h ;-----Block 5----------- lea DX,tabss mov AH,0Ah int 21h ;-----Block 6----------- lea DX,mes3 mov AH,09h int 21h ;-----Block 7----------- lea DX,famm mov AH,0Ah int 21h ;-----Block 8----------- mov SI,0 lea DI,dim mov CX,10 ;-----Block 9----------- M1: mov AX,tabs[SI] mov bx,fam[SI] cmp AX,BX je Equal mov AX,3030h Equal: mov [DI],AX add SI,2 add DI,2 loop M1 ;-----Block 10---------- mov CH,0 mov CL,0 mov DH,25 mov DL,80 mov BH,07 mov AH,06 mov AL,0 int 10h ;-----Block 11---------- mov AH,02 mov BH,0 mov DX,0 int 10h ;-----Block 12---------- lea DX,mes4 mov AH,09 int 21h ;-----Block 13---------- mov CX,5 mov SI,0 M2: push CX mov AX,dim[SI] mov BL,04h call print mov AX,dim[SI+2] mov BL,10h call print pop CX add SI,4 loop M2 ;----------------------- ret main endp ;======================= print proc ;-----Block 14---------- push AX ;-----Block 15---------- mov AH,09 mov BH,0 mov CX,1 int 10h ;-----Block 16---------- mov AH,03 mov BH,0 int 10h ;-----Block 17---------- add DL,1 mov AH,02 mov BH,0 int 10h ;-----Block 18---------- pop AX xchg AH,AL ;-----Block 19---------- mov AH,09 mov CX,1 int 10h ;-----Block 20---------- mov AH,03 mov BH,0 int 10h ;-----Block 21---------- add DL,2 mov AH,02 mov BH,0 int 10h ;----------------------- ret print endp text ends end main
Решение задачи: «Сравнение массивов A и B. Элементы в результирующем массиве равны: 0 - при A[i]<>B[i], A[i] - при A[i]=B[i]»
textual
Листинг программы
sts SEGMENT PARA STACK 'Stack' DW 32 DUP (?) sts ENDS data SEGMENT mes1 db 'Enter',0Ah,0Dh,'$' mes2 db '1st',0Ah,0Dh,'$' mes3 db 10,13,'2nd',0Ah,0Dh,'$' mes4 db 10,13,'Rezult ',0Ah,0Dh,'$' famm db 21,? fam db 22 dup (?) tabss db 21,? tabs db 22 dup (?) dim db 20 dup (?) data ends text SEGMENT assume CS:text, DS:data, SS:sts main proc far ;-----Block 1----------- push DS xor AX,AX push ax ;-----Block 2----------- mov ax,data mov DS,AX ;-----Block 3----------- lea DX,mes1 mov AH,09h int 21h ;-----Block 4----------- lea DX,mes2 mov AH,09h int 21h ;-----Block 5----------- lea DX,tabss mov AH,0Ah int 21h ;-----Block 6----------- lea DX,mes3 mov AH,09h int 21h ;-----Block 7----------- lea DX,famm mov AH,0Ah int 21h ;-----Block 8----------- mov SI,0 lea DI,dim mov CX,20 ;-----Block 9----------- M1: mov AL,tabs[SI] mov AH,fam[SI] cmp AL,AH je Equal mov AL,30h Equal: mov [DI],AL inc SI inc DI loop M1 ;-----Block 10---------- mov CH,0 mov CL,0 mov DH,25 mov DL,80 mov BH,07 mov AH,06 mov AL,0 int 10h ;-----Block 11---------- mov AH,02 mov BH,0 mov DX,0 int 10h ;-----Block 12---------- lea DX,mes4 mov AH,09 int 21h ;-----Block 13---------- mov CX,10 mov SI,0 M2: push CX mov AL,dim[SI] mov BL,04h call print mov AL,dim[SI+1] mov BL,10h call print pop CX add SI,2 loop M2 ;----------------------- ret main endp ;======================= print proc ;-----Block 14---------- ; push AX ;-----Block 15---------- mov AH,09 mov BH,0 mov CX,1 int 10h ;-----Block 16---------- mov AH,03 mov BH,0 int 10h ;-----Block 17---------- add DL,1 mov AH,02 mov BH,0 int 10h comment * ;-----Block 18---------- pop AX xchg AH,AL ;-----Block 19---------- mov AH,09 mov CX,1 int 10h ;-----Block 20---------- mov AH,03 mov BH,0 int 10h ;-----Block 21---------- add DL,2 mov AH,02 mov BH,0 int 10h ;----------------------- * ret print endp text ends end main
ИИ поможет Вам:
- решить любую задачу по программированию
- объяснить код
- расставить комментарии в коде
- и т.д