汇编语言 统计负数个数(一)


DTSEG SEGMENT
MES1  DB	'The result is:$'
NUMB  DB 12H,88H,82H,89H,33H,90H,01H,10H,0BDH,01H
DTSEG ENDS

CDSEG SEGMENT
      ASSUME CS:CDSEG,DS:DTSEG
START:MOV AX,DTSEG
      MOV DS,AX
      
      MOV	DX,OFFSET MES1
	  MOV	AH,09H
	  INT	21H
      MOV BL,0H
      MOV CX,0AH
      MOV SI,OFFSET NUMB
NEXT: MOV AX,[SI]
      AND AX,80H
      CMP AX,0H
      JG  MIN
      JMP CON
MIN:  INC BL
CON:  INC SI
      LOOP NEXT
      CALL SHOW 
      MOV AH,4CH
      INT 21H
           
SHOW	PROC	NEAR
	   PUSH	AX
	   PUSH	DX
	   MOV	AL,BL
	   AND	AL,0F0H			;取高4位
	   SHR	AL,4
	   CMP	AL,0AH			;是否是A以上的数
	   JB	C2		
	   ADD	AL,07H		
C2:	   ADD	AL,30H		
	   MOV	DL,AL			;show character 
	   MOV	AH,02H
	   INT	21H
	   MOV	AL,BL
	   AND	AL,0FH			;取低4位
	   CMP	AL,0AH
	   JB	C3
	   ADD 	AL,07H
C3:	   ADD	AL,30H
	   MOV	DL,AL			;show character 
	   MOV	AH,02H
	   INT	21H
	   POP	DX
	   POP	AX
	   RET
	   ENDP	
CDSEG ENDS
      END START

 

你可能感兴趣的:(汇编程序)