Search This Blog

Thursday, January 10, 2013

Read number from user in assembly language of 8086


;Read number from user in assembly language of 8086

DATA SEGMENT
          FIRST DB 00H
DATA ENDS
CODE SEGMENT
    ASSUME CS:CODE, DS:DATA
 START:
      MOV AX, DATA
      MOV DS, AX
READMORE:
      MOV AH,01H
      INT 21H
      CMP AL,'0'
      JB NOMOREREAD
      CMP AL, '9'
      JA NOMOREREAD
      MOV BL,AL
      MOV AH,10
      MUL FIRST
      SUB BL,30H
      ADD AH, BL
      MOV FIRST, AH
      JMP READMORE
 NOMOREREAD:
      ; THIS IS TO TERMINATE AND GIVE CONTROL TO DOS
      MOV AH, 4CH
      INT 21H

CODE ENDS
 END START

1 comment: