Практические задания на экзамен по дисциплине "Цифровые и микропроцессорные устройства", страница 9

                    INX            H

                    MOV         D,M

                    CMP          D

                    JNC           NC

                    LDA           COUNT1

                    INR            A

                    STA           COUNT1

                    JMP           NC

LSB:         

                    PUSH        H

                    DCX          H

                    MOV         A,E

                    MOV         E,M

                    CMP          E

                    POP           H

                    JNC           NC

                    LDA           COUNT1

                    INR            A

                    STA           COUNT1

NC:

                    JZ              LSB

                    INX            H

                    DCRB

JNZLOOP4

5.1. Из массива расположенного между адресами ADDR1 и ADDR2 (ADDR1 < ADDR2), выделить минимальное и максимальное числа без учета знака (формат байты/слова). Записать результат в ячейки MIN и MAX.

ZAD5:                                                                                     

             ;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

                    ;в задаче не нужно, приведено для наглядности: 

INIT5:

        LXI    H,ADDR1

                    MVI           B,ADDR2-ADDR1

                    MVI           A,0FH

LOOP_INIT5:

                    RLC          

                    MOV         M,A

                    INX            H

                    DCR           B

                    JNZ           LOOP_INIT5

;                  JMP           BYTEFORM              ;байтовыйформатмассива

                    JMP           WORDFORM             ;word`овыйформатмассива

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;         

BYTEFORM:

                    LXI            H,ADDR1

                    MVI           B,ADDR2-ADDR1

MVI           D,0FFH

LOOPMIN1:                                                      ;поиск минимального слова в массиве

MOV         A,M

                    CMP          D

                    JNC           NO_MIN1

                    MOV         D,A

NO_MIN1:                 

                    INX            H

                    DCR           B

                    JNZ           LOOPMIN1

                    MOV         A,D

                    STA           MIN

                    LXI            H,ADDR1

                    MVI           B,ADDR2-ADDR1

                    MVI           D,0

LOOPMAX1:                                                    ;поиск максимального байта в массиве

MOV         A,M

                    CMP          D

                    JC              NO_MAX1

                    MOV         D,A

NO_MAX1:                

                    INX            H

                    DCR           B

                    JNZ           LOOPMAX1

                    MOV         A,D

                    STA           MAX

5.2.

WORDFORM:

                    LXI            H,ADDR1

                    MVI           A,ADDR2-ADDR1

                    RRC

                    MOV         B,A

                    LXI            D,0FFFFH

LOOPMIN2:                                                      ;поиск минимального слова в массиве

INX            H

                    MOV         A,M

                    CMP          D

                    JNC           NO_MIN2

                    MOV         D,A

                    DCX          H

                    MOV         E,M

                    INX            H

NO_MIN2:                 

                    INX            H

                    DCR           B

                    JNZ           LOOPMIN2

                    XCHG

                    SHLD        MIN

                    LXI            H,ADDR1

                    MVI           A,ADDR2-ADDR1

                    RRC

                    MOV         B,A

                    LXID,0