DEV Community

Gustavo Tavares
Gustavo Tavares

Posted on

SPO600 - W5

Hello there,

This time we will talk about what we learned in Week 5 in SPO600 classes. Make, Makefiles, and different computer architectures (x86_64 and AARCH64).

Makes and Makefiles

In week 5, we talked about Makes and Makefiles, both used when building software.
Let’s take a look on both and see how they work:

Make

Make is a specialized scripting language used to build software according to or WIKI.
The interesting about make is that its commands are not executed in a linear logic as we are used to, instead they follow a input and output order and make will automatically sequence the order for us.

When we run the make command, it will execute the makefile, but what is it?

Makefile

The makefile is a script, a set of commands with variables and targets to create a file.
A makefile looks like this (example from our WIKI):

CC=cc
CFLAGS=-O3

all:         half double

half:        half.o sauce.o
             ${CC} ${CFLAGS} -o half half.o sauce.o

double:      double.o sauce.o
             ${CC} ${CFLAGS} -o double double.o sauce.o

half.o:      half.c number.h
             ${CC} ${CFLAGS} -c half.c

double.o:    double.c number.h
             ${CC} ${CFLAGS} -c double.c

sauce.o:     sauce.c
             ${CC} ${CFLAGS} -c sauce.c

Enter fullscreen mode Exit fullscreen mode

So when the make is exectured, it will use this makefile as guide and 5 compilations will be performed:

$ make
cc         -O3 -c half.c
cc         -O3 -c sauce.c
cc         -O3 -o half half.o sauce.o
cc         -O3 -c double.c
cc         -O3 -o double double.o sauce.o
Enter fullscreen mode Exit fullscreen mode

I like to imagine that make is the cook and makefile is the recipe for a software.


x86_64 vs AArch64

Let’s talk about the register differences between x86_64 and AArch64:

x86_64

x86 - The Intel/AMD architecture which debuted with the Intel 8086 processor (16-bit), gained desktop and server dominance as the 386/486/x86 32-bit architecture, and was extended by AMD to the 64-bit x86_64 architecture. Intel and AMD vigorously compete with x86_64 CPUs, which continue as the preeminent server architecture and most popular desktop architecture.

source: WIKI

The general-purpose registers:

• rax - register a extended
• rbx - register b extended
• rcx - register c extended
• rdx - register d extended
• rbp - register base pointer (start of stack)
• rsp - register stack pointer (current location in stack, growing downwards)
• rsi - register source index (source for data copies)
• rdi - register destination index (destination for data copies)
• r8 - register 8
• r9 - register 9
• r10 - register 10
• r11 - register 11
• r12 - register 12
• r13 - register 13
• r14 - register 14
• r15 - register 15

Enter fullscreen mode Exit fullscreen mode

AArch64

ARM - An architecture which started with the Acorn computer company, became the dominant mobile and embedded architecture in its 32-bit incarnations, and was extended to 64-bit in version 8 (ARMv8) with the AArch64 mode. 64-bit ARM processors are dominant in smartphone applications and starting to be compete in server and high-performance computing systems.

source: WIKI

• r0 through r30 – general registers
• x0 through x30 - for 64-bit-wide access (same registers)
• w0 through w30 - for 32-bit-wide access (same registers - upper 32 bits are either cleared on load or sign-extended (set to the value of the most significant bit of the loaded value)).

Enter fullscreen mode Exit fullscreen mode

Top comments (0)