Sieve of Eratosthenes

Published: October 17, 2017 | Last Modified: May 13, 2025

Tags: assembly prime numbers

Categories: MASM



This is my first attempt a prime sieve in assembly. It is largely a direct translation from a Sieve of Eratosthenes originally written in Java, so this program is not exactly optimally structured. Firstly, it stores all primes up to n in an array. Secondly, it counts the number of primes before n and stores that hexadecimal value in the EAX register. This is rough. There is much room for improvement, and I intend to revisit this program without using the MUL function.