;TAKE INPUT ANY SINGLE,DOUBLE,TRIPLE NUMBERS AND DYNAMIC DISPLAY RESULT

ORG 100H

.MODEL SMALL

.STACK 100H

.DATA

EN DB 'ENTER A NUMBER: $'

N DW 7

UN DB 13,10, 'YOU ENTERED: $'

.CODE

MAIN PROC

MOV AX,@DATA

MOV DS,AX

MOV DX,OFFSET EN

MOV AH,9 ;FOR PRINTING STRING

INT 21H

;INPUT CODE STARTS HERE

MOV N,0 ;N = 0

MOV BL,10 ;BL = 10

INPUT: ;LOOP LABEL

MOV AH,1 ;INPUT A CHARACTER => STORES IN AL

INT 21H ;INTERUPT FOR TEXT

CMP AL,13 ;COMPARE INPUT WITH ENTER KEY

JE NEXT ;IF JUMP EQUAL TO THEN ITS JUMP ON LABEL

SUB AL,30H ;SUB AL = AL - 48 = AL - 30H

MOV AH,0 ;AH = 0

MOV CX,AX ;CX = AX

MOV AX,N ;AX = N

MUL BL ;MULTIPLY => AX = AX * BL

ADD AX,CX ;ADD => AX = AX + CX

MOV N,AX ;N = AX

JMP INPUT

;INPUT CODE ENDS HERE

NEXT:

LEA DX,UN ;LOAD EFFECTIVE ADDRESS

MOV AH,9

INT 21H

;OUTPUT CODE STARTS HERE

MOV AX,N ;AX = N = 25

MOV DX,0 ;DX = 0

MOV BX,10 ;BX = 10

MOV CX,0 ;CX = 0 => COUNTER REGISTER

L1:

DIV BX ;DIVIDE => AX = AX / BX

;IN CASE OF 8 BIT REGISTER => AL = QUOTIENT, AH = REMAINDER

;IN CASE OF 16 BIT REGISTER => AX = QUOTIENT, DX = REMAINDER

;AX = 2 , DX = 5

PUSH DX ;5 SAVE IN STACK

MOV DX,0 ;DX = 0

MOV AH,0 ;AX AH = 00000000, AL = QUOTIENT

INC CX ;CX = CX + 1

CMP AX,0 ;(2 == 0)

JNE L1 ;JUMP NOT EQUAL => AX != 0

MOV AH,2 ;OUTPUT/PRINT A SINGLE CHARACTER

L2:

POP DX ;FIRST TIME POP 2 AND SECOND TIME POP 5 = 25

ADD DX,48

INT 21H

LOOP L2

;OUTPUT CODE ENDS HERE

RET

MAIN ENDP

END MAINP