Tag Archives: nasm

Calculator in Assembly with NASM on Windows

Calculator in Assembly

this is a basic calculator written in assembly, it has some nice features, it was developed for the laboratory of  the Computer Architecture course of the Computer Science Engineering on the USAC (so it is an useful tool for learning purposes)

  1. Written fully in assembly, no external library for input/output, just interruptions.
  2. Internally use a 128 bit representation for holding operators and result. The requirement was operate (+,-) with numbers up to 20 digits, and (*,/) with numbers up to 10 digits.
  3. Multiplication using repeated addition operations instead of the native “mult”.
  4. Divide by repeated subtraction and counting instead of the native “div”.
  5. Convert an ASCII String to Binary Number and vice versa. this is required to handle user input, and to display results.
  6. Basic Input/Output functions, like GetCh, PutCh, NewLine, WriteLine
  7. Custom Input/Output functions to read and write 128bit numbers, like Read128BitNum, Write128BitNum
  8. Basic Menu in Text Mode.
  9. Easy to modify, build. The package include the assembler and linker so the executable can be created anytime. (using DOSBox if you are running on a modern operating system)

For Example, in this image sequence, we can see a simple addition.

assembler calculator main menu

Calculator Main Menu

assembler calculator addition result

Calculator after execution of a addition operation.

And for large numbers (123456789 + 987654321)

assembler calculator with large numbers

Calculator after execution of an addition of two large numbers.

Continue reading