本实验通过求某数据区内负数的个数来表示循环程序的结构形式。
实验清单:
STACK1 SEGMENT STACK
DW 256 DUP(?)
STACK1 ENDS
DATA SEGMENT
NUMB DB 12H,88H,82H,89H,33H,90H,01H,10H,0BDH,01H
MES1 DB 'The number of negative is:$'
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE, DS:DATA
START: MOV AX,DATA
MOV DS,AX
MOV DI,OFFSET NUMB
XOR BH,BH
MOV CX,10D
A1: MOV AL,[DI]
TEST AL,80H
JE A2
INC BL
A2: INC DI
LOOP A1
MOV DX,OFFSET MES1
MOV AH,09H
INT 21H
MOV AL,BL
AND AL,0F0H
MOV CL,4
SHR AL,CL
CMP AL,0AH
JB C2
ADD AL,07H
C2: ADD AL,30H
MOV DL,AL
MOV AH,02H
INT 21H
MOV AL,BL
AND AL,0FH
CMP AL,0AH
JB C3
ADD AL,07H
C3: ADD AL,30H
MOV DL,AL
MOV AH,02H
INT 21H
WAIT1: MOV AH,1
INT 16H
JZ WAIT1
MOV AX,4C00H
INT 21H
CODE ENDS
END START