;uses list. 3 through sqrt. ;will use add, cmp and xor instead of sqr org 100h xor ax, ax int 1ah mov [start], dx mov ax, 1 call decout mov ax, 2 call decout mov cx, 1 nextcx: add cx, 2 jc stop mov di, primes mov [sqrt], cx fild dword [sqrt] fsqrt fistp dword [sqrt] mov bp, [sqrt] nextpr: mov bx, [di] cmp bx, bp ja gotone inc di inc di mov ax, cx xor dx, dx div bx cmp dx, 0 jne nextpr jmp nextcx gotone: add word [maxdi], 2 mov di, [maxdi] mov [di], cx mov ax, cx call decout jmp nextcx stop: mov word [thiscol], 0 mov dx, endmsg1 mov ah, 9 int 21h mov ax, [maxdi] sub ax, primes-4 shr ax, 1 call decout mov dx, endmsg2 mov ah, 9 int 21h xor ax, ax int 1ah sub dx, [start] mov ax, dx mov bx, 10 xor dx, dx mul bx mov bx, 182 div bx mov cx, dx cmp ax, 0 je skipsec call decout mov ah, 9 mov dx, endmsg3 int 21h skipsec: mov ax, cx call decout mov ah, 9 mov dx, endmsg4 int 21h mov ax, 4c00h int 21h decout: mov di, decbuff+6 decloop: dec di mov bx, 10 xor dx, dx div bx add dl, '0' mov [di], dl cmp ax, 0 jne decloop dec di mov byte [di], ' ' mov dx, di sub di, decbuff mov ax, 6 sub ax, di add word [thiscol], ax cmp word [thiscol], 78 jna nonew mov word [thiscol], ax mov bx, dx mov ah, 2 mov dl, 13 int 21h mov ah, 2 mov dl, 10 int 21h mov dx, bx nonew: mov ax, 900h int 21h ret decbuff db ' $' endmsgp db 13, 10, 13, 10, '$' endmsgs db 'prime numbers found between 1 and 65535.',13,10,'$' start dw 0 endmsg1 db 13, 10, 13, 10, '$' endmsg2 db ' primes between 1 and 65535 found in$' endmsg3 db ' and$' endmsg4 db '/182 seconds.',13,10,13,10,"Inhahe '98",13,10,'$' sqrt dd 0 thiscol dw 0 maxdi dw primes primes: dw 3