UPC Validation Logic
The program applies the UPC check digit process by separating odd and even digit positions, multiplying the odd-position sum, combining the totals, and checking whether the result validates the code.
Coding Projects ยท Assembly
An assembly language program created for CS2208 at Western to check whether a UPC code is valid.
This project was created in my third year at Western for CS2208. The goal was to write an assembly program that checks whether a UPC code is valid by processing each digit and applying the UPC check digit calculation.
The program works through the UPC string one digit at a time, converts each ASCII character into a number, separates the odd and even digit positions, builds the running sum, and determines whether the final code passes the validation check.
Since this was my first larger program in assembly, I focused on keeping the logic organized and readable. I used registers to track the current digit, running sum, loop counter, and odd/even position, then used branch instructions to control the flow of the program. I also added detailed comments throughout the code so each step of the calculation was easier to follow. That made the program much easier to debug, especially compared to higher-level languages where more of the logic is hidden.
The assembly code for the UPC checker, showing the digit loop, odd/even calculation, validation logic, and test UPC strings.
The program applies the UPC check digit process by separating odd and even digit positions, multiplying the odd-position sum, combining the totals, and checking whether the result validates the code.
The code uses registers, labels, loops, comparisons, and branch instructions to move through the UPC string and control whether the program ends with a correct or incorrect result.
I added comments beside the assembly instructions to explain how each register was being used and how each step contributed to the final UPC check.
This project helped me understand how much work happens underneath higher-level programming languages. Tasks that seem simple, like reading a character, converting it to a number, or looping through a string, have to be handled much more directly in assembly. I also became more comfortable with registers, flags, labels, conditional branching, and using comments to make low-level code easier to understand and debug.
I had a lot of fun with this assignment because it was one of my first larger assembly programs. It felt satisfying to take a real validation problem and break it down into small, precise instructions. Compared to my earlier coding projects, this one gave me a better appreciation for how computers execute logic at a lower level. It was challenging, but it made the final result feel especially rewarding.