START: MOV AX,@DATA MOV DS,AX MOV AL,DAT CMP AL,0 JZ ZERO JNS POSI MOV DL,’-’ DISPLAY
STOP: MOV AX,4C00H INT 21H
ZERO: MOV DL,’0’ DISPLAY JMP STOP
POSI: MOV DL,’+’ DISPLAY JMP STOP END START
4.23答: .MODEL SMALL .CODE
START: XOR BX,0 MOV CX,200 MOV DX,1
AGN: ADD BX,DX; 求和 INC DX INC DX LOOP AGN CALL BTOH MOV AX,4C00H INT 21H BTOH PROC MOV CL,4
MOV DL,BH;最高位 SHR DL,CL CMP DL,0AH JC N1
ADD DL,7
N1: ADD DL,30H MOV AH,2 INT 21H
MOV DL,BH;次高位 AND DL,0FH CMP DL,0AH JC N2 ADD DL,7
N2: ADD DL,30H MOV AH,2 INT 21H
MOV DL,BL;次低位 SHR DL,CL CMP DL,0AH JC N3 ADD DL,7
N3: ADD DL,30H MOV AH,2 INT 21H
MOV DL,BL;最低位 AND DL,0FH CMP DL,0AH JC N4 ADD DL,7
N4: ADD DL,30H MOV AH,2 INT 21H RET
BTOH ENDP END START
4.24答:
.MODEL SMALL .DATA
DAT DB ??;准备100个数 RESULT DW ?
.CODE
START: MOV AX,@DATA
MOV DS,AX MOV CX,99 LEA SI,DAT MOV DL,[SI] MOV DH,DL INC SI MOV BX,SI
AGN1: CMP DH,[SI];求出最大值
JNB NEXT1 MOV DH,[SI] NEXT1: INC SI
LOOP AGN1 MOV CX,99
AGN2: CMP DL,[BX];求出最小值
JB NEXT2 MOV DL,[BX] NEXT2: INC BX
LOOP AGN2 XOR AX,AX;求和 ADD DH,DL MOV AL,DH ADC AX,0 MOV RESULT,AX ;int 3
MOV AX,4C00H INT 21H END START 4.25答: DPLY0 MACRO MOV DL,30H MOV AH,2 INT 21H ENDM
DPLY1 MACRO
MOV DL,31H MOV AH,2 INT 21H ENDM
.MODEL SMALL
.DATA
CNT DW 0AB3FH;准备数
.CODE
START: MOV AX,@DATA
MOV DS,AX MOV BX,CNT MOV CX,16 AGN: SHL BX,1 JC NEXT DPLY0 LOOP AGN NEXT: DPLY1 LOOP AGN MOV AX,4C00H INT 21H END START
4.26答:
.MODEL SMALL .DATA
STRG DB ??;准备字符串
.CODE
START: MOV AX,@DATA
MOV DS,AX LEA SI,STRG MOV CX,100
AGN: MOV AL,[SI] CMP AL,61H JB N1 CMP AL,7AH JA N1 SUB AL,20H