In this reading, you will be introduced to the basics of the x86-64 assembly language, including how to copy data and perform basic arithmetic and logical operations.
Our ultimate goal in studying x86-64 isn’t to be able to write complex programs directly in this language: for the most part this job is handled automatically, and much more efficiently by a compiler. Rather, our goal is to use our knowledge of x86-64 to gain some insight into the processor interface and understand what programs run efficiently on real computer systems.
Sections 3.1 - 3.5.4 (pp. 166-196), excluding sections 3.4.4 and 3.5.1, from the course textbook.
Each student will be responsible for learning and demonstrating proficiency in the following objectives PRIOR to the class meeting. The reading quiz will test these objectives.
The following objectives should be mastered by each student DURING and FOLLOWING the class session through active work and practice.
These exercises are geared towards mastering the BASIC learning objectives listed above. You are expected to submit them before class and it is highly recommended that you complete them before attempting the reading quiz.
Use GCC to compile the following C code to x86-64 code, copying the resulting x86-64 code here.
#include <stdio.h>
void foo() {
printf("hello!\n");
}
int main() {
foo();
int x = 9;
printf("%d\n", x);
return 0;
}
What x86-64 instruction suffix (b
, w
, l
, or q
) is most likely to be used for copying from one int
variable to another int
?
Assuming that %eax
contains 8 and %ebx
contains 10, what is the effective memory address for the following operands.
4(%eax, %ebx)
(%eax, %ebx, 4)
10(%ebx)
Describe in your own words what the following instruction does: movsbq %bl, %rdx
Write an equation using C-like syntax that shows the final value of %rax
in terms of the other registers.
incq %rbx
addq %rbx, %rax
salq $5, %rax