Thursday, January 21, 2010

8086 or MASM PROGRAM to display the multiplication table (first 10 values) for a number N(<10d)

assume ds:data1,cs:code1
data1 segment
msg db 0ah,0dh,'enter the number$'
number db 2,0,2 dup('$')
decimal db '0','1','2','3','4','5','6','7','8','9'
ans db 0ah,'0','*','0','=','0','0','$'
data1 ends
code1 segment
start;mov ax,seg data1
mov ds,ax
lea dx,msg
mov ah,09h
int 21h
mov cx,000ah
mov dl,0ah
mov ah,02h
int 21h
lea dx,number
mov ah,0ah
int 21h
lea dx,number
inc dx
inc dx
mov di,dx
mov bl,[di]
and bl,0fh
lea dx,ans
inc dx
mov si,dx
mov dl,[di]
mov [si],dl
lea dx,ans
inc dx
mov di,dx
lea dx,decimal
mov si,dx
again:lea dx,ans
inc dx
mov di,dx
mov al,[si]
inc di
inc di
mov [di],al
mov bh,[si]
mov ax,0000h
and bh,0fh
mov al,bh
mul bl
aam
add ax,03030h
inc di
inc di
mov [di],ah
inc di
mov [di],al
lea dx,ans
mov ah,09h
int 21h
inc si
loop again
mov ah,4ch
int 21h
code1 ends
end start

1 comment: