CSC231 Homework 2 2017
--D. Thiebaut (talk) 16:14, 9 February 2017 (EST)
--D. Thiebaut 13:51, 19 September 2012 (EDT)
This assignment is due on 10/07/15 at 11:55 p.m.
Problem #1
Answer the quizzes in the Moodle Homework 2 section.
Problem #2
In your 231b-xx account on aurora, run the following commands:
getcopy 231Lib.asm getcopy hw2_skel.asm cp hw2_skel.asm hw2.asm
You should now have a new file called hw2.asm in your directory, and a library file called 231Lib.asm as well. The library file will help us get input from the keyboard, and print strings.
The hw2.asm file is just a skeleton and you will need to add code to it to solve this problem. For right now, just assemble and link it to the new library, and run it:
nasm -f elf 231Lib.asm ld -o hw2 hw2.o 231Lib.o ld -melf_i386 -o hw2 hw2.o 231Lib.o
The program will prompt you for 3 integer numbers, which it will put into three 32-bit integers called a, b, and c in the data segment. It then takes the integer stored in a fourth variable called ans (for answer), and prints it. Since ans is initialized with 0, that's the number that gets printed.
Here's an example of what happens if I run the program and feed it 3 numbers: 1, 2, and 3 (user input underlined):
./hw2 > 1 > 2 > 3 ans = 0