Assembly language experiments

This is an in-class lab. Nothing to hand in.

Setup and experimentation

Experiment 1

Write a function that computes the maximum value of two int parameters

Experiment 2

Write a function that contains a loop. For example, write the function

// Returns the sum 1 + 2 + 3 + ... + n int triangular_number(int n)
(The nth triangular number is also n * (n - 1) / 2, which is faster to compute, but write the loop anyway so you can see how x86_64 does loops.)

Experiment 3

Write a function that calls a second function. For example, you could take your maximum-value function from experiment 1 and call it twice to implement max(int a, int b, int c).

Experiment 4

Go wild. Grab one of your recent assignments (bits.c, queue.c, etc.) and stick it into Compiler Explorer. Can you make sense of the result?

Have fun!