Upload
ayad
View
212
Download
0
Embed Size (px)
DESCRIPTION
d
Citation preview
data segment
msg db "enter number$"
maxl db 100
actl db ?
num db 100 dup(0)
prime_nos db 100 dup('$')
data ends
mystack segment
dw 40 dup(0)
tos label word
mystack ends
code segment
assume cs: code, ds: data
start:
mov ax,data
mov ds,ax
mov ah,09h
lea dx,msg
int 21h
mov ah,0ah
lea dx,maxl
int 21h
lea bx,num
mov dh,0ah
cmp num,dh
jae go
mov dl,[bx]
and dl,0fh
jmp ahed
go:
push cx
push ax
mov dl,[bx]
mov cl,[bx+1]
sub dl,30h
sub cl,30h
mov ch,0ah
mov ah,00h
mov al,dl
mul ch
add al,cl
mov dl,al
pop ax
pop cx
ahed:
jz outer_loop
mov bx,offset prime_nos
outer_loop:
dec dl
cmp dl,01h
jz done
mov cl,dl
shr cl,01h
inner_loop:
cmp cl,01h
jz inner_loop_end
mov ah,00h
mov al,dl
div cl
cmp ah,00h
jz outer_loop
dec cl
jmp inner_loop
inner_loop_end:
mov dh,0ah
cmp dl,dh
jae go1
mov ah,dl
add ah,30h
mov [bx],ah
inc bx
jmp ahed1
go1:
push ax
push cx
mov ah,00h
mov al,dl
mov ch,0ah
div ch
add al,30h
mov [bx],al
inc bx
add ah,30h
mov [bx],ah
inc bx
pop cx
pop ax
ahed1:
jmp outer_loop
done:
mov ah,09h
lea dx,prime_nos
int 21h
mov ah,4ch
int 21h
code ends
end start