1. 程式人生 > >彙編第一題(找出負數個數)

彙編第一題(找出負數個數)

DATAS SEGMENT
  M     DB -3,0,27,62,-45,-20,-82,+255,+18
  COUNT DB 9
  N     DB 0
DATAS ENDS


CODES SEGMENT
    ASSUME CS:CODES,DS:DATAS
START PROC FAR
      PUSH DS
       MOV AX,0
      PUSH AX
       MOV AX,DATAS
       MOV DS,AX
      
       MOV BX,OFFSET M
       ;MOV N,0
       MOV DX,0
      
LOP1:  MOV AL,[BX]
       CMP AL,0
       JGE LOP2
       INC N
LOP2:  INC BX
       DEC COUNT
       JNE LOP1
      
       MOV DL,N
       ADD DL,30H
       MOV AH,2
       INT 21H
       RET
   
       MOV AH,4CH
       INT 21H
START ENDP
CODES ENDS
    END START