1、7例456例4 设2000H开始的区域中,存放着14H个数据,请编写一个程序段,找出其中的最大数,并存到2000H单元。解:所求程序段如下: GATMAX: MOV BX,2000H MOV AL,BX MOV CX,14H PL1: INC BX CMP AL,BX JAE PL2 MOV AL,BX PL2: DEC CX JNZ PL1 MOV BX,2000H MOV BX,AL 例5 求两数差的绝对值data_seg SEGMENT oper1 DW 135 oper2 DW 289 result DW ?data_seg ENDScode_seg SEGMENT ASSUME CS
2、:code_seg,DS:data_segstart: MOV AX,data_seg MOV DS,AX MOV AX,oper1 SUB AX,oper2 JGE store NEG AXstore: MOV result,AX MOV AH,4CH INT 21Hcode_seg ENDSEND start例6 求两数差的绝对值data_seg SEGMENT oper1 DW 135 oper2 DW 289 result DW ?data_seg ENDScode_seg SEGMENT ASSUME CS:code_seg,DS:data_seg start: MOV AX,oper1 CMP AX,oper2 JL branch2 SUB AX,oper2 JMP storebranch2:SUB oper2,AX MOV AX,oper2 store: MOV result,AX MOV AH,4CH INT 21Hcode_seg ENDS END START