Computer Science 251
Computer Organization and Architecture
Dickinson College
Fall Semester 2005
Grant Braught
Class #10 - Assembly Language Programming Exercises
Main Ideas For Today 
- Practice with Assembly Language
In Class Exercises For Today 
- Write an assembly language program that performs the same task as the following HLL code:
int A = 199;
int B = 440;
int D = 4 * (A + B);
- Write an assembly language program that reads a number in from
STDIN and writes its complement (i.e. -1 times the number) out to STDOUT.
- Write an assembly language program that is equivalent to the following HLL program:
main() {
int X = 50;
int Y =
while (X > 0 && X <= 100) {
X = X + Y;
}
Print X
}
- Write an assembly language program that is equivalent to the following HLL program:
main() {
int i;
int x = 0;
for (i=1; i<100; i++) {
if (i % 2 == 0) {
x = x - i;
}
else {
x = x + 4 * i;
}
}
Print x
}
HINT: (i % 2 == 0) is true when i is even.
- Write an assembly language program that reads a value from
STDIN and then displays on STDOUT all Fibonacci numbers less than or equal to the specified value. Recall that each Fibonacci number is found by adding the two previous Fibonacci numbers and that the first two Fibonacci numbers are 1 by definition. So the first several Fibonacci numbers are 1, 1, 2, 3, 5, 8, 13, etc...