COMP1521 Week 2 Data

This week is about data.

make and Makefile

Make (build system) is a powerful tool.
dependencies and actions

bm : bm.o Stack.o
	gcc -o bm bm.o Stack.o

bm.o : bm.c Stack.h
	gcc -c -Wall -Werror bm.c

Stack.o : Stack.c Stack.h
	gcc -c -Wall -Werror Stack.c

There are three components: target, source and action. Words before : is the target, after it is the source, and below it is the action.
make is smart as it compares the modification timestamp of sources to decide what actions to do (if it is newly modified).


Memory regions during C program execution
Memory regions during C program execution

Physical Memory

Data Representation

Memory allows you to load bit-strings of sizes 1,2,4,8 bytes from N-byte boundary addresses into registers in the CPU. Data representation is to give these bytes meanings.

Character Data

Character Data is about encodings of characters.


Fun stuffs

For week 2’s lab, we are to create a struct for big number and write a big number adder. One of the challenge task and one of the most interesting task is to make the struct more compact. At first, we used unsigned char to represent a digit, and I was thinking of to use a data type that occupies only 4 bits (enough to represent 1 - 16). But after searching around, I found that unsigned char or uinit8_t is the smallest data types in C, which only occupies 1 byte, which is atomic.