# TDT4258 - Lowlevel Programming

[Course link][tdt4258]

## Exercise 1

For this exercise, we were tasked with writing a palindrome finder in assembly.

The code should be able to run on a [DE1-SoC][de1soc] emulator, that can be found at [CPUlator][cpulator].

### ARM Assembly Resources

![ARM Assembly cheat sheet](./.arm_cheat_sheet.png)

Source: [Azeria Labs][azeria-labs-cheat-sheet]

[StackOverflow - What are assembler section directives used for?][assembler-section-directives]

## Exercise 2 - Cache Simulator

In this exercise, we were tasked with writing a cache simulator.

This should run on almost any machine with a proper C compiler.

There is a Makefile and a python script included, which builds both release and debug versions of the program, and tests it with some hardcoded values.

Run the tests by executing:

```command
user@<...>/ex2 $ make test
```

### Haskell variant

I tried writing a haskell clone of this program just for fun, but I ended up never finishing it.

The code exists within a separate folder.

## Exercise 3 - Tetris on Raspberry Pi

NOTE: You will need a Raspberry Pi with a [sense hat][sense-hat] to run this code.

For this exercise, we were tasked with making an existing tetris program run on a sense hat, by writing directly to a Linux framebuffer, and reading joystick input from the Linux input driver.

Move both the Makefile and the code over to the raspberry pi before running.

[tdt4258]: https://www.ntnu.edu/studies/courses/TDT4258
[de1soc]: https://ftp.intel.com/Public/Pub/fpgaup/pub/Intel_Material/18.1/Computer_Systems/DE1-SoC/DE1-SoC_Computer_ARM.pdf
[cpulator]: https://cpulator.01xz.net/?sys=arm-de1soc
[azeria-labs-cheat-sheet]: https://azeria-labs.com/assembly-basics-cheatsheet/
[sense-hat]: https://www.raspberrypi.com/products/sense-hat/
[assembler-section-directives]: https://stackoverflow.com/questions/55107587/what-are-assembler-section-directives-used-for
