MC logo
CSc 314 Assignment 2
[^] CSc 314 Home
[CSc 314 Assignment 1] [CSc 314 Assignment 2]
[Adding In C] [A2 Key]

We Still Count

Mar 27
Apr 20
45 pts
Write a 32-bit i386 program to read numbers from the console and print a running total. Stop when -1 is entered, and print some good-bye message. Mine looks like this:
[bennet@m-mcc-csc-01456 i386]$ ./add
Enter a number (-1 to quit): 14
  Total ==> 14
Enter a number (-1 to quit): 10
  Total ==> 24
Enter a number (-1 to quit): -30
  Total ==> -6
Enter a number (-1 to quit): 15
  Total ==> 9
Enter a number (-1 to quit): 11
  Total ==> 20
Enter a number (-1 to quit): -17
  Total ==> 3
Enter a number (-1 to quit): 3
  Total ==> 6
Enter a number (-1 to quit): -1
All done.
Your program should promt for each number, label the total, and issue some message when done. Use the plain C function scanf and printf to perform I/O. Should you be unfamiliar with the plain C I/O features, here is a plain C program which does the same thing.

You will need to get a copy of NASM and a C compiler to provide the libraries. If you have CodeBlocks, you might find this useful. Alternatively, you might want to install MinGW.

A Windows version will differ slightly from a Linux one (Windows needs an underscore at the front of each global name, so it's _main and _printf instead of main and printf.) Send either; I'll figure it out.

When your program works and is well-comented, submit it here. Since assembler language is particularly obscure, comments are particularly important. It's not unreasonable to comment each line.
<<CSc 314 Assignment 1