You are on page 1of 2

;1ST PROGRAM

;ENTER A NUMBER AND DISLAY IT


sseg segment stack
db 100h dup(0)
sseg ends
dseg segment
num dw 0
msg db "enter a number:",0ah,0dh,"$"
newline db 0ah,0dh,"$"
dseg ends
cseg segment
assume cs:cseg,ds:dseg,ss:sseg
main proc far
mov ax,dseg
mov ds,ax
mov ah,09h
mov dx,offset msg
int 21h
mov cx,0
mov bx,10
push cx
mov bx,10
push cx

l3:
mov ah,01h
int 21h
cmp al,0dh
je exit

sub al,48
mov ah,0
mov cx,ax
pop ax
mul bx
add ax,cx
push ax

jmp l3
exit:

mov ah,09h
mov dx,offset newline
int 21h

pop ax
call disp_num
mov ah,4ch
int 21h

main endp
disp_num proc near

mov bx,10
mov cx,0

l1:
mov dx,0
div bx
add dx,48
push dx
inc cx
cmp ax,0

jnz l1
l2:
pop dx
mov ah,02h
int 21h
loop l2

ret
disp_num endp
cseg ends
end main

You might also like